835 lines
35 KiB
C#
835 lines
35 KiB
C#
using YLErp.Modules.SystemModule;
|
|
|
|
namespace YLErp.Modules.ClientModule
|
|
{
|
|
/// <summary>
|
|
/// 客户数据变更记录处理
|
|
/// </summary>
|
|
public class ClientDataChangeLogHandle
|
|
{
|
|
public static List<List<string>> Handle(string optType, List<List<string>> changeList)
|
|
{
|
|
switch (optType)
|
|
{
|
|
case "编辑客户":
|
|
changeList = Handle(typeof(Client), changeList);
|
|
break;
|
|
case "编辑客户人员":
|
|
changeList = Handle(typeof(ClientDuty), changeList);
|
|
break;
|
|
case "编辑银行卡":
|
|
changeList = Handle(typeof(ClientBankCard), changeList);
|
|
break;
|
|
|
|
}
|
|
return changeList;
|
|
}
|
|
|
|
|
|
public static List<List<string>> Handle(Type type, List<List<string>> changeList)
|
|
{
|
|
if (type == typeof(Client))
|
|
{
|
|
changeList = HandleByClient(changeList);
|
|
}
|
|
if (type == typeof(ClientDuty))
|
|
{
|
|
changeList = HandleByClientDuty(changeList);
|
|
}
|
|
if (type == typeof(ClientBankCard))
|
|
{
|
|
changeList = HandleByBankCard(changeList);
|
|
}
|
|
return changeList;
|
|
}
|
|
|
|
|
|
private static List<List<string>> HandleByBankCard(List<List<string>> changeList)
|
|
{
|
|
foreach (var changeLog in changeList)
|
|
{
|
|
switch (changeLog[0])
|
|
{
|
|
case "ValidState":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
changeLog[2] = "\"" + ("\"InValid\"".Equals(changeLog[2]) ? "无效" : "有效") + "\"";
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
changeLog[3] = "\"" + ("\"InValid\"".Equals(changeLog[3]) ? "无效" : "有效") + "\"";
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
}
|
|
}
|
|
return changeList;
|
|
}
|
|
|
|
|
|
|
|
private static List<List<string>> HandleByClient(List<List<string>> changeList)
|
|
{
|
|
foreach(var changeLog in changeList)
|
|
{
|
|
switch (changeLog[0])
|
|
{
|
|
case "EvaluateExpireDate":
|
|
if (!string.IsNullOrEmpty(changeLog[2])&& changeLog[2].StartsWith("\"9999"))
|
|
{
|
|
changeLog[2] = "\"长期有效\"";
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]) && changeLog[3].StartsWith("\"9999"))
|
|
{
|
|
changeLog[3] = "\"长期有效\"";
|
|
}
|
|
break;
|
|
case "CustomerManagerId":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var userIds = ConvertStringToIntIds(changeLog[2]);
|
|
if (userIds == null || userIds.Count == 0)
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
var userList = GetUserNamesByUserIds(userIds);
|
|
if (userList != null && userList.Count > 0)
|
|
{
|
|
changeLog[2] = "\"" + String.Join(",", userList) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var userIds = ConvertStringToIntIds(changeLog[3]);
|
|
if (userIds == null || userIds.Count == 0)
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
var userList = GetUserNamesByUserIds(userIds);
|
|
if (userList != null && userList.Count > 0)
|
|
{
|
|
changeLog[3] = "\"" + String.Join(",", userList) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "SalesDepartmentId":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var ids = ConvertStringToIntIds(changeLog[2]);
|
|
if (ids == null || ids.Count == 0)
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
var list = GetDepartNamesByIds(ids);
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
changeLog[2] = "\"" + String.Join(",", list) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var ids = ConvertStringToIntIds(changeLog[3]);
|
|
if (ids == null || ids.Count == 0)
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
var list = GetDepartNamesByIds(ids);
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
changeLog[3] = "\"" + String.Join(",", list) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "Seller":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var ids = ConvertStringToIntIds(changeLog[2]);
|
|
if (ids == null || ids.Count == 0)
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
var list = GetSalemanNamesByIds(ids);
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
changeLog[2] = "\"" + String.Join(",", list) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var ids = ConvertStringToIntIds(changeLog[3]);
|
|
if (ids == null || ids.Count == 0)
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
var list = GetSalemanNamesByIds(ids);
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
changeLog[3] = "\"" + String.Join(",", list) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "IsTradeCredit":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
if (changeLog[2] == "1")
|
|
{
|
|
changeLog[2] = "是";
|
|
}
|
|
if (changeLog[2] == "0")
|
|
{
|
|
changeLog[2] = "否";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
if (changeLog[3] == "1")
|
|
{
|
|
changeLog[3] = "是";
|
|
}
|
|
if (changeLog[3] == "0")
|
|
{
|
|
changeLog[3] = "否";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "ParentId":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
int id;
|
|
if (int.TryParse(changeLog[2], out id))
|
|
{
|
|
var name = GetClientNameById(id);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
int id;
|
|
if (int.TryParse(changeLog[3], out id))
|
|
{
|
|
var name = GetClientNameById(id);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "DerivativesInvestmentVarieties":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var ids = ConvertStringToIntIds(changeLog[2]);
|
|
if (ids == null || ids.Count == 0)
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
var list = GetDerivativesInvestmentVarietiesNamesByIds(ids);
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
changeLog[2] = "\"" + String.Join(",", list) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var ids = ConvertStringToIntIds(changeLog[3]);
|
|
if (ids == null || ids.Count == 0)
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
var list = GetDerivativesInvestmentVarietiesNamesByIds(ids);
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
changeLog[3] = "\"" + String.Join(",", list) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "FundsSource":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var name = GetOptionNameById("FundsSource",changeLog[2]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var name = GetOptionNameById("FundsSource", changeLog[3]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "IsRealControl":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var name = GetOptionNameById("IsRealControl", changeLog[2]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var name = GetOptionNameById("IsRealControl", changeLog[3]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "BadFaithRecord":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var name = GetOptionNameById("BadFaithRecord", changeLog[2]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var name = GetOptionNameById("BadFaithRecord", changeLog[3]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "InvestmentTerm":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var name = GetOptionNameById("InvestmentTerm", changeLog[2]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var name = GetOptionNameById("InvestmentTerm", changeLog[3]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "IsIndustryConnectVariety":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var name = GetOptionNameById("IsIndustryConnectVariety", changeLog[2]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var name = GetOptionNameById("IsIndustryConnectVariety", changeLog[3]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "TradingInstType":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var id=int.Parse(changeLog[2]);
|
|
var names = GetOptionNameByOrAndId("TradingInstType", id);
|
|
if (names!=null&&names.Count>0)
|
|
{
|
|
changeLog[2] = "\"" + string.Join(",",names) + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var id=int.Parse(changeLog[3]);
|
|
var names = GetOptionNameByOrAndId("TradingInstType", id);
|
|
if (names != null && names.Count > 0)
|
|
{
|
|
changeLog[3] = "\"" + string.Join(",", names) + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "ProperClientClass":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var name = GetOptionNameById("ProperClientClass", changeLog[2]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var name = GetOptionNameById("ProperClientClass", changeLog[3]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "IsEvaluate":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
if (changeLog[2] == "1")
|
|
{
|
|
changeLog[2] = "是";
|
|
}
|
|
if (changeLog[2] == "0")
|
|
{
|
|
changeLog[2] = "否";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
if (changeLog[3] == "1")
|
|
{
|
|
changeLog[3] = "是";
|
|
}
|
|
if (changeLog[3] == "0")
|
|
{
|
|
changeLog[3] = "否";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "AppropriatenessDegree":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var name = GetOptionNameById("AppropriatenessDegree", changeLog[2]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var name = GetOptionNameById("AppropriatenessDegree", changeLog[3]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "RiskServiceDegree":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var name = GetOptionNameById("RiskServiceDegree", changeLog[2]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[2] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var name = GetOptionNameById("RiskServiceDegree", changeLog[3]);
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
changeLog[3] = "\"" + name + "\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "AppropriatenessAssessor":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var userIds = ConvertStringToIntIds(changeLog[2]);
|
|
if (userIds == null || userIds.Count == 0)
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
var userList = GetUserNamesByUserIds(userIds);
|
|
if (userList != null && userList.Count > 0)
|
|
{
|
|
changeLog[2] = "\"" + String.Join(",", userList) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var userIds = ConvertStringToIntIds(changeLog[3]);
|
|
if (userIds == null || userIds.Count == 0)
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
var userList = GetUserNamesByUserIds(userIds);
|
|
if (userList != null && userList.Count > 0)
|
|
{
|
|
changeLog[3] = "\"" + String.Join(",", userList) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "IsRequireConversionTypes":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
if (changeLog[2] == "1")
|
|
{
|
|
changeLog[2] = "是";
|
|
}
|
|
if (changeLog[2] == "0")
|
|
{
|
|
changeLog[2] = "否";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
if (changeLog[3] == "1")
|
|
{
|
|
changeLog[3] = "是";
|
|
}
|
|
if (changeLog[3] == "0")
|
|
{
|
|
changeLog[3] = "否";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
case "IsAssessmentResultChange":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
if (changeLog[2] == "1")
|
|
{
|
|
changeLog[2] = "是";
|
|
}
|
|
if (changeLog[2] == "0")
|
|
{
|
|
changeLog[2] = "否";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
if (changeLog[3] == "1")
|
|
{
|
|
changeLog[3] = "是";
|
|
}
|
|
if (changeLog[3] == "0")
|
|
{
|
|
changeLog[3] = "否";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
}
|
|
}
|
|
return changeList;
|
|
}
|
|
|
|
private static List<List<string>> HandleByClientDuty(List<List<string>> changeList)
|
|
{
|
|
foreach (var changeLog in changeList)
|
|
{
|
|
switch (changeLog[0])
|
|
{
|
|
case "ContactTypeId":
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(changeLog[2]))
|
|
{
|
|
var contactTypeIds = ConvertStringToIntIds(changeLog[2]);
|
|
if (contactTypeIds == null || contactTypeIds.Count == 0)
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
var contactTypeList = GetContactTypeNamesByTypeIds(contactTypeIds);
|
|
if (contactTypeList != null && contactTypeList.Count > 0)
|
|
{
|
|
changeLog[2] = "\"" + String.Join(",", contactTypeList) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[2] = "\"\"";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(changeLog[3]))
|
|
{
|
|
var contactTypeIds = ConvertStringToIntIds(changeLog[3]);
|
|
if (contactTypeIds == null || contactTypeIds.Count == 0)
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
var contactTypeList = GetContactTypeNamesByTypeIds(contactTypeIds);
|
|
if (contactTypeList != null && contactTypeList.Count > 0)
|
|
{
|
|
changeLog[3] = "\"" + String.Join(",", contactTypeList) + "\"";
|
|
}
|
|
else
|
|
{
|
|
changeLog[3] = "\"\"";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception) { }
|
|
break;
|
|
}
|
|
}
|
|
return changeList;
|
|
}
|
|
|
|
|
|
|
|
private static List<int> ConvertStringToIntIds(string intStr)
|
|
{
|
|
intStr=intStr.Replace("\"", "");
|
|
if (string.IsNullOrEmpty(intStr))
|
|
{
|
|
return new List<int>();
|
|
}
|
|
return intStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(p => int.Parse(p)).ToList();
|
|
}
|
|
|
|
private static List<string> ConvertStringToStringIds(string intStr)
|
|
{
|
|
intStr = intStr.Replace("\"", "");
|
|
if (string.IsNullOrEmpty(intStr))
|
|
{
|
|
return new List<string>();
|
|
}
|
|
return intStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().Select(p => p).ToList();
|
|
}
|
|
|
|
|
|
private static string GetOptionNameById(string key,string id)
|
|
{
|
|
id = id.Replace("\"", "");
|
|
var config = ClientEditConfigService.GetConfig(true);
|
|
if (config == null|| config.selects==null|| !config.selects.ContainsKey(key))
|
|
{
|
|
return id;
|
|
}
|
|
|
|
return config.selects.FirstOrDefault(p => p.Key.Equals(key)).Value.FirstOrDefault(p => p.Value == id)?.Text;
|
|
}
|
|
|
|
|
|
private static List<string> GetOptionNameByOrAndId(string key, int id)
|
|
{
|
|
|
|
|
|
var config = ClientEditConfigService.GetConfig(true);
|
|
if (config == null || config.selects == null || !config.selects.ContainsKey(key))
|
|
{
|
|
return null;
|
|
}
|
|
var values = config.selects.FirstOrDefault(p => p.Key.Equals(key)).Value;
|
|
if (values == null || !values.Any())
|
|
{
|
|
return null;
|
|
}
|
|
if (id == 0)
|
|
{
|
|
return values.Select(p => p.Text).ToList();
|
|
}
|
|
var result = new List<string>();
|
|
values.ToList().ForEach(p =>
|
|
{
|
|
var intValue = int.Parse(p.Value);
|
|
if ((id & intValue) > 0)
|
|
{
|
|
result.Add(p.Text);
|
|
}
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 通过userId获取用户名称
|
|
/// </summary>
|
|
/// <param name="userIds"></param>
|
|
/// <returns></returns>
|
|
private static List<string> GetUserNamesByUserIds(List<int> userIds)
|
|
{
|
|
using(var dbContext = DbContextFactory.GetErpBaseContext())
|
|
{
|
|
return dbContext.SystemUsers.AsNoTracking().Where(p => userIds.Contains(p.Id)).Select(p => p.Name).ToList();
|
|
}
|
|
}
|
|
|
|
private static List<string> GetDepartNamesByIds(List<int> ids)
|
|
{
|
|
using (var dbContext = DbContextFactory.GetErpBaseContext())
|
|
{
|
|
return dbContext.Departments.AsNoTracking().Where(p => ids.Contains(p.Id)).Select(p => p.Name).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
private static List<string> GetDerivativesInvestmentVarietiesNamesByIds(List<int> ids)
|
|
{
|
|
var result = new List<string>();
|
|
ids.ForEach(p =>
|
|
{
|
|
result.Add(Enum.GetName(typeof(DerivativesInvestmentVarietiesEnum), p));
|
|
});
|
|
return result;
|
|
}
|
|
|
|
|
|
private static List<string> GetSalemanNamesByIds(List<int> ids)
|
|
{
|
|
using (var dbContext = DbContextFactory.GetYLDbContext())
|
|
{
|
|
return dbContext.salesmen.AsNoTracking().Where(p => ids.Contains(p.id)).Select(p => p.Name).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
private static string GetClientNameById(int id)
|
|
{
|
|
using (var dbContext = DbContextFactory.GetClientDbContext(null))
|
|
{
|
|
var client= dbContext.client.AsNoTracking().FirstOrDefault(p => p.id==id);
|
|
return client != null ? client.Name : "";
|
|
}
|
|
}
|
|
|
|
|
|
private static List<string> GetContactTypeNamesByTypeIds(List<int> typeIds)
|
|
{
|
|
using (var dbContext = DbContextFactory.GetClientDbContext(null))
|
|
{
|
|
return dbContext.contactype.AsNoTracking().Where(p => typeIds.Contains(p.id)).Select(p => p.ContactType).ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|