Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightAggregationManager
This commit is contained in:
commit
84b14491e2
4 files changed
+74
-16
No files matched your search
+24
-14
@@ -31,7 +31,9 @@ namespace SunlightAggregationManager.UserClass
|
||||
//TcpService service = new TcpService();
|
||||
service.Connecting = (client, e) => { return EasyTask.CompletedTask; };//有客户端正在连接
|
||||
service.Connected = (client, e) => {return EasyTask.CompletedTask;};//有客户端成功连接
|
||||
service.Closing = (client, e) => { return EasyTask.CompletedTask; };//有客户端正在断开连接,只有当主动断开时才有效。
|
||||
service.Closing = (client, e) => {
|
||||
Console.WriteLine("[Disconnecting]IP[" + client.IP + "]ID[" + client.Id + "]");
|
||||
return EasyTask.CompletedTask; };//有客户端正在断开连接,只有当主动断开时才有效。
|
||||
service.Closed = (client, e) => {
|
||||
//离线记录
|
||||
Dictionary<string, object> myDictOff = new Dictionary<string, object>();
|
||||
@@ -66,7 +68,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + deserializedPerson?.User + "'", myDict);
|
||||
|
||||
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]");
|
||||
client.SendAsync(Command(deserializedPerson?.Dat?? "NOT"));
|
||||
Command(deserializedPerson?.Dat ?? "NOT", client.Id);
|
||||
}
|
||||
else
|
||||
{//首次登录记录
|
||||
@@ -140,18 +142,12 @@ namespace SunlightAggregationManager.UserClass
|
||||
}
|
||||
}
|
||||
|
||||
//string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8).Substring(5);
|
||||
//string SYSDAT = "";// = e.ByteBlock.Span.ToString(Encoding.ASCII).Substring(5);
|
||||
// string SYSKEY = "";
|
||||
// if (DAT.Length >= 16) SYSKEY = DAT.Substring(0, 16);
|
||||
// if (DAT.Length > 16) SYSDAT = DAT.Substring(16);
|
||||
|
||||
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
|
||||
|
||||
await service.SetupAsync(new TouchSocketConfig()//载入配置
|
||||
// .SetMaxBufferSize(1024 * 1024 * 100)
|
||||
// .SetMaxBufferSize(1024 * 1024 * 100)
|
||||
//.SetMinBufferSize(1024 * 1024)
|
||||
.SetListenIPHosts(new IPHost[] { new IPHost(port1), new IPHost(port2) })//同时监听两个地址
|
||||
.ConfigureContainer(a =>//容器的配置顺序应该在最前面
|
||||
@@ -161,6 +157,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
{
|
||||
})
|
||||
);
|
||||
|
||||
await service.StartAsync();//启动
|
||||
|
||||
Console.WriteLine("TCP Port:"+ port1.ToString());
|
||||
@@ -168,7 +165,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
Console.WriteLine("TCP SERVER:START");
|
||||
}
|
||||
|
||||
public static string Command(string dat)//
|
||||
public static async void Command(string dat,string id)//
|
||||
{
|
||||
string Command="", ret ="";
|
||||
|
||||
@@ -179,14 +176,27 @@ namespace SunlightAggregationManager.UserClass
|
||||
if (Command == "Info")//回复info请求的信息
|
||||
{
|
||||
var t = ToList(MainWindowViewModel._machines).ToJsonString();
|
||||
|
||||
//格式化返回信息
|
||||
data_.Add("Info", t);
|
||||
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "Query")//回复Query请求的信息
|
||||
{
|
||||
string s_ = deserialized.GetValue("StartTime").ToString()!;
|
||||
string e_ = deserialized.GetValue("EndTime").ToString()!;
|
||||
|
||||
DataTable resultTable = await MainWindowViewModel.dataBase.ExecuteQueryAsync("SELECT * FROM [dbo].[Dyelots] " +
|
||||
"WHERE CreationTime>'"+s_+"'and CreationTime<'"+e_+"'");
|
||||
//格式化返回信息
|
||||
data_.Add("Query", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "QueryDetail")//回复info请求的信息
|
||||
{
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
await service.SendAsync(id, ret);
|
||||
}
|
||||
|
||||
public static List<Dictionary<string, object?>>? ToList(DataTable table)//datatable转list
|
||||
|
||||
Reference in new issue
Block a user