解决子线程异常退出后,主线程还在但不处理业务的问题。
增加运抵与预配数据的减重对碰,件重不一样转人工发送。
正在显示
1 个修改的文件
包含
41 行增加
和
7 行删除
@@ -74,7 +74,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | @@ -74,7 +74,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | ||
74 | set; | 74 | set; |
75 | } | 75 | } |
76 | 76 | ||
77 | - public bool IsThreadNeedRun | 77 | + public static bool IsThreadNeedRun |
78 | { | 78 | { |
79 | get; | 79 | get; |
80 | set; | 80 | set; |
@@ -83,7 +83,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | @@ -83,7 +83,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | ||
83 | public MainService() | 83 | public MainService() |
84 | { | 84 | { |
85 | InitializeComponent(); | 85 | InitializeComponent(); |
86 | - IsThreadNeedRun = true; | 86 | + IsThreadNeedRun = false; |
87 | ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; | 87 | ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; |
88 | QmName = ConfigurationManager.AppSettings["qmName"]; | 88 | QmName = ConfigurationManager.AppSettings["qmName"]; |
89 | QueueInName = ConfigurationManager.AppSettings["queueInName"]; | 89 | QueueInName = ConfigurationManager.AppSettings["queueInName"]; |
@@ -96,10 +96,17 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | @@ -96,10 +96,17 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | ||
96 | { | 96 | { |
97 | try | 97 | try |
98 | { | 98 | { |
99 | - Log.WriteLog("9systemlog", "订阅服务开启"); | ||
100 | - IsThreadNeedRun = true; | ||
101 | - ServiceThread = new Thread(StartServiceThread_IMF); | ||
102 | - ServiceThread.Start(); | 99 | + //change by mrz 解决子线程异常退出的问题 |
100 | + while (true) | ||
101 | + { | ||
102 | + if (!IsThreadNeedRun && !ServiceThread.IsAlive) | ||
103 | + { | ||
104 | + ServiceThread = new Thread(StartServiceThread_IMF); | ||
105 | + ServiceThread.Start(); | ||
106 | + Log.WriteLog("9systemlog", "订阅服务开启"); | ||
107 | + } | ||
108 | + Thread.Sleep(5000); | ||
109 | + } | ||
103 | } | 110 | } |
104 | catch (Exception ex) | 111 | catch (Exception ex) |
105 | { | 112 | { |
@@ -179,6 +186,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | @@ -179,6 +186,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | ||
179 | 186 | ||
180 | public void StartServiceThread_IMF(object obj) | 187 | public void StartServiceThread_IMF(object obj) |
181 | { | 188 | { |
189 | + IsThreadNeedRun = true; | ||
182 | string connectionString = ConnectionString; | 190 | string connectionString = ConnectionString; |
183 | while (IsThreadNeedRun) | 191 | while (IsThreadNeedRun) |
184 | { | 192 | { |
@@ -262,6 +270,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | @@ -262,6 +270,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | ||
262 | } | 270 | } |
263 | }catch(IOException e){ | 271 | }catch(IOException e){ |
264 | Log.WriteLog("9systemlog", e.ToString()+"IOerror"); | 272 | Log.WriteLog("9systemlog", e.ToString()+"IOerror"); |
273 | + IsThreadNeedRun = false; | ||
265 | } | 274 | } |
266 | Thread.Sleep(500); | 275 | Thread.Sleep(500); |
267 | } | 276 | } |
@@ -269,7 +278,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | @@ -269,7 +278,7 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | ||
269 | 278 | ||
270 | protected override void OnStop() | 279 | protected override void OnStop() |
271 | { | 280 | { |
272 | - IsThreadNeedRun = false; | 281 | + IsThreadNeedRun = true; |
273 | try | 282 | try |
274 | { | 283 | { |
275 | ServiceThread.Abort(); | 284 | ServiceThread.Abort(); |
@@ -425,6 +434,18 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | @@ -425,6 +434,18 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | ||
425 | text = arrivedMaster.WAYBILLNOMASTER; | 434 | text = arrivedMaster.WAYBILLNOMASTER; |
426 | Log.WriteMessage("FSU_FOH", arrivedMaster.WAYBILLNOMASTER, xmlDoc.InnerXml); | 435 | Log.WriteMessage("FSU_FOH", arrivedMaster.WAYBILLNOMASTER, xmlDoc.InnerXml); |
427 | string masterid = ""; | 436 | string masterid = ""; |
437 | + // add by mrz校验预配件数重量,件重对不上转人工发送 | ||
438 | + DateTime pre_flightDate = DateTime.Parse(arrivedMaster.FLIGHTDATE).Date; | ||
439 | + IEnumerable<Model.PrepareMaster> premaster_result = CustomsCargoSystem.Data.PrepareMaster.query_preparemaster(connectionString, arrivedMaster.CARRIER, arrivedMaster.FLIGHTNO, pre_flightDate, arrivedMaster.WAYBILLNOMASTER); | ||
440 | + if (premaster_result.Count() > 0) | ||
441 | + { | ||
442 | + Model.PrepareMaster pre_configured = premaster_result.FirstOrDefault(); | ||
443 | + if (pre_configured.totalweight != arrivedMaster.ARRIVEDTOTALWEIGHT && pre_configured.totalpiece != arrivedMaster.ARRIVEDTOTALPIECE) | ||
444 | + { | ||
445 | + arrivedMaster.STATUS = "17"; | ||
446 | + } | ||
447 | + } | ||
448 | + | ||
428 | num = CustomsCargoSystem.Data.ArrivedMaster.Save(connectionString, arrivedMaster, out masterid); | 449 | num = CustomsCargoSystem.Data.ArrivedMaster.Save(connectionString, arrivedMaster, out masterid); |
429 | if (num > 0 && !string.IsNullOrEmpty(masterid)) | 450 | if (num > 0 && !string.IsNullOrEmpty(masterid)) |
430 | { | 451 | { |
@@ -439,6 +460,19 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | @@ -439,6 +460,19 @@ namespace CustomsCargoSystem.ExchangeDataStorageService | ||
439 | { | 460 | { |
440 | CustomsCargoSystem.Model.ArrivedSecondary arrivedSecondary = CustomsCargoSystem.Parser.ArrivedSecondary.Parse(xmlDoc); | 461 | CustomsCargoSystem.Model.ArrivedSecondary arrivedSecondary = CustomsCargoSystem.Parser.ArrivedSecondary.Parse(xmlDoc); |
441 | Log.WriteMessage("FZE_FOH", arrivedSecondary.WAYBILLNOMASTER, xmlDoc.InnerXml); | 462 | Log.WriteMessage("FZE_FOH", arrivedSecondary.WAYBILLNOMASTER, xmlDoc.InnerXml); |
463 | + | ||
464 | + // add by mrz校验预配件数重量,件重对不上转人工发送 | ||
465 | + DateTime pre_flightDate = arrivedSecondary.FLIGHTDATE.Date; | ||
466 | + IEnumerable<CustomsCargoSystem.Model.PrepareSecondary> source = CustomsCargoSystem.Data.PrepareSecondary.querydatabywaybillnosecondary(connectionString, arrivedSecondary.WAYBILLNOMASTER, arrivedSecondary.WAYBILLNOSECONDARY); | ||
467 | + if (source.Count() > 0) | ||
468 | + { | ||
469 | + Model.PrepareSecondary pre_configured = source.FirstOrDefault(); | ||
470 | + if (pre_configured.prepareweight != arrivedSecondary.ARRIVEDTOTALWEIGHT && pre_configured.preparepiece != arrivedSecondary.ARRIVEDTOTALPIECE) | ||
471 | + { | ||
472 | + arrivedSecondary.status = "17"; | ||
473 | + } | ||
474 | + } | ||
475 | + | ||
442 | num = CustomsCargoSystem.Data.ArrivedSecondary.Save(connectionString, arrivedSecondary); | 476 | num = CustomsCargoSystem.Data.ArrivedSecondary.Save(connectionString, arrivedSecondary); |
443 | } | 477 | } |
444 | if ("UDEP" == innerText2) | 478 | if ("UDEP" == innerText2) |
-
请 注册 或 登录 后发表评论