namespace CounsellorBL.BLStructure.SYS { using CounsellorBL.Common; using CounsellorBL.Helper; using MonumentDefine; using Newtonsoft.Json.Linq; using OT.COM.ArsenalDB; using OT.COM.LogisticsUtil; using OT.COM.SignalerMessage; using SoldierData.EnterprizeV4; using System; using System.Collections.Generic; using static CounsellorBL.Common.EntityBaseExtension; public class ParamCatalogService : SingleDataTableTemplate { public ParamCatalogService() { dgDeleteCommandGenerator = deleteCommandGenerator; ldgCopy_ModifyEachCopyItemCommand .Add( _addParams ); } [Auth(false)] public new CResponseMessage Read(CRequestMessage i_crmInput) => base.Read(i_crmInput); private string _addParams(ArsenalInterface ai, EntityBase i_ebOld, EntityBase i_oInst, out List o_lcAddition, [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 lCmds = null; try { tb_sys_param pDetailDisplay = new tb_sys_param(); pDetailDisplay.SetFullDirtyEx(EColumnFilter.ES_NO_SYSTEMCOLUMN_NO_UID); string sNewMstUID = (i_oInst as tb_sys_paramcatalog).uid; tb_sys_param pDetailCond = new tb_sys_param() { paramcatalog = (i_ebOld as tb_sys_paramcatalog).uid }; List lcTemp = new List(); Command cSelectPara = Command.SetupSelectCmd(pDetailDisplay, pDetailCond); List lAllDetail = ai.RunQueryList(cSelectPara); foreach (tb_sys_param pa in lAllDetail) { pa.uid = Guid.NewGuid().ToString(); pa.paramcatalog = sNewMstUID; lcTemp.Add(Command.SetupInsertCmd(pa)); } lCmds = lcTemp; } catch (Exception ex) { LogHelper.DBLog(Util.GetLastExceptionMsg(ex)); sMsg = $"{nameof(_addParams)} unknwon exception. Call from {i_sMemberName} {i_sSourcePath}({i_nCodeLine})."; #if DEBUG System.Diagnostics.Debug.WriteLine(sMsg); #endif } o_lcAddition = lCmds; return sMsg; } protected string deleteCommandGenerator(CRequestMessage i_crmInput, JArray i_jaItems, tb_sys_session i_sSessionUser, out List o_lcResult, List 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 lcCmds = new List(); try { do { foreach (JToken jtkItem in i_jaItems) { Dictionary dicItem = jtkItem.ToObject>(); sMsg = getManualLog(i_crmInput, dicItem, BLWording.LOG_ACTION_NAME_DELETESQL, out Command cLog); if (sMsg != null) { break; } if (cLog != null) { lcCmds.Add(cLog); } string sParamCatalogUID = null; if (dicItem.ContainsKey(BLWording.WHEREDATA) && dicItem[BLWording.WHEREDATA] is JObject wheredata) { Dictionary wheredataDic = wheredata.ToObject>(); // Get all prgram if (wheredataDic != null && wheredataDic.ContainsKey(BLWording.UID)) { sParamCatalogUID = wheredataDic[tb_sys_paramcatalog.CN_UID].ToString(); lcCmds.Add(Command.SetupDeleteCmd(new tb_sys_param() { paramcatalog = sParamCatalogUID })); lcCmds.Add(Command.SetupDeleteCmd(new tb_sys_paramcatalog() { uid = sParamCatalogUID })); } } } } while (false); } catch (Exception ex) { LogHelper.DBLog(Util.GetLastExceptionMsg(ex)); sMsg = $"{nameof(_addParams)} unknwon exception. Call from {i_sMemberName} {i_sSourcePath}({i_nCodeLine})."; #if DEBUG System.Diagnostics.Debug.WriteLine(sMsg); #endif } o_lcResult = lcCmds; return sMsg; } } }