1
czw
2025-07-03 99da99b13c68c5f2b82da2764d54b92b1b598657
2025Äê6ÔÂ12ÈÕ/AuxAllWCS/Build/Project/´úÂë/½çÃæÊ¼þ.cs
@@ -387,15 +387,7 @@
            try
            {
                #region    [脚本][20250605212104026][业务逻辑.SocketServer]
                var host = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
                foreach (var ip in host.AddressList)
                {
                    if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        Console.WriteLine($"ip= {ip.ToString()}");
                        new TcpServer(ip.ToString());
                    }
                }
                AutoThread.InvokeMethod(AutoThread.Instance, "TaskEverythingRun");
                #endregion [脚本][20250605212104026][业务逻辑.SocketServer]
            }
            catch (Exception ex)
@@ -771,6 +763,7 @@
                }
                ExitJudgeStack.TryPop(out int exitJudgeVal);
            });
            /// <summary>
            /// ç¨‹åºç‰‡æ®µ:Program1
            /// æè¿°:
@@ -1061,12 +1054,13 @@
        #endregion
        #region Http服务监听
        private void HttpSvcListenerCallback(IAsyncResult ar)
        private async void HttpSvcListenerCallback(IAsyncResult ar)
        {
            System.Net.HttpListenerContext context = null;
            try
            {
                HttpSvcHost.BeginGetContext(HttpSvcListenerCallback, null);
                System.Net.HttpListenerContext context = HttpSvcHost.EndGetContext(ar);
                context = HttpSvcHost.EndGetContext(ar);
                System.Net.HttpListenerRequest request = context.Request;
                System.Net.HttpListenerResponse response = context.Response;
                switch (request.LocalEndPoint.ToString())
@@ -1076,21 +1070,28 @@
                            using (var reader = new System.IO.StreamReader(request.InputStream, System.Text.Encoding.UTF8))
                            {
                                string requestJson = reader.ReadToEnd();
                                string respstr = HttpSvcListenerCallback_he(request.HttpMethod, request.Url.AbsolutePath, requestJson, out System.Net.HttpStatusCode statusCode);
                                System.Net.HttpStatusCode statusCode = 0;
                                string respstr = await Task.Run(() =>
                                {
                                    return HttpSvcListenerCallback_he(request.HttpMethod, request.Url.AbsolutePath, requestJson, out statusCode);
                                });
                                string logContent = "";
                                logContent += $"\r\n[{request.HttpMethod}]{request.Url.AbsolutePath}";
                                logContent += $"\r\n[request]{requestJson}";
                                logContent += $"\r\n[response]{respstr}";
                                Conn.默认日志?.Info(logContent);
                                _ = Task.Run(() =>
                                {
                                    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);
                                response.Close();
                                // å¼‚步写入响应
                                await response.OutputStream.WriteAsync(bytstr, 0, bytstr.Length);
                            }
                            break;
                        }
@@ -1099,6 +1100,10 @@
            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)
@@ -1167,12 +1172,12 @@
                        {
                            switch (path)
                            {
                                case "/inddddddddddddddddd":
                                case var _ when System.Text.RegularExpressions.Regex.IsMatch(path, @"\.(html|ico|js|css)(\?.*)?$", System.Text.RegularExpressions.RegexOptions.IgnoreCase):
                                    {
                                        statusCode = System.Net.HttpStatusCode.OK;
                                        // å¤åˆ¶åˆ°case ä¸Š
                                        //var _ when System.Text.RegularExpressions.Regex.IsMatch(path, @"\.(html|ico|js|css)(\?.*)?$", System.Text.RegularExpressions.RegexOptions.IgnoreCase)
                                        var filePath = System.IO.Path.Combine("Static", path.Substring(1));
                                        var filePath = /*Directory.GetCurrentDirectory() + "\\Static" + "\\" + path.Substring(1);*/System.IO.Path.Combine(Directory.GetCurrentDirectory() + "\\Static", path.Substring(1));
                                        return File.ReadAllText(filePath);
                                    }
                            }