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.

134 lines
5.1 KiB

  1. namespace CounsellorBL.BLStructure.SYS
  2. {
  3. using CounsellorBL.Common;
  4. using CounsellorBL.Helper;
  5. using MonumentDefine;
  6. using Newtonsoft.Json.Linq;
  7. using OT.COM.ArsenalDB;
  8. using OT.COM.LogisticsUtil;
  9. using OT.COM.SignalerMessage;
  10. using SoldierData.EnterprizeV4;
  11. using System;
  12. using System.Collections.Generic;
  13. using static CounsellorBL.Common.EntityBaseExtension;
  14. public class ParamCatalogService : SingleDataTableTemplate<tb_sys_paramcatalog>
  15. {
  16. public ParamCatalogService()
  17. {
  18. dgDeleteCommandGenerator = deleteCommandGenerator;
  19. ldgCopy_ModifyEachCopyItemCommand .Add( _addParams );
  20. }
  21. [Auth(false)]
  22. public new CResponseMessage Read(CRequestMessage i_crmInput) => base.Read(i_crmInput);
  23. private string _addParams(ArsenalInterface ai, EntityBase i_ebOld, EntityBase i_oInst, out List<Command> o_lcAddition,
  24. [System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
  25. [System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
  26. [System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
  27. {
  28. string sMsg = null;
  29. List<Command> lCmds = null;
  30. try
  31. {
  32. tb_sys_param pDetailDisplay = new tb_sys_param();
  33. pDetailDisplay.SetFullDirtyEx(EColumnFilter.ES_NO_SYSTEMCOLUMN_NO_UID);
  34. string sNewMstUID = (i_oInst as tb_sys_paramcatalog).uid;
  35. tb_sys_param pDetailCond = new tb_sys_param()
  36. {
  37. paramcatalog = (i_ebOld as tb_sys_paramcatalog).uid
  38. };
  39. List<Command> lcTemp = new List<Command>();
  40. Command cSelectPara = Command.SetupSelectCmd(pDetailDisplay, pDetailCond);
  41. List<tb_sys_param> lAllDetail = ai.RunQueryList<tb_sys_param>(cSelectPara);
  42. foreach (tb_sys_param pa in lAllDetail)
  43. {
  44. pa.uid = Guid.NewGuid().ToString();
  45. pa.paramcatalog = sNewMstUID;
  46. lcTemp.Add(Command.SetupInsertCmd(pa));
  47. }
  48. lCmds = lcTemp;
  49. }
  50. catch (Exception ex)
  51. {
  52. LogHelper.DBLog(Util.GetLastExceptionMsg(ex));
  53. sMsg = $"{nameof(_addParams)} unknwon exception. Call from {i_sMemberName} {i_sSourcePath}({i_nCodeLine}).";
  54. #if DEBUG
  55. System.Diagnostics.Debug.WriteLine(sMsg);
  56. #endif
  57. }
  58. o_lcAddition = lCmds;
  59. return sMsg;
  60. }
  61. protected string deleteCommandGenerator(CRequestMessage i_crmInput, JArray i_jaItems, tb_sys_session i_sSessionUser, out List<Command> o_lcResult, List<string> i_saQryContainKeys,
  62. [System.Runtime.CompilerServices.CallerLineNumber] int i_nCodeLine = 0,
  63. [System.Runtime.CompilerServices.CallerMemberName] string i_sMemberName = "",
  64. [System.Runtime.CompilerServices.CallerFilePath] string i_sSourcePath = "")
  65. {
  66. string sMsg = null;
  67. List<Command> lcCmds = new List<Command>();
  68. try
  69. {
  70. do
  71. {
  72. foreach (JToken jtkItem in i_jaItems)
  73. {
  74. Dictionary<string, object> dicItem = jtkItem.ToObject<Dictionary<string, object>>();
  75. sMsg = getManualLog(i_crmInput, dicItem, BLWording.LOG_ACTION_NAME_DELETESQL, out Command cLog);
  76. if (sMsg != null)
  77. {
  78. break;
  79. }
  80. if (cLog != null)
  81. {
  82. lcCmds.Add(cLog);
  83. }
  84. string sParamCatalogUID = null;
  85. if (dicItem.ContainsKey(BLWording.WHEREDATA) && dicItem[BLWording.WHEREDATA] is JObject wheredata)
  86. {
  87. Dictionary<string, object> wheredataDic = wheredata.ToObject<Dictionary<string, object>>();
  88. // Get all prgram
  89. if (wheredataDic != null && wheredataDic.ContainsKey(BLWording.UID))
  90. {
  91. sParamCatalogUID = wheredataDic[tb_sys_paramcatalog.CN_UID].ToString();
  92. lcCmds.Add(Command.SetupDeleteCmd(new tb_sys_param() { paramcatalog = sParamCatalogUID }));
  93. lcCmds.Add(Command.SetupDeleteCmd(new tb_sys_paramcatalog() { uid = sParamCatalogUID }));
  94. }
  95. }
  96. }
  97. }
  98. while (false);
  99. }
  100. catch (Exception ex)
  101. {
  102. LogHelper.DBLog(Util.GetLastExceptionMsg(ex));
  103. sMsg = $"{nameof(_addParams)} unknwon exception. Call from {i_sMemberName} {i_sSourcePath}({i_nCodeLine}).";
  104. #if DEBUG
  105. System.Diagnostics.Debug.WriteLine(sMsg);
  106. #endif
  107. }
  108. o_lcResult = lcCmds;
  109. return sMsg;
  110. }
  111. }
  112. }