@ -23,6 +23,11 @@ using SocialExplorer.IO.FastDBF;
using System.Linq ;
using DSWeb.Common ;
using DSWeb.Areas.Dispatch.Helper ;
using DSWeb.Areas.MvcShipping.DAL.MsCwVouchersGlDAL ;
using System.Net.Http ;
using System.Security.Cryptography.X509Certificates ;
using System.Net.Security ;
using System.Security.Cryptography ;
namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlDAL
{
@ -3006,7 +3011,59 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlDAL
#region 浪潮inSuite
public static string GenerateNewParamByRecursion ( object param )
//public static Dictionary<string, object> ToDictionary(this object obj)
//{
// var dictionary = new Dictionary<string, object>();
// if (obj == null) return dictionary;
// foreach (var property in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
// {
// var value = property.GetValue(obj);
// dictionary.Add(property.Name, value);
// }
// return dictionary;
//}
static string GenerateNewParamByRecursion ( object param )
{
var newParam = "" ;
var tmpparam = param . GetType ( ) ;
if ( param . GetType ( ) = = typeof ( List < object > ) )
{
foreach ( var temp_dict in param as List < object > )
{
var d_order = ( temp_dict . ToDictionary ( ) ) . OrderBy ( x = > x . Key ) ;
foreach ( var kv in d_order )
{
if ( ! ( kv . Value is List < object > ) )
{
newParam = newParam + kv . Key ;
newParam = newParam + kv . Value . ToString ( ) ;
newParam = newParam + "&" ;
}
}
}
}
else
{
var d_order = param . ToDictionary ( ) . OrderBy ( x = > x . Key ) ;
foreach ( var kv in d_order )
{
if ( kv . Key ! = "line_ids" & & ! ( kv . Value is List < object > ) )
{
newParam = newParam + kv . Key ;
newParam = newParam + kv . Value . ToString ( ) ;
newParam = newParam + "&" ;
}
}
}
return newParam ;
}
public static string GenerateNewParamByRecursion2 ( object param )
{
var newParam = "" ;
if ( param is List < object > )
@ -3043,7 +3100,7 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlDAL
return newParam ;
}
public static DBResult setExcelReportGlinSuite ( string strCondition , string userid , string usercode , string companyid , string strCwSTARTGID )
public static DBResult setExcelReportGlinSuite ( string strCondition , string userid , string usercode , string companyid , string strCwSTARTGID ,string templatepath )
{
var result = new DBResult ( ) ;
@ -3086,13 +3143,14 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlDAL
{
Param VoucherDetail = new Param ( ) ;
VoucherDetail . accting_org_number = "" ;
VoucherDetail . acct_book_number = "" ;
VoucherDetail . accting_org_number = INSUITECOMPANY ;
VoucherDetail . acct_book_number = INSUITEACCOUNT ;
VoucherDetail . voucher_word_name = vou . VKNO ;
VoucherDetail . attachment_qty = vou . ATTACHS ;
VoucherDetail . number = vou . VOUNO . ToString ( ) ;
VoucherDetail . business_date = Convert . ToDateTime ( vou . VOUDATE ) ;
VoucherDetail . business_date = Convert . ToDateTime ( vou . VOUDATE ) . ToString ( "yyyy-MM-dd" ) + "T00:00:00" ;
VoucherDetail . voucher_source = "" ;
VoucherDetail . creator_phone = "" ;
var voudetaildataList = MsCwVouchersGlDAL . GetDataCwVVList ( 0 , 1000 , "ORDNO='" + vou . ORDNO + "'" , userid , usercode , companyid , strCwSTARTGID ) ;
var vouitemsList = new List < Line_ids > ( ) ;
foreach ( var voudetail in voudetaildataList )
@ -3140,40 +3198,72 @@ namespace DSWeb.MvcShipping.DAL.MsCwVouchersGlDAL
vouitemsList . Add ( vouitems ) ;
}
VoucherDetail . line_ids = vouitemsList ;
VoucherDetailList . Add ( VoucherDetail ) ;
}
var signstr = "" ;
if ( VoucherDetailList . Count = = 1 )
signstr = GenerateNewParamByRecursion ( VoucherDetailList [ 0 ] ) + thirdpartyaccount . ACCOUNTPSW ;
else
signstr = GenerateNewParamByRecursion ( VoucherDetailList ) + thirdpartyaccount . ACCOUNTPSW ;
byte [ ] utf8Bytes = Encoding . UTF8 . GetBytes ( signstr ) ;
byte [ ] hashBytes ;
using ( var md5 = MD5 . Create ( ) )
{
hashBytes = md5 . ComputeHash ( utf8Bytes ) ;
}
var signstr = GenerateNewParamByRecursion ( VoucherDetailList ) + thirdpartyaccount . ACCOUNTPSW ;
string sign = BitConverter . ToString ( hashBytes ) . Replace ( "-" , "" ) . ToLower ( ) ;
paramsend paramsends = new paramsend ( ) ;
paramsends . client_id = thirdpartyaccount . ACCOUNT ;
paramsends . sign = sign ;
paramsends . param = VoucherDetailList ;
var postObj = new
{
client_id = thirdpartyaccount . ACCOUNT ,
sign = signstr . ToMd5 ( ) , //固定
param = VoucherDetailList
paramsendlangchao = paramsends
} ;
var errstr = "" ;
var apiJson = JsonConvert . SerializeObject ( postObj ) ;
apiJson = apiJson . Replace ( "paramsendlangchao" , "params" ) ;
var apiRtn = Areas . Dispatch . Helper . WebRequestHelper . DoPost ( INSUITEWEB , apiJson ) ;
var objRtn2 = Newtonsoft . Json . JsonConvert . DeserializeAnonymousType ( apiRtn , new Root ( ) ) ;
int voucount = 0 ;
int errvoucount = 0 ;
if ( objRtn2 . result . res ! = null ) {
foreach ( var res in objRtn2 . result . res ) {
if ( objRtn2 . result . res ! = null )
{
foreach ( var res in objRtn2 . result . res )
{
if ( res . state = = 1 )
if ( res . state = = "1" )
{
var vou = dataList . Find ( x = > x . VOUNO . ToString ( ) = = res . param . number ) ;
if ( vou ! = null ) {
if ( vou ! = null )
{
sSql = " update cw_vouchers_gl set ISEXPORT=1 where ORDNO=" + vou . ORDNO ;
SqlHelper . ExecuteSql ( SqlHelper . ConnectionStringLocalTransaction , sSql ) ;
}
voucount = voucount + 1 ;
}
else {
else
{
errstr = errstr + res . msg ;
errvoucount = errvoucount + 1 ;
}
}
}
else {
errvoucount = dataList . Count ;
errstr = errstr + dataList . Count + objRtn2 . result . msg ;
}
if ( ! string . IsNullOrEmpty ( errstr ) ) errstr = "失败" + errvoucount + "票,提示:" + errstr ;