Compare commits
10
Commits
c2451be4a2
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9afd362de6 | ||
|
|
5b9cf5a538 | ||
|
|
db203d01e1 | ||
|
|
8690824663 | ||
|
|
5ca8148c42 | ||
|
|
e54cafd16b | ||
|
|
c21504993f | ||
|
|
8e90c904ee | ||
|
|
85e60c01bc | ||
|
|
0ce1a57a53 |
No files matched your search
+76
-18
@@ -3,11 +3,14 @@ using SunlightAggregationManager.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using static SunlightAggregationManager.UserClass.AsyncTcpServer;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace SunlightAggregationManager.UserClass
|
||||
{
|
||||
@@ -105,19 +108,50 @@ namespace SunlightAggregationManager.UserClass
|
||||
//行为
|
||||
Dictionary<string, object> myDict = new Dictionary<string, object>();
|
||||
//myDict.Add("LinkID", client.Id);
|
||||
|
||||
//AES解密
|
||||
string dataAES = AES.AesDecrypt(deserializedPerson!.Terminal, deserializedPerson.Dat);
|
||||
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]COMMAND[" +
|
||||
Regex.Replace(dataAES, @"\\u[0-9A-Fa-f]{4}", match =>
|
||||
{ return Regex.Unescape(match.Value); }) + "]");
|
||||
|
||||
//记录
|
||||
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);
|
||||
myDict.Add("Note", dataAES ?? "unknown");
|
||||
|
||||
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]Note[" + (deserializedPerson?.Dat ?? "unknown") + "]");
|
||||
CommandC(deserializedPerson?.Dat ?? "NOT", deserializedPerson!);
|
||||
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" +
|
||||
deserializedPerson?.User + "'", myDict);
|
||||
|
||||
CommandC(dataAES ?? "NOT", deserializedPerson!);
|
||||
}
|
||||
else
|
||||
{//停用账号关闭连接
|
||||
client.SendAsync("Account Deactivated");
|
||||
}
|
||||
}
|
||||
else if (password== MainWindowViewModel.SERRVERPASWORD && deserializedPerson?.User== MainWindowViewModel.SERVERUSER)
|
||||
{
|
||||
//行为
|
||||
Dictionary<string, object> myDict = new Dictionary<string, object>();
|
||||
//myDict.Add("LinkID", client.Id);
|
||||
|
||||
//AES解密
|
||||
string dataAES = AES.AesDecrypt(deserializedPerson!.Terminal, deserializedPerson.Dat);
|
||||
Console.WriteLine("[Log on]User[" + deserializedPerson?.User + "]COMMAND[" +
|
||||
Regex.Replace(dataAES, @"\\u[0-9A-Fa-f]{4}", match =>
|
||||
{ return Regex.Unescape(match.Value); }) + "]");
|
||||
|
||||
//记录
|
||||
myDict.Add("LastLoginIP", deserializedPerson?.IP ?? client.IP);
|
||||
myDict.Add("LastActionTime", DateTime.Now);
|
||||
myDict.Add("Note", dataAES ?? "unknown");
|
||||
|
||||
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData, "User='" +
|
||||
deserializedPerson?.User + "'", myDict);
|
||||
|
||||
CommandC(dataAES ?? "NOT", deserializedPerson!);
|
||||
}
|
||||
else
|
||||
{ //无效账号关闭连接
|
||||
client.SendAsync("Invalid Account");
|
||||
@@ -194,9 +228,13 @@ namespace SunlightAggregationManager.UserClass
|
||||
string Command = "", ret = "";
|
||||
|
||||
Dictionary<string, object> data_ = new Dictionary<string, object>();
|
||||
var deserialized = JsonSerializer.Deserialize<Dictionary<string, object>>( AES.AesDecrypt(person.Terminal, dat))!;
|
||||
var deserialized = JsonSerializer.Deserialize<Dictionary<string, object>>(dat)!;
|
||||
if (deserialized.TryGetValue("Command", out var val) && val != null) Command = val.ToString()!;
|
||||
if (Command == "Log")//回复请求的信息
|
||||
if (Command == "SysCom")//回复指令的信息
|
||||
{
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
else if (Command == "Log")//回复请求的信息
|
||||
{
|
||||
DataRow? _user = MainWindowViewModel.Selet_Row(MainWindowViewModel._userData, "User='" +
|
||||
person?.User + "'");
|
||||
@@ -207,17 +245,33 @@ namespace SunlightAggregationManager.UserClass
|
||||
data_.Add("UserId", _user?.Field<object>("UserID") ?? "");
|
||||
data_.Add("UserName", _user?.Field<object>("Name") ?? "");
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "SysData")//回复请求的信息
|
||||
}
|
||||
else if (Command == "SysData")//特殊指令数据库查询
|
||||
{
|
||||
string com_ = deserialized.GetValue("Comm").ToString()!;
|
||||
string da_ = deserialized.GetValue("Data").ToString()!;
|
||||
if (com_ == "SYSDB")//本机sqlite数据库
|
||||
{
|
||||
DataTable resultTable = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet(da_, null)?.Tables[0] ?? new DataTable();
|
||||
data_.Add("DB", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
|
||||
data_.Add("Comm", "SYSDB");
|
||||
data_.Add("Enterprise", MainWindowViewModel.Enterprise);
|
||||
}
|
||||
else if (com_ == "DBCDB")//系统dbc数据库
|
||||
{
|
||||
DataTable resultTable = await MainWindowViewModel.dataBase.ExecuteQueryAsync(da_);
|
||||
data_.Add("DB", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
|
||||
data_.Add("Comm", "DBCDB");
|
||||
data_.Add("Enterprise", MainWindowViewModel.Enterprise);
|
||||
}
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "ChemicalStatistics")//回复请求的信息
|
||||
else if (Command == "ChemicalStatistics")//回复请求的信息
|
||||
{
|
||||
data_.Add("ChemicalStatistics", Newtonsoft.Json.JsonConvert.SerializeObject(MainWindowViewModel.ChemicalStatistics));
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "Info")//回复info请求的信息
|
||||
else if (Command == "Info")//回复info请求的信息
|
||||
{
|
||||
var t = ToList(MainWindowViewModel._machines).ToJsonString();
|
||||
//格式化返回信息
|
||||
@@ -228,7 +282,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
data_.Add("DyeDissolveNumber", MainWindowViewModel.DyeDissolveNumber.ToString());
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "Query")//回复Query请求的信息
|
||||
else if (Command == "Query")//回复Query请求的信息
|
||||
{
|
||||
string s_ = deserialized.GetValue("StartTime").ToString()!;
|
||||
string e_ = deserialized.GetValue("EndTime").ToString()!;
|
||||
@@ -240,7 +294,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
data_.Add("Query", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "QueryDyelot")//回复QueryDyelot请求的信息
|
||||
else if (Command == "QueryDyelot")//回复QueryDyelot请求的信息
|
||||
{
|
||||
string d_ = deserialized.GetValue("DyelotName").ToString()!;
|
||||
string f_ = deserialized.GetValue("Field").ToString()!;
|
||||
@@ -251,7 +305,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
data_.Add("Query", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "QueryDetail")//回复QueryDetail请求的信息
|
||||
else if (Command == "QueryDetail")//回复QueryDetail请求的信息
|
||||
{
|
||||
string d_ = deserialized.GetValue("Dyelot").ToString()!;
|
||||
string r_ = deserialized.GetValue("ReDye").ToString()!;
|
||||
@@ -263,7 +317,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
data_.Add("QueryDetail", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "Notification")//回复Notification请求的信息
|
||||
else if (Command == "Notification")//回复Notification请求的信息
|
||||
{
|
||||
string s_; try { s_ = deserialized.GetValue("StartTime").ToString()!; } catch(Exception) { s_ = "0"; }
|
||||
string e_ = deserialized.GetValue("EndTime").ToString()!;
|
||||
@@ -282,7 +336,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
data_.Add("Notification", Newtonsoft.Json.JsonConvert.SerializeObject(resultTable));
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "InfoMachine")//回复InfoMachine请求的信息
|
||||
else if (Command == "InfoMachine")//回复InfoMachine请求的信息
|
||||
{
|
||||
string t_ = deserialized.GetValue("Type").ToString()!;
|
||||
string? m_ =null, f_ = "*";
|
||||
@@ -319,7 +373,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
//格式化返回信息
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "InfoMachineHistory")//回复InfoMachineHistory请求的信息
|
||||
else if (Command == "InfoMachineHistory")//回复InfoMachineHistory请求的信息
|
||||
{
|
||||
string t_ = deserialized.GetValue("Type").ToString()!;
|
||||
string? m_ = null, f_ = "*";
|
||||
@@ -358,7 +412,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
//格式化返回信息
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "InfoMachinePipes")//回复Notification请求的信息
|
||||
else if (Command == "InfoMachinePipes")//回复Notification请求的信息
|
||||
{
|
||||
string? m_ = null, f_ = "*";
|
||||
|
||||
@@ -372,7 +426,7 @@ namespace SunlightAggregationManager.UserClass
|
||||
//格式化返回信息
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
if (Command == "SETUSER")//回复请求的信息
|
||||
else if (Command == "SETUSER")//回复请求的信息
|
||||
{
|
||||
MainWindowViewModel.Updata_Memory(MainWindowViewModel._userData,
|
||||
"User='" + deserialized.GetValue("USER").ToString()! + "'" ,
|
||||
@@ -385,6 +439,10 @@ namespace SunlightAggregationManager.UserClass
|
||||
ret = JsonSerializer.Serialize(data_);
|
||||
}
|
||||
//加密回传
|
||||
/*Console.WriteLine("[Log on]User[" + person?.User + "]REPLY[" +
|
||||
Regex.Replace(ret, @"\\u[0-9A-Fa-f]{4}", match =>
|
||||
{ return Regex.Unescape(match.Value); }) + "]");*/
|
||||
|
||||
person!.Dat =AES.AesEncipher( person.Terminal, ret);
|
||||
var jsdat = JsonSerializer.Serialize(person);
|
||||
await tcpClient.SendAsync(jsdat);
|
||||
|
||||
@@ -324,9 +324,14 @@ namespace SunlightAggregationManager.ViewModel
|
||||
{
|
||||
lock (DB)
|
||||
{
|
||||
DataRow drEmployee = DB.Select(key).First();
|
||||
object? index = drEmployee.Field<object>(name);
|
||||
return index;
|
||||
DataRow[] dataRows = DB.Select(key);
|
||||
if (dataRows.Count() > 0)
|
||||
{
|
||||
DataRow drEmployee = dataRows.First();
|
||||
object? index = drEmployee.Field<object>(name);
|
||||
return index;
|
||||
}
|
||||
else { return null; }
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in new issue
Block a user