GlobalVar.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. using LJLib.LocalLog;
  2. using LJLib.Net.SPI.Server;
  3. using LJLib.Tools.DEncrypt;
  4. using LJLib.Tools.File;
  5. using System;
  6. using System.Data.SqlClient;
  7. using System.Diagnostics;
  8. using System.IO;
  9. using System.Reflection;
  10. using System.Threading;
  11. using JLHHJSvr.BLL;
  12. using JLHHJSvr.Com;
  13. using JLHHJSvr.Com.APP;
  14. using JLHHJSvr.DBA;
  15. using JLHHJSvr.Excutor;
  16. using JLHHJSvr.Excutor.APP;
  17. using JLHHJSvr.LJLib.HttpServer;
  18. using LJLib;
  19. using LJLib.TextLog;
  20. using JLHHJSvr.Tools;
  21. using JLHHJSvr.Helper;
  22. namespace JLHHJSvr
  23. {
  24. public static class GlobalVar
  25. {
  26. private static ExcutorManager excutorManager = null;
  27. private static Timer _timer = null;
  28. private static object _syncRoot = new object();
  29. private static bool _initing = false;
  30. /// <summary>
  31. /// L1业务后台-HTTP端口(HTTP协议)
  32. /// </summary>
  33. public static string ERP_API_URL { get; set; }
  34. /// <summary>
  35. /// L1业务后台-登录账套名
  36. /// </summary>
  37. public static string ERP_ACCOUNT_NAME { get; set; }
  38. /// <summary>
  39. /// L1业务后台-登录账号
  40. /// </summary>
  41. public static string ERP_ACCOUNT_USERNAME { get; set; }
  42. /// <summary>
  43. /// L1业务后台-登录密码
  44. /// </summary>
  45. public static string ERP_ACCOUNT_PASSWORD { get; set; }
  46. /// <summary>
  47. /// L1业务后台-Token
  48. /// </summary>
  49. public static string ERP_TOKEN { get; set; }
  50. public static ILJServer server
  51. {
  52. get
  53. {
  54. return excutorManager;
  55. }
  56. }
  57. internal static void Init()
  58. {
  59. Trace.Listeners.Clear();
  60. Trace.Listeners.Add(new LocalTraceListener(new SyncLogger(new Logger(App_Data))));
  61. try
  62. {
  63. _timer = new Timer((state) =>
  64. {
  65. lock (_syncRoot)
  66. {
  67. if (_initing)
  68. {
  69. return;
  70. }
  71. _initing = true;
  72. }
  73. try
  74. {
  75. if (_timer == null)
  76. {
  77. return;
  78. }
  79. // 获取数据库连接
  80. string xmlfile = GlobalVar.XmlFile;
  81. XmlConfig xmlconfig = new XmlConfig();
  82. string connectionString = xmlconfig.GetXmlFileValue(xmlfile, string.Empty, "ConnectionString", string.Empty);
  83. string L1Password = xmlconfig.GetXmlFileValue(xmlfile, string.Empty, "L1Password", "");
  84. GlobalVar.ERP_ACCOUNT_NAME = xmlconfig.GetXmlFileValue(xmlfile, string.Empty, "L1Server", "");
  85. GlobalVar.ERP_API_URL = xmlconfig.GetXmlFileValue(xmlfile, string.Empty, "L1API", "");
  86. GlobalVar.ERP_ACCOUNT_USERNAME = xmlconfig.GetXmlFileValue(xmlfile, string.Empty, "L1Usercode", "");
  87. GlobalVar.ERP_ACCOUNT_PASSWORD = DESEncrypt.Decrypt(L1Password, "4A61A8B51C3E42BCAE991F6C913A6A33");//DONE: 解密
  88. if (string.IsNullOrEmpty(connectionString))
  89. {
  90. Trace.Write("未设置数据库连接");
  91. }
  92. else
  93. {
  94. try
  95. {
  96. connectionString = DESEncrypt.Decrypt(connectionString, "4A61A8B51C3E42BCAE991F6C913A6A33");//DONE: 解密
  97. GlobalVar.ConnectionString = connectionString;
  98. // DONE: 更新数据库
  99. var version = new ParkDbVersion();
  100. version.CreateTables(GlobalVar.ConnectionString);
  101. BllHelper.InitUser(GlobalVar.ConnectionString);
  102. _timer.Dispose();
  103. _timer = null;
  104. }
  105. catch (Exception ex)
  106. {
  107. Trace.Write(ex.ToString());
  108. GlobalVar.ConnectionString = string.Empty;
  109. }
  110. }
  111. }
  112. catch (Exception ex)
  113. {
  114. Trace.Write(ex.ToString());
  115. }
  116. finally
  117. {
  118. _initing = false;
  119. }
  120. }, null, 0, 10000);
  121. // HTTP服务
  122. excutorManager = new ExcutorManager();
  123. // excutorManager.AddMap("HelloWord", typeof(HelloWordRequest), new HelloWordExcutor());
  124. excutorManager.AddMap("Login", typeof(LoginRequest), new LoginExcutor());//登陆
  125. excutorManager.AddMap("ChangePassword", typeof(ChangePasswordRequest), new ChangePasswordExcutor());
  126. excutorManager.AddMap("GetSysUserFileString", typeof(GetSysUserFileStringRequest), new GetSysUserFileStringExcutor());
  127. excutorManager.AddMap("SetSysUserFileString", typeof(SetSysUserFileStringRequest), new SetSysUserFileStringExcutor());
  128. excutorManager.AddMap("CommonDynamicSelect", typeof(CommonDynamicSelectRequest), new CommonDynamicSelectExcutor());
  129. excutorManager.AddMap("PingToken", typeof(PingTokenRequest), new PingTokenExcutor());//没啥用
  130. excutorManager.AddMap("GetFileByMd5", typeof(GetFileByMd5Request), new GetFileByMd5Excutor());//根据md5获取文件
  131. excutorManager.AddMap("PostFile", typeof(PostFileRequest), new PostFileExcutor());//上传文件
  132. excutorManager.AddMap("GetUserList", typeof(GetUserListRequest), new GetUserListExcutor());//获取用户列表
  133. excutorManager.AddMap("SaveUserList", typeof(SaveUserListRequest), new SaveUserListExcutor());//保存用户列表
  134. excutorManager.AddMap("DelUserList", typeof(DelUserListRequest), new DelUserListExcutor());//删除用户列表
  135. excutorManager.AddMap("UnLockUser", typeof(UnLockUserRequest), new UnLockUserExcutor());//删除用户列表
  136. excutorManager.AddMap("GetSysFuncPwr", typeof(GetSysFuncPwrRequest), new GetSysFuncPwrExcutor());//获取权限列表
  137. excutorManager.AddMap("GetDept", typeof(GetDeptRequest), new GetDeptExcutor());//获取部门列表
  138. excutorManager.AddMap("GetPriceList", typeof(GetPriceListRequest), new GetPriceListExcutor());//获取价格表列表
  139. excutorManager.AddMap("AuditPriceList", typeof(AuditPriceListRequest), new AuditPriceListExcutor());//审核价格表列表
  140. excutorManager.AddMap("SaveDept", typeof(SaveDeptRequest), new SaveDeptExcutor());//保存部门
  141. excutorManager.AddMap("DeleteDept", typeof(DeleteDeptRequest), new DeleteDeptExcutor());//删除部门
  142. excutorManager.AddMap("AuditDept", typeof(AuditDeptRequest), new AuditDeptExcutor());//审核部门
  143. excutorManager.AddMap("SaveProfitrate", typeof(SaveProfitrateRequest), new SaveProfitrateExcutor());// 保存工厂利润率
  144. excutorManager.AddMap("SaveWorkmanship", typeof(SaveWorkmanshipRequest), new SaveWorkmanshipExcutor());// 保存工艺加点设置
  145. excutorManager.AddMap("DeleteWorkmanship", typeof(DeleteWorkmanshipRequest), new DeleteWorkmanshipExcutor());// 删除工艺加点设置
  146. excutorManager.AddMap("AuditWorkmanship", typeof(AuditWorkmanshipRequest), new AuditWorkmanshipExcutor());// 删除工艺加点设置
  147. excutorManager.AddMap("SaveBedNetType", typeof(SaveBedNetTypeRequest), new SaveBedNetTypeExcutor());// 保存床网类别定义
  148. excutorManager.AddMap("DeleteBedNetType", typeof(DeleteBedNetTypeRequest), new DeleteBedNetTypeExcutor());// 删除床网类别定义
  149. excutorManager.AddMap("SaveMattressType", typeof(SaveMattressTypeRequest), new SaveMattressTypeExcutor());// 保存床垫类别定义
  150. excutorManager.AddMap("DeleteMattressType", typeof(DeleteMattressTypeRequest), new DeleteMattressTypeExcutor());// 删除床垫类别定义
  151. excutorManager.AddMap("SaveMattressFormula", typeof(SaveMattressFormulaRequest), new SaveMattressFormulaExcutor());// 保存床垫公式定义
  152. excutorManager.AddMap("DeleteMattressFormula", typeof(DeleteMattressFormulaRequest), new DeleteMattressFormulaExcutor());// 删除床垫公式定义
  153. excutorManager.AddMap("SaveShrinkage", typeof(SaveShrinkageRequest), new SaveShrinkageExcutor());// 保存裥棉收缩率
  154. excutorManager.AddMap("DeleteShrinkage", typeof(DeleteShrinkageRequest), new DeleteShrinkageExcutor());// 删除裥棉收缩率
  155. excutorManager.AddMap("SaveSpring", typeof(SaveSpringRequest), new SaveSpringExcutor());// 保存弹簧资料
  156. excutorManager.AddMap("DeleteSpring", typeof(DeleteSpringRequest), new DeleteSpringExcutor());// 删除弹簧资料
  157. excutorManager.AddMap("AuditSpring", typeof(AuditSpringRequest), new AuditSpringExcutor());// 审核弹簧资料
  158. excutorManager.AddMap("GetBedNetVarList", typeof(GetBedNetVarListRequest), new GetBedNetVarListExcutor());// 获取物料类型
  159. excutorManager.AddMap("SaveBedNetVar", typeof(SaveBedNetVarRequest), new SaveBedNetVarExcutor());// 保存床网/床垫变量定义
  160. excutorManager.AddMap("DeleteBedNetVar", typeof(DeleteBedNetVarRequest), new DeleteBedNetVarExcutor());// 删除床网/床垫变量定义
  161. excutorManager.AddMap("GetMtrlTypeList", typeof(GetMtrlTypeListRequest), new GetMtrlTypeListExcutor());// 获取物料类型
  162. excutorManager.AddMap("SaveMtrlType", typeof(SaveMtrlTypeRequest), new SaveMtrlTypeExcutor());// 获取物料类型
  163. excutorManager.AddMap("DeleteMtrlType", typeof(DeleteMtrlTypeRequest), new DeleteMtrlTypeExcutor());// 获取物料类型
  164. excutorManager.AddMap("GetMtrlDefList", typeof(GetMtrlDefListRequest), new GetMtrlDefListExcutor());// 获取物料资料
  165. excutorManager.AddMap("SaveMtrlDef", typeof(SaveMtrlDefRequest), new SaveMtrlDefExcutor());// 保存物料资料
  166. excutorManager.AddMap("DeleteMtrlDef", typeof(DeleteMtrlDefRequest), new DeleteMtrlDefExcutor());// 删除物料资料
  167. excutorManager.AddMap("BanMtrlDef", typeof(BanMtrlDefRequest), new BanMtrlDefExcutor());// 禁用物料资料
  168. excutorManager.AddMap("CopyMtrlDef", typeof(CopyMtrlDefRequest), new CopyMtrlDefExcutor());// 复制物料资料
  169. excutorManager.AddMap("ModifyMtrlDefList", typeof(ModifyMtrlDefListRequest), new ModifyMtrlDefListExcutor());// 复制物料资料
  170. excutorManager.AddMap("GetFormulaCompute", typeof(GetFormulaComputeRequest), new GetFormulaComputeExcutor());// 公式计算
  171. excutorManager.AddMap("SaveMultiPrice", typeof(SaveMultiPriceRequest), new SaveMultiPriceExcutor());// 保存多维度定价
  172. excutorManager.AddMap("DeleteMultiPrice", typeof(DeleteMultiPriceRequest), new DeleteMultiPriceExcutor());// 删除多维度定价
  173. excutorManager.AddMap("BanMultiPrice", typeof(BanMultiPriceRequest), new BanMultiPriceExcutor());// 禁用多维度定价
  174. excutorManager.AddMap("SaveBedNetArea", typeof(SaveBedNetAreaRequest), new SaveBedNetAreaExcutor());// 保存床网分区定义
  175. excutorManager.AddMap("DeleteBedNetArea", typeof(DeleteBedNetAreaRequest), new DeleteBedNetAreaExcutor());// 删除床网分区定义
  176. excutorManager.AddMap("SaveConfigureType", typeof(SaveConfigureTypeRequest), new SaveConfigureTypeExcutor());// 保存部件选配类型
  177. excutorManager.AddMap("DeleteConfigureType", typeof(DeleteConfigureTypeRequest), new DeleteConfigureTypeExcutor());// 删除部件选配类型
  178. excutorManager.AddMap("SaveConfigureCode", typeof(SaveConfigureCodeRequest), new SaveConfigureCodeExcutor());// 保存部件选配项
  179. excutorManager.AddMap("DeleteConfigureCode", typeof(DeleteConfigureCodeRequest), new DeleteConfigureCodeExcutor());// 删除部件选配项
  180. excutorManager.AddMap("SaveConfigureCodeMx", typeof(SaveConfigureCodeMxRequest), new SaveConfigureCodeMxExcutor());// 保存部件选配项值
  181. excutorManager.AddMap("DeleteConfigureCodeMx", typeof(DeleteConfigureCodeMxRequest), new DeleteConfigureCodeMxExcutor());// 删除部件选配项值
  182. excutorManager.AddMap("SaveConfigureBomList", typeof(SaveConfigureBomListRequest), new SaveConfigureBomListExcutor());// 删除部件选配项值
  183. excutorManager.AddMap("DeleteConfigureBomList", typeof(DeleteConfigureBomListRequest), new DeleteConfigureBomListExcutor());// 删除部件选配项值
  184. excutorManager.AddMap("GetMattressImportDW2", typeof(GetMattressImportDW2Request), new GetMattressImportDW2Excutor());// 下拉选择床垫类别
  185. excutorManager.AddMap("SaveMattress", typeof(SaveMattressRequest), new SaveMattressExcutor());// 保存床垫报价
  186. excutorManager.AddMap("SaveMattressAuditing", typeof(SaveMattressAuditingRequest), new SaveMattressAuditingExcutor());// 床垫报价:业务下单/取消
  187. excutorManager.AddMap("DelMattress", typeof(DelMattressRequest), new DelMattressExcutor());// 床垫报价:删除
  188. excutorManager.AddMap("SaveMattressBcp", typeof(SaveMattressBcpRequest), new SaveMattressBcpExcutor());// 保存半成品报价
  189. excutorManager.AddMap("DeleteMattressBcp", typeof(DeleteMattressBcpRequest), new DeleteMattressBcpExcutor());// 删除半成品报价
  190. excutorManager.AddMap("AuditMattressBcp", typeof(AuditMattressBcpRequest), new AuditMattressBcpExcutor());// 审核半成品报价
  191. excutorManager.AddMap("GetMattressPackagMx", typeof(GetMattressPackagMxRequest), new GetMattressPackagMxExcutor());// 包装方式切换
  192. excutorManager.AddMap("GetMattressSubspecs", typeof(GetMattressSubspecsRequest), new GetMattressSubspecsExcutor());// 获取主副规格
  193. excutorManager.AddMap("SaveBedNet", typeof(SaveBedNetRequest), new SaveBedNetExcutor());// 保存床网报价
  194. excutorManager.AddMap("DeleteBedNet", typeof(DeleteBedNetRequest), new DeleteBedNetExcutor());// 删除床网报价
  195. excutorManager.AddMap("AuditBedNet", typeof(AuditBedNetRequest), new AuditBedNetExcutor());// 审核床网报价
  196. excutorManager.AddMap("GetComputeMattress", typeof(GetComputeMattressRequest), new GetComputeMattressExcutor());// 计算床垫报价
  197. excutorManager.AddMap("GetComputeMattressById", typeof(GetComputeMattressByIdRequest), new GetComputeMattressByIdExcutor());// 计算床垫报价
  198. excutorManager.AddMap("GetComputeBednet", typeof(GetComputeBednetRequest), new GetComputeBednetExcutor());// 计算床网报价
  199. excutorManager.AddMap("GetComputeSpring", typeof(GetComputeSpringRequest), new GetComputeSpringExcutor());// 计算弹簧数量
  200. excutorManager.AddMap("CopyMattressAudited", typeof(CopyMattressAuditedRequest), new CopyMattressAuditedExcutor());// 复制审核床垫报价
  201. excutorManager.AddMap("ReCalculateNoAudit", typeof(ReCalculateNoAuditRequest), new ReCalculateNoAuditExcutor());// 重算床垫报价
  202. excutorManager.AddMap("ReCalculateBedNetNoAudit", typeof(ReCalculateBedNetNoAuditRequest), new ReCalculateBedNetNoAuditExcutor());// 重算床网报价
  203. excutorManager.AddMap("ReCalculateERPCost", typeof(ReCalculateERPCostRequest), new ReCalculateERPCostExcutor());// 重算床网报价
  204. excutorManager.AddMap("CoverMattressInterface", typeof(CoverMattressInterfaceRequest), new CoverMattressInterfaceExcutor());// 覆盖配置到副规格产品
  205. excutorManager.AddMap("MattressYWAudit", typeof(MattressYWAuditRequest), new MattressYWAuditExcutor());// 床垫接口业务审核撤审
  206. excutorManager.AddMap("MattressJSAudit", typeof(MattressJSAuditRequest), new MattressJSAuditExcutor());// 床垫接口产品补充审核撤审
  207. excutorManager.AddMap("MattressJS2Audit", typeof(MattressJS2AuditRequest), new MattressJS2AuditExcutor());// 床垫接口清单补充审核撤审
  208. excutorManager.AddMap("SaveMattressInterface", typeof(SaveMattressInterfaceRequest), new SaveMattressInterfaceExcutor());// 床垫接口清单补充审核撤审
  209. excutorManager.AddMap("RefreshMattressInterface", typeof(RefreshMattressInterfaceRequest), new RefreshMattressInterfaceExcutor());// 刷新床垫配置清单
  210. excutorManager.AddMap("RefreshMattressInterfaceQd", typeof(RefreshMattressInterfaceQdRequest), new RefreshMattressInterfaceQdExcutor());// 刷新床垫清单
  211. excutorManager.AddMap("CreatMtrldef", typeof(CreatMtrldefRequest), new CreatMtrldefExcutor());// 生成L1物料
  212. excutorManager.AddMap("UpdateMtrlPrice", typeof(UpdateMtrlPriceRequest), new UpdateMtrlPriceExcutor());// 更新L1计划价
  213. excutorManager.AddMap("DelMtrlPf", typeof(CreatMtrldefRequest), new DelMtrlPfExcutor());// 删除L1清单
  214. excutorManager.AddMap("CreatPrdPf", typeof(CreatPrdPfRequest), new CreatPrdPfExcutor());// 生成L1清单
  215. excutorManager.AddMap("GetERPMtrldefList", typeof(GetERPMtrldefListRequest), new GetERPMtrldefListExcutor());// 获取ERP物料资料
  216. excutorManager.AddMap("GetERPConfigureList", typeof(GetERPConfigureListRequest), new GetERPConfigureListExcutor());// 获取ERP配置资料
  217. excutorManager.AddMap("GetERPWrkGrpList", typeof(GetERPWrkGrpListRequest), new GetERPWrkGrpListExcutor());// 获取工组列表
  218. excutorManager.AddMap("GetERPMtrlTypeList", typeof(GetERPMtrlTypeListRequest), new GetERPMtrlTypeListExcutor());// 获取ERP物料类型
  219. excutorManager.AddMap("GetMattressInterfaceList", typeof(GetMattressInterfaceListRequest), new GetMattressInterfaceListExcutor());// 获取产品清单明细
  220. //excutorManager.AddMap("GetSemiFinishedMxList", typeof(GetSemiFinishedMxListRequest), new GetSemiFinishedMxListExcutor());// 获取产品清单明细
  221. //excutorManager.AddMap("ImportSpring", typeof(ImportSpringRequest), new ImportSpringExcutor());
  222. excutorManager.AddMap("SaveMattressExtra", typeof(SaveMattressExtraRequest), new SaveMattressExtraExcutor());// 保存床网分区定义
  223. excutorManager.AddMap("DeleteMattressExtra", typeof(DeleteMattressExtraRequest), new DeleteMattressExtraExcutor());// 删除床网分区定义
  224. excutorManager.AddMap("SaveMattressExtraType", typeof(SaveMattressExtraTypeRequest), new SaveMattressExtraTypeExcutor());// 保存床网分区类型
  225. excutorManager.AddMap("DeleteMattressExtraType", typeof(DeleteMattressExtraTypeRequest), new DeleteMattressExtraTypeExcutor());// 删除床网分区类型
  226. excutorManager.AddMap("GetFormulaVarList",typeof(GetFormulaVarListRequest),new GetFormulaVarListExcutor());
  227. excutorManager.AddMap("FormulaCheck", typeof(FormulaCheckRequest),new FormulaCheckExcutor());
  228. excutorManager.AddMap("JLH_FetchPrice", typeof(JLH_FetchPriceRequest), new JLH_FetchPriceExcutor());
  229. excutorManager.AddMap("GetResetWiptype", typeof(GetResetWiptypeRequest), new GetResetWiptypeExcutor());
  230. excutorManager.AddMap("ImportMtrlPriceByExcel", typeof(ImportMtrlPriceByExcelRequest), new ImportMtrlPriceByExcelExcutor()); //更新物料价格表单价
  231. excutorManager.AddMap("UpdateL1Basicinfo", typeof(UpdateL1BasicinfoRequest), new UpdateL1BasicinfoExcutor()); // 更新L1基础资料(物料、物料分类、工组)
  232. excutorManager.AddMap("GetBedNetInterfaceList", typeof(GetBedNetInterfaceListRequest), new GetBedNetInterfaceListExcutor()); // 床网清单获取
  233. excutorManager.AddMap("SaveBedNetInterface", typeof(SaveBedNetInterfaceRequest), new SaveBedNetInterfaceExcutor());// 床网接口清单补充审核撤审
  234. excutorManager.AddMap("RefreshBedNetInterface", typeof(RefreshBedNetInterfaceRequest), new RefreshBedNetInterfaceExcutor());// 刷新床网配置清单
  235. excutorManager.AddMap("RefreshBedNetInterfaceQd", typeof(RefreshBedNetInterfaceQdRequest), new RefreshBedNetInterfaceQdExcutor());// 刷新床网清单
  236. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  237. excutorManager.AddMap("CopyConfigureCodeMxList", typeof(CopyConfigureCodeMxListRequest), new CopyConfigureCodeMxListExcutor()); // 复制部件选配项值
  238. excutorManager.AddMap("SaveSoftBedQuote", typeof(SaveSoftBedQuoteRequest), new SaveSoftBedQuoteExcutor()); // 保存/修改软床报价
  239. excutorManager.AddMap("DeleteSoftBedQuote", typeof(DeleteSoftBedQuoteRequest), new DeleteSoftBedQuoteExcutor()); // 删除软床报价
  240. excutorManager.AddMap("AuditSoftBedQuote", typeof(AuditSoftBedQuoteRequest), new AuditSoftBedQuoteExcutor()); // 审核软床报价
  241. excutorManager.AddMap("GetSoftBedMxList", typeof(GetSoftBedMxListRequest), new GetSoftBedMxListExcutor()); // 获取软床报价明细
  242. excutorManager.AddMap("GetSoftBedConfigureList", typeof(GetSoftBedConfigureListRequest), new GetSoftBedConfigureListExcutor()); // 获取软床报价部件选配
  243. excutorManager.AddMap("SaveSoftBedFormula", typeof(SaveSoftBedFormulaRequest), new SaveSoftBedFormulaExcutor()); // 保存软床公式定义
  244. excutorManager.AddMap("SaveErpMtrlPriceList", typeof(SaveErpMtrlPriceListRequest), new SaveErpMtrlPriceListExcutor()); // 保存物料价格
  245. excutorManager.AddMap("GetErpMtrlPriceList", typeof(GetErpMtrlPriceListRequest), new GetErpMtrlPriceListExcutor()); // 获取ERP物料资料定义
  246. excutorManager.AddMap("GetChangeSoftBedMxList", typeof(GetChangeSoftBedMxListRequest), new GetChangeSoftBedMxListExcutor()); // 获取软床报价换料后明细
  247. excutorManager.AddMap("SaveMattressSubSpecs", typeof(SaveMattressSubSpecsRequest), new SaveMattressSubSpecsExcutor()); // 获取软床报价换料后明细
  248. excutorManager.AddMap("SaveSysPost", typeof(SaveSysPostRequest), new SaveSysPostExcutor()); // 发布公告
  249. excutorManager.AddMap("DeleteSysPostMessage", typeof(DeleteSysPostMessageRequest), new DeleteSysPostMessageExcutor()); // 删除公告
  250. excutorManager.AddMap("LockTable", typeof(LockTableRequest), new LockTableExcutor()); // 单据加锁
  251. excutorManager.AddMap("UnLockTable", typeof(UnLockTableRequest), new UnLockTableExcutor()); // 单据解锁
  252. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  253. //excutorManager.AddMap("AdminTestFunction", typeof(AdminTestFunctionRequest), new AdminTestFunctionExcutor());
  254. }
  255. catch (Exception ex)
  256. {
  257. Trace.Write(ex.ToString());
  258. }
  259. }
  260. /// <summary>
  261. /// 定时任务
  262. /// </summary>
  263. public static void StartTimer()
  264. {
  265. var manager = new DailySchedulerManager();
  266. manager.AddTask("ClearExpireLock", new TimeSpan(2, 0, 0),() => ClearExpireLock());
  267. manager.AddTask("ClearOldLogs", new TimeSpan(2, 0, 0),() => CleanupOldLogs());
  268. }
  269. /// <summary>
  270. /// 清理7天前的请求日志文件
  271. /// </summary>
  272. public static void CleanupOldLogs()
  273. {
  274. try
  275. {
  276. var files = Directory.GetFiles(Path.Combine(App_Data, "log"), "REQUEST_*.log");
  277. DateTime threshold = DateTime.Now.AddDays(-7);
  278. foreach (var file in files)
  279. {
  280. string fileName = Path.GetFileNameWithoutExtension(file);
  281. // 格式: REQUEST_yyyyMMdd
  282. if (fileName.Length == "REQUEST_yyyyMMdd".Length &&
  283. DateTime.TryParseExact(fileName.Replace("REQUEST_", ""),
  284. "yyyyMMdd",
  285. null,
  286. System.Globalization.DateTimeStyles.None,
  287. out DateTime logDate))
  288. {
  289. if (logDate < threshold.Date)
  290. {
  291. File.Delete(file);
  292. }
  293. }
  294. }
  295. }
  296. catch(Exception ex)
  297. {
  298. Trace.Write(ex);
  299. }
  300. }
  301. /// <summary>
  302. /// 清理过期锁
  303. /// </summary>
  304. public static void ClearExpireLock()
  305. {
  306. using (SqlConnection con = new SqlConnection(GlobalVar.ConnectionString))
  307. using (SqlCommand cmd = con.CreateCommand())
  308. {
  309. con.Open();
  310. using (cmd.Transaction = con.BeginTransaction())
  311. {
  312. try
  313. {
  314. LockHelper.ClearExpireLock(cmd);
  315. cmd.Transaction.Commit();
  316. }
  317. catch (Exception e)
  318. {
  319. cmd.Transaction?.Rollback();
  320. }
  321. }
  322. }
  323. }
  324. public static string ConnectionString { get; set; }
  325. public static string BinPath
  326. {
  327. get
  328. {
  329. return Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");
  330. }
  331. }
  332. public static bool webapp { get; set; }
  333. public static string App_Data
  334. {
  335. get
  336. {
  337. string app_data = BinPath;
  338. if (webapp)
  339. {
  340. app_data = Directory.GetParent(app_data).FullName + "\\App_Data";
  341. }
  342. if (!Directory.Exists(app_data))
  343. {
  344. Directory.CreateDirectory(app_data);
  345. }
  346. return app_data;
  347. }
  348. }
  349. /// <summary>
  350. /// 是否Web启动模式
  351. /// </summary>
  352. public static bool WebMode { get; set; }
  353. public static string XmlFile
  354. {
  355. get
  356. {
  357. return App_Data + "\\config.xml";
  358. }
  359. }
  360. public static string DataPath
  361. {
  362. get
  363. {
  364. var binpath = FilePathHelper.GetExecutingPath();
  365. string dataPath = binpath;
  366. if (WebMode)
  367. {
  368. dataPath = Directory.GetParent(binpath).FullName + "\\App_Data";
  369. }
  370. if (!Directory.Exists(dataPath))
  371. {
  372. Directory.CreateDirectory(dataPath);
  373. }
  374. return dataPath;
  375. }
  376. }
  377. public static string App_Files
  378. {
  379. get
  380. {
  381. string app_files = App_Data + "\\App_Files";
  382. if (!Directory.Exists(app_files))
  383. {
  384. Directory.CreateDirectory(app_files);
  385. }
  386. return app_files;
  387. }
  388. }
  389. public class ParkFileModel:IFileDBModel
  390. {
  391. public byte[] GetBytes(string md5)
  392. {
  393. if (!string.IsNullOrEmpty(md5))
  394. {
  395. using (var con = new SqlConnection(ConnectionString))
  396. using (var cmd = con.CreateCommand())
  397. {
  398. con.Open();
  399. cmd.CommandText = @"SELECT filedata
  400. FROM st_file
  401. WHERE filemd5 = @filemd5 ";
  402. cmd.Parameters.Clear();
  403. cmd.Parameters.AddWithValue("@filemd5", md5);
  404. using (var reader = cmd.ExecuteReader())
  405. {
  406. if (reader.Read())
  407. {
  408. return reader["fileData"] == DBNull.Value ? null : (byte[]) reader["fileData"];
  409. }
  410. }
  411. }
  412. }
  413. return null;
  414. }
  415. }
  416. }
  417. }