连线逻辑修改
This commit is contained in:
commit
3b6ab69a71
5 files changed
+98
-131
No files matched your search
+71
-80
@@ -44,76 +44,67 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//即将连接到服务器,此时已经创建socket,但是还未建立tcp
|
||||
tcpClient.Connected = (client, e) =>
|
||||
{
|
||||
lock (MainWindowViewModel.Machines)
|
||||
try
|
||||
{
|
||||
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++;
|
||||
}
|
||||
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) =>
|
||||
{
|
||||
lock (MainWindowViewModel.Machines)
|
||||
try
|
||||
{
|
||||
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++;
|
||||
}
|
||||
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) =>
|
||||
{
|
||||
lock (MainWindowViewModel.Machines)
|
||||
try
|
||||
{
|
||||
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++;
|
||||
}
|
||||
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;
|
||||
};//从服务器断开连接,当连接不成功时不会触发。
|
||||
@@ -124,27 +115,25 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
string DAT = e.ByteBlock.Span.ToString(Encoding.UTF8);
|
||||
if (SYSAPI == "SC800")
|
||||
{
|
||||
lock (MainWindowViewModel.Machines)
|
||||
try
|
||||
{
|
||||
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++;
|
||||
}
|
||||
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 + "'").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++;
|
||||
}
|
||||
|
||||
}
|
||||
else if (SYSAPI == "SC810")
|
||||
{
|
||||
@@ -172,16 +161,18 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } },
|
||||
"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 == "SC830")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||
_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["Message"] = _new.GetValue("Status");
|
||||
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
|
||||
@@ -191,7 +182,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
drEmployee["Step"] = _new.GetValue("Step");
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
|
||||
if (_new.GetValue("Status").ToString() != "----------")
|
||||
{
|
||||
@@ -216,6 +206,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
SQLiteHelpers.InsertData("Chart", Chart_new);// 执行插入
|
||||
SQLiteHelpers.Close();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||
}
|
||||
@@ -316,7 +307,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
else if (SYSAPI == "SC980")
|
||||
{
|
||||
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;
|
||||
@@ -331,7 +322,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
{
|
||||
a.UseCheckClear()
|
||||
.SetCheckClearType(CheckClearType.All)
|
||||
.SetTick(TimeSpan.FromSeconds(30))
|
||||
.SetTick(TimeSpan.FromSeconds(60))
|
||||
.SetOnClose((c, t) =>
|
||||
{
|
||||
c.TryShutdown();
|
||||
|
||||
Reference in new issue
Block a user