diff --git a/UserClass/AsyncTcpClient.cs b/UserClass/AsyncTcpClient.cs index 865737b..57448eb 100644 --- a/UserClass/AsyncTcpClient.cs +++ b/UserClass/AsyncTcpClient.cs @@ -34,7 +34,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass /// public class AsyncTcpClient { - + private static SQLiteHelper SQLiteHelpers = null; //定义数据库 + private static readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径 public static async Task TcpClient(TcpClient tcpClient, string ip, string port) { //TcpClient tcpClient = new TcpClient(); @@ -95,16 +96,38 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass else if (SYSAPI == "SC830") { DAT = DAT.Substring(DAT.IndexOf("]") + 1); - Dictionary Chart_new = new Dictionary();//缓存函数 - Chart_new = JsonConvert.DeserializeObject>(DAT);//反序列化 + Dictionary _new = new Dictionary();//缓存函数 + _new = JsonConvert.DeserializeObject>(DAT);//反序列化 DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First(); drEmployee.BeginEdit(); - drEmployee["Message"] = Chart_new.GetValue("Status").ToString(); - drEmployee["WorkOrder"] = Chart_new.GetValue("WorkNumder").ToString(); - drEmployee["Temperature"] = Chart_new.GetValue("MTT").ToString(); + drEmployee["Message"] = _new.GetValue("Status").ToString(); + drEmployee["WorkOrder"] = _new.GetValue("WorkNumder").ToString(); + drEmployee["Temperature"] = _new.GetValue("MTT").ToString(); drEmployee.EndEdit(); drEmployee.AcceptChanges(); drEmployee.ClearErrors(); + + Dictionary Chart_new = new Dictionary();//缓存函数 + // Chart_new.Add("DYELOT", _new.GetValue("Status")); + Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder")); + Chart_new.Add("Machine", _new.GetValue("Machine")); + Chart_new.Add("Time", _new.GetValue("Time")); + Chart_new.Add("MST", _new.GetValue("MST")); + Chart_new.Add("MTT", _new.GetValue("MTT")); + Chart_new.Add("MTL", _new.GetValue("MTL")); + Chart_new.Add("MTH", _new.GetValue("MTH")); + Chart_new.Add("MUT", _new.GetValue("MUT")); + Chart_new.Add("STTA", _new.GetValue("STTA")); + Chart_new.Add("STLA", _new.GetValue("STLA")); + Chart_new.Add("STTB", _new.GetValue("STTB")); + Chart_new.Add("STLB", _new.GetValue("STLB")); + Chart_new.Add("STTC", _new.GetValue("STTC")); + Chart_new.Add("STLC", _new.GetValue("STLC")); + + SQLiteHelpers = new SQLiteHelper(ChartAdress); //数据库连接路径 + SQLiteHelpers.Open(); //打开数据库 + SQLiteHelpers.InsertData("Chart", Chart_new);// 执行插入 + SQLiteHelpers.Close(); } else if (SYSAPI == "SC831") {