Global.asax.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. using System;
  2. using System.Globalization;
  3. using System.ServiceModel.Activation;
  4. using System.Timers;
  5. using System.Web;
  6. using System.Web.Routing;
  7. using Curtain.Core;
  8. using Curtain.DataAccess;
  9. using Curtain.Log;
  10. using Dongke.IBOSS.PRD.Basics.BaseResources;
  11. using Dongke.IBOSS.PRD.Basics.DataAccess;
  12. using Dongke.IBOSS.PRD.Basics.Library;
  13. using Dongke.IBOSS.PRD.WCF.Contracts;
  14. using Dongke.IBOSS.PRD.WCF.ExHGS3QRS;
  15. using Dongke.IBOSS.PRD.WCF.Services;
  16. namespace Dongke.IBOSS.PRD.WCF.WebHosting
  17. {
  18. public class Global : HttpApplication
  19. {
  20. protected void Application_Start(object sender, EventArgs e)
  21. {
  22. Logger.DefaultLogDirectory = "Log";
  23. InitService();
  24. // 更改连接串
  25. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.Config);
  26. DataManager.ConnectionString = string.Format(DataManager.ConnectionStringFormat,
  27. ini.ReadIniData("DBSetting", "DBIP"),
  28. ini.ReadIniData("DBSetting", "DBPort"),
  29. ini.ReadIniData("DBSetting", "SID"),
  30. ini.ReadIniData("DBSetting", "DBUser"),
  31. Encryption.DecryptDES(ini.ReadIniData("DBSetting", "DBPassword"), Constant.S_ENCRYPTION_KEY)
  32. );
  33. DataManager.ConnectionStringReport = DataManager.ConnectionString;
  34. try
  35. {
  36. string DBIP = ini.ReadIniData("DBSettingReport", "DBIP");
  37. if (!string.IsNullOrWhiteSpace(DBIP))
  38. {
  39. DataManager.ConnectionStringReport = string.Format(DataManager.ConnectionStringFormat,
  40. DBIP,
  41. ini.ReadIniData("DBSettingReport", "DBPort"),
  42. ini.ReadIniData("DBSettingReport", "SID"),
  43. ini.ReadIniData("DBSettingReport", "DBUser"),
  44. Encryption.DecryptDES(ini.ReadIniData("DBSettingReport", "DBPassword"), Constant.S_ENCRYPTION_KEY)
  45. );
  46. }
  47. }
  48. catch
  49. {
  50. }
  51. DataAccess.DefaultDataBaseType = Curtain.DataAccess.DataBaseType.Oracle;
  52. DataAccess.DefaultConnectionString = DataManager.ConnectionString;
  53. // SAP接口自动调用
  54. InitSAP_HEGII();
  55. }
  56. private void InitService()
  57. {
  58. // 此处处理需要进行映射的服务类
  59. /* ServiceRoute实体
  60. * 第一个参数为客户端调用终结点地址的名称
  61. * 第二个参数固定写法
  62. * 第三个参数为终结点调用对应的服务类
  63. */
  64. RouteTable.Routes.Add
  65. (
  66. new ServiceRoute
  67. (
  68. "DKService/PDAModuleService", new WebServiceHostFactory(), typeof(PDAModuleService)
  69. )
  70. );
  71. RouteTable.Routes.Add
  72. (
  73. new ServiceRoute
  74. (
  75. "DKService/DKIBOSSPRDService", new WebServiceHostFactory(), typeof(DKIBOSSPRDService)
  76. )
  77. );
  78. RouteTable.Routes.Add
  79. (
  80. new ServiceRoute
  81. (
  82. "DKService/CommonModuleService", new WebServiceHostFactory(), typeof(CommonModuleService)
  83. )
  84. );
  85. RouteTable.Routes.Add
  86. (
  87. new ServiceRoute
  88. (
  89. "DKService/SystemModuleService", new WebServiceHostFactory(), typeof(SystemModuleService)
  90. )
  91. );
  92. RouteTable.Routes.Add
  93. (
  94. new ServiceRoute
  95. (
  96. "DKService/HRModuleService", new WebServiceHostFactory(), typeof(HRModuleService)
  97. )
  98. );
  99. RouteTable.Routes.Add
  100. (
  101. new ServiceRoute
  102. (
  103. "DKService/PCModuleService", new WebServiceHostFactory(), typeof(PCModuleService)
  104. )
  105. );
  106. RouteTable.Routes.Add
  107. (
  108. new ServiceRoute
  109. (
  110. "DKService/PMModuleService", new WebServiceHostFactory(), typeof(PMModuleService)
  111. )
  112. );
  113. RouteTable.Routes.Add
  114. (
  115. new ServiceRoute
  116. (
  117. "DKService/TATModuleService", new WebServiceHostFactory(), typeof(TATModuleService)
  118. )
  119. );
  120. RouteTable.Routes.Add
  121. (
  122. new ServiceRoute
  123. (
  124. "DKService/ReportModuleService", new WebServiceHostFactory(), typeof(ReportModuleService)
  125. )
  126. );
  127. RouteTable.Routes.Add
  128. (
  129. new ServiceRoute
  130. (
  131. "DKService/WCFTestService", new WebServiceHostFactory(), typeof(WCFTestService)
  132. )
  133. );
  134. RouteTable.Routes.Add
  135. (
  136. new ServiceRoute
  137. (
  138. "DKService/CMNModuleService", new WebServiceHostFactory(), typeof(CMNModuleService)
  139. )
  140. );
  141. RouteTable.Routes.Add
  142. (
  143. new ServiceRoute
  144. (
  145. "DKService/PMModuleServiceNew", new WebServiceHostFactory(), typeof(PMModuleServiceNew)
  146. )
  147. );
  148. RouteTable.Routes.Add
  149. (
  150. new ServiceRoute
  151. (
  152. "DKService/PCModuleServiceNew", new WebServiceHostFactory(), typeof(PCModuleServiceNew)
  153. )
  154. );
  155. RouteTable.Routes.Add
  156. (
  157. new ServiceRoute
  158. (
  159. "DKService/PAMModuleService", new WebServiceHostFactory(), typeof(PAMModuleService)
  160. )
  161. );
  162. RouteTable.Routes.Add
  163. (
  164. new ServiceRoute
  165. (
  166. "DKService/PublicModuleService", new WebServiceHostFactory(), typeof(PublicModuleService)
  167. )
  168. );
  169. RouteTable.Routes.Add
  170. (
  171. new ServiceRoute
  172. (
  173. "DKService/SmartDeviceService", new WebServiceHostFactory(), typeof(SmartDeviceService)
  174. )
  175. );
  176. RouteTable.Routes.Add
  177. (
  178. new ServiceRoute
  179. (
  180. "DKService/ExHGS3QR", new WebServiceHostFactory(), typeof(ExHGS3QR)
  181. )
  182. );
  183. RouteTable.Routes.Add
  184. (
  185. new ServiceRoute
  186. (
  187. "DKService/SAPDataService", new WebServiceHostFactory(), typeof(SAPDataService)
  188. )
  189. );
  190. RouteTable.Routes.Add
  191. (
  192. new ServiceRoute
  193. (
  194. "DKService/PPModuleService", new WebServiceHostFactory(), typeof(PPModuleService)
  195. )
  196. );
  197. }
  198. #region SAP_HEGII
  199. private class TimerLocker
  200. {
  201. public string LockerName = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff");
  202. }
  203. private static Timer SAP_HEGII_Timer = null;
  204. private static TimerLocker Timer_Loker = null;
  205. private static bool Timer_doing = false;
  206. public static void InitSAP_HEGII()
  207. {
  208. try
  209. {
  210. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  211. // 下次开始时间
  212. string SAP_ING = ini.ReadIniData("SAP_HEGII", "SAP_ING");
  213. if (SAP_ING != "1")
  214. {
  215. OutputLog.TraceLog(LogPriority.Information,
  216. "Global",
  217. "Application_Start - InitSAP_HEGII",
  218. "Timer not Started",
  219. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  220. return;
  221. }
  222. //if (string.IsNullOrWhiteSpace(interval))
  223. //{
  224. // return;
  225. //}
  226. double intt = 60000;
  227. //if (!double.TryParse(interval, out intt) || intt < 30000)
  228. //{
  229. // intt = 60000;
  230. //}
  231. Timer_Loker = new TimerLocker();
  232. SAP_HEGII_Timer = new Timer();
  233. SAP_HEGII_Timer.Interval = intt;
  234. SAP_HEGII_Timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
  235. SAP_HEGII_Timer.AutoReset = true;
  236. SAP_HEGII_Timer.Enabled = true;
  237. OutputLog.TraceLog(LogPriority.Information,
  238. "Global",
  239. "Application_Start - InitSAP_HEGII",
  240. "Timer Started : " + Timer_Loker.LockerName + " - " + intt,
  241. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  242. }
  243. catch (Exception ex)
  244. {
  245. OutputLog.TraceLog(LogPriority.Error,
  246. "Global",
  247. "InitSAP_HEGII",
  248. ex.ToString(),
  249. LocalPath.LogExePath + "SAP_HEGII\\Error_");
  250. }
  251. }
  252. private static void OnTimedEvent(object source, ElapsedEventArgs e)
  253. {
  254. if (Timer_doing)
  255. {
  256. return;
  257. }
  258. try
  259. {
  260. Timer_doing = true;
  261. lock (Timer_Loker)
  262. {
  263. // 当前时间
  264. IDBConnection oracleConn = ClsDbFactory.CreateDBConnection(Basics.DataAccess.DataBaseType.ORACLE, DataManager.ConnectionString);
  265. DateTime dateTimeNow = Convert.ToDateTime(oracleConn.GetSqlResultToObj("SELECT SYSDATE FROM DUAL"));
  266. DateTime ndate;
  267. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  268. #region 报工_10,20,30,40
  269. string nextDate_BG = ini.ReadIniData("SAP_HEGII", "NextDate_BG");
  270. string strInterval_BG = ini.ReadIniData("SAP_HEGII", "Interval_BG");
  271. if (!string.IsNullOrWhiteSpace(nextDate_BG) && !string.IsNullOrWhiteSpace(strInterval_BG) &&
  272. DateTime.TryParseExact(nextDate_BG, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  273. {
  274. // 间隔时间(分钟)
  275. int interva_BG = strInterval_BG.ToInt32();
  276. DateTime nextDateINI_BG = ndate.AddMinutes(interva_BG);
  277. while (nextDateINI_BG <= dateTimeNow)
  278. {
  279. nextDateINI_BG = nextDateINI_BG.AddMinutes(interva_BG);
  280. }
  281. // 更新下次执行时间
  282. ini.WriteIniData("SAP_HEGII", "NextDate_BG", nextDateINI_BG.ToString("yyyy-MM-dd HH:mm"));
  283. OutputLog.TraceLog(LogPriority.Information,
  284. "Global2",
  285. "OnTimedEvent begin: ",
  286. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  287. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  288. + $" -[{interva_BG}]" + nextDateINI_BG.ToString("yyyy-MM-dd HH:mm:ss"),
  289. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  290. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("10,20,30,40", ndate);
  291. OutputLog.TraceLog(LogPriority.Information,
  292. "Global2",
  293. "OnTimedEvent end",
  294. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  295. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  296. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  297. }
  298. #endregion
  299. #region 报工_50
  300. string nextDate_BG_50 = ini.ReadIniData("SAP_HEGII", "NextDate_BG_50");
  301. string strInterval_BG_50 = ini.ReadIniData("SAP_HEGII", "Interval_BG_50");
  302. if (!string.IsNullOrWhiteSpace(nextDate_BG_50) && !string.IsNullOrWhiteSpace(strInterval_BG_50) &&
  303. DateTime.TryParseExact(nextDate_BG_50, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  304. {
  305. // 间隔时间(分钟)
  306. int interva_BG_50 = strInterval_BG_50.ToInt32();
  307. DateTime nextDateINI_BG_50 = ndate.AddMinutes(interva_BG_50);
  308. while (nextDateINI_BG_50 <= dateTimeNow)
  309. {
  310. nextDateINI_BG_50 = nextDateINI_BG_50.AddMinutes(interva_BG_50);
  311. }
  312. // 更新下次执行时间
  313. ini.WriteIniData("SAP_HEGII", "NextDate_BG_50", nextDateINI_BG_50.ToString("yyyy-MM-dd HH:mm"));
  314. OutputLog.TraceLog(LogPriority.Information,
  315. "Global2",
  316. "OnTimedEvent begin: ",
  317. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  318. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  319. + $" -[{interva_BG_50}]" + nextDateINI_BG_50.ToString("yyyy-MM-dd HH:mm:ss"),
  320. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  321. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("50", ndate);
  322. OutputLog.TraceLog(LogPriority.Information,
  323. "Global2",
  324. "OnTimedEvent end",
  325. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  326. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  327. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  328. }
  329. #endregion
  330. #region 报工_60
  331. string nextDate_BG_60 = ini.ReadIniData("SAP_HEGII", "NextDate_BG_60");
  332. string strInterval_BG_60 = ini.ReadIniData("SAP_HEGII", "Interval_BG_60");
  333. if (!string.IsNullOrWhiteSpace(nextDate_BG_60) && !string.IsNullOrWhiteSpace(strInterval_BG_60) &&
  334. DateTime.TryParseExact(nextDate_BG_60, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  335. {
  336. // 间隔时间(分钟)
  337. int interva_BG_60 = strInterval_BG_60.ToInt32();
  338. DateTime nextDateINI_BG_60 = ndate.AddMinutes(interva_BG_60);
  339. while (nextDateINI_BG_60 <= dateTimeNow)
  340. {
  341. nextDateINI_BG_60 = nextDateINI_BG_60.AddMinutes(interva_BG_60);
  342. }
  343. // 更新下次执行时间
  344. ini.WriteIniData("SAP_HEGII", "NextDate_BG_60", nextDateINI_BG_60.ToString("yyyy-MM-dd HH:mm"));
  345. OutputLog.TraceLog(LogPriority.Information,
  346. "Global2",
  347. "OnTimedEvent begin: ",
  348. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  349. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  350. + $" -[{interva_BG_60}]" + nextDateINI_BG_60.ToString("yyyy-MM-dd HH:mm:ss"),
  351. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  352. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("60", ndate);
  353. OutputLog.TraceLog(LogPriority.Information,
  354. "Global2",
  355. "OnTimedEvent end",
  356. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  357. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  358. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  359. }
  360. #endregion
  361. #region 移库
  362. string nextDate_YK = ini.ReadIniData("SAP_HEGII", "NextDate_YK");
  363. string strInterval_YK = ini.ReadIniData("SAP_HEGII", "Interval_YK");
  364. if (!string.IsNullOrWhiteSpace(nextDate_YK) && !string.IsNullOrWhiteSpace(strInterval_YK) &&
  365. DateTime.TryParseExact(nextDate_YK, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  366. {
  367. // 间隔时间(分钟)
  368. int interva_YK = strInterval_YK.ToInt32();
  369. DateTime nextDateINI_YK = ndate.AddMinutes(interva_YK);
  370. while (nextDateINI_YK <= dateTimeNow)
  371. {
  372. nextDateINI_YK = nextDateINI_YK.AddMinutes(interva_YK);
  373. }
  374. // 更新下次执行时间
  375. ini.WriteIniData("SAP_HEGII", "NextDate_YK", nextDateINI_YK.ToString("yyyy-MM-dd HH:mm"));
  376. OutputLog.TraceLog(LogPriority.Information,
  377. "Global2",
  378. "OnTimedEvent begin: ",
  379. "BGYKToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  380. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  381. + $" -[{interva_YK}]" + nextDateINI_YK.ToString("yyyy-MM-dd HH:mm:ss"),
  382. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  383. Service.SAPHegiiDataService.SAPDataLogic.BGYKToSAP(ndate, ndate);
  384. OutputLog.TraceLog(LogPriority.Information,
  385. "Global2",
  386. "OnTimedEvent end",
  387. "BGYKToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  388. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  389. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  390. }
  391. #endregion
  392. #region 跨车间作业
  393. string nextDate_KCJ = ini.ReadIniData("SAP_HEGII", "NextDate_KCJ");
  394. //string strInterval_KCJ = ini.ReadIniData("SAP_HEGII", "Interval_KCJ");
  395. if (!string.IsNullOrWhiteSpace(nextDate_KCJ) &&
  396. DateTime.TryParseExact(nextDate_KCJ, "yyyy-MM-dd", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  397. {
  398. // 间隔时间(分钟)
  399. //int interva_KCJ = strInterval_KCJ.ToInt32();
  400. DateTime nextDateINI_KCJ = ndate.AddMonths(1);
  401. while (nextDateINI_KCJ <= dateTimeNow)
  402. {
  403. nextDateINI_KCJ = nextDateINI_KCJ.AddMonths(1);
  404. }
  405. // 更新下次执行时间
  406. ini.WriteIniData("SAP_HEGII", "NextDate_KCJ", nextDateINI_KCJ.ToString("yyyy-MM-dd"));
  407. OutputLog.TraceLog(LogPriority.Information,
  408. "Global2",
  409. "OnTimedEvent begin: ",
  410. "CrossWorkshopToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  411. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  412. + $" -[{1}]" + nextDateINI_KCJ.ToString("yyyy-MM-dd HH:mm:ss"),
  413. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  414. Service.SAPHegiiDataService.SAPDataLogic.CrossWorkshopToSAP(ndate, ndate);
  415. OutputLog.TraceLog(LogPriority.Information,
  416. "Global2",
  417. "OnTimedEvent end",
  418. "CrossWorkshopToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  419. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  420. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  421. }
  422. #endregion
  423. //2022年9月23日13:06:25 添加时间限制,10月1号零点10分不再传输原接口产量数据
  424. //DateTime setTime = new DateTime(2022, 10, 1, 0, 10, 0);
  425. // 下次开始时间
  426. //string nextDate = ini.ReadIniData("SAP_HEGII", "NextDate");
  427. //string strInterval = ini.ReadIniData("SAP_HEGII", "Interval");
  428. #region 原报工(注销)
  429. //if (dateTimeNow < setTime
  430. // && !string.IsNullOrWhiteSpace(nextDate) && !string.IsNullOrWhiteSpace(strInterval))
  431. //{
  432. // ndate = DateTime.ParseExact(nextDate, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
  433. // DateTime.TryParseExact(nextDate, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out ndate);
  434. // if (ndate != null && ndate <= dateTimeNow)
  435. // {
  436. // // 间隔时间(分钟)
  437. // int interval = strInterval.ToInt32();
  438. // DateTime nextDateINI = ndate.AddMinutes(interval);
  439. // while (nextDateINI <= dateTimeNow)
  440. // {
  441. // nextDateINI = nextDateINI.AddMinutes(interval);
  442. // }
  443. // // 更新下次执行时间
  444. // ini.WriteIniData("SAP_HEGII", "NextDate", nextDateINI.ToString("yyyy-MM-dd HH:mm"));
  445. // string funCode = ini.ReadIniData("SAP_HEGII", "FunCode");
  446. // OutputLog.TraceLog(LogPriority.Information,
  447. // "Global2",
  448. // "OnTimedEvent begin: " + funCode,
  449. // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  450. // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  451. // + $" -[{interval}]" + nextDateINI.ToString("yyyy-MM-dd HH:mm:ss"),
  452. // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  453. // Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(ndate, funCode, ndate);
  454. // OutputLog.TraceLog(LogPriority.Information,
  455. // "Global2",
  456. // "OnTimedEvent end",
  457. // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  458. // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  459. // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  460. // }
  461. //}
  462. #endregion
  463. #region 50(注销)
  464. //string nextDate50 = ini.ReadIniData("SAP_HEGII", "NextDate50");
  465. //string strInterval50 = ini.ReadIniData("SAP_HEGII", "Interval50");
  466. ////2022年9月23日13:06:25 添加时间限制,10月1号零点10分不再传输原接口产量数据
  467. //if (dateTimeNow < setTime &&
  468. // !string.IsNullOrWhiteSpace(nextDate50) && !string.IsNullOrWhiteSpace(strInterval50) &&
  469. // DateTime.TryParseExact(nextDate50, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) &&
  470. //ndate <= dateTimeNow)
  471. //{
  472. // // 间隔时间(分钟)
  473. // int interval50 = strInterval50.ToInt32();
  474. // DateTime nextDateINI50 = ndate.AddMinutes(interval50);
  475. // while (nextDateINI50 <= dateTimeNow)
  476. // {
  477. // nextDateINI50 = nextDateINI50.AddMinutes(interval50);
  478. // }
  479. // // 更新下次执行时间
  480. // ini.WriteIniData("SAP_HEGII", "NextDate50", nextDateINI50.ToString("yyyy-MM-dd HH:mm"));
  481. // string funCode = "50";
  482. // OutputLog.TraceLog(LogPriority.Information,
  483. // "Global2",
  484. // "OnTimedEvent begin: " + funCode,
  485. // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  486. // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  487. // + $" -[{interval50}]" + nextDateINI50.ToString("yyyy-MM-dd HH:mm:ss"),
  488. // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  489. // Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(ndate, funCode, ndate);
  490. // OutputLog.TraceLog(LogPriority.Information,
  491. // "Global2",
  492. // "OnTimedEvent end",
  493. // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  494. // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  495. // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  496. //}
  497. #endregion
  498. #region 6002(注销)
  499. /*
  500. string nextDate6002 = ini.ReadIniData("SAP_HEGII", "NextDate6002");
  501. if (!string.IsNullOrWhiteSpace(nextDate6002))
  502. {
  503. if (DateTime.TryParseExact(nextDate6002, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate))
  504. {
  505. //DateTime date = e.SignalTime; //DateTime.Now;
  506. DateTime date = DateTime.Now;
  507. if (ndate <= date)
  508. {
  509. //ini.WriteIniData("SAP_HEGII", "NextDate6002", date.AddHours(1).ToString("yyyy-MM-dd HH:")+ ndate.ToString("mm"));
  510. ini.WriteIniData("SAP_HEGII", "NextDate6002", date.AddMinutes(20).ToString("yyyy-MM-dd HH:mm"));
  511. string funCode = "6002"; // ini.ReadIniData("SAP_HEGII", "FunCode");
  512. OutputLog.TraceLog(LogPriority.Information,
  513. "Global",
  514. "OnTimedEvent begin: " + funCode,
  515. "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  516. + " - " + date.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  517. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  518. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(date, funCode);
  519. OutputLog.TraceLog(LogPriority.Information,
  520. "Global",
  521. "OnTimedEvent end",
  522. "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  523. + " - " + date.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  524. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  525. }
  526. }
  527. }
  528. */
  529. #endregion
  530. }
  531. }
  532. catch (Exception ex)
  533. {
  534. OutputLog.TraceLog(LogPriority.Error,
  535. "Global",
  536. "OnTimedEvent - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss"),
  537. ex.ToString(),
  538. LocalPath.LogExePath + "SAP_HEGII\\Error_");
  539. }
  540. finally
  541. {
  542. Timer_doing = false;
  543. }
  544. }
  545. #endregion
  546. protected void Session_Start(object sender, EventArgs e)
  547. {
  548. }
  549. protected void Application_BeginRequest(object sender, EventArgs e)
  550. {
  551. }
  552. protected void Application_AuthenticateRequest(object sender, EventArgs e)
  553. {
  554. }
  555. protected void Application_Error(object sender, EventArgs e)
  556. {
  557. //try
  558. //{
  559. // Logger.Error(
  560. //}
  561. //catch
  562. //{
  563. //}
  564. }
  565. protected void Session_End(object sender, EventArgs e)
  566. {
  567. }
  568. protected void Application_End(object sender, EventArgs e)
  569. {
  570. SAP_HEGII_Timer?.Dispose();
  571. SAP_HEGII_Timer = null;
  572. string lockerName = Timer_Loker?.LockerName;
  573. Timer_Loker = null;
  574. if (!string.IsNullOrEmpty(lockerName))
  575. {
  576. OutputLog.TraceLog(LogPriority.Information,
  577. "Global",
  578. "Application_End",
  579. "Timer End : " + lockerName,
  580. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  581. }
  582. }
  583. }
  584. }