Compare commits

...
34 Commits
Author SHA1 Message Date
sc eb2828aab0 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2026-01-04 23:26:01 +08:00
sc 33b970eff9 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2026-01-04 23:26:00 +08:00
sc 5caf92be59 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2026-01-04 23:24:46 +08:00
sc 437b8957ce Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2026-01-04 23:24:44 +08:00
sc a68fb9ae01 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-27 22:10:41 +08:00
sc 68b98ac7e4 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-27 22:10:39 +08:00
sc 2329ac9abc Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-26 01:35:33 +08:00
sc b062420be1 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-26 01:35:30 +08:00
sc a248c41163 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-25 20:18:34 +08:00
sc 2b676adbba 修正错误 2025-10-25 20:18:31 +08:00
sc 00a5cd3ec7 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 22:14:27 +08:00
sc abfcf6e36a Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 22:14:26 +08:00
sc 1df7212414 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 20:49:37 +08:00
sc 751a2b092f Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 20:49:34 +08:00
sc 8a5e0ecfd9 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-15 00:09:05 +08:00
sc ebcd5b7182 串口通讯部分修改 2025-10-15 00:09:03 +08:00
sc 7f905617fa Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-10 02:02:24 +08:00
sc 54d8cc7266 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-10 02:02:21 +08:00
sc 33e83fa5d6 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-10 00:56:15 +08:00
sc 927c38853d 添加485串口线路指令 2025-10-10 00:56:14 +08:00
sc 552d45485d Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 23:35:40 +08:00
sc 17a5d6b718 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 23:35:38 +08:00
sc 34d3e6c292 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 23:19:40 +08:00
sc 5b60ea4765 添加数据库 2025-10-08 23:19:39 +08:00
sc b2817d1b01 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 23:18:50 +08:00
sc 7403914ba5 串口功能逻辑,810,811,812指令修改 2025-10-08 23:18:48 +08:00
sc 878d49c4a0 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-08 00:04:22 +08:00
sc e457b0ab21 添加去重逻辑 2025-10-08 00:04:20 +08:00
sc b0ce5bc8f9 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-07 19:52:43 +08:00
sc d3375fd6ac 处理lock (Machines.Rows.SyncRoot)并发写datatable问题 2025-10-07 19:52:42 +08:00
sc 7671f0ef08 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-07 00:24:31 +08:00
sc 25e6ae1563 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-07 00:24:29 +08:00
sc e020333b82 Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement 2025-10-07 00:03:53 +08:00
sc 8914ea3660 Merge branch 'master' of http://192.168.0.12:13000/sc/SunlightCentralizedControlManagement 2025-10-07 00:03:51 +08:00
11 changed files with 1537 additions and 290 deletions

No files matched your search

BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
@@ -135,6 +135,7 @@
<Compile Include="UserClass\CSV.cs" /> <Compile Include="UserClass\CSV.cs" />
<Compile Include="UserClass\DataGridHelper.cs" /> <Compile Include="UserClass\DataGridHelper.cs" />
<Compile Include="UserClass\DataTableForToObservableCollection.cs" /> <Compile Include="UserClass\DataTableForToObservableCollection.cs" />
<Compile Include="UserClass\DataTableManager .cs" />
<Compile Include="UserClass\get_local_ip_address.cs" /> <Compile Include="UserClass\get_local_ip_address.cs" />
<Compile Include="UserClass\HardwareSN.cs" /> <Compile Include="UserClass\HardwareSN.cs" />
<Compile Include="UserClass\IniFile.cs" /> <Compile Include="UserClass\IniFile.cs" />
+82 -29
View File
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
@@ -59,31 +60,34 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
portclient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从端口断开连接,当连接不成功时不会触发。 portclient.Closed = (client, e) => { return EasyTask.CompletedTask; };//从端口断开连接,当连接不成功时不会触发。
portclient.Received = (client, e) => portclient.Received = (client, e) =>
{ {
//接受重置事件状态
_responseEvent.Set(); _responseEvent.Set();
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8), string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
@"\n", RegexOptions.IgnoreCase); @"\n", RegexOptions.IgnoreCase);
for (int i = 0; i < sArray.Length; i++) for (int i = 0; i < sArray.Length; i++)
{ {
if (sArray[i].Length>5) if (sArray[i].Length > 5)
{ {
return EasyTask.CompletedTask; ;
string SYSAPI = sArray[i].Substring(0, 5); string SYSAPI = sArray[i].Substring(0, 5);
string Station = ClipBetween(sArray[i], '[', ']'); string Station = ClipBetween(sArray[i], '[', ']');
string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1); string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1);
if (SYSAPI == "SC800") if (SYSAPI == "SC800")
{ {
try try
{ {
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("Station='" + lock (MainWindowViewModel.Machines.Rows.SyncRoot)
Station + "' AND Serial = 'PORT1'").First(); {
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
drEmployee["State"] = "802"; drEmployee["State"] = "802";
drEmployee.EndEdit(); drEmployee.EndEdit();
drEmployee.AcceptChanges(); drEmployee.AcceptChanges();
} }
}
catch (Exception ex) catch (Exception ex)
{ {
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
@@ -93,32 +97,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) catch (Exception ex)
{ {
LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++;
} }
} }//回复的工单记录状态后就位111
else if (SYSAPI == "SC811") else if (SYSAPI == "SC811")
{ {
try try
{
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkorderSteps", new Dictionary<string, object> { { "Mode", 1 } },
"WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Step ='" +
_dat.GetValue("Step") + "'", null);
int x = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
_dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "' AND Mode <> '1'", null).Tables[0].Rows.Count;
if (x == 0)
{ {
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
}
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }//回复的工单明细状态后就位113
else if (SYSAPI == "SC812") else if (SYSAPI == "SC812")
{ {
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> _dat;
_dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 101 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + _dat.GetValue("Work") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }//回复的工单设置状态后就位101
else if (SYSAPI == "SC827") else if (SYSAPI == "SC827")
{ {
try try
@@ -132,33 +154,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
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("Station='" + string mac;
Station + "' AND Serial = 'PORT1'").First(); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
mac = drEmployee["Name"].ToString();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
drEmployee["ERR"] = _new.GetValue("ERR"); drEmployee["ERR"] = _new.GetValue("ERR");
drEmployee["LOCK"] = _new.GetValue("LOCK"); drEmployee["LOCK"] = _new.GetValue("LOCK");
drEmployee["Message"] = _new.GetValue("Status"); drEmployee["Message"] = _new.GetValue("Status");
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder"); drEmployee["WorkOrder"] = _new.GetValue("Work");
drEmployee["Temperature"] = _new.GetValue("MTT"); drEmployee["Temperature"] = _new.GetValue("MTT");
drEmployee["WaterLevel"] = _new.GetValue("MTL"); drEmployee["WaterLevel"] = _new.GetValue("MTL");
drEmployee["Process"] = _new.GetValue("Process"); drEmployee["Process"] = _new.GetValue("Process");
drEmployee["Step"] = _new.GetValue("Step"); drEmployee["Step"] = _new.GetValue("Step");
drEmployee["UserButton"] = _new.GetValue("UserButton"); drEmployee["UserButton"] = _new.GetValue("UserB");
if (_new.GetValue("UserInfoStart").ToString() != "900") if (_new.GetValue("InfoS").ToString() != "900")
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); } { drEmployee["UserInfoStart"] = _new.GetValue("InfoS"); }
drEmployee["UserInfo"] = _new.GetValue("UserInfo"); drEmployee["UserInfo"] = _new.GetValue("Info");
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN"); drEmployee["WORK_RUN"] = _new.GetValue("RUN");
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID"); drEmployee["RUN_STEPID"] = _new.GetValue("STEPID");
drEmployee["CALL"] = _new.GetValue("CALL"); drEmployee["CALL"] = _new.GetValue("CALL");
drEmployee.EndEdit(); drEmployee.EndEdit();
drEmployee.AcceptChanges(); drEmployee.AcceptChanges();
}
if (_new.GetValue("Status").ToString() != "----------") if (_new.GetValue("Status").ToString() != "----------")
{ {
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder")); Chart_new.Add("WorkOrder", _new.GetValue("Work"));
Chart_new.Add("Machine", _new.GetValue("Machine")); //Chart_new.Add("Machine", mac);
Chart_new.Add("Time", _new.GetValue("Time")); //Chart_new.Add("Time", _new.GetValue("Time"));
Chart_new.Add("MST", _new.GetValue("MST")); Chart_new.Add("MST", _new.GetValue("MST"));
Chart_new.Add("MTT", _new.GetValue("MTT")); Chart_new.Add("MTT", _new.GetValue("MTT"));
Chart_new.Add("MTL", _new.GetValue("MTL")); Chart_new.Add("MTL", _new.GetValue("MTL"));
@@ -174,7 +200,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入 MainWindowViewModel.SQLiteChartAdress.InsertData("Chart", Chart_new);// 执行插入
} }
} }
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 == "SC831") else if (SYSAPI == "SC831")
{ {
@@ -378,8 +407,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8), string[] sArray = Regex.Split(e.ByteBlock.Span.ToString(Encoding.UTF8),
@"\n", RegexOptions.IgnoreCase); @"\n", RegexOptions.IgnoreCase);
return EasyTask.CompletedTask; ; return EasyTask.CompletedTask; ;
}; };
await portclient.SetupAsync(new TouchSocketConfig() await portclient.SetupAsync(new TouchSocketConfig()
@@ -391,7 +418,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
PortName = com,//COM PortName = com,//COM
StopBits = System.IO.Ports.StopBits.One,//停止位 StopBits = System.IO.Ports.StopBits.One,//停止位
}) })
.SetSerialDataHandlingAdapter(() => new PeriodPackageAdapter() { CacheTimeout = TimeSpan.FromMilliseconds(100) }) .SetSerialDataHandlingAdapter(() => new PeriodPackageAdapter() { CacheTimeout = TimeSpan.FromMilliseconds(500) })
.ConfigurePlugins(a => .ConfigurePlugins(a =>
{ {
//a.Add<MyPlugin>(); //a.Add<MyPlugin>();
@@ -416,13 +443,39 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{ {
try try
{ {
var t= CRCcheck16.ToCRC16(command); var t = CRCcheck16.ToCRC16(command);
_responseEvent.Reset(); _responseEvent.Reset();
serialPortClients.Send(command); // 发送指令 serialPortClients.Send(command); // 发送指令
// 等待500毫秒或直到收到响应 // 等待500毫秒或直到收到响应
_responseEvent.Wait(TimeSpan.FromMilliseconds(1000)); if (!_responseEvent.Wait(TimeSpan.FromMilliseconds(1000)))
// 重置事件状态 {
_responseEvent.Set(); _responseEvent.Set();
//清楚了解状态
string Station = ClipBetween(command, '[', ']');
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
Station + "' AND Serial = 'PORT1'").First();
if (drEmployee.Field<int>("State") != 800)
{
drEmployee.BeginEdit();
drEmployee["State"] = "800";
drEmployee["WorkOrder"] = "------";
drEmployee["Dyelot"] = "";
drEmployee["Temperature"] = 0.0;
drEmployee["WaterLevel"] = 0.0;
drEmployee["Process"] = "";
drEmployee["Step"] = "";
drEmployee["Message"] = "";
drEmployee["SYSKEY"] = "";
drEmployee["WORK_RUN"] = "-1";
drEmployee["ERR"] = false;
drEmployee.EndEdit();
drEmployee.AcceptChanges();
}
}
}
} }
catch (Exception) { } catch (Exception) { }
} }
+37 -8
View File
@@ -48,13 +48,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
tcpClient.Connected = (client, e) => tcpClient.Connected = (client, e) =>
{ {
try try
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
drEmployee["State"] = "801"; drEmployee["State"] = "801";
drEmployee.EndEdit(); drEmployee.EndEdit();
drEmployee.AcceptChanges(); drEmployee.AcceptChanges();
}
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK"); LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK");
} }
catch (Exception ex) catch (Exception ex)
@@ -67,6 +69,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
tcpClient.Closing = (client, e) => tcpClient.Closing = (client, e) =>
{ {
try try
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
@@ -74,7 +78,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee["WorkOrder"] = "------"; drEmployee["WorkOrder"] = "------";
drEmployee["Dyelot"] = ""; drEmployee["Dyelot"] = "";
drEmployee["Temperature"] = 0.0; drEmployee["Temperature"] = 0.0;
drEmployee["WaterLevel"] = "----"; drEmployee["WaterLevel"] = 0.0;
drEmployee["Process"] = ""; drEmployee["Process"] = "";
drEmployee["Step"] = ""; drEmployee["Step"] = "";
drEmployee["Message"] = ""; drEmployee["Message"] = "";
@@ -83,6 +87,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee["ERR"] = false; drEmployee["ERR"] = false;
drEmployee.EndEdit(); drEmployee.EndEdit();
drEmployee.AcceptChanges(); drEmployee.AcceptChanges();
}
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP"); LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP");
} }
catch (Exception ex) catch (Exception ex)
@@ -94,6 +99,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
tcpClient.Closed = (client, e) => tcpClient.Closed = (client, e) =>
{ {
try try
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
@@ -101,7 +108,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee["WorkOrder"] = "------"; drEmployee["WorkOrder"] = "------";
drEmployee["Dyelot"] = ""; drEmployee["Dyelot"] = "";
drEmployee["Temperature"] = 0.0; drEmployee["Temperature"] = 0.0;
drEmployee["WaterLevel"] = "----"; drEmployee["WaterLevel"] = 0.0;
drEmployee["Process"] = ""; drEmployee["Process"] = "";
drEmployee["Step"] = ""; drEmployee["Step"] = "";
drEmployee["Message"] = ""; drEmployee["Message"] = "";
@@ -110,6 +117,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee["ERR"] = false; drEmployee["ERR"] = false;
drEmployee.EndEdit(); drEmployee.EndEdit();
drEmployee.AcceptChanges(); drEmployee.AcceptChanges();
}
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT"); LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT");
} }
catch (Exception ex) catch (Exception ex)
@@ -130,6 +138,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
DAT = DAT.Substring(DAT.IndexOf("]") + 1); DAT = DAT.Substring(DAT.IndexOf("]") + 1);
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化 Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString(); drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
@@ -139,6 +149,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee.EndEdit(); drEmployee.EndEdit();
drEmployee.AcceptChanges(); drEmployee.AcceptChanges();
} }
}
catch (Exception ex) catch (Exception ex)
{ {
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
@@ -149,8 +160,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1); DAT = DAT.Substring(DAT.IndexOf("]") + 1);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } }, MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + DAT + "'", null);
// Dictionary<string, object> _dat;
// _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
// MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
// "WorkOrder ='" + _dat.GetValue("WorkOrder") + "' AND ReDye ='" + _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -162,8 +178,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
try try
{ {
DAT = DAT.Substring(DAT.IndexOf("]") + 1); DAT = DAT.Substring(DAT.IndexOf("]") + 1);
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 111 } },
"WorkOrder ='" + DAT + "'", null); "WorkOrder ='" + DAT + "'", null);
// Dictionary<string, object> _dat;
// _dat = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(DAT);
// MainWindowViewModel.SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 113 } },
// "WorkOrder ='" + _dat.GetValue("WorkOrder") + "' AND ReDye ='"+ _dat.GetValue("ReDye") + "'", null);
} }
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
} }
@@ -212,6 +233,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
DataTable dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化 DataTable dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
foreach (DataRow sourceRow in dataTable.Rows) foreach (DataRow sourceRow in dataTable.Rows)
{
lock (MainWindowViewModel.Dyelot_CALL.Rows.SyncRoot)
{ {
// 创建新行(基于目标表结构) // 创建新行(基于目标表结构)
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow(); DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
@@ -247,6 +270,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
}); });
} }
} }
}
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")
@@ -256,7 +280,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
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);//反序列化
string mac;
// 首先确保 DataTable 使用线程安全的访问方式
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
mac = drEmployee["Name"].ToString();
drEmployee.BeginEdit(); drEmployee.BeginEdit();
drEmployee["ERR"] = _new.GetValue("ERR"); drEmployee["ERR"] = _new.GetValue("ERR");
drEmployee["LOCK"] = _new.GetValue("LOCK"); drEmployee["LOCK"] = _new.GetValue("LOCK");
@@ -275,12 +304,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee["CALL"] = _new.GetValue("CALL"); drEmployee["CALL"] = _new.GetValue("CALL");
drEmployee.EndEdit(); drEmployee.EndEdit();
drEmployee.AcceptChanges(); drEmployee.AcceptChanges();
}
if (_new.GetValue("Status").ToString() != "----------") if (_new.GetValue("Status").ToString() != "----------")
{ {
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder")); Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder"));
Chart_new.Add("Machine", drEmployee["Name"]); Chart_new.Add("Machine", mac);
Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); Chart_new.Add("Time", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
Chart_new.Add("MST", _new.GetValue("MST")); Chart_new.Add("MST", _new.GetValue("MST"));
Chart_new.Add("MTT", _new.GetValue("MTT")); Chart_new.Add("MTT", _new.GetValue("MTT"));
@@ -308,7 +337,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
MainWindowViewModel.dt_TP = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化 MainWindowViewModel.dt_TP = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
} }
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 == "SC832") else if (SYSAPI == "SC832")
{ {
try try
@@ -380,7 +409,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
MachinesView.LOG_dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化 MachinesView.LOG_dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
} }
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 == "SC910") else if (SYSAPI == "SC910")
{ {
try try
+360
View File
@@ -0,0 +1,360 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{
/// <summary>
/// 线程安全的 DataTable 管理器
/// 提供对 DataTable 的安全并发访问
/// </summary>
public class DataTableManager : IDisposable
{
private DataTable _dataTable;
private readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
private bool _disposed = false;
#region 构造函数
public DataTableManager()
{
_dataTable = new DataTable();
}
public DataTableManager(DataTable dataTable)
{
_dataTable = dataTable ?? throw new ArgumentNullException(nameof(dataTable));
}
public DataTableManager(string tableName)
{
_dataTable = new DataTable(tableName);
}
#endregion
#region 基本操作
/// <summary>
/// 安全地添加列
/// </summary>
public void AddColumn(string columnName, Type dataType)
{
ExecuteWriteOperation(table =>
{
table.Columns.Add(columnName, dataType);
});
}
/// <summary>
/// 安全地添加行
/// </summary>
public void AddRow(params object[] values)
{
ExecuteWriteOperation(table =>
{
DataRow newRow = table.NewRow();
for (int i = 0; i < Math.Min(values.Length, table.Columns.Count); i++)
{
newRow[i] = values[i] ?? DBNull.Value;
}
table.Rows.Add(newRow);
});
}
/// <summary>
/// 安全地更新单元格值
/// </summary>
public bool UpdateCell(int rowIndex, string columnName, object value)
{
return ExecuteWriteOperation(table =>
{
if (IsValidRowIndex(table, rowIndex) && table.Columns.Contains(columnName))
{
table.Rows[rowIndex][columnName] = value ?? DBNull.Value;
return true;
}
return false;
});
}
/// <summary>
/// 安全地删除行
/// </summary>
public bool DeleteRow(int rowIndex)
{
return ExecuteWriteOperation(table =>
{
if (IsValidRowIndex(table, rowIndex))
{
table.Rows[rowIndex].Delete();
return true;
}
return false;
});
}
#endregion
#region 查询操作
/// <summary>
/// 安全地获取行
/// </summary>
public DataRow GetRow(int rowIndex)
{
return ExecuteReadOperation(table =>
{
return IsValidRowIndex(table, rowIndex) ? table.Rows[rowIndex] : null;
});
}
/// <summary>
/// 安全地查找行(使用筛选条件)
/// </summary>
public DataRow[] FindRows(string filterExpression)
{
return ExecuteReadOperation(table =>
{
try
{
return string.IsNullOrEmpty(filterExpression)
? table.Select()
: table.Select(filterExpression);
}
catch (EvaluateException)
{
return new DataRow[0];
}
});
}
/// <summary>
/// 安全地获取行数
/// </summary>
public int GetRowCount()
{
return ExecuteReadOperation(table => table.Rows.Count);
}
/// <summary>
/// 安全地检查行是否存在
/// </summary>
public bool RowExists(int rowIndex)
{
return ExecuteReadOperation(table => IsValidRowIndex(table, rowIndex));
}
#endregion
#region 批量操作
/// <summary>
/// 安全地批量添加行
/// </summary>
public void BulkAddRows(IEnumerable<object[]> rowsData)
{
ExecuteWriteOperation(table =>
{
foreach (var rowData in rowsData)
{
DataRow newRow = table.NewRow();
for (int i = 0; i < Math.Min(rowData.Length, table.Columns.Count); i++)
{
newRow[i] = rowData[i] ?? DBNull.Value;
}
table.Rows.Add(newRow);
}
});
}
/// <summary>
/// 安全地清空所有数据
/// </summary>
public void Clear()
{
ExecuteWriteOperation(table =>
{
table.Clear();
});
}
#endregion
#region 数据导出
/// <summary>
/// 获取数据快照(线程安全的副本)
/// </summary>
public DataTable GetSnapshot()
{
return ExecuteReadOperation(table =>
{
return table.Copy(); // 创建数据的独立副本
});
}
/// <summary>
/// 获取只读视图
/// </summary>
public DataView GetReadOnlyView()
{
return ExecuteReadOperation(table =>
{
return new DataView(table) { AllowEdit = false };
});
}
/// <summary>
/// 导出到新 DataTable(包含结构)
/// </summary>
public DataTable ExportToDataTable()
{
return ExecuteReadOperation(table =>
{
DataTable exported = table.Clone();
exported.Merge(table, false, MissingSchemaAction.Add);
return exported;
});
}
#endregion
#region 锁操作核心
/// <summary>
/// 执行读取操作(共享锁)
/// </summary>
private T ExecuteReadOperation<T>(Func<DataTable, T> operation)
{
_lock.EnterReadLock();
try
{
return operation(_dataTable);
}
finally
{
_lock.ExitReadLock();
}
}
/// <summary>
/// 执行写入操作(独占锁)
/// </summary>
private void ExecuteWriteOperation(Action<DataTable> operation)
{
_lock.EnterWriteLock();
try
{
operation(_dataTable);
_dataTable.AcceptChanges();
}
finally
{
_lock.ExitWriteLock();
}
}
private T ExecuteWriteOperation<T>(Func<DataTable, T> operation)
{
_lock.EnterWriteLock();
try
{
var result = operation(_dataTable);
_dataTable.AcceptChanges();
return result;
}
finally
{
_lock.ExitWriteLock();
}
}
private bool IsValidRowIndex(DataTable table, int rowIndex)
{
return rowIndex >= 0 && rowIndex < table.Rows.Count;
}
#endregion
#region 高级功能
/// <summary>
/// 带超时的安全操作
/// </summary>
public bool TryUpdateCell(int rowIndex, string columnName, object value, int timeoutMs = 5000)
{
if (_lock.TryEnterWriteLock(timeoutMs))
{
try
{
if (IsValidRowIndex(_dataTable, rowIndex) && _dataTable.Columns.Contains(columnName))
{
_dataTable.Rows[rowIndex][columnName] = value ?? DBNull.Value;
_dataTable.AcceptChanges();
return true;
}
return false;
}
finally
{
_lock.ExitWriteLock();
}
}
return false;
}
/// <summary>
/// 执行事务性操作
/// </summary>
public void ExecuteTransaction(Action<DataTable> transaction)
{
_lock.EnterWriteLock();
try
{
// 开始事务
_dataTable.BeginLoadData();
try
{
transaction(_dataTable);
_dataTable.AcceptChanges();
}
catch
{
_dataTable.RejectChanges();
throw;
}
finally
{
_dataTable.EndLoadData();
}
}
finally
{
_lock.ExitWriteLock();
}
}
#endregion
#region 属性和清理
public string TableName
{
get => ExecuteReadOperation(table => table.TableName);
set => ExecuteWriteOperation(table => table.TableName = value);
}
public DataColumnCollection Columns
{
get => ExecuteReadOperation(table => table.Columns);
}
public void Dispose()
{
if (!_disposed)
{
_lock?.Dispose();
_dataTable?.Dispose();
_disposed = true;
}
GC.SuppressFinalize(this);
}
~DataTableManager()
{
Dispose();
}
#endregion
}
}
+15 -5
View File
@@ -77,7 +77,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
if (MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0) if (MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Machines where name ='" + comboBoxMachine.Text + "'", null).Tables[0].Rows.Count == 0)
{ {
DataRow dat_= MainWindowViewModel.Machines.NewRow(); lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
DataRow dat_ = MainWindowViewModel.Machines.NewRow();
dat_.BeginEdit(); dat_.BeginEdit();
dat_["Name"] = comboBoxMachine.Text; dat_["Name"] = comboBoxMachine.Text;
dat_["Groups"] = TextMachineGroup.Text; dat_["Groups"] = TextMachineGroup.Text;
@@ -96,7 +98,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_["WaterLevel"] = 0; dat_["WaterLevel"] = 0;
dat_["WORK_RUN"] = -1; dat_["WORK_RUN"] = -1;
dat_["UserInfoStart"] = 900; dat_["UserInfoStart"] = 900;
if (comboBoxtype.Text.Contains( link_model)) if (comboBoxtype.Text.Contains(link_model))
{ {
dat_["Desktop"] = true; dat_["Desktop"] = true;
dat_["Type"] = true; dat_["Type"] = true;
@@ -127,7 +129,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Machines_DAT.Clear(); Machines_DAT.Clear();
} }
} }
}
else else
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{ {
DataRow dr = MainWindowViewModel.Machines.Rows[ID_]; DataRow dr = MainWindowViewModel.Machines.Rows[ID_];
dr.BeginEdit(); dr.BeginEdit();
@@ -139,8 +144,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dr["Model"] = comboBoxtype.Text; dr["Model"] = comboBoxtype.Text;
dr["Station"] = Station.Text; dr["Station"] = Station.Text;
if (comboBoxtype.Text.Contains(link_model)) if (comboBoxtype.Text.Contains(link_model))
{ dr["Desktop"] = true; {
dr["Type"] = true; } dr["Desktop"] = true;
dr["Type"] = true;
}
else else
{ {
dr["Desktop"] = false; dr["Desktop"] = false;
@@ -166,6 +173,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Machines_DAT.Clear(); Machines_DAT.Clear();
} }
} }
}
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView; Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
comboBoxMachine.Text = null; comboBoxMachine.Text = null;
TextMachineGroup.Text = null; TextMachineGroup.Text = null;
@@ -186,10 +194,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{ {
MessageBoxResult vr = System.Windows.MessageBox.Show(Properties.Resources.Delete + comboBoxMachine.Text, "SCCM", MessageBoxButton.OKCancel, MessageBoxImage.Question); MessageBoxResult vr = System.Windows.MessageBox.Show(Properties.Resources.Delete + comboBoxMachine.Text, "SCCM", MessageBoxButton.OKCancel, MessageBoxImage.Question);
if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码 if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{ {
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1); MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1);
DatSteps(MainWindowViewModel.Machines); DatSteps(MainWindowViewModel.Machines);
}
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数 Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);// MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
+522 -18
View File
@@ -28,6 +28,8 @@ using System.Xml.Linq;
using TouchSocket.Core; using TouchSocket.Core;
using TouchSocket.Sockets; using TouchSocket.Sockets;
using VncSharpWpf; using VncSharpWpf;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep; using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
using static System.Net.WebRequestMethods; using static System.Net.WebRequestMethods;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
@@ -120,7 +122,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
else else
{ {
MessageBox.Show(Properties.Resources.TMNR, "800", MessageBoxButton.OK, MessageBoxImage.Information); // // MessageBox.Show(Properties.Resources.TMNR, "800", MessageBoxButton.OK, MessageBoxImage.Information); //
} }
} }
@@ -143,6 +145,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e) private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e)
{ {
if (!string.IsNullOrEmpty(machine)) if (!string.IsNullOrEmpty(machine))
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{ {
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK"); bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
@@ -164,12 +168,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
});
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{ {
ID = index, ID = index,
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString() DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
}); });
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
}
if (!mode) if (!mode)
{ {
MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
@@ -179,10 +221,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
}
}//锁定 }//锁定
private void MenuItem_AUTO_XML(object sender, RoutedEventArgs e) private void MenuItem_AUTO_XML(object sender, RoutedEventArgs e)
{ {
if (!string.IsNullOrEmpty(machine)) if (!string.IsNullOrEmpty(machine))
{
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{ {
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("AUTO"); bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("AUTO");
@@ -204,13 +249,51 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString() DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
}); });
} }
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
});
}
}
}
}
}//手自动 }//手自动
private void MenuItem_Stop_XML(object sender, RoutedEventArgs e) private void MenuItem_Stop_XML(object sender, RoutedEventArgs e)
{ {
@@ -219,14 +302,55 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Dictionary<string, object> dat_821 = new Dictionary<string, object>(); Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear(); dat_821.Clear();
dat_821.Add("INSTRUCTION", "STOP"); dat_821.Add("INSTRUCTION", "STOP");
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
} }
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
}
}
}//停止 }//停止
private void MenuItem_Start_XML(object sender, RoutedEventArgs e) private void MenuItem_Start_XML(object sender, RoutedEventArgs e)
{ {
@@ -234,12 +358,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{ {
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC822" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") DAT = "SC822" + drEmployee.Field<string>("SYSKEY")
}); });
} }
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC822" + drEmployee.Field<string>("Station")
});
}
}
}
}//开始 }//开始
private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e) private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e)
{ {
@@ -312,12 +474,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC833" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") DAT = "SC833" + drEmployee.Field<string>("SYSKEY")
}); });
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC833" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC833" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC833" + drEmployee.Field<string>("Station")
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC833" + drEmployee.Field<string>("Station")
});
}
}
machines_info = 2; machines_info = 2;
log.Visibility = Visibility.Collapsed; log.Visibility = Visibility.Collapsed;
rdp.Visibility = Visibility.Collapsed; rdp.Visibility = Visibility.Collapsed;
@@ -345,12 +544,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("INSTRUCTION", "CONTINUE"); dat_821.Add("INSTRUCTION", "CONTINUE");
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
} }
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
}
Insert.IsHitTestVisible = false; Insert.IsHitTestVisible = false;
edit.IsHitTestVisible = false; edit.IsHitTestVisible = false;
Resume.IsHitTestVisible = false; Resume.IsHitTestVisible = false;
@@ -368,12 +605,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("INSTRUCTION", "PAUSE"); dat_821.Add("INSTRUCTION", "PAUSE");
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
} }
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
}
Insert.IsHitTestVisible = true; Insert.IsHitTestVisible = true;
edit.IsHitTestVisible = true; edit.IsHitTestVisible = true;
Paused.IsHitTestVisible = true; Paused.IsHitTestVisible = true;
@@ -392,12 +667,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("INSTRUCTION", "STOP"); dat_821.Add("INSTRUCTION", "STOP");
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
} }
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
}
}//停止 }//停止
private void ListViewItem_edit(object sender, MouseButtonEventArgs e) private void ListViewItem_edit(object sender, MouseButtonEventArgs e)
{ {
@@ -454,11 +767,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
TechnologicalProcess_bool = true; TechnologicalProcess_bool = true;
} }
private void ListViewItem_Jump(object sender, MouseButtonEventArgs e) private void ListViewItem_Jump(object sender, MouseButtonEventArgs e)
@@ -482,11 +833,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
TechnologicalProcess_bool = true; TechnologicalProcess_bool = true;
}//跳步 }//跳步
@@ -545,11 +934,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
} }
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e) private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
@@ -562,11 +989,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("ID", ID); dat_821.Add("ID", ID);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
MainWindowViewModel.dt_TP.Select("Step="+ID).First().Delete(); MainWindowViewModel.dt_TP.Select("Step="+ID).First().Delete();
MainWindowViewModel.dt_TP.AcceptChanges(); MainWindowViewModel.dt_TP.AcceptChanges();
@@ -609,6 +1074,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
} }
} }
private void MenuItem_Delete(object sender, RoutedEventArgs e)//右键删除 private void MenuItem_Delete(object sender, RoutedEventArgs e)//右键删除
{ {
int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量 int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效 if (rownum != -1)//判断鼠标定位是否有效
@@ -622,11 +1088,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dat_821.Add("ID", ID); dat_821.Add("ID", ID);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
}); });
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
});
}
}
MainWindowViewModel.dt_TP.Select("Step=" + ID).First().Delete(); MainWindowViewModel.dt_TP.Select("Step=" + ID).First().Delete();
MainWindowViewModel.dt_TP.AcceptChanges(); MainWindowViewModel.dt_TP.AcceptChanges();
@@ -679,7 +1183,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC832" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") DAT = "SC832" + drEmployee.Field<string>("SYSKEY")
}); });
}//信息 }//信息
else if (machines_info == 1) else if (machines_info == 1)
@@ -697,7 +1201,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC831" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") DAT = "SC831" + drEmployee.Field<string>("SYSKEY")
}); });
} }
else else
+3 -1
View File
@@ -1,4 +1,6 @@
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel; using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using SunlightCentralizedControlManagement_SCCM_.WindowsView; using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System; using System;
File diff suppressed because it is too large. Load diff
+63 -2
View File
@@ -1,4 +1,5 @@
using SunlightCentralizedControlManagement_SCCM_.ViewModel; using ScottPlot.TickGenerators.TimeUnits;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@@ -22,6 +23,7 @@ using System.Windows.Threading;
using System.Xml.Linq; using System.Xml.Linq;
using TouchSocket.Core; using TouchSocket.Core;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
{ {
@@ -51,11 +53,70 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
dat_821.Add("WorkOrder", WorkOrder_); dat_821.Add("WorkOrder", WorkOrder_);
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine_ + "'").First(); DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine_ + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID")); int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
string dat = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString();
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
{
if (drEmployee.Field<bool>("Type"))
{//网络
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{ {
ID = index, ID = index,
DAT = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() DAT = dat
}); });
}
else
{//串口
if (drEmployee.Field<string>("Serial") == "PORT1")
{
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat);
if (!exists)
{
stringQueueSerial_1.Enqueue(new QueueSerial
{
ID = index,
DAT = dat
});
}
}
else if (drEmployee.Field<string>("Serial") == "PORT2")
{
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat);
if (!exists)
{
stringQueueSerial_2.Enqueue(new QueueSerial
{
ID = index,
DAT = dat
});
}
}
else if (drEmployee.Field<string>("Serial") == "PORT3")
{
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat);
if (!exists)
{
stringQueueSerial_3.Enqueue(new QueueSerial
{
ID = index,
DAT = dat
});
}
}
else if (drEmployee.Field<string>("Serial") == "PORT4")
{
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat);
if (!exists)
{
stringQueueSerial_4.Enqueue(new QueueSerial
{
ID = index,
DAT = dat
});
}
}
}
}
this.Close(); this.Close();
} }