master
ddlucky 6 months ago
parent d6f15b2c3b
commit 9e5a2edd28

@ -1162,7 +1162,7 @@ namespace DSWeb.Common.DB
/// 获取一个需要Insert的新客户信息
/// </summary>
/// <returns></returns>
public t_crm_client_md GetCrmClient() {
public t_crm_client_md GetCrmClient(string ) {
var result = new t_crm_client_md();
result. = "合作客户";
@ -1199,7 +1199,7 @@ namespace DSWeb.Common.DB
result. = SetLength(email,50);
result. = SetLength(fax,50);
var = WebConfigurationManager.AppSettings["InfoClientInputUser"].ToString();
//var 录入人名字 = WebConfigurationManager.AppSettings["InfoClientInputUser"].ToString();
result. = ;
result. = string.IsNullOrWhiteSpace( createTime ) ? DateTime.Now : Convert.ToDateTime(createTime);

@ -11,6 +11,7 @@ using System.Security.Permissions;
using System.ServiceModel.Configuration;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Windows.Forms;
using DSWeb.Areas.CommMng.Models;
using DSWeb.Areas.MvcShipping.Models.Message.VGM;
@ -152,234 +153,234 @@ namespace DSWeb.Areas.CommMng.PublicInterfaceDAL
// var jsonstr = LogParam.Param;
#endregion
//测试逻辑
//var LogParamList = ds6.t_PublicInterface_Log.Where(x => x.ID >= 4).ToList();
//var jsonstr = LogParamList[0].Param;
//测试逻辑
//var LogParamList = ds6.t_PublicInterface_Log.Where(x => x.ID >= 4).ToList();
//var jsonstr = LogParamList[0].Param;
//正式逻辑
var jsonstr = paramObject.ToString();
//正式逻辑
var jsonstr = paramObject.ToString();
errorstr = jsonstr;
errorstr = jsonstr;
csCustHead custhead = JsonConvert.Deserialize<csCustHead>(jsonstr);
var custlist = custhead.csCust;
csCustHead custhead = JsonConvert.Deserialize<csCustHead>(jsonstr);
var custlist = custhead.csCust;
//解析param.Param
foreach (var cust in custlist)
{
var = WebConfigurationManager.AppSettings["InfoClientInputUser"].ToString();
var ds6cust = cust.GetCrmClient();
//解析param.Param
foreach (var cust in custlist)
{
var currInfoclient = ds6.t_crm_client.Where(x => x. == cust.MDGCustCode).ToList();
var ds6cust = cust.GetCrmClient();
//if (currInfoclient == null || currInfoclient.Count == 0)
// currInfoclient=ds6.t_crm_client.Where(x => x.国税登记 == cust.taxpayerIdentificatioNo).ToList();
var currInfoclient = ds6.t_crm_client.Where(x => x. == cust.MDGCustCode).ToList();
var io = "";
if (currInfoclient == null || currInfoclient.Count == 0)
{
ds6.t_crm_client.Add(ds6cust);
io = "新增";
//ds6.SaveChanges();
}
else
{
//foreach (var oldclient in currInfoclient)
//{
// ds6cust = cust.GetCrmClient(oldclient);
//if (currInfoclient == null || currInfoclient.Count == 0)
// currInfoclient=ds6.t_crm_client.Where(x => x.国税登记 == cust.taxpayerIdentificatioNo).ToList();
// ds6.t_crm_client.AddOrUpdate(ds6cust);
//}
io = "更新";
}
var io = "";
if (currInfoclient == null || currInfoclient.Count == 0)
{
ds6.t_crm_client.Add(ds6cust);
io = "新增";
//ds6.SaveChanges();
}
else
{
//foreach (var oldclient in currInfoclient)
//{
// ds6cust = cust.GetCrmClient(oldclient);
#region
//var newerror = new t_sys_soft_error_md();
//newerror.针对版本 = 1;
//newerror.升级日期 = DateTime.Now;
//newerror.升级人 = io;
//newerror.执行文件 = $"[{cust.bizCsCustId},{cust.MDGCustCode},{cust.custAlias}]"+ errorstr;
//var ds62 = new DS6DataContext();
//ds62.t_sys_soft_error.Add(newerror);
//ds62.SaveChanges();
#endregion
// ds6.t_crm_client.AddOrUpdate(ds6cust);
//}
io = "更新";
}
ds6.CustInfo.AddOrUpdate(cust);
#region
//var newerror = new t_sys_soft_error_md();
//newerror.针对版本 = 1;
//newerror.升级日期 = DateTime.Now;
//newerror.升级人 = io;
//newerror.执行文件 = $"[{cust.bizCsCustId},{cust.MDGCustCode},{cust.custAlias}]"+ errorstr;
//var ds62 = new DS6DataContext();
//ds62.t_sys_soft_error.Add(newerror);
//ds62.SaveChanges();
#endregion
if (cust.csCustOfficeInfo != null && cust.csCustOfficeInfo.Count > 0)
ds6.CustInfo.AddOrUpdate(cust);
if (cust.csCustOfficeInfo != null && cust.csCustOfficeInfo.Count > 0)
{
var old_csCustOfficeInfo = ds6.CustOfficeInfo.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustOfficeInfo != null && old_csCustOfficeInfo.Count > 0)
{
var old_csCustOfficeInfo = ds6.CustOfficeInfo.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustOfficeInfo != null && old_csCustOfficeInfo.Count > 0)
{
var newid = cust.csCustOfficeInfo.Select(s => s.bizCsCustOfficeInfoId).ToList();
var delrec = old_csCustOfficeInfo.Where(x => !newid.Contains(x.bizCsCustOfficeInfoId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustOfficeInfo.RemoveRange(delrec);
}
var newid = cust.csCustOfficeInfo.Select(s => s.bizCsCustOfficeInfoId).ToList();
var delrec = old_csCustOfficeInfo.Where(x => !newid.Contains(x.bizCsCustOfficeInfoId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustOfficeInfo.RemoveRange(delrec);
}
foreach (var item in cust.csCustOfficeInfo)
{
item.SetAllLength();
ds6.CustOfficeInfo.AddOrUpdate(item);
}
foreach (var item in cust.csCustOfficeInfo)
{
item.SetAllLength();
ds6.CustOfficeInfo.AddOrUpdate(item);
}
else
}
else
{
var old_csCustOfficeInfo = ds6.CustOfficeInfo.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustOfficeInfo != null && old_csCustOfficeInfo.Count > 0)
{
var old_csCustOfficeInfo = ds6.CustOfficeInfo.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustOfficeInfo != null && old_csCustOfficeInfo.Count > 0)
{
ds6.CustOfficeInfo.RemoveRange(old_csCustOfficeInfo);
}
ds6.CustOfficeInfo.RemoveRange(old_csCustOfficeInfo);
}
}
if (cust.csCustTypes != null && cust.csCustTypes.Count > 0)
if (cust.csCustTypes != null && cust.csCustTypes.Count > 0)
{
var old_csCustType = ds6.CustType.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustType != null && old_csCustType.Count > 0)
{
var old_csCustType = ds6.CustType.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustType != null && old_csCustType.Count > 0)
{
var newid = cust.csCustTypes.Select(s => s.bizCsCustTypeId).ToList();
var delrec = old_csCustType.Where(x => !newid.Contains(x.bizCsCustTypeId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustType.RemoveRange(delrec);
}
var newid = cust.csCustTypes.Select(s => s.bizCsCustTypeId).ToList();
var delrec = old_csCustType.Where(x => !newid.Contains(x.bizCsCustTypeId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustType.RemoveRange(delrec);
}
foreach (var item in cust.csCustTypes)
{
item.SetAllLength();
ds6.CustType.AddOrUpdate(item);
}
foreach (var item in cust.csCustTypes)
{
item.SetAllLength();
ds6.CustType.AddOrUpdate(item);
}
else
}
else
{
var old_csCustType = ds6.CustType.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustType != null && old_csCustType.Count > 0)
{
var old_csCustType = ds6.CustType.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustType != null && old_csCustType.Count > 0)
{
ds6.CustType.RemoveRange(old_csCustType);
}
ds6.CustType.RemoveRange(old_csCustType);
}
}
if (cust.csCustContacts != null && cust.csCustContacts.Count > 0)
if (cust.csCustContacts != null && cust.csCustContacts.Count > 0)
{
var old_csCustContacts = ds6.CustContact.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustContacts != null && old_csCustContacts.Count > 0)
{
var old_csCustContacts = ds6.CustContact.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustContacts != null && old_csCustContacts.Count > 0)
{
var newid = cust.csCustContacts.Select(s => s.bizCsCustContactId).ToList();
var delrec = old_csCustContacts.Where(x => !newid.Contains(x.bizCsCustContactId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustContact.RemoveRange(delrec);
}
var newid = cust.csCustContacts.Select(s => s.bizCsCustContactId).ToList();
var delrec = old_csCustContacts.Where(x => !newid.Contains(x.bizCsCustContactId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustContact.RemoveRange(delrec);
}
foreach (var item in cust.csCustContacts)
{
item.SetAllLength();
ds6.CustContact.AddOrUpdate(item);
}
foreach (var item in cust.csCustContacts)
{
item.SetAllLength();
ds6.CustContact.AddOrUpdate(item);
}
else
}
else
{
var old_csCustContacts = ds6.CustContact.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustContacts != null && old_csCustContacts.Count > 0)
{
var old_csCustContacts = ds6.CustContact.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustContacts != null && old_csCustContacts.Count > 0)
{
ds6.CustContact.RemoveRange(old_csCustContacts);
}
ds6.CustContact.RemoveRange(old_csCustContacts);
}
}
if (cust.csCustSaless != null && cust.csCustSaless.Count > 0)
if (cust.csCustSaless != null && cust.csCustSaless.Count > 0)
{
var old_csCustSales = ds6.CustSales.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustSales != null && old_csCustSales.Count > 0)
{
var old_csCustSales = ds6.CustSales.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustSales != null && old_csCustSales.Count > 0)
{
var newid = cust.csCustSaless.Select(s => s.bizCsCustSalesId).ToList();
var delrec = old_csCustSales.Where(x => !newid.Contains(x.bizCsCustSalesId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustSales.RemoveRange(delrec);
}
var newid = cust.csCustSaless.Select(s => s.bizCsCustSalesId).ToList();
var delrec = old_csCustSales.Where(x => !newid.Contains(x.bizCsCustSalesId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustSales.RemoveRange(delrec);
}
foreach (var item in cust.csCustSaless)
{
item.SetAllLength();
ds6.CustSales.AddOrUpdate(item);
}
foreach (var item in cust.csCustSaless)
{
item.SetAllLength();
ds6.CustSales.AddOrUpdate(item);
}
else
}
else
{
var old_csCustSales = ds6.CustSales.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustSales != null && old_csCustSales.Count > 0)
{
var old_csCustSales = ds6.CustSales.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustSales != null && old_csCustSales.Count > 0)
{
ds6.CustSales.RemoveRange(old_csCustSales);
}
ds6.CustSales.RemoveRange(old_csCustSales);
}
}
if (cust.csCustAccounts != null && cust.csCustAccounts.Count > 0)
if (cust.csCustAccounts != null && cust.csCustAccounts.Count > 0)
{
var old_csCustAccounts = ds6.CustAccount.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustAccounts != null && old_csCustAccounts.Count > 0)
{
var old_csCustAccounts = ds6.CustAccount.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustAccounts != null && old_csCustAccounts.Count > 0)
{
var newid = cust.csCustAccounts.Select(s => s.bizCsCustAccountId).ToList();
var delrec = old_csCustAccounts.Where(x => !newid.Contains(x.bizCsCustAccountId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustAccount.RemoveRange(delrec);
}
foreach (var item in cust.csCustAccounts)
{
item.SetAllLength();
ds6.CustAccount.AddOrUpdate(item);
}
var newid = cust.csCustAccounts.Select(s => s.bizCsCustAccountId).ToList();
var delrec = old_csCustAccounts.Where(x => !newid.Contains(x.bizCsCustAccountId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustAccount.RemoveRange(delrec);
}
else
foreach (var item in cust.csCustAccounts)
{
var old_csCustAccounts = ds6.CustAccount.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustAccounts != null && old_csCustAccounts.Count > 0)
{
ds6.CustAccount.RemoveRange(old_csCustAccounts);
}
item.SetAllLength();
ds6.CustAccount.AddOrUpdate(item);
}
}
else
{
var old_csCustAccounts = ds6.CustAccount.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustAccounts != null && old_csCustAccounts.Count > 0)
{
ds6.CustAccount.RemoveRange(old_csCustAccounts);
}
}
if (cust.csCustInvoices != null && cust.csCustInvoices.Count > 0)
if (cust.csCustInvoices != null && cust.csCustInvoices.Count > 0)
{
var old_csCustInvoice = ds6.CustInvoice.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustInvoice != null && old_csCustInvoice.Count > 0)
{
var old_csCustInvoice = ds6.CustInvoice.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustInvoice != null && old_csCustInvoice.Count > 0)
{
var newid = cust.csCustInvoices.Select(s => s.bizCsCustInvoiceId).ToList();
var delrec = old_csCustInvoice.Where(x => !newid.Contains(x.bizCsCustInvoiceId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustInvoice.RemoveRange(delrec);
}
foreach (var item in cust.csCustInvoices)
{
item.SetAllLength();
ds6.CustInvoice.AddOrUpdate(item);
}
var newid = cust.csCustInvoices.Select(s => s.bizCsCustInvoiceId).ToList();
var delrec = old_csCustInvoice.Where(x => !newid.Contains(x.bizCsCustInvoiceId)).ToList();
if (delrec != null && delrec.Count > 0)
ds6.CustInvoice.RemoveRange(delrec);
}
else
foreach (var item in cust.csCustInvoices)
{
var old_csCustInvoice = ds6.CustInvoice.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustInvoice != null && old_csCustInvoice.Count > 0)
{
ds6.CustInvoice.RemoveRange(old_csCustInvoice);
}
item.SetAllLength();
ds6.CustInvoice.AddOrUpdate(item);
}
}
if (custlist.Count > 0)
else
{
ds6.SaveChanges();
var old_csCustInvoice = ds6.CustInvoice.Where(x => x.bizCsCustId == cust.bizCsCustId).ToList();
if (old_csCustInvoice != null && old_csCustInvoice.Count > 0)
{
ds6.CustInvoice.RemoveRange(old_csCustInvoice);
}
}
result.Success = true;
result.Message = "保存成功";
}
if (custlist.Count > 0)
{
ds6.SaveChanges();
}
result.Success = true;
result.Message = "保存成功";
//}
}
catch(Exception ex)

Loading…
Cancel
Save