diff --git a/Class/AsyncHttpServer.cs b/Class/AsyncHttpServer.cs index 5164175..c756313 100644 --- a/Class/AsyncHttpServer.cs +++ b/Class/AsyncHttpServer.cs @@ -73,11 +73,19 @@ namespace ForwardingServerUI.Class await AsyncTcpServer.service.SendAsync(s_, bodyString); MainWindowViewModel.Person deserializedPerson = JsonSerializer.Deserialize(bodyString)!; - + Application.Current.Dispatcher.Invoke(() => { MainWindowViewModel._userTable.Rows.Add(client.Id, client.IP, deserializedPerson.User, - "", deserializedPerson.Terminal, "", ""); + URL, deserializedPerson.Terminal, "", ""); }); + //记录请求指令 + LogGing.LINKDATA(URL, "[COMMAND]" + deserializedPerson.User, Regex.Replace( + AES.AesDecrypt(deserializedPerson.Terminal, deserializedPerson.Dat) + , @"\\u[0-9A-Fa-f]{4}", match => + { + return Regex.Unescape(match.Value); + })); + // 创建一个 秒的延时任务 Task delayTask = Task.Delay(15000); // 创建一个监测任务,不断检查变量 diff --git a/Class/AsyncTcpServer.cs b/Class/AsyncTcpServer.cs index 1c77505..457474c 100644 --- a/Class/AsyncTcpServer.cs +++ b/Class/AsyncTcpServer.cs @@ -4,6 +4,7 @@ using System.Data; using System.Security.Cryptography.Pkcs; using System.Text; using System.Text.Json; +using System.Text.RegularExpressions; using System.Threading.Channels; using System.Windows; using System.Windows.Markup; @@ -91,8 +92,13 @@ namespace ForwardingServerUI.Class drEmployee.AcceptChanges(); PersonUser deserializedPersonuser = JsonSerializer.Deserialize(trimmedDat)!; - var data = JsonSerializer.Deserialize> - (AES.AesDecrypt(deserializedPersonuser.Terminal, deserializedPersonuser.Dat)); + string data = AES.AesDecrypt(deserializedPersonuser.Terminal, deserializedPersonuser.Dat); + string decodedData = Regex.Replace(data, @"\\u[0-9A-Fa-f]{4}", match => + { + return Regex.Unescape(match.Value); + }); + + LogGing.LINKDATA(drEmployee["Enterprise"].ToString()!,"[REPLY]"+ drEmployee["User"].ToString()!, decodedData); } } } diff --git a/Class/LogGing.cs b/Class/LogGing.cs index d8e2cb5..3ac58bb 100644 --- a/Class/LogGing.cs +++ b/Class/LogGing.cs @@ -7,6 +7,25 @@ namespace ForwardingServerUI.Class { public class LogGing { + public static void LINKDATA(string path,string User, string dat) + { + string logpath = System.Environment.CurrentDirectory + "\\DB\\"+path;//日志文件目录 + string logPath = logpath +"\\" + DateTime.Now.ToString(" yyyy-MM-dd HH-mm-ss-ffff") + User + ".txt";//日志文件 + + if (Directory.Exists(logpath))//检查日志路径 + { + FileStream fs = new FileStream(logPath, FileMode.CreateNew, FileAccess.Write);//创建写入文件 + StreamWriter wr = new StreamWriter(fs);//创建文件 + wr.WriteLine(dat); + wr.Close(); + } + else + { + DirectoryInfo directoryInfo = new DirectoryInfo(logpath); + directoryInfo.Create();//创建日志路径 + } + } + public static void LogGingDATA(string dat) { string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录