Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightAggregationManager
This commit is contained in:
commit
ec7e89f5bb
2 files changed
+46
-2
No files matched your search
@@ -5,9 +5,11 @@ using System.Data;
|
||||
using System.Security.Cryptography.Pkcs;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Markup;
|
||||
using System.Xml.Linq;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace SunlightAggregationManager.UserClass
|
||||
{
|
||||
@@ -64,6 +66,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"));
|
||||
}
|
||||
else
|
||||
{//首次登录记录
|
||||
@@ -164,6 +167,44 @@ namespace SunlightAggregationManager.UserClass
|
||||
Console.WriteLine("TCP Port:"+ port2.ToString());
|
||||
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>
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace SunlightAggregationManager.ViewModel
|
||||
[ObservableProperty]
|
||||
public static DataTable _userData = new DataTable();
|
||||
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
||||
@@ -70,7 +69,7 @@ namespace SunlightAggregationManager.ViewModel
|
||||
row["LinkID"] = 0;
|
||||
}
|
||||
|
||||
|
||||
Machines.RowChanged += Machines_Updata;
|
||||
UserData.RowChanged += UserData_Updata;//注册userdata表更新事件
|
||||
|
||||
}
|
||||
@@ -101,6 +100,10 @@ namespace SunlightAggregationManager.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private void Machines_Updata(object sender, DataRowChangeEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void UserData_Updata(object sender, DataRowChangeEventArgs e)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user