From 0d6d67bd9fe82fd477d67439cb3e5d2d853561bf Mon Sep 17 00:00:00 2001 From: czw <selecti@yeah.net> Date: 星期二, 08 七月 2025 10:50:26 +0800 Subject: [PATCH] 1 --- 2025年6月12日/AuxAllWCS/Build/Project/代码/界面事件.cs | 60 +++++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 39 insertions(+), 21 deletions(-) diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\347\225\214\351\235\242\344\272\213\344\273\266.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\347\225\214\351\235\242\344\272\213\344\273\266.cs" index b0ec9b5..7df8fe7 100644 --- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\347\225\214\351\235\242\344\272\213\344\273\266.cs" +++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/\347\225\214\351\235\242\344\272\213\344\273\266.cs" @@ -763,7 +763,6 @@ } ExitJudgeStack.TryPop(out int exitJudgeVal); }); - /// <summary> /// 绋嬪簭鐗囨:Program1 /// 鎻忚堪: @@ -823,6 +822,35 @@ System.Threading.Thread.Sleep(3000); } } + /// <summary> + /// 绋嬪簭鐗囨:鏂扮嚎绋嬫�绾�+ /// 鎻忚堪:1 + /// </summary> + System.Threading.Tasks.Task.Factory.StartNew(() => + { + System.Threading.Thread.CurrentThread.IsBackground = true; + ExitJudgeStack.Push(0); + //涓�洿鎵ц锛岀洿鍒版弧瓒崇粨鏉熸潯浠�+ while (true) + { + if (IsExitApp) { break; } + try + { + #region [鑴氭湰][20250708095248653][涓氬姟閫昏緫.鏂扮嚎绋嬫�绾縘 + AutoThread.InvokeMethod(AutoThread.Instance, "ThreaTotal", new object[] { tag }); + #endregion [鑴氭湰][20250708095248653][涓氬姟閫昏緫.鏂扮嚎绋嬫�绾縘 + } + catch (Exception ex) + { + Conn.榛樿鏃ュ織.Error(ex.ToString()); + } + finally + { + System.Threading.Thread.Sleep(3000); + } + } + ExitJudgeStack.TryPop(out int exitJudgeVal); + }); } /// <summary> @@ -927,6 +955,7 @@ Device.RGV?.Stop(); Device.p鍙戦偅绉�涓嬬嚎?.Stop(); Device.p鍙戦偅绉�涓婄嚎?.Stop(); + Device.p鍙戦偅绉�涓婄嚎?.Stop(); } catch (Exception ex) { @@ -979,6 +1008,7 @@ || (Device.RGV == null ? false : Device.RGV.State != GZ.Device.PLC.PlcRunState.Stoped) || (Device.p鍙戦偅绉�涓嬬嚎 == null ? false : Device.p鍙戦偅绉�涓嬬嚎.State != GZ.Device.PLC.PlcRunState.Stoped) || (Device.p鍙戦偅绉�涓婄嚎 == null ? false : Device.p鍙戦偅绉�涓婄嚎.State != GZ.Device.PLC.PlcRunState.Stoped) + || (Device.p鍙戦偅绉�涓婄嚎 == null ? false : Device.p鍙戦偅绉�涓婄嚎.State != GZ.Device.PLC.PlcRunState.Stoped) ) { System.Threading.Thread.Sleep(1000); @@ -1054,13 +1084,12 @@ #endregion #region Http鏈嶅姟鐩戝惉 - private async void HttpSvcListenerCallback(IAsyncResult ar) + private void HttpSvcListenerCallback(IAsyncResult ar) { - System.Net.HttpListenerContext context = null; try { HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null); - context = HttpSvcHost.EndGetContext(ar); + System.Net.HttpListenerContext context = HttpSvcHost.EndGetContext(ar); System.Net.HttpListenerRequest request = context.Request; System.Net.HttpListenerResponse response = context.Response; switch (request.LocalEndPoint.ToString()) @@ -1070,28 +1099,21 @@ using (var reader = new System.IO.StreamReader(request.InputStream, System.Text.Encoding.UTF8)) { string requestJson = reader.ReadToEnd(); - System.Net.HttpStatusCode statusCode = 0; - string respstr = await Task.Run(() => - { - return HttpSvcListenerCallback_he(request.HttpMethod, request.Url.AbsolutePath, requestJson, out statusCode); - }); + + string respstr = HttpSvcListenerCallback_he(request.HttpMethod, request.Url.AbsolutePath, requestJson, out System.Net.HttpStatusCode statusCode); + string logContent = ""; logContent += $"\r\n[{request.HttpMethod}]{request.Url.AbsolutePath}"; logContent += $"\r\n[request]{requestJson}"; logContent += $"\r\n[response]{respstr}"; - _ = Task.Run(() => - { - Conn.榛樿鏃ュ織?.Info(logContent); - }); + Conn.榛樿鏃ュ織?.Info(logContent); byte[] bytstr = Encoding.UTF8.GetBytes(respstr); response.StatusCode = (int)statusCode; response.SendChunked = false; response.ContentLength64 = bytstr.Length; response.OutputStream.Write(bytstr, 0, bytstr.Length); - // 寮傛鍐欏叆鍝嶅簲 - await response.OutputStream.WriteAsync(bytstr, 0, bytstr.Length); - + response.Close(); } break; } @@ -1100,10 +1122,6 @@ catch (Exception ex) { Conn.榛樿鏃ュ織.Error(ex.ToString()); - } - finally - { - context?.Response.Close(); } } private System.String HttpSvcListenerCallback_he(System.String method, System.String path, System.String requestJson, out System.Net.HttpStatusCode statusCode) @@ -1172,7 +1190,7 @@ { switch (path) { - case var _ when System.Text.RegularExpressions.Regex.IsMatch(path, @"\.(html|ico|js|css)(\?.*)?$", System.Text.RegularExpressions.RegexOptions.IgnoreCase): + case "/inddddddddddddddddd": { statusCode = System.Net.HttpStatusCode.OK; // 澶嶅埗鍒癱ase 涓� -- Gitblit v1.9.1