Global.asax.cs 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  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.DataAccess;
  8. using Curtain.Extension.ExObjectConvert;
  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. oracleConn.Close();
  267. DateTime ndate;
  268. INIUtility ini = INIUtility.Instance(INIUtility.IniFile.SAP_HEGII);
  269. #region 报工_1001
  270. string nextDate_BG_1001 = ini.ReadIniData("SAP_HEGII", "NextDate_BG_1001");
  271. string strInterval_BG_1001 = ini.ReadIniData("SAP_HEGII", "Interval_BG_1001");
  272. if (!string.IsNullOrWhiteSpace(nextDate_BG_1001) && !string.IsNullOrWhiteSpace(strInterval_BG_1001) &&
  273. DateTime.TryParseExact(nextDate_BG_1001, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  274. {
  275. // 间隔时间(分钟)
  276. int interva_BG_1001 = strInterval_BG_1001.ToInt32();
  277. DateTime nextDateINI_BG_1001 = ndate.AddMinutes(interva_BG_1001);
  278. while (nextDateINI_BG_1001 <= dateTimeNow)
  279. {
  280. nextDateINI_BG_1001 = nextDateINI_BG_1001.AddMinutes(interva_BG_1001);
  281. }
  282. // 更新下次执行时间
  283. ini.WriteIniData("SAP_HEGII", "NextDate_BG_1001", nextDateINI_BG_1001.ToString("yyyy-MM-dd HH:mm"));
  284. OutputLog.TraceLog(LogPriority.Information,
  285. "Global2",
  286. "OnTimedEvent begin: ",
  287. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  288. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  289. + $" -[{interva_BG_1001}]" + nextDateINI_BG_1001.ToString("yyyy-MM-dd HH:mm:ss"),
  290. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  291. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("1001", ndate);
  292. OutputLog.TraceLog(LogPriority.Information,
  293. "Global2",
  294. "OnTimedEvent end",
  295. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  296. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  297. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  298. }
  299. #endregion
  300. #region 报工_10,20,30,40
  301. string nextDate_BG = ini.ReadIniData("SAP_HEGII", "NextDate_BG");
  302. string strInterval_BG = ini.ReadIniData("SAP_HEGII", "Interval_BG");
  303. if (!string.IsNullOrWhiteSpace(nextDate_BG) && !string.IsNullOrWhiteSpace(strInterval_BG) &&
  304. DateTime.TryParseExact(nextDate_BG, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  305. {
  306. // 间隔时间(分钟)
  307. int interva_BG = strInterval_BG.ToInt32();
  308. DateTime nextDateINI_BG = ndate.AddMinutes(interva_BG);
  309. while (nextDateINI_BG <= dateTimeNow)
  310. {
  311. nextDateINI_BG = nextDateINI_BG.AddMinutes(interva_BG);
  312. }
  313. // 更新下次执行时间
  314. ini.WriteIniData("SAP_HEGII", "NextDate_BG", nextDateINI_BG.ToString("yyyy-MM-dd HH:mm"));
  315. OutputLog.TraceLog(LogPriority.Information,
  316. "Global2",
  317. "OnTimedEvent begin: ",
  318. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  319. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  320. + $" -[{interva_BG}]" + nextDateINI_BG.ToString("yyyy-MM-dd HH:mm:ss"),
  321. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  322. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("10,20,30,40", ndate);
  323. OutputLog.TraceLog(LogPriority.Information,
  324. "Global2",
  325. "OnTimedEvent end",
  326. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  327. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  328. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  329. }
  330. #endregion
  331. #region 报工_50
  332. string nextDate_BG_50 = ini.ReadIniData("SAP_HEGII", "NextDate_BG_50");
  333. string strInterval_BG_50 = ini.ReadIniData("SAP_HEGII", "Interval_BG_50");
  334. if (!string.IsNullOrWhiteSpace(nextDate_BG_50) && !string.IsNullOrWhiteSpace(strInterval_BG_50) &&
  335. DateTime.TryParseExact(nextDate_BG_50, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  336. {
  337. // 间隔时间(分钟)
  338. int interva_BG_50 = strInterval_BG_50.ToInt32();
  339. DateTime nextDateINI_BG_50 = ndate.AddMinutes(interva_BG_50);
  340. while (nextDateINI_BG_50 <= dateTimeNow)
  341. {
  342. nextDateINI_BG_50 = nextDateINI_BG_50.AddMinutes(interva_BG_50);
  343. }
  344. // 更新下次执行时间
  345. ini.WriteIniData("SAP_HEGII", "NextDate_BG_50", nextDateINI_BG_50.ToString("yyyy-MM-dd HH:mm"));
  346. OutputLog.TraceLog(LogPriority.Information,
  347. "Global2",
  348. "OnTimedEvent begin: ",
  349. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  350. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  351. + $" -[{interva_BG_50}]" + nextDateINI_BG_50.ToString("yyyy-MM-dd HH:mm:ss"),
  352. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  353. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("50", ndate);
  354. OutputLog.TraceLog(LogPriority.Information,
  355. "Global2",
  356. "OnTimedEvent end",
  357. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  358. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  359. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  360. }
  361. #endregion
  362. #region 报工_60
  363. string nextDate_BG_60 = ini.ReadIniData("SAP_HEGII", "NextDate_BG_60");
  364. string strInterval_BG_60 = ini.ReadIniData("SAP_HEGII", "Interval_BG_60");
  365. if (!string.IsNullOrWhiteSpace(nextDate_BG_60) && !string.IsNullOrWhiteSpace(strInterval_BG_60) &&
  366. DateTime.TryParseExact(nextDate_BG_60, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  367. {
  368. // 间隔时间(分钟)
  369. int interva_BG_60 = strInterval_BG_60.ToInt32();
  370. DateTime nextDateINI_BG_60 = ndate.AddMinutes(interva_BG_60);
  371. while (nextDateINI_BG_60 <= dateTimeNow)
  372. {
  373. nextDateINI_BG_60 = nextDateINI_BG_60.AddMinutes(interva_BG_60);
  374. }
  375. // 更新下次执行时间
  376. ini.WriteIniData("SAP_HEGII", "NextDate_BG_60", nextDateINI_BG_60.ToString("yyyy-MM-dd HH:mm"));
  377. OutputLog.TraceLog(LogPriority.Information,
  378. "Global2",
  379. "OnTimedEvent begin: ",
  380. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  381. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  382. + $" -[{interva_BG_60}]" + nextDateINI_BG_60.ToString("yyyy-MM-dd HH:mm:ss"),
  383. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  384. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000("60", ndate);
  385. OutputLog.TraceLog(LogPriority.Information,
  386. "Global2",
  387. "OnTimedEvent end",
  388. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  389. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  390. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  391. }
  392. #endregion
  393. #region 移库
  394. string nextDate_YK = ini.ReadIniData("SAP_HEGII", "NextDate_YK");
  395. string strInterval_YK = ini.ReadIniData("SAP_HEGII", "Interval_YK");
  396. if (!string.IsNullOrWhiteSpace(nextDate_YK) && !string.IsNullOrWhiteSpace(strInterval_YK) &&
  397. DateTime.TryParseExact(nextDate_YK, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  398. {
  399. // 间隔时间(分钟)
  400. int interva_YK = strInterval_YK.ToInt32();
  401. DateTime nextDateINI_YK = ndate.AddMinutes(interva_YK);
  402. while (nextDateINI_YK <= dateTimeNow)
  403. {
  404. nextDateINI_YK = nextDateINI_YK.AddMinutes(interva_YK);
  405. }
  406. // 更新下次执行时间
  407. ini.WriteIniData("SAP_HEGII", "NextDate_YK", nextDateINI_YK.ToString("yyyy-MM-dd HH:mm"));
  408. OutputLog.TraceLog(LogPriority.Information,
  409. "Global2",
  410. "OnTimedEvent begin: ",
  411. "BGYKToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  412. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  413. + $" -[{interva_YK}]" + nextDateINI_YK.ToString("yyyy-MM-dd HH:mm:ss"),
  414. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  415. Service.SAPHegiiDataService.SAPDataLogic.BGYKToSAP(ndate, ndate);
  416. OutputLog.TraceLog(LogPriority.Information,
  417. "Global2",
  418. "OnTimedEvent end",
  419. "BGYKToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  420. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  421. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  422. }
  423. #endregion
  424. #region 跨车间作业
  425. string nextDate_KCJ = ini.ReadIniData("SAP_HEGII", "NextDate_KCJ");
  426. //string strInterval_KCJ = ini.ReadIniData("SAP_HEGII", "Interval_KCJ");
  427. if (!string.IsNullOrWhiteSpace(nextDate_KCJ) &&
  428. DateTime.TryParseExact(nextDate_KCJ, "yyyy-MM-dd", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  429. {
  430. // 间隔时间(分钟)
  431. //int interva_KCJ = strInterval_KCJ.ToInt32();
  432. DateTime nextDateINI_KCJ = ndate.AddMonths(1);
  433. while (nextDateINI_KCJ <= dateTimeNow)
  434. {
  435. nextDateINI_KCJ = nextDateINI_KCJ.AddMonths(1);
  436. }
  437. // 更新下次执行时间
  438. ini.WriteIniData("SAP_HEGII", "NextDate_KCJ", nextDateINI_KCJ.ToString("yyyy-MM-dd"));
  439. OutputLog.TraceLog(LogPriority.Information,
  440. "Global2",
  441. "OnTimedEvent begin: ",
  442. "CrossWorkshopToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  443. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  444. + $" -[{1}]" + nextDateINI_KCJ.ToString("yyyy-MM-dd HH:mm:ss"),
  445. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  446. Service.SAPHegiiDataService.SAPDataLogic.CrossWorkshopToSAP(ndate, ndate);
  447. OutputLog.TraceLog(LogPriority.Information,
  448. "Global2",
  449. "OnTimedEvent end",
  450. "CrossWorkshopToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  451. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  452. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  453. }
  454. #endregion
  455. #region 商标变更
  456. string nextDate_SBBG = ini.ReadIniData("SAP_HEGII", "NextDate_SBBG");
  457. string strInterval_SBBG = ini.ReadIniData("SAP_HEGII", "Interval_SBBG");
  458. if (!string.IsNullOrWhiteSpace(nextDate_SBBG) && !string.IsNullOrWhiteSpace(strInterval_SBBG) &&
  459. DateTime.TryParseExact(nextDate_SBBG, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) && ndate <= dateTimeNow)
  460. {
  461. // 间隔时间(分钟)
  462. int interva_SBBG = strInterval_SBBG.ToInt32();
  463. DateTime nextDateINI_SBBG = ndate.AddMinutes(interva_SBBG);
  464. while (nextDateINI_SBBG <= dateTimeNow)
  465. {
  466. nextDateINI_SBBG = nextDateINI_SBBG.AddMinutes(interva_SBBG);
  467. }
  468. // 更新下次执行时间
  469. ini.WriteIniData("SAP_HEGII", "nextDate_SBBG", nextDateINI_SBBG.ToString("yyyy-MM-dd HH:mm"));
  470. OutputLog.TraceLog(LogPriority.Information,
  471. "Global2",
  472. "OnTimedEvent begin: ",
  473. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  474. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  475. + $" -[{interva_SBBG}]" + nextDateINI_SBBG.ToString("yyyy-MM-dd HH:mm:ss"),
  476. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  477. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP5000SBBG( ndate);
  478. OutputLog.TraceLog(LogPriority.Information,
  479. "Global2",
  480. "OnTimedEvent end",
  481. "SyncSap5000 : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  482. + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  483. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  484. }
  485. #endregion
  486. //2022年9月23日13:06:25 添加时间限制,10月1号零点10分不再传输原接口产量数据
  487. //DateTime setTime = new DateTime(2022, 10, 1, 0, 10, 0);
  488. // 下次开始时间
  489. //string nextDate = ini.ReadIniData("SAP_HEGII", "NextDate");
  490. //string strInterval = ini.ReadIniData("SAP_HEGII", "Interval");
  491. #region 原报工(注销)
  492. //if (dateTimeNow < setTime
  493. // && !string.IsNullOrWhiteSpace(nextDate) && !string.IsNullOrWhiteSpace(strInterval))
  494. //{
  495. // ndate = DateTime.ParseExact(nextDate, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture);
  496. // DateTime.TryParseExact(nextDate, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out ndate);
  497. // if (ndate != null && ndate <= dateTimeNow)
  498. // {
  499. // // 间隔时间(分钟)
  500. // int interval = strInterval.ToInt32();
  501. // DateTime nextDateINI = ndate.AddMinutes(interval);
  502. // while (nextDateINI <= dateTimeNow)
  503. // {
  504. // nextDateINI = nextDateINI.AddMinutes(interval);
  505. // }
  506. // // 更新下次执行时间
  507. // ini.WriteIniData("SAP_HEGII", "NextDate", nextDateINI.ToString("yyyy-MM-dd HH:mm"));
  508. // string funCode = ini.ReadIniData("SAP_HEGII", "FunCode");
  509. // OutputLog.TraceLog(LogPriority.Information,
  510. // "Global2",
  511. // "OnTimedEvent begin: " + funCode,
  512. // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  513. // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  514. // + $" -[{interval}]" + nextDateINI.ToString("yyyy-MM-dd HH:mm:ss"),
  515. // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  516. // Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(ndate, funCode, ndate);
  517. // OutputLog.TraceLog(LogPriority.Information,
  518. // "Global2",
  519. // "OnTimedEvent end",
  520. // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  521. // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  522. // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  523. // }
  524. //}
  525. #endregion
  526. #region 50(注销)
  527. //string nextDate50 = ini.ReadIniData("SAP_HEGII", "NextDate50");
  528. //string strInterval50 = ini.ReadIniData("SAP_HEGII", "Interval50");
  529. ////2022年9月23日13:06:25 添加时间限制,10月1号零点10分不再传输原接口产量数据
  530. //if (dateTimeNow < setTime &&
  531. // !string.IsNullOrWhiteSpace(nextDate50) && !string.IsNullOrWhiteSpace(strInterval50) &&
  532. // DateTime.TryParseExact(nextDate50, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate) &&
  533. //ndate <= dateTimeNow)
  534. //{
  535. // // 间隔时间(分钟)
  536. // int interval50 = strInterval50.ToInt32();
  537. // DateTime nextDateINI50 = ndate.AddMinutes(interval50);
  538. // while (nextDateINI50 <= dateTimeNow)
  539. // {
  540. // nextDateINI50 = nextDateINI50.AddMinutes(interval50);
  541. // }
  542. // // 更新下次执行时间
  543. // ini.WriteIniData("SAP_HEGII", "NextDate50", nextDateINI50.ToString("yyyy-MM-dd HH:mm"));
  544. // string funCode = "50";
  545. // OutputLog.TraceLog(LogPriority.Information,
  546. // "Global2",
  547. // "OnTimedEvent begin: " + funCode,
  548. // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  549. // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + $" -date:" + ndate.ToString("yyyy-MM-dd HH:mm:ss")
  550. // + $" -[{interval50}]" + nextDateINI50.ToString("yyyy-MM-dd HH:mm:ss"),
  551. // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  552. // Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(ndate, funCode, ndate);
  553. // OutputLog.TraceLog(LogPriority.Information,
  554. // "Global2",
  555. // "OnTimedEvent end",
  556. // "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  557. // + " - " + dateTimeNow.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  558. // LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  559. //}
  560. #endregion
  561. #region 6002(注销)
  562. /*
  563. string nextDate6002 = ini.ReadIniData("SAP_HEGII", "NextDate6002");
  564. if (!string.IsNullOrWhiteSpace(nextDate6002))
  565. {
  566. if (DateTime.TryParseExact(nextDate6002, "yyyy-MM-dd HH:mm", null, DateTimeStyles.None, out ndate))
  567. {
  568. //DateTime date = e.SignalTime; //DateTime.Now;
  569. DateTime date = DateTime.Now;
  570. if (ndate <= date)
  571. {
  572. //ini.WriteIniData("SAP_HEGII", "NextDate6002", date.AddHours(1).ToString("yyyy-MM-dd HH:")+ ndate.ToString("mm"));
  573. ini.WriteIniData("SAP_HEGII", "NextDate6002", date.AddMinutes(20).ToString("yyyy-MM-dd HH:mm"));
  574. string funCode = "6002"; // ini.ReadIniData("SAP_HEGII", "FunCode");
  575. OutputLog.TraceLog(LogPriority.Information,
  576. "Global",
  577. "OnTimedEvent begin: " + funCode,
  578. "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  579. + " - " + date.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  580. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  581. Service.SAPHegiiDataService.SAPDataLogic.AutoWorkDataToSAP(date, funCode);
  582. OutputLog.TraceLog(LogPriority.Information,
  583. "Global",
  584. "OnTimedEvent end",
  585. "AutoWorkDataToSAP : " + Timer_Loker.LockerName + " - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss")
  586. + " - " + date.ToString("yyyy-MM-dd HH:mm:ss") + " - " + ndate.ToString("yyyy-MM-dd HH:mm:ss"),
  587. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  588. }
  589. }
  590. }
  591. */
  592. #endregion
  593. }
  594. }
  595. catch (Exception ex)
  596. {
  597. OutputLog.TraceLog(LogPriority.Error,
  598. "Global",
  599. "OnTimedEvent - " + e.SignalTime.ToString("yyyy-MM-dd HH:mm:ss"),
  600. ex.ToString(),
  601. LocalPath.LogExePath + "SAP_HEGII\\Error_");
  602. }
  603. finally
  604. {
  605. Timer_doing = false;
  606. }
  607. }
  608. #endregion
  609. protected void Session_Start(object sender, EventArgs e)
  610. {
  611. }
  612. protected void Application_BeginRequest(object sender, EventArgs e)
  613. {
  614. }
  615. protected void Application_AuthenticateRequest(object sender, EventArgs e)
  616. {
  617. }
  618. protected void Application_Error(object sender, EventArgs e)
  619. {
  620. //try
  621. //{
  622. // Logger.Error(
  623. //}
  624. //catch
  625. //{
  626. //}
  627. }
  628. protected void Session_End(object sender, EventArgs e)
  629. {
  630. }
  631. protected void Application_End(object sender, EventArgs e)
  632. {
  633. SAP_HEGII_Timer?.Dispose();
  634. SAP_HEGII_Timer = null;
  635. string lockerName = Timer_Loker?.LockerName;
  636. Timer_Loker = null;
  637. if (!string.IsNullOrEmpty(lockerName))
  638. {
  639. OutputLog.TraceLog(LogPriority.Information,
  640. "Global",
  641. "Application_End",
  642. "Timer End : " + lockerName,
  643. LocalPath.LogExePath + "SAP_HEGII\\Timer_");
  644. }
  645. }
  646. }
  647. }