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/Scripts/Custom.json                   |    2 
 HnSx/Build/Project/代码/界面事件.cs              |  555 ++++++++++++++++++++++--------------------
 HnSx/HnSx.json                             |    2 
 HnSx/RunTime/Code/集成互联.cs                  |    6 
 HnSx/Scripts/Script.json                   |  125 ++++++---
 HnSx/Build/Project/代码/VS自定义类/AutoThread.cs |   77 +++--
 6 files changed, 423 insertions(+), 344 deletions(-)

diff --git "a/HnSx/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs" "b/HnSx/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
index c35ed3a..603683d 100644
--- "a/HnSx/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
+++ "b/HnSx/Build/Project/\344\273\243\347\240\201/VS\350\207\252\345\256\232\344\271\211\347\261\273/AutoThread.cs"
@@ -27,6 +27,8 @@
 using NLog.Targets;
 using NLog;
 using ServiceStack.Messaging.Rcon;
+using System.Runtime.ExceptionServices;
+using System.Runtime.InteropServices;
 
 namespace GZ.Projects.HnSx
 {
@@ -108,7 +110,33 @@
         {
 
         }
-        public void TaskEverythingRun()
+
+        public async void ThreadwebSoc()
+        {
+            List<object> list = new List<object>();
+            //read Alldata from database
+            //灏嗘暟鎹紦瀛樺埌鍐呭瓨銆�+            try
+            {
+                Thread.Sleep(1000);
+                while (true)
+                {
+                    if (/*list.Count > 0 && */WebSocketClientWithReconnect.GetWebSocketState() == WebSocketState.Open)
+                        for (int i = 60000; i < 70000; i++)
+                        {
+                            Thread.Sleep(1000);
+                            Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")}>>>GGG{i}");
+                            var b = WebSocketClientWithReconnect.Instance?.SendAsync($"He >>GGG{i}").Result;
+                            Console.WriteLine("鍙戦�瀹屾垚锛侊紒" + b);
+                        }
+                }
+            }
+            catch (Exception ex)
+            {
+                LogHelper.Error(ex.Message, ex);
+            }
+        }
+        public async Task TaskEverythingRun()
         {
             var host = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
             foreach (var ip in host.AddressList)
@@ -119,35 +147,8 @@
                     //new HttpServer(ip.ToString()).HttpServerRun();
                     //new TcpServer(ip.ToString());
                     //var server = new EnhancedWebSocketServer($"http://{ip.ToString()}:8809/").StartAsync();
-                    var client = new WebSocketClientWithReconnect($"ws://{ip.ToString()}:8809/socket")/*.StartAsync()*/;
-                    //Task.Run(async () =>
-                    //{
-                    client.StartAsync();
-                    Task.Run(async () =>
-                    {
-                        while (true)
-                        {
-                            for (int i = 0; i < 10000; i++)
-                            {
-                                Thread.Sleep(1000);
-                                Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")}>>>Server{i}");
-                               await client.SendAsync($"Hello Server{i}!");
-                            }
-                        }
-                    });
-                    //Task.Run(async () =>
-                    //{
-                    //    while (true)
-                    //    {
-                    //        for (int i = 60000; i < 70000; i++)
-                    //        {
-                    //            Thread.Sleep(1000);
-                    //            Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")}>>>GGG{i}");
-                    //            await client.SendAsync($"Hello GGG{i}!");
-                    //        }
-                    //    }
-                    //});
-                    //});
+                    new WebSocketClientWithReconnect($"ws://{ip.ToString()}:8809/socket").StartAsync();
+
                     break;
                 }
             }
@@ -470,7 +471,8 @@
 
     public class WebSocketClientWithReconnect
     {
-        private ClientWebSocket _webSocket;
+        public static ClientWebSocket _webSocket;
+        private static WebSocketClientWithReconnect _instance;
         private readonly Uri _serverUri;
         private readonly CancellationTokenSource _cts = new CancellationTokenSource();
         private readonly int _reconnectDelayMs;
@@ -485,9 +487,18 @@
             _serverUri = new Uri(serverUrl);
             _reconnectDelayMs = reconnectDelayMs;
         }
+        public static WebSocketClientWithReconnect Instance
+        {
+            get
+            {
+                return _instance;
+            }
+        }
 
+        public static WebSocketState GetWebSocketState() => _webSocket != null ? _webSocket.State : WebSocketState.Closed;
         public async Task StartAsync()
         {
+            _instance = this;
             while (!_cts.IsCancellationRequested)
             {
                 try
@@ -570,7 +581,7 @@
             }
         }
 
-        public async Task SendAsync(string message)
+        public async Task<bool> SendAsync(string message)
         {
             if (_webSocket?.State != WebSocketState.Open)
             {
@@ -579,7 +590,7 @@
 
             var bytes = System.Text.Encoding.UTF8.GetBytes(message);
             await _webSocket.SendAsync(new ArraySegment<byte>(bytes), WebSocketMessageType.Text, true, _cts.Token);
-
+            return true;    
         }
     }
 
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
+    }
 }
 
diff --git a/HnSx/HnSx.json b/HnSx/HnSx.json
index 45fc356..c9ae529 100644
--- a/HnSx/HnSx.json
+++ b/HnSx/HnSx.json
@@ -9,5 +9,5 @@
   "DevelopVersion": "1.0.6.0",
   "Encode": "1bKKzS3nmbstyerHBqNS0Q==",
   "CreationTime": "0001-01-01 00:00:00",
-  "LastWriteTime": "2025-07-04 11:18:35"
+  "LastWriteTime": "2025-07-04 14:55:05"
 }
\ No newline at end of file
diff --git "a/HnSx/RunTime/Code/\351\233\206\346\210\220\344\272\222\350\201\224.cs" "b/HnSx/RunTime/Code/\351\233\206\346\210\220\344\272\222\350\201\224.cs"
index 2504b8d..dbbc602 100644
--- "a/HnSx/RunTime/Code/\351\233\206\346\210\220\344\272\222\350\201\224.cs"
+++ "b/HnSx/RunTime/Code/\351\233\206\346\210\220\344\272\222\350\201\224.cs"
@@ -28,12 +28,12 @@
 	/// </summary>
 	public class Conn
 	{
-		public static GZ.Modular.Log.ILogger 榛樿涓氬姟鏃ュ織 = null;
-		public static GZ.Modular.Redis.RedisTagHelper 榛樿Redis = new GZ.Modular.Redis.RedisTagHelper(榛樿涓氬姟鏃ュ織);
+		public static GZ.Modular.Log.ILogger log榛樿鏃ュ織 = null;
+		public static GZ.Modular.Redis.RedisTagHelper 榛樿Redis = new GZ.Modular.Redis.RedisTagHelper(log榛樿鏃ュ織);
 		public Conn()
 		{
 			string[] allKeys = System.Configuration.ConfigurationManager.AppSettings.AllKeys;
-		榛樿涓氬姟鏃ュ織 = new GZ.Modular.Log.NLogger("NLogger",7,"",true,"mongodb://localhost:27017?connectTimeoutMS=3000&socketTimeoutMS=5000","HnSx");
+		log榛樿鏃ュ織 = new GZ.Modular.Log.NLogger("NLogger",7,"",true,"mongodb://localhost:27017?connectTimeoutMS=3000&socketTimeoutMS=5000","HnSx");
 		
 		}
 	}
diff --git a/HnSx/Scripts/Custom.json b/HnSx/Scripts/Custom.json
index 418e7d7..45a3d73 100644
--- a/HnSx/Scripts/Custom.json
+++ b/HnSx/Scripts/Custom.json
@@ -23,6 +23,6 @@
     }
   ],
   "CreationTime": "2025-07-01 10:23:43",
-  "LastWriteTime": "2025-07-04 11:04:09",
+  "LastWriteTime": "2025-07-04 14:55:05",
   "HasSaved": true
 }
\ No newline at end of file
diff --git a/HnSx/Scripts/Script.json b/HnSx/Scripts/Script.json
index 233efaf..254a0d6 100644
--- a/HnSx/Scripts/Script.json
+++ b/HnSx/Scripts/Script.json
@@ -11,48 +11,9 @@
       "ParentID": "",
       "Children": [
         {
-          "ID": "20250701110610426",
-          "Name": "Program1",
-          "Desc": "",
-          "Content": "AutoThread.InvokeMethod(AutoThread.Instance, \"TaskEverythingRun\");",
-          "ContentCopy": "AutoThread.InvokeMethod(AutoThread.Instance, \"TaskEverythingRun\");",
-          "ParentID": "20250701102338326",
-          "Children": [],
-          "Type": "Program",
-          "Property": {
-            "SyncExec": "True",
-            "RepeatExec": "None",
-            "ExceCount": 1,
-            "ExceInternal": 3000,
-            "StartCondition": {
-              "Type": "View",
-              "Event": "",
-              "Expression": "",
-              "Judge": "",
-              "Command": {},
-              "HmiEvent": {
-                "20250704082900797": [
-                  "Open"
-                ]
-              }
-            },
-            "EndCondition": {
-              "Type": "None",
-              "Event": "",
-              "Expression": "",
-              "Judge": "",
-              "Command": {},
-              "HmiEvent": {}
-            }
-          },
-          "FullName": "涓氬姟閫昏緫.Program1",
-          "ParentFullName": "涓氬姟閫昏緫",
-          "Enabled": "Enabled"
-        },
-        {
           "ID": "20250704090126015",
-          "Name": "Program2",
-          "Desc": "",
+          "Name": "鍒濆鍖栭厤缃�,
+          "Desc": "exec",
           "Content": "AutoThread.InvokeMethod(AutoThread.Instance, \"ThreadSettingInit\", new object[] { tag });",
           "ContentCopy": "AutoThread.InvokeMethod(AutoThread.Instance, \"ThreadSettingInit\", new object[] { tag });",
           "ParentID": "20250701102338326",
@@ -84,7 +45,85 @@
               "HmiEvent": {}
             }
           },
-          "FullName": "涓氬姟閫昏緫.Program2",
+          "FullName": "涓氬姟閫昏緫.鍒濆鍖栭厤缃�,
+          "ParentFullName": "涓氬姟閫昏緫",
+          "Enabled": "Enabled"
+        },
+        {
+          "ID": "20250701110610426",
+          "Name": "鍚姩杩炴帴鏈嶅姟",
+          "Desc": "姣斿tcp http 鍜�websocket",
+          "Content": "AutoThread.InvokeMethod(AutoThread.Instance, \"TaskEverythingRun\");",
+          "ContentCopy": "AutoThread.InvokeMethod(AutoThread.Instance, \"TaskEverythingRun\");",
+          "ParentID": "20250701102338326",
+          "Children": [],
+          "Type": "Program",
+          "Property": {
+            "SyncExec": "True",
+            "RepeatExec": "None",
+            "ExceCount": 1,
+            "ExceInternal": 3000,
+            "StartCondition": {
+              "Type": "View",
+              "Event": "",
+              "Expression": "",
+              "Judge": "",
+              "Command": {},
+              "HmiEvent": {
+                "20250704082900797": [
+                  "Open"
+                ]
+              }
+            },
+            "EndCondition": {
+              "Type": "None",
+              "Event": "",
+              "Expression": "",
+              "Judge": "",
+              "Command": {},
+              "HmiEvent": {}
+            }
+          },
+          "FullName": "涓氬姟閫昏緫.鍚姩杩炴帴鏈嶅姟",
+          "ParentFullName": "涓氬姟閫昏緫",
+          "Enabled": "Enabled"
+        },
+        {
+          "ID": "20250704145122680",
+          "Name": "楂橀�鎵爜鍒嗘嫞妯″潡",
+          "Desc": "1",
+          "Content": "AutoThread.InvokeMethod(AutoThread.Instance, \"ThreadwebSoc\");",
+          "ContentCopy": "AutoThread.InvokeMethod(AutoThread.Instance, \"ThreadwebSoc\");",
+          "ParentID": "20250701102338326",
+          "Children": [],
+          "Type": "Program",
+          "Property": {
+            "SyncExec": "False",
+            "RepeatExec": "Until",
+            "ExceCount": 1,
+            "ExceInternal": 3000,
+            "StartCondition": {
+              "Type": "View",
+              "Event": "",
+              "Expression": "",
+              "Judge": "",
+              "Command": {},
+              "HmiEvent": {
+                "20250704082900797": [
+                  "Open"
+                ]
+              }
+            },
+            "EndCondition": {
+              "Type": "None",
+              "Event": "",
+              "Expression": "",
+              "Judge": "",
+              "Command": {},
+              "HmiEvent": {}
+            }
+          },
+          "FullName": "涓氬姟閫昏緫.楂橀�鎵爜鍒嗘嫞妯″潡",
           "ParentFullName": "涓氬姟閫昏緫",
           "Enabled": "Enabled"
         }
@@ -153,6 +192,6 @@
     }
   ],
   "CreationTime": "2025-07-01 10:23:38",
-  "LastWriteTime": "2025-07-04 11:04:09",
+  "LastWriteTime": "2025-07-04 14:55:05",
   "HasSaved": true
 }
\ No newline at end of file

--
Gitblit v1.9.1