Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightAggregationManager
This commit is contained in:
commit
480d705255
3 files changed
+29
-20
No files matched your search
@@ -60,21 +60,22 @@ namespace SunlightAggregationManager.UserClass
|
||||
if (_dat != "99")
|
||||
{
|
||||
//行为
|
||||
Dictionary<string, object> myDict = new Dictionary<string, object>();
|
||||
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);
|
||||
Dictionary<string, object> myDict = new Dictionary<string, object>();
|
||||
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!);
|
||||
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]");
|
||||
|
||||
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();
|
||||
deserializedPerson!.Dat = await Command(deserializedPerson!);
|
||||
var jsdat = JsonSerializer.Serialize(deserializedPerson);
|
||||
|
||||
e.Context.Response.Headers.Add("SUNLIGHT", "SUNLIGHT");
|
||||
e.Context.Response.SetStatus(200, "success");
|
||||
e.Context.Response.SetContent(jsdat);
|
||||
await e.Context.Response.AnswerAsync();
|
||||
}
|
||||
else
|
||||
{//停用账号关闭连接
|
||||
|
||||
@@ -44,13 +44,15 @@ namespace SunlightAggregationManager.UserClass
|
||||
}
|
||||
//发送本机信息到转发服务器
|
||||
Dictionary<string, object> myDict = new Dictionary<string, object>();
|
||||
myDict.Add("Enterprise", MainWindowViewModel.Enterprise);
|
||||
myDict.Add("MachineName", MainWindowViewModel.MachineName);
|
||||
myDict.Add("SERVEREnterprise", MainWindowViewModel.Enterprise);
|
||||
myDict.Add("SERVERMachineName", MainWindowViewModel.MachineName);
|
||||
myDict.Add("SERVERNAME", MainWindowViewModel.SERVERNAME);
|
||||
myDict.Add("SERVERUSER", MainWindowViewModel.SERVERUSER);
|
||||
myDict.Add("SERRVERPASWORD", MainWindowViewModel.SERRVERPASWORD);
|
||||
myDict.Add("MachineVer", MainWindowViewModel.MachineVer);
|
||||
TcpTransmit(myDict);
|
||||
|
||||
Console.WriteLine("Sunlight_Server_Connected");
|
||||
return EasyTask.CompletedTask;
|
||||
};//成功连接到服务器
|
||||
tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//即将从服务器断开连接。此处仅主动断开才有效。
|
||||
@@ -62,6 +64,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
targetRow["Status"] = "Disconnect";
|
||||
targetRow.EndEdit();
|
||||
}
|
||||
Console.WriteLine("Sunlight_Server_Disconnect");
|
||||
return EasyTask.CompletedTask; };//从服务器断开连接,当连接不成功时不会触发。
|
||||
#region Tcp客户端使用Received异步委托接收数据
|
||||
tcpClient.Received = (client, e) =>
|
||||
|
||||
@@ -5,10 +5,12 @@ using System.Data;
|
||||
using System.Security.Cryptography.Pkcs;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Xml.Linq;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using static SunlightAggregationManager.UserClass.AsyncTcpServer;
|
||||
|
||||
namespace SunlightAggregationManager.UserClass
|
||||
{
|
||||
@@ -67,7 +69,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + deserializedPerson?.User + "'", myDict);
|
||||
|
||||
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]");
|
||||
Command(deserializedPerson?.Dat ?? "NOT", client.Id);
|
||||
Command(deserializedPerson?.Dat ?? "NOT", client.Id, deserializedPerson!);
|
||||
}
|
||||
else
|
||||
{//首次登录记录
|
||||
@@ -94,8 +96,9 @@ namespace SunlightAggregationManager.UserClass
|
||||
login.Add("UserId", dat?.Field<object>("UserID") ?? "");
|
||||
login.Add("UserName", dat?.Field<object>("Name") ?? "");
|
||||
|
||||
var d = JsonSerializer.Serialize(login);
|
||||
client.SendAsync(d);
|
||||
deserializedPerson!.Dat = JsonSerializer.Serialize(login);
|
||||
var jsdat = JsonSerializer.Serialize(deserializedPerson);
|
||||
client.SendAsync(jsdat);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -164,7 +167,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
Console.WriteLine("TCP SERVER:START");
|
||||
}
|
||||
|
||||
public static async void Command(string dat,string id)//
|
||||
public static async void Command(string dat,string id , Person person)//
|
||||
{
|
||||
string Command="", ret ="";
|
||||
|
||||
@@ -215,7 +218,9 @@ namespace SunlightAggregationManager.UserClass
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
|
||||
await service.SendAsync(id, ret);
|
||||
person.Dat=ret.ToString();
|
||||
var jsdat = JsonSerializer.Serialize(person);
|
||||
await service.SendAsync(id, jsdat);
|
||||
}
|
||||
|
||||
public static List<Dictionary<string, object?>>? ToList(DataTable table)//datatable转list
|
||||
|
||||
Reference in new issue
Block a user