You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
7.1 KiB
157 lines
7.1 KiB
|
|
using CounsellorBL.Helper;
|
|
using MonumentDefine;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using OT.COM.ArsenalDB;
|
|
using OT.COM.LogisticsUtil;
|
|
using OT.COM.SignalerMessage;
|
|
using SoldierData;
|
|
using SoldierData.EnterprizeV4;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CounsellorBL.BLStructure.SYS
|
|
{
|
|
class PersonalInfoService : ModelDataTemplate<VMPersionalInfo>
|
|
{
|
|
public PersonalInfoService() : base()
|
|
{
|
|
dgReadCommandGenerator = readCommandGenerator;
|
|
|
|
dgUpdateCommandGenerator = updateCommandGenerator;
|
|
}
|
|
|
|
protected string readCommandGenerator(CRequestMessage i_crmInput, JArray i_jaData, tb_sys_session i_sSessionUser, out Command o_c,
|
|
[System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
|
|
[System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
|
|
[System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
|
|
{
|
|
string sMsg;
|
|
Command cRes = null;
|
|
|
|
try
|
|
{
|
|
do
|
|
{
|
|
QueryJsonElementCollection lBlocks = new QueryJsonElementCollection();
|
|
QueryJsonElement qjeA = lBlocks.GetInst();
|
|
qjeA.table = tb_sys_session.TABLENAME;
|
|
qjeA.wherecols = new WhereNode(tb_sys_session.CN_UID, WhereNode.EColumnOperation.EOT_EQ, typeof(tb_sys_session), i_crmInput.token);
|
|
lBlocks.Add(qjeA);
|
|
|
|
QueryJsonElement qjeUser = lBlocks.GetInst();
|
|
qjeUser.table = tb_sys_user.TABLENAME;
|
|
qjeUser.jointype = QueryJsonElement.LEFT_JOIN;
|
|
qjeUser.jointable = qjeA;
|
|
qjeUser.joincols = new Dictionary<string, string>() {
|
|
{ tb_sys_user.CN_UID, tb_sys_session.CN_CREATE_USER_UID }};
|
|
lBlocks.Add(qjeUser);
|
|
|
|
QueryJsonElement qjeB = lBlocks.GetInst();
|
|
qjeB.table = tb_hr_employee.TABLENAME;
|
|
qjeB.jointype = QueryJsonElement.LEFT_JOIN;
|
|
qjeB.displaycols = new List<string>() { tb_hr_employee.CN_EMAIL, tb_hr_employee.CN_UID };
|
|
qjeB.jointable = qjeUser;
|
|
qjeB.joincols = new Dictionary<string, string>() {
|
|
{ tb_hr_employee.CN_UID, tb_sys_user.CN_UID }};
|
|
lBlocks.Add(qjeB);
|
|
|
|
|
|
QueryJsonElement qjeC = lBlocks.GetInst();
|
|
qjeC.table = tb_sys_user2entercode.TABLENAME;
|
|
qjeC.aliascols = new Dictionary<string, List<string>>()
|
|
{ {tb_sys_user2entercode.CN_UID, new List<string>(){ VMPersionalInfo.CN_USER2ENTERCODE_UID } } };
|
|
qjeC.displaycols = new List<string>() { tb_sys_user2entercode.CN_USER_ENTERCODE };
|
|
qjeC.jointype = QueryJsonElement.LEFT_JOIN;
|
|
qjeC.jointable = qjeUser;
|
|
qjeC.joincols = new Dictionary<string, string>() {
|
|
{ tb_sys_user2entercode.CN_USER_UID, tb_sys_user.CN_UID }};
|
|
lBlocks.Add(qjeC);
|
|
|
|
sMsg = MakeSelectJoinByBlocks(lBlocks, out cRes);
|
|
|
|
if (sMsg != null)
|
|
{
|
|
break;
|
|
}
|
|
|
|
}
|
|
while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.DBLog(Util.GetLastExceptionMsg(ex), i_nCodeLine, i_sMemberName, i_sSourcePath);
|
|
sMsg = $"{nameof(readCommandGenerator)} unknwon exception. i_crmInput={JsonConvert.SerializeObject(i_crmInput)}. Call from {i_sMemberName} {i_sSourcePath}({i_nCodeLine}).";
|
|
#if DEBUG
|
|
System.Diagnostics.Debug.WriteLine(sMsg);
|
|
#endif
|
|
}
|
|
|
|
o_c = cRes;
|
|
return sMsg;
|
|
}
|
|
|
|
protected string updateCommandGenerator(CRequestMessage i_crmInput, JArray i_jaData, tb_sys_session i_sSessionUser, out List<Command> o_lResult, List<string> i_saQryContainKeys,
|
|
[System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
|
|
[System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
|
|
[System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
|
|
{
|
|
string sMsg = null;
|
|
List<Command> lcCmd = new List<Command>();
|
|
|
|
try
|
|
{
|
|
do
|
|
{
|
|
foreach (JToken joData in i_jaData)
|
|
{
|
|
Dictionary<string, object> dicData = joData.ToObject<Dictionary<string, object>>();
|
|
|
|
string sUserID = null;
|
|
|
|
if (dicData.ContainsKey(BLWording.WHEREDATA))
|
|
{
|
|
JObject wheredata = dicData[BLWording.WHEREDATA] as JObject;
|
|
Dictionary<string, object> wheredataDic = wheredata?.ToObject<Dictionary<string, object>>();
|
|
if (wheredataDic != null && wheredataDic.ContainsKey(BLWording.UID))
|
|
{
|
|
sUserID = wheredataDic[BLWording.UID].ToString();
|
|
}
|
|
}
|
|
|
|
JObject joWriteData = dicData[BLWording.DATA] as JObject;
|
|
Dictionary<string, object> dicWriteData = joWriteData.ToObject<Dictionary<string, object>>();
|
|
if (dicWriteData.ContainsKey(tb_sys_user2entercode.CN_USER_ENTERCODE))
|
|
{
|
|
tb_sys_user2entercode u2p = new tb_sys_user2entercode() { user_entercode = dicWriteData[tb_sys_user2entercode.CN_USER_ENTERCODE].ToString() };
|
|
Command c = Command.SetupUpdateCmd(u2p, new WhereNode(tb_sys_user2entercode.CN_USER_UID, WhereNode.EColumnOperation.EOT_EQ, typeof(tb_sys_user2entercode), sUserID));
|
|
lcCmd.Add(c);
|
|
}
|
|
|
|
if (dicWriteData.ContainsKey(tb_hr_employee.CN_EMAIL))
|
|
{
|
|
tb_hr_employee u = new tb_hr_employee() { email = dicWriteData[tb_hr_employee.CN_EMAIL].ToString() };
|
|
Command c = Command.SetupUpdateCmd(u, new WhereNode(tb_sys_user.CN_UID, WhereNode.EColumnOperation.EOT_EQ, typeof(tb_sys_user), sUserID));
|
|
lcCmd.Add(c);
|
|
}
|
|
}
|
|
|
|
}
|
|
while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.DBLog(Util.GetLastExceptionMsg(ex), i_nCodeLine, i_sMemberName, i_sSourcePath);
|
|
sMsg = $"{nameof(updateCommandGenerator)} unknwon exception. i_crmInput={JsonConvert.SerializeObject(i_crmInput)}. Call from {i_sMemberName} {i_sSourcePath}({i_nCodeLine}).";
|
|
#if DEBUG
|
|
System.Diagnostics.Debug.WriteLine(sMsg);
|
|
#endif
|
|
}
|
|
|
|
o_lResult = lcCmd;
|
|
return sMsg;
|
|
}
|
|
|
|
}
|
|
}
|