MainWindowViewModel.Machines读写逻辑修改
This commit is contained in:
commit
a9f505e960
4 files changed
+183
-114
No files matched your search
+86
-54
@@ -44,53 +44,77 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
|
||||
tcpClient.Connected = (client, e) =>
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "801";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK");
|
||||
lock (MainWindowViewModel.Machines)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "801";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||
}
|
||||
}
|
||||
|
||||
return EasyTask.CompletedTask;
|
||||
};//成功连接到服务器
|
||||
};//成功连接到服务器
|
||||
tcpClient.Closing = (client, e) =>
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "899";
|
||||
drEmployee["WorkOrder"] = "------";
|
||||
drEmployee["Dyelot"] = "";
|
||||
drEmployee["Temperature"] = "---.-";
|
||||
drEmployee["WaterLevel"] = "----";
|
||||
drEmployee["Process"] = "";
|
||||
drEmployee["Step"] = "";
|
||||
drEmployee["Message"] = "";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP");
|
||||
|
||||
lock (MainWindowViewModel.Machines)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "899";
|
||||
drEmployee["WorkOrder"] = "------";
|
||||
drEmployee["Dyelot"] = "";
|
||||
drEmployee["Temperature"] = "---.-";
|
||||
drEmployee["WaterLevel"] = "----";
|
||||
drEmployee["Process"] = "";
|
||||
drEmployee["Step"] = "";
|
||||
drEmployee["Message"] = "";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||
}
|
||||
}
|
||||
return EasyTask.CompletedTask;
|
||||
};//即将从服务器断开连接。此处仅主动断开才有效。
|
||||
tcpClient.Closed = (client, e) =>
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "899";
|
||||
drEmployee["WorkOrder"] = "------";
|
||||
drEmployee["Dyelot"] = "";
|
||||
drEmployee["Temperature"] = "---.-";
|
||||
drEmployee["WaterLevel"] = "----";
|
||||
drEmployee["Process"] = "";
|
||||
drEmployee["Step"] = "";
|
||||
drEmployee["Message"] = "";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT");
|
||||
|
||||
lock (MainWindowViewModel.Machines)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "899";
|
||||
drEmployee["WorkOrder"] = "------";
|
||||
drEmployee["Dyelot"] = "";
|
||||
drEmployee["Temperature"] = "---.-";
|
||||
drEmployee["WaterLevel"] = "----";
|
||||
drEmployee["Process"] = "";
|
||||
drEmployee["Step"] = "";
|
||||
drEmployee["Message"] = "";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||
}
|
||||
}
|
||||
return EasyTask.CompletedTask;
|
||||
};//从服务器断开连接,当连接不成功时不会触发。
|
||||
tcpClient.Received = (client, e) =>
|
||||
@@ -100,22 +124,27 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8);
|
||||
if (SYSAPI == "SC800")
|
||||
{
|
||||
try
|
||||
lock (MainWindowViewModel.Machines)
|
||||
{
|
||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
|
||||
drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString();
|
||||
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString();
|
||||
drEmployee["State"] = "802";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
try
|
||||
{
|
||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
|
||||
drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString();
|
||||
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString();
|
||||
drEmployee["State"] = "802";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||
}
|
||||
else if (SYSAPI == "SC810")
|
||||
{
|
||||
@@ -128,7 +157,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
"WorkOrder ='" + DAT + "'", null);
|
||||
SQLiteHelpers.Close();
|
||||
}
|
||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
|
||||
}
|
||||
}
|
||||
else if (SYSAPI == "SC811")
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user