|
|
@ -5,9 +5,11 @@ using System.Data; |
|
|
using System.Security.Cryptography.Pkcs; |
|
|
using System.Security.Cryptography.Pkcs; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Text.Json; |
|
|
using System.Text.Json; |
|
|
|
|
|
using System.Windows.Markup; |
|
|
using System.Xml.Linq; |
|
|
using System.Xml.Linq; |
|
|
using TouchSocket.Core; |
|
|
using TouchSocket.Core; |
|
|
using TouchSocket.Sockets; |
|
|
using TouchSocket.Sockets; |
|
|
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType; |
|
|
|
|
|
|
|
|
namespace SunlightAggregationManager.UserClass |
|
|
namespace SunlightAggregationManager.UserClass |
|
|
{ |
|
|
{ |
|
|
@ -64,6 +66,7 @@ namespace SunlightAggregationManager.UserClass |
|
|
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + deserializedPerson?.User + "'", myDict); |
|
|
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" + deserializedPerson?.User + "'", myDict); |
|
|
|
|
|
|
|
|
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]"); |
|
|
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]"); |
|
|
|
|
|
client.SendAsync(Command(deserializedPerson?.Dat?? "NOT")); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{//首次登录记录
|
|
|
{//首次登录记录
|
|
|
@ -164,6 +167,44 @@ namespace SunlightAggregationManager.UserClass |
|
|
Console.WriteLine("TCP Port:"+ port2.ToString()); |
|
|
Console.WriteLine("TCP Port:"+ port2.ToString()); |
|
|
Console.WriteLine("TCP SERVER:START"); |
|
|
Console.WriteLine("TCP SERVER:START"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static string Command(string dat) |
|
|
|
|
|
{ |
|
|
|
|
|
string Command="", ret =""; |
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, object> data_ = new Dictionary<string, object>(); |
|
|
|
|
|
var deserialized = JsonSerializer.Deserialize<Dictionary<string, object>>(dat)!; |
|
|
|
|
|
if (deserialized.TryGetValue("Command", out var val) && val != null) Command = val.ToString()!; |
|
|
|
|
|
|
|
|
|
|
|
if (Command == "Info") |
|
|
|
|
|
{ |
|
|
|
|
|
var t = ToList(MainWindowViewModel._machines).ToJsonString(); |
|
|
|
|
|
|
|
|
|
|
|
data_.Add("Info", t); |
|
|
|
|
|
|
|
|
|
|
|
ret = JsonSerializer.Serialize(data_); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static List<Dictionary<string, object>> ToList(DataTable table) |
|
|
|
|
|
{ |
|
|
|
|
|
if (table == null) return null; |
|
|
|
|
|
|
|
|
|
|
|
// 使用 AsEnumerable() 将 DataTable 转换为 IEnumerable<DataRow>
|
|
|
|
|
|
// 然后投影为 Dictionary
|
|
|
|
|
|
return table.AsEnumerable().Select(row => |
|
|
|
|
|
table.Columns.Cast<DataColumn>().ToDictionary( |
|
|
|
|
|
col => col.ColumnName, |
|
|
|
|
|
col => row[col] |
|
|
|
|
|
) |
|
|
|
|
|
).ToList(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class MyTcpService : TcpService<MyTcpSessionClient> |
|
|
class MyTcpService : TcpService<MyTcpSessionClient> |
|
|
|