diff --git a/SunlightAggregationManager.csproj b/SunlightAggregationManager.csproj
index 9ec952f..4b37532 100644
--- a/SunlightAggregationManager.csproj
+++ b/SunlightAggregationManager.csproj
@@ -15,7 +15,8 @@
-
+
+
diff --git a/UserClass/AsyncHttpServer.cs b/UserClass/AsyncHttpServer.cs
new file mode 100644
index 0000000..cf61710
--- /dev/null
+++ b/UserClass/AsyncHttpServer.cs
@@ -0,0 +1,205 @@
+using SunlightAggregationManager.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Text;
+using System.Text.Json;
+using TouchSocket.Core;
+using TouchSocket.Http;
+using TouchSocket.Http.WebSockets;
+using TouchSocket.Sockets;
+using static SunlightAggregationManager.UserClass.AsyncTcpServer;
+
+
+namespace SunlightAggregationManager.UserClass
+{
+ public class AsyncHttpServer
+ {
+ public static HttpService httpservice = new HttpService();
+
+ public static async Task HttpMain(int port1)
+ {
+ NetFwManger.AllowPort(port1, "TCP");//开放端口
+ await httpservice.SetupAsync(new TouchSocketConfig()//加载配置
+ .SetListenIPHosts(port1)
+ .ConfigureContainer(a =>
+ {
+ a.AddConsoleLogger();
+ })
+ .ConfigurePlugins(a =>
+ {
+ a.Add();
+ //default插件应该最后添加,其作用是
+ //1、为找不到的路由返回404
+ //2、处理 header 为Option的探视跨域请求。
+ a.UseDefaultHttpServicePlugin();
+ }));
+ await httpservice.StartAsync();
+ Console.WriteLine("HTTP Port:" + port1.ToString());
+ }
+
+ public class MyHttpPlug1 : PluginBase, IHttpPlugin
+ {
+ public async Task OnHttpRequest(IHttpSessionClient client, HttpContextEventArgs e)
+ {
+ #region HttpContext生命周期
+ //var request = e.Context.Request;//http请求体
+ var response = e.Context.Response;//http响应体
+ #endregion
+
+ var bodyString = await e.Context.Request.GetBodyAsync();
+ try
+ {
+ Person? deserializedPerson = JsonSerializer.Deserialize(bodyString);
+
+ var _user = MainWindowViewModel.Selet_Memory(MainWindowViewModel._userData, "State", "User='" +
+ deserializedPerson?.User + "' and Password ='" + deserializedPerson?.Password + "'");
+ if (_user != null)
+ {
+ string _dat = _user?.ToString() ?? "0";
+ if (_dat != "99")
+ {
+ //行为
+ Dictionary myDict = new Dictionary();
+ myDict.Add("LinkID", client.Id);
+ myDict.Add("LastLoginIP", deserializedPerson?.IP ?? client.IP);
+ myDict.Add("LastActionTime", DateTime.Now);
+ myDict.Add("Note", deserializedPerson?.Dat ?? "unknown");
+ MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + deserializedPerson?.User + "'", myDict);
+
+ Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]");
+
+ var dt = await Command(deserializedPerson!);
+
+ e.Context.Response.Headers.Add("SUNLIGHT", "SUNLIGHT");
+ e.Context.Response.SetStatus(200, "success");
+ e.Context.Response.SetContent(Encoding.UTF8.GetBytes(dt.ToCharArray()));
+ await e.Context.Response.AnswerAsync();
+ }
+ else
+ {//停用账号关闭连接
+ //client.SendAsync("Account Deactivated");
+ e.Context.Response.Headers.Add("SUNLIGHT", "SUNLIGHT");
+ e.Context.Response.SetStatus(200, "success");
+ e.Context.Response.SetContent("Account Deactivated");
+ await e.Context.Response.AnswerAsync();
+ }
+ }
+ else
+ { //无效账号关闭连接
+ //client.SendAsync("Invalid Account");
+ e.Context.Response.Headers.Add("SUNLIGHT", "SUNLIGHT");
+ e.Context.Response.SetStatus(200, "success");
+ e.Context.Response.SetContent("Invalid Account");
+ await e.Context.Response.AnswerAsync();
+ }
+ }
+ catch (Exception ex)
+ {//错误
+ Console.WriteLine("Http:" + ex.ToString());
+ //client.SendAsync("Target instruction parsing error manager will close connection");
+ }
+
+
+ /* if (request.IsGet() && request.UrlEquals("/success"))
+ {
+ //直接响应文字
+ await response
+ .SetStatus(200, "success")
+ .FromText("Success")
+ .AnswerAsync();//直接回应
+ Console.WriteLine("处理/success");
+ return;
+ }
+
+
+ //无法处理,调用下一个插件
+ await e.InvokeNext();*/
+ }
+ }
+
+ public static async Task Command(Person deserializedPerson)//
+ {
+ string Command = "", ret = "";
+
+ Dictionary data_ = new Dictionary();
+ var deserialized = JsonSerializer.Deserialize>(deserializedPerson.Dat)!;
+ if (deserialized.TryGetValue("Command", out var val) && val != null) Command = val.ToString()!;
+ if (Command == "Log")//回复请求的信息
+ {
+ DataRow? _user = MainWindowViewModel.Selet_Row(MainWindowViewModel._userData, "User='" +
+ deserializedPerson?.User + "' and Password ='" + deserializedPerson?.Password + "'");
+
+ data_.Add("Enterprise", _user?.Field