|
@ -44,76 +44,67 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass |
|
|
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
|
|
|
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
|
|
|
tcpClient.Connected = (client, e) => |
|
|
tcpClient.Connected = (client, e) => |
|
|
{ |
|
|
{ |
|
|
lock (MainWindowViewModel.Machines) |
|
|
try |
|
|
{ |
|
|
{ |
|
|
try |
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); |
|
|
{ |
|
|
drEmployee.BeginEdit(); |
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); |
|
|
drEmployee["State"] = "801"; |
|
|
drEmployee.BeginEdit(); |
|
|
drEmployee.EndEdit(); |
|
|
drEmployee["State"] = "801"; |
|
|
drEmployee.AcceptChanges(); |
|
|
drEmployee.EndEdit(); |
|
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK"); |
|
|
drEmployee.AcceptChanges(); |
|
|
} |
|
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK"); |
|
|
catch (Exception ex) |
|
|
} |
|
|
{ |
|
|
catch (Exception ex) |
|
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; |
|
|
{ |
|
|
|
|
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return EasyTask.CompletedTask; |
|
|
return EasyTask.CompletedTask; |
|
|
};//成功连接到服务器
|
|
|
};//成功连接到服务器
|
|
|
tcpClient.Closing = (client, e) => |
|
|
tcpClient.Closing = (client, e) => |
|
|
{ |
|
|
{ |
|
|
lock (MainWindowViewModel.Machines) |
|
|
try |
|
|
{ |
|
|
{ |
|
|
try |
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); |
|
|
{ |
|
|
drEmployee.BeginEdit(); |
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); |
|
|
drEmployee["State"] = "899"; |
|
|
drEmployee.BeginEdit(); |
|
|
drEmployee["WorkOrder"] = "------"; |
|
|
drEmployee["State"] = "899"; |
|
|
drEmployee["Dyelot"] = ""; |
|
|
drEmployee["WorkOrder"] = "------"; |
|
|
drEmployee["Temperature"] = "---.-"; |
|
|
drEmployee["Dyelot"] = ""; |
|
|
drEmployee["WaterLevel"] = "----"; |
|
|
drEmployee["Temperature"] = "---.-"; |
|
|
drEmployee["Process"] = ""; |
|
|
drEmployee["WaterLevel"] = "----"; |
|
|
drEmployee["Step"] = ""; |
|
|
drEmployee["Process"] = ""; |
|
|
drEmployee["Message"] = ""; |
|
|
drEmployee["Step"] = ""; |
|
|
drEmployee.EndEdit(); |
|
|
drEmployee["Message"] = ""; |
|
|
drEmployee.AcceptChanges(); |
|
|
drEmployee.EndEdit(); |
|
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP"); |
|
|
drEmployee.AcceptChanges(); |
|
|
} |
|
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP"); |
|
|
catch (Exception ex) |
|
|
} |
|
|
{ |
|
|
catch (Exception ex) |
|
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; |
|
|
{ |
|
|
|
|
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
return EasyTask.CompletedTask; |
|
|
return EasyTask.CompletedTask; |
|
|
};//即将从服务器断开连接。此处仅主动断开才有效。
|
|
|
};//即将从服务器断开连接。此处仅主动断开才有效。
|
|
|
tcpClient.Closed = (client, e) => |
|
|
tcpClient.Closed = (client, e) => |
|
|
{ |
|
|
{ |
|
|
lock (MainWindowViewModel.Machines) |
|
|
try |
|
|
{ |
|
|
{ |
|
|
try |
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); |
|
|
{ |
|
|
drEmployee.BeginEdit(); |
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); |
|
|
drEmployee["State"] = "899"; |
|
|
drEmployee.BeginEdit(); |
|
|
drEmployee["WorkOrder"] = "------"; |
|
|
drEmployee["State"] = "899"; |
|
|
drEmployee["Dyelot"] = ""; |
|
|
drEmployee["WorkOrder"] = "------"; |
|
|
drEmployee["Temperature"] = "---.-"; |
|
|
drEmployee["Dyelot"] = ""; |
|
|
drEmployee["WaterLevel"] = "----"; |
|
|
drEmployee["Temperature"] = "---.-"; |
|
|
drEmployee["Process"] = ""; |
|
|
drEmployee["WaterLevel"] = "----"; |
|
|
drEmployee["Step"] = ""; |
|
|
drEmployee["Process"] = ""; |
|
|
drEmployee["Message"] = ""; |
|
|
drEmployee["Step"] = ""; |
|
|
drEmployee.EndEdit(); |
|
|
drEmployee["Message"] = ""; |
|
|
drEmployee.AcceptChanges(); |
|
|
drEmployee.EndEdit(); |
|
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT"); |
|
|
drEmployee.AcceptChanges(); |
|
|
} |
|
|
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT"); |
|
|
catch (Exception ex) |
|
|
} |
|
|
{ |
|
|
catch (Exception ex) |
|
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; |
|
|
{ |
|
|
|
|
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
return EasyTask.CompletedTask; |
|
|
return EasyTask.CompletedTask; |
|
|
};//从服务器断开连接,当连接不成功时不会触发。
|
|
|
};//从服务器断开连接,当连接不成功时不会触发。
|
|
@ -124,27 +115,25 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass |
|
|
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8); |
|
|
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8); |
|
|
if (SYSAPI == "SC800") |
|
|
if (SYSAPI == "SC800") |
|
|
{ |
|
|
{ |
|
|
lock (MainWindowViewModel.Machines) |
|
|
try |
|
|
{ |
|
|
{ |
|
|
try |
|
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1); |
|
|
{ |
|
|
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
|
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1); |
|
|
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
|
|
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); |
|
|
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
|
|
drEmployee.BeginEdit(); |
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First(); |
|
|
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString(); |
|
|
drEmployee.BeginEdit(); |
|
|
drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString(); |
|
|
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString(); |
|
|
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString(); |
|
|
drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString(); |
|
|
drEmployee["State"] = "802"; |
|
|
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString(); |
|
|
drEmployee.EndEdit(); |
|
|
drEmployee["State"] = "802"; |
|
|
drEmployee.AcceptChanges(); |
|
|
drEmployee.EndEdit(); |
|
|
} |
|
|
drEmployee.AcceptChanges(); |
|
|
catch (Exception ex) |
|
|
} |
|
|
{ |
|
|
catch (Exception ex) |
|
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; |
|
|
{ |
|
|
|
|
|
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else if (SYSAPI == "SC810") |
|
|
else if (SYSAPI == "SC810") |
|
|
{ |
|
|
{ |
|
@ -172,16 +161,18 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass |
|
|
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } }, |
|
|
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } }, |
|
|
"WorkOrder ='" + DAT + "'", null); |
|
|
"WorkOrder ='" + DAT + "'", null); |
|
|
SQLiteHelpers.Close(); |
|
|
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 == "SC830") |
|
|
else if (SYSAPI == "SC830") |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1); |
|
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1); |
|
|
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
|
|
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
|
|
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
|
|
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First(); |
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); |
|
|
drEmployee.BeginEdit(); |
|
|
drEmployee.BeginEdit(); |
|
|
drEmployee["Message"] = _new.GetValue("Status"); |
|
|
drEmployee["Message"] = _new.GetValue("Status"); |
|
|
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder"); |
|
|
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder"); |
|
@ -191,7 +182,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass |
|
|
drEmployee["Step"] = _new.GetValue("Step"); |
|
|
drEmployee["Step"] = _new.GetValue("Step"); |
|
|
drEmployee.EndEdit(); |
|
|
drEmployee.EndEdit(); |
|
|
drEmployee.AcceptChanges(); |
|
|
drEmployee.AcceptChanges(); |
|
|
drEmployee.ClearErrors(); |
|
|
|
|
|
|
|
|
|
|
|
if (_new.GetValue("Status").ToString() != "----------") |
|
|
if (_new.GetValue("Status").ToString() != "----------") |
|
|
{ |
|
|
{ |
|
@ -216,6 +206,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass |
|
|
SQLiteHelpers.InsertData("Chart", Chart_new);// 执行插入
|
|
|
SQLiteHelpers.InsertData("Chart", Chart_new);// 执行插入
|
|
|
SQLiteHelpers.Close(); |
|
|
SQLiteHelpers.Close(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } |
|
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } |
|
|
} |
|
|
} |
|
@ -316,7 +307,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass |
|
|
else if (SYSAPI == "SC980") |
|
|
else if (SYSAPI == "SC980") |
|
|
{ |
|
|
{ |
|
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1); |
|
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1); |
|
|
MessageBox.Show(DAT,"SCCM", MessageBoxButton.OK, MessageBoxImage.Question); |
|
|
MessageBox.Show(DAT, "SCCM", MessageBoxButton.OK, MessageBoxImage.Question); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return EasyTask.CompletedTask; |
|
|
return EasyTask.CompletedTask; |
|
@ -331,7 +322,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass |
|
|
{ |
|
|
{ |
|
|
a.UseCheckClear() |
|
|
a.UseCheckClear() |
|
|
.SetCheckClearType(CheckClearType.All) |
|
|
.SetCheckClearType(CheckClearType.All) |
|
|
.SetTick(TimeSpan.FromSeconds(30)) |
|
|
.SetTick(TimeSpan.FromSeconds(60)) |
|
|
.SetOnClose((c, t) => |
|
|
.SetOnClose((c, t) => |
|
|
{ |
|
|
{ |
|
|
c.TryShutdown(); |
|
|
c.TryShutdown(); |
|
|