Merge branch 'master' of http://192.168.0.12:13000/sc/ForwardingServer
This commit is contained in:
commit
a470d9fa34
1 file changed
+13
-1
+13
-1
@@ -72,12 +72,14 @@ namespace ForwardingServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (IsValidJson(DAT))
|
||||||
{
|
{
|
||||||
Personm deserializedPerson = JsonSerializer.Deserialize<Personm>(DAT)!;
|
Personm deserializedPerson = JsonSerializer.Deserialize<Personm>(DAT)!;
|
||||||
DATA.MachineTable.Rows.Add(client.Id, client.IP, 30, "/" + deserializedPerson.SERVEREnterprise,
|
DATA.MachineTable.Rows.Add(client.Id, client.IP, 30, "/" + deserializedPerson.SERVEREnterprise,
|
||||||
deserializedPerson.SERVERMachineName, deserializedPerson.MachineVer);
|
deserializedPerson.SERVERMachineName, deserializedPerson.MachineVer);
|
||||||
Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss:fff") + " [LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT);
|
Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-DD HH:mm:ss:fff") + " [LINK ID " + client.Id + " IP " + client.IP + "]\nDATA =" + DAT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,5 +111,15 @@ namespace ForwardingServer
|
|||||||
Console.WriteLine("TcpServer:Run");
|
Console.WriteLine("TcpServer:Run");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 辅助方法检查JSON格式
|
||||||
|
private static bool IsValidJson(string jsonString)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(jsonString))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
jsonString = jsonString.Trim();
|
||||||
|
return (jsonString.StartsWith("{") && jsonString.EndsWith("}")) ||
|
||||||
|
(jsonString.StartsWith("[") && jsonString.EndsWith("]"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user