From 58c1a87f19a96a1d62df382a01ed0dfd36e2f84b Mon Sep 17 00:00:00 2001
From: czw <selecti@yeah.net>
Date: 星期五, 04 七月 2025 16:34:53 +0800
Subject: [PATCH] 1

---
 HnSx/Build/Project/代码/界面事件.cs |  555 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 292 insertions(+), 263 deletions(-)

diff --git "a/HnSx/Build/Project/\344\273\243\347\240\201/\347\225\214\351\235\242\344\272\213\344\273\266.cs" "b/HnSx/Build/Project/\344\273\243\347\240\201/\347\225\214\351\235\242\344\272\213\344\273\266.cs"
index 9b81730..ed6731a 100644
--- "a/HnSx/Build/Project/\344\273\243\347\240\201/\347\225\214\351\235\242\344\272\213\344\273\266.cs"
+++ "b/HnSx/Build/Project/\344\273\243\347\240\201/\347\225\214\351\235\242\344\272\213\344\273\266.cs"
@@ -23,286 +23,315 @@
 using Dapper;
 namespace GZ.Projects.HnSx
 {
-	/// <summary>
-	/// 浜嬩欢
-	/// </summary>
-	public partial class ViewModel : System.ComponentModel.INotifyPropertyChanged
-	{
+    /// <summary>
+    /// 浜嬩欢
+    /// </summary>
+    public partial class ViewModel : System.ComponentModel.INotifyPropertyChanged
+    {
         bool IsExitApp = false;
         ConcurrentStack<int> ExitJudgeStack = new ConcurrentStack<int>();
-		System.Net.HttpListener HttpSvcHost = null;
-	
-		#region View1浜嬩欢
-		/// <summary>
+        System.Net.HttpListener HttpSvcHost = null;
+
+        #region View1浜嬩欢
+        /// <summary>
         /// View1鎵撳紑浜嬩欢
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-		public void View1_LoadEvent(object sender, RoutedEventArgs e)
-		{
-	
-			try
-			{
-				//HttpSvcHost = new System.Net.HttpListener();
-				//HttpSvcHost.AuthenticationSchemes = System.Net.AuthenticationSchemes.Anonymous;
-				//HttpSvcHost.Prefixes.Add("http://127.0.0.1:8808/");
-				//HttpSvcHost.Start();
-				//HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
-			}
-			catch(Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-			View1_Init(sender, e);
-		
-			try
-			{
-				#region    [鑴氭湰][20250701110610426][涓氬姟閫昏緫.Program1]
-				AutoThread.InvokeMethod(AutoThread.Instance, "TaskEverythingRun");
-				#endregion [鑴氭湰][20250701110610426][涓氬姟閫昏緫.Program1]
-			}
-			catch(Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-			finally
-			{
-			}	
-			/// <summary>
-			/// 绋嬪簭鐗囨:Program2
-			/// 鎻忚堪:
-			/// </summary>
-			System.Threading.Tasks.Task.Factory.StartNew(() =>
-			{
-				System.Threading.Thread.CurrentThread.IsBackground = true;
-				ExitJudgeStack.Push(0);
-			//涓�洿鎵ц锛岀洿鍒版弧瓒崇粨鏉熸潯浠�-			while(true)
-			{
-				if (IsExitApp) { break; }
-			try
-			{
-				#region    [鑴氭湰][20250704090126015][涓氬姟閫昏緫.Program2]
-				AutoThread.InvokeMethod(AutoThread.Instance, "ThreadSettingInit", new object[] { tag });
-				#endregion [鑴氭湰][20250704090126015][涓氬姟閫昏緫.Program2]
-			}
-			catch(Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-			finally
-			{
-				System.Threading.Thread.Sleep(10000);
-			}	
-			}
-				ExitJudgeStack.TryPop(out int exitJudgeVal);
-});
-	
-		}
-		/// <summary>
+        public void View1_LoadEvent(object sender, RoutedEventArgs e)
+        {
+
+            try
+            {
+                //HttpSvcHost = new System.Net.HttpListener();
+                //HttpSvcHost.AuthenticationSchemes = System.Net.AuthenticationSchemes.Anonymous;
+                //HttpSvcHost.Prefixes.Add("http://127.0.0.1:8808/");
+                //HttpSvcHost.Start();
+                //HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
+            }
+            catch (Exception ex)
+            {
+                Conn.log榛樿鏃ュ織.Error(ex.ToString());
+            }
+            View1_Init(sender, e);
+
+            try
+            {
+                #region    [鑴氭湰][20250701110610426][涓氬姟閫昏緫.Program1]
+                AutoThread.InvokeMethod(AutoThread.Instance, "TaskEverythingRun");
+                #endregion [鑴氭湰][20250701110610426][涓氬姟閫昏緫.Program1]
+            }
+            catch (Exception ex)
+            {
+                Conn.log榛樿鏃ュ織.Error(ex.ToString());
+            }
+            finally
+            {
+            }
+            /// <summary>
+            /// 绋嬪簭鐗囨:Program2
+            /// 鎻忚堪:
+            /// </summary>
+            System.Threading.Tasks.Task.Factory.StartNew(() =>
+            {
+                System.Threading.Thread.CurrentThread.IsBackground = true;
+                ExitJudgeStack.Push(0);
+                //涓�洿鎵ц锛岀洿鍒版弧瓒崇粨鏉熸潯浠�+                while (true)
+                {
+                    if (IsExitApp) { break; }
+                    try
+                    {
+                        #region    [鑴氭湰][20250704090126015][涓氬姟閫昏緫.Program2]
+                        AutoThread.InvokeMethod(AutoThread.Instance, "ThreadwebSoc");
+                        #endregion [鑴氭湰][20250704090126015][涓氬姟閫昏緫.Program2]
+                    }
+                    catch (Exception ex)
+                    {
+                        Conn.log榛樿鏃ュ織.Error(ex.ToString());
+                    }
+                    finally
+                    {
+                        System.Threading.Thread.Sleep(10000);
+                    }
+                }
+                ExitJudgeStack.TryPop(out int exitJudgeVal);
+            });
+            /// <summary>
+            /// 绋嬪簭鐗囨:Program2
+            /// 鎻忚堪:
+            /// </summary>
+            System.Threading.Tasks.Task.Factory.StartNew(() =>
+            {
+                System.Threading.Thread.CurrentThread.IsBackground = true;
+                ExitJudgeStack.Push(0);
+                //涓�洿鎵ц锛岀洿鍒版弧瓒崇粨鏉熸潯浠�+                while (true)
+                {
+                    if (IsExitApp) { break; }
+                    try
+                    {
+                        #region    [鑴氭湰][20250704090126015][涓氬姟閫昏緫.Program2]
+                        AutoThread.InvokeMethod(AutoThread.Instance, "ThreadSettingInit", new object[] { tag });
+                        #endregion [鑴氭湰][20250704090126015][涓氬姟閫昏緫.Program2]
+                    }
+                    catch (Exception ex)
+                    {
+                        Conn.log榛樿鏃ュ織.Error(ex.ToString());
+                    }
+                    finally
+                    {
+                        System.Threading.Thread.Sleep(10000);
+                    }
+                }
+                ExitJudgeStack.TryPop(out int exitJudgeVal);
+            });
+
+        }
+        /// <summary>
         /// View1鍏抽棴浜嬩欢
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-		public void View1_CloseEvent(object sender, System.ComponentModel.CancelEventArgs e)
-		{
-		
-			try
-			{
-                System.Threading.Tasks.Task.Factory.StartNew(() => { MessageBox.Show("绋嬪簭姝e湪鍏抽棴锛岃绛夊緟..."); });
-			}
-			catch(Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-			try
-			{
-				Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][Start]鍏抽棴Http鏈嶅姟");
-				if(HttpSvcHost!=null)
-				{
-					HttpSvcHost.Stop();
-				}
-			}
-			catch(Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-			finally
-			{
-				Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][End]鍏抽棴Http鏈嶅姟");
-			}
+        public void View1_CloseEvent(object sender, System.ComponentModel.CancelEventArgs e)
+        {
 
-			try
-			{
-				Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][Start]鍒ゆ柇涓氬姟澶勭悊鐘舵�");
-				IsExitApp = true;
-				//int exitCnt = 0;
-				while 
-				(
-					ExitJudgeStack.Count > 0
-				)
-				{
-					System.Threading.Thread.Sleep(100);
-					//++exitCnt;
-					//10绉掓湭缁撴潫鍒欏己鍒跺叧闂�-					//if (exitCnt >= 100)
-					//{
-					//	break;
-					//}
-				}
-			}
-			catch (Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-			finally
-			{
-				Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][End]鍒ゆ柇涓氬姟澶勭悊鐘舵�");
-			}
-			
+            try
+            {
+                System.Threading.Tasks.Task.Factory.StartNew(() => { MessageBox.Show("绋嬪簭姝e湪鍏抽棴锛岃绛夊緟..."); });
+            }
+            catch (Exception ex)
+            {
+                Conn.log榛樿鏃ュ織.Error(ex.ToString());
+            }
+            try
+            {
+                Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][Start]鍏抽棴Http鏈嶅姟");
+                if (HttpSvcHost != null)
+                {
+                    HttpSvcHost.Stop();
+                }
+            }
+            catch (Exception ex)
+            {
+                Conn.log榛樿鏃ュ織.Error(ex.ToString());
+            }
+            finally
+            {
+                Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][End]鍏抽棴Http鏈嶅姟");
+            }
+
+            try
+            {
+                Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][Start]鍒ゆ柇涓氬姟澶勭悊鐘舵�");
+                IsExitApp = true;
+                //int exitCnt = 0;
+                while
+                (
+                    ExitJudgeStack.Count > 0
+                )
+                {
+                    System.Threading.Thread.Sleep(100);
+                    //++exitCnt;
+                    //10绉掓湭缁撴潫鍒欏己鍒跺叧闂�+                    //if (exitCnt >= 100)
+                    //{
+                    //	break;
+                    //}
+                }
+            }
+            catch (Exception ex)
+            {
+                Conn.log榛樿鏃ュ織.Error(ex.ToString());
+            }
+            finally
+            {
+                Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][End]鍒ゆ柇涓氬姟澶勭悊鐘舵�");
+            }
+
             e.Cancel = true;
-			System.Threading.Tasks.Task.Factory.StartNew(() =>
-			{
-						try
-			{
-				Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][Start]鍏抽棴PLC");
-				Device.PLC1?.Stop();
-			}
-			catch(Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-			finally
-			{
-				Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][End]鍏抽棴PLC");
-			}
-			try
-			{
-			
-				Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][Start]鍒ゆ柇PLC鐘舵�");
-				//int exitCnt = 0;
-				while 
-				(
-					false
-					|| (Device.PLC1 == null ? false : Device.PLC1.State != GZ.Device.PLC.PlcRunState.Stoped)
-				)
-				{
-					System.Threading.Thread.Sleep(1000);
-					//++exitCnt;
-					//10绉掓湭缁撴潫鍒欏己鍒跺叧闂�-					//if (exitCnt >= 100)
-					//{
-					//	break;
-					//}
-				}
-			}
-			catch (Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-			finally
-			{
-				Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][End]鍒ゆ柇PLC鐘舵�");
-			}
-			Application.Current.Dispatcher.Invoke(() => { Environment.Exit(0); });
-			});
-	
-			//System.Windows.Application.Current.Shutdown();
-		}
-		/// <summary>
+            System.Threading.Tasks.Task.Factory.StartNew(() =>
+            {
+                try
+                {
+                    Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][Start]鍏抽棴PLC");
+                    Device.PLC1?.Stop();
+                }
+                catch (Exception ex)
+                {
+                    Conn.log榛樿鏃ュ織.Error(ex.ToString());
+                }
+                finally
+                {
+                    Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][End]鍏抽棴PLC");
+                }
+                try
+                {
+
+                    Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][Start]鍒ゆ柇PLC鐘舵�");
+                    //int exitCnt = 0;
+                    while
+                    (
+                        false
+                        || (Device.PLC1 == null ? false : Device.PLC1.State != GZ.Device.PLC.PlcRunState.Stoped)
+                    )
+                    {
+                        System.Threading.Thread.Sleep(1000);
+                        //++exitCnt;
+                        //10绉掓湭缁撴潫鍒欏己鍒跺叧闂�+                        //if (exitCnt >= 100)
+                        //{
+                        //	break;
+                        //}
+                    }
+                }
+                catch (Exception ex)
+                {
+                    Conn.log榛樿鏃ュ織.Error(ex.ToString());
+                }
+                finally
+                {
+                    Conn.log榛樿鏃ュ織.Debug("[鍏抽棴澶勭悊][End]鍒ゆ柇PLC鐘舵�");
+                }
+                Application.Current.Dispatcher.Invoke(() => { Environment.Exit(0); });
+            });
+
+            //System.Windows.Application.Current.Shutdown();
+        }
+        /// <summary>
         /// View1鍒濆鍖�         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-		public void View1_Init(object sender, RoutedEventArgs e)
-		{
-		}
-		#endregion
-		
-		#region 鍒囨崲tab椤�-		public void tab_SelectionChanged(object sender, EventArgs e)
-		{
-			//TabItem ti = (sender as TabControl).SelectedItem as TabItem;
-			//MessageBox.Show(ti.Name);
-		}
-		#endregion
-		
-		#region Http鏈嶅姟鐩戝惉
-		private void HttpSvcListenerCallback(IAsyncResult ar)
-		{
-			try
-			{
-				HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
-				System.Net.HttpListenerContext context = HttpSvcHost.EndGetContext(ar);
-				System.Net.HttpListenerRequest request = context.Request;
-				System.Net.HttpListenerResponse response = context.Response;
-				switch(request.LocalEndPoint.ToString())
-				{
-					case "127.0.0.1:8808":
-					{
-						using (var reader = new System.IO.StreamReader(request.InputStream, System.Text.Encoding.UTF8))
-						{
-							string requestJson = reader.ReadToEnd();
+        public void View1_Init(object sender, RoutedEventArgs e)
+        {
+        }
+        #endregion
 
-							string respstr = HttpSvcListenerCallback_Api(request.HttpMethod,request.Url.AbsolutePath,requestJson,out System.Net.HttpStatusCode statusCode);
+        #region 鍒囨崲tab椤�+        public void tab_SelectionChanged(object sender, EventArgs e)
+        {
+            //TabItem ti = (sender as TabControl).SelectedItem as TabItem;
+            //MessageBox.Show(ti.Name);
+        }
+        #endregion
 
-							string logContent="";
-							logContent += $"\r\n[{request.HttpMethod}]{request.Url.AbsolutePath}";
-							logContent += $"\r\n[request]{requestJson}";
-							logContent += $"\r\n[response]{respstr}";
-							Conn.log榛樿鏃ュ織?.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);
-							response.Close();
-						}
-						break;
-					}
-				}
-			}
-			catch(Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-			}
-		}
-		private System.String HttpSvcListenerCallback_Api(System.String method,System.String path,System.String requestJson,out System.Net.HttpStatusCode statusCode)
-		{
-			try
-			{
-				switch(method)
-				{
-					case "POST":
-					{
-						switch(path)
-						{
-							case "/Api/sendTask":
-							{
-								statusCode = System.Net.HttpStatusCode.OK;
-								return "";
-							}
-							case "/Api/cancelTask":
-							{
-								statusCode = System.Net.HttpStatusCode.OK;
-								return "";
-							}
-						}
-						break;
-					}
-				}
-				statusCode = System.Net.HttpStatusCode.NotFound;
-				return "";
-			}
-			catch(Exception ex)
-			{
-				Conn.log榛樿鏃ュ織.Error(ex.ToString());
-				statusCode = System.Net.HttpStatusCode.InternalServerError;
-				return "";
-			}
-		}
-		#endregion
-	}
+        #region Http鏈嶅姟鐩戝惉
+        private void HttpSvcListenerCallback(IAsyncResult ar)
+        {
+            try
+            {
+                HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
+                System.Net.HttpListenerContext context = HttpSvcHost.EndGetContext(ar);
+                System.Net.HttpListenerRequest request = context.Request;
+                System.Net.HttpListenerResponse response = context.Response;
+                switch (request.LocalEndPoint.ToString())
+                {
+                    case "127.0.0.1:8808":
+                        {
+                            using (var reader = new System.IO.StreamReader(request.InputStream, System.Text.Encoding.UTF8))
+                            {
+                                string requestJson = reader.ReadToEnd();
+
+                                string respstr = HttpSvcListenerCallback_Api(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}";
+                                Conn.log榛樿鏃ュ織?.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);
+                                response.Close();
+                            }
+                            break;
+                        }
+                }
+            }
+            catch (Exception ex)
+            {
+                Conn.log榛樿鏃ュ織.Error(ex.ToString());
+            }
+        }
+        private System.String HttpSvcListenerCallback_Api(System.String method, System.String path, System.String requestJson, out System.Net.HttpStatusCode statusCode)
+        {
+            try
+            {
+                switch (method)
+                {
+                    case "POST":
+                        {
+                            switch (path)
+                            {
+                                case "/Api/sendTask":
+                                    {
+                                        statusCode = System.Net.HttpStatusCode.OK;
+                                        return "";
+                                    }
+                                case "/Api/cancelTask":
+                                    {
+                                        statusCode = System.Net.HttpStatusCode.OK;
+                                        return "";
+                                    }
+                            }
+                            break;
+                        }
+                }
+                statusCode = System.Net.HttpStatusCode.NotFound;
+                return "";
+            }
+            catch (Exception ex)
+            {
+                Conn.log榛樿鏃ュ織.Error(ex.ToString());
+                statusCode = System.Net.HttpStatusCode.InternalServerError;
+                return "";
+            }
+        }
+        #endregion
+    }
 }
 

--
Gitblit v1.9.1