|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Data.Entity.Migrations;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using CK.SCP.Models;
|
|
|
|
using CK.SCP.Models.AppBoxEntity;
|
|
|
|
using CK.SCP.Models.ScpEntity;
|
|
|
|
using CK.SCP.Utils;
|
|
|
|
using System.Data.Entity.Core;
|
|
|
|
using CK.SCP.Models.Enums;
|
|
|
|
using CK.SCP.Models.ScpEntity.ExcelExportEnttity;
|
|
|
|
|
|
|
|
namespace CK.SCP.Controller
|
|
|
|
{
|
|
|
|
public class SCP_TA_LANGUAGE_CONTROLLER
|
|
|
|
{
|
|
|
|
public static ResultObject<List<TA_LANGUAGE>> Get_TA_LANGUAGE_List(TA_LANGUAGE p_entity)
|
|
|
|
{
|
|
|
|
ResultObject<List<TA_LANGUAGE>> _ret = new ResultObject<List<TA_LANGUAGE>>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
IQueryable<TA_LANGUAGE> q = db.TA_LANGUAGE;
|
|
|
|
if (p_entity.UID != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.UID == p_entity.UID);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.GUID))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.GUID.Contains(p_entity.GUID));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.CH))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.CH==p_entity.CH);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.EN))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.EN.Contains(p_entity.EN));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.RU))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.RU.Contains(p_entity.RU));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.DE))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.DE.Contains(p_entity.DE));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.FR))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.FR.Contains(p_entity.FR));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.EL))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.EL.Contains(p_entity.EL));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.AR))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.AR.Contains(p_entity.AR));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.JP))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.JP.Contains(p_entity.JP));
|
|
|
|
}
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = q.ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Get_TA_LANGUAGE_List", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Get_TA_LANGUAGE_List", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Get_TA_LANGUAGE_List", ex.ToString());
|
|
|
|
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
|
|
|
|
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Get_TA_LANGUAGE_List", e.Message);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
return _ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 导入收货信息管理(重庆专用)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="p_order_list">导入信息</param>
|
|
|
|
/// <param name="site">当前登录地点</param>
|
|
|
|
/// <param name="p_creator">创建人</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static ResultObject<bool> EXCEL_ADRESS_LIST_CQ(List<SCP_VENDER_EXPORT> p_order_list, string site, string p_creator)
|
|
|
|
{
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
List<string> lineError = new List<string>();
|
|
|
|
List<string> ErrorList = new List<string>();
|
|
|
|
var _lst = p_order_list;
|
|
|
|
|
|
|
|
|
|
|
|
if (lineError.Count > 0)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.MessageList.AddRange(ErrorList);
|
|
|
|
_ret.Result = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var cou = _lst.Select(q => q.收货地址).Count();
|
|
|
|
var cou1 = _lst.Select(q => q.收货地址).Distinct().Count();
|
|
|
|
if (cou != cou1)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.MessageList.Add("收货地址重复!");
|
|
|
|
_ret.Result = false;
|
|
|
|
return _ret;
|
|
|
|
}
|
|
|
|
_lst.ForEach(p =>
|
|
|
|
{
|
|
|
|
|
|
|
|
var _Sitelist = db.TB_ADDRESS.Count(t => t.Address == p.收货地址 && t.SubSite == site);
|
|
|
|
if (_Sitelist == 0)
|
|
|
|
{
|
|
|
|
TB_ADDRESS address = new TB_ADDRESS();
|
|
|
|
address.Address = p.收货地址;
|
|
|
|
address.NamePone = p.收货人信息;
|
|
|
|
address.SubSite = site;
|
|
|
|
db.TB_ADDRESS.AddOrUpdate(address);
|
|
|
|
}
|
|
|
|
else if (_Sitelist == 1)
|
|
|
|
{
|
|
|
|
TB_ADDRESS tB_address = db.TB_ADDRESS.SingleOrDefault(t => t.Address == p.收货地址 && t.SubSite == site);
|
|
|
|
tB_address.NamePone = p.收货人信息;
|
|
|
|
db.TB_ADDRESS.AddOrUpdate(tB_address);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
if (_ret.MessageList.Count == 0)
|
|
|
|
{
|
|
|
|
int state = db.SaveChanges();
|
|
|
|
if (state != -1)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_VENDER_PART_MOD", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_VENDER_PART_MOD", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_VENDER_PART_MOD", ex.ToString());
|
|
|
|
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
|
|
|
|
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_PO_CONTROLLER), "EXCEL_VENDER_PART_MOD", e.Message);
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
return _ret;
|
|
|
|
}
|
|
|
|
public static ResultObject<bool> Save_TA_LANGUAGE(List<TA_LANGUAGE> p_entitys)
|
|
|
|
{
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
foreach (var itm in p_entitys)
|
|
|
|
{
|
|
|
|
db.TA_LANGUAGE.AddOrUpdate(p => p.GUID, itm);
|
|
|
|
}
|
|
|
|
if (db.SaveChanges() != -1)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Save_TA_LANGUAGE", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Save_TA_LANGUAGE", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Save_TA_LANGUAGE", ex.ToString());
|
|
|
|
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
|
|
|
|
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Save_TA_LANGUAGE", e.Message);
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
return _ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static ResultObject<bool> Del_TA_LANGUAGE(TA_LANGUAGE p_entity)
|
|
|
|
{
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
var _entity = db.TA_LANGUAGE.Where(itm => itm.GUID == p_entity.GUID).FirstOrDefault();
|
|
|
|
|
|
|
|
db.TA_LANGUAGE.Remove(_entity);
|
|
|
|
if (db.SaveChanges() != -1)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Del_TA_LANGUAGE", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Del_TA_LANGUAGE", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Del_TA_LANGUAGE", ex.ToString());
|
|
|
|
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
|
|
|
|
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TA_LANGUAGE_CONTROLLER), "Del_TA_LANGUAGE", e.Message); throw e;
|
|
|
|
}
|
|
|
|
return _ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|