处理lock (Machines.Rows.SyncRoot)并发写datatable问题
This commit is contained in:
commit
d3375fd6ac
7 files changed
+1938
-1129
No files matched your search
@@ -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" />
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -67,7 +68,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
{
|
{
|
||||||
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);
|
||||||
@@ -77,12 +77,14 @@ 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='" +
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
Station + "' AND Serial = 'PORT1'").First();
|
{
|
||||||
drEmployee.BeginEdit();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
|
||||||
drEmployee["State"] = "802";
|
drEmployee.BeginEdit();
|
||||||
drEmployee.EndEdit();
|
drEmployee["State"] = "802";
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -132,32 +134,36 @@ 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)
|
||||||
drEmployee.BeginEdit();
|
{
|
||||||
drEmployee["ERR"] = _new.GetValue("ERR");
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
|
||||||
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
mac = drEmployee["Name"].ToString();
|
||||||
drEmployee["Message"] = _new.GetValue("Status");
|
drEmployee.BeginEdit();
|
||||||
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
|
drEmployee["ERR"] = _new.GetValue("ERR");
|
||||||
drEmployee["Temperature"] = _new.GetValue("MTT");
|
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
||||||
drEmployee["WaterLevel"] = _new.GetValue("MTL");
|
drEmployee["Message"] = _new.GetValue("Status");
|
||||||
drEmployee["Process"] = _new.GetValue("Process");
|
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
|
||||||
drEmployee["Step"] = _new.GetValue("Step");
|
drEmployee["Temperature"] = _new.GetValue("MTT");
|
||||||
drEmployee["UserButton"] = _new.GetValue("UserButton");
|
drEmployee["WaterLevel"] = _new.GetValue("MTL");
|
||||||
if (_new.GetValue("UserInfoStart").ToString() != "900")
|
drEmployee["Process"] = _new.GetValue("Process");
|
||||||
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); }
|
drEmployee["Step"] = _new.GetValue("Step");
|
||||||
drEmployee["UserInfo"] = _new.GetValue("UserInfo");
|
drEmployee["UserButton"] = _new.GetValue("UserButton");
|
||||||
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN");
|
if (_new.GetValue("UserInfoStart").ToString() != "900")
|
||||||
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID");
|
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); }
|
||||||
drEmployee["CALL"] = _new.GetValue("CALL");
|
drEmployee["UserInfo"] = _new.GetValue("UserInfo");
|
||||||
drEmployee.EndEdit();
|
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN");
|
||||||
drEmployee.AcceptChanges();
|
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID");
|
||||||
|
drEmployee["CALL"] = _new.GetValue("CALL");
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
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", _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"));
|
||||||
@@ -174,7 +180,8 @@ 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")
|
||||||
{
|
{
|
||||||
@@ -416,13 +423,38 @@ 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));
|
_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) { }
|
||||||
}
|
}
|
||||||
|
|||||||
+112
-93
@@ -49,12 +49,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
drEmployee.BeginEdit();
|
{
|
||||||
drEmployee["State"] = "801";
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
drEmployee.EndEdit();
|
drEmployee.BeginEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee["State"] = "801";
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
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)
|
||||||
@@ -68,21 +70,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
drEmployee.BeginEdit();
|
{
|
||||||
drEmployee["State"] = "800";
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
drEmployee["WorkOrder"] = "------";
|
drEmployee.BeginEdit();
|
||||||
drEmployee["Dyelot"] = "";
|
drEmployee["State"] = "800";
|
||||||
drEmployee["Temperature"] = 0.0;
|
drEmployee["WorkOrder"] = "------";
|
||||||
drEmployee["WaterLevel"] = "----";
|
drEmployee["Dyelot"] = "";
|
||||||
drEmployee["Process"] = "";
|
drEmployee["Temperature"] = 0.0;
|
||||||
drEmployee["Step"] = "";
|
drEmployee["WaterLevel"] = 0.0;
|
||||||
drEmployee["Message"] = "";
|
drEmployee["Process"] = "";
|
||||||
drEmployee["SYSKEY"] = "";
|
drEmployee["Step"] = "";
|
||||||
drEmployee["WORK_RUN"] = "-1";
|
drEmployee["Message"] = "";
|
||||||
drEmployee["ERR"] = false;
|
drEmployee["SYSKEY"] = "";
|
||||||
drEmployee.EndEdit();
|
drEmployee["WORK_RUN"] = "-1";
|
||||||
drEmployee.AcceptChanges();
|
drEmployee["ERR"] = false;
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
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)
|
||||||
@@ -95,21 +100,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
drEmployee.BeginEdit();
|
{
|
||||||
drEmployee["State"] = "800";
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
drEmployee["WorkOrder"] = "------";
|
drEmployee.BeginEdit();
|
||||||
drEmployee["Dyelot"] = "";
|
drEmployee["State"] = "800";
|
||||||
drEmployee["Temperature"] = 0.0;
|
drEmployee["WorkOrder"] = "------";
|
||||||
drEmployee["WaterLevel"] = "----";
|
drEmployee["Dyelot"] = "";
|
||||||
drEmployee["Process"] = "";
|
drEmployee["Temperature"] = 0.0;
|
||||||
drEmployee["Step"] = "";
|
drEmployee["WaterLevel"] = 0.0;
|
||||||
drEmployee["Message"] = "";
|
drEmployee["Process"] = "";
|
||||||
drEmployee["SYSKEY"] = "";
|
drEmployee["Step"] = "";
|
||||||
drEmployee["WORK_RUN"] = "-1";
|
drEmployee["Message"] = "";
|
||||||
drEmployee["ERR"] = false;
|
drEmployee["SYSKEY"] = "";
|
||||||
drEmployee.EndEdit();
|
drEmployee["WORK_RUN"] = "-1";
|
||||||
drEmployee.AcceptChanges();
|
drEmployee["ERR"] = false;
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
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,14 +138,17 @@ 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);//反序列化
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
drEmployee.BeginEdit();
|
{
|
||||||
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
// drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString();
|
drEmployee.BeginEdit();
|
||||||
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString();
|
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
|
||||||
drEmployee["State"] = "802";
|
// drEmployee["NAME"] = Chart_new.GetValue("MACHINE").ToString();
|
||||||
drEmployee.EndEdit();
|
drEmployee["Groups"] = Chart_new.GetValue("GROUP").ToString();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee["State"] = "802";
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -213,38 +224,41 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
|
|
||||||
foreach (DataRow sourceRow in dataTable.Rows)
|
foreach (DataRow sourceRow in dataTable.Rows)
|
||||||
{
|
{
|
||||||
// 创建新行(基于目标表结构)
|
lock (MainWindowViewModel.Dyelot_CALL.Rows.SyncRoot)
|
||||||
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
|
|
||||||
// 复制源表中存在的列数据
|
|
||||||
foreach (DataColumn column in dataTable.Columns)
|
|
||||||
{
|
{
|
||||||
if (MainWindowViewModel.Dyelot_CALL.Columns.Contains(column.ColumnName))
|
// 创建新行(基于目标表结构)
|
||||||
|
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
|
||||||
|
// 复制源表中存在的列数据
|
||||||
|
foreach (DataColumn column in dataTable.Columns)
|
||||||
{
|
{
|
||||||
newRow[column.ColumnName] = sourceRow[column.ColumnName];
|
if (MainWindowViewModel.Dyelot_CALL.Columns.Contains(column.ColumnName))
|
||||||
|
{
|
||||||
|
newRow[column.ColumnName] = sourceRow[column.ColumnName];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
MainWindowViewModel.Dyelot_CALL.Rows.Add(newRow);
|
||||||
|
|
||||||
|
Dictionary<string, object> Product_ = new Dictionary<string, object>();//缓存函数
|
||||||
|
Product_.Add("State", 202);
|
||||||
|
Product_.Add("Dyelot", newRow.Field<string>("Dyelot"));
|
||||||
|
Product_.Add("Step", newRow.Field<int>("Step"));
|
||||||
|
Product_.Add("ProductCode", newRow.Field<string>("ProductCode"));
|
||||||
|
Product_.Add("Amount", newRow.Field<object>("Amount"));
|
||||||
|
Product_.Add("DispenseEndTime", newRow.Field<object>("DispenseEndTime"));
|
||||||
|
|
||||||
|
newRow.BeginEdit();
|
||||||
|
newRow["State"] = 202;
|
||||||
|
newRow.EndEdit();
|
||||||
|
|
||||||
|
MainWindowViewModel.SQLiteHelpers.InsertData("DyelotHistory", MainWindowViewModel.SQLiteHelpers.ToDictionary(newRow));// 执行插入
|
||||||
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
|
{
|
||||||
|
ID = Convert.ToInt16(MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
|
||||||
|
"ID", "Name='" + newRow.Field<string>("Machine") + "'")),
|
||||||
|
DAT = "SC828" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
|
||||||
|
"SYSKEY", "Name='" + newRow.Field<string>("Machine") + "'") + Product_.ToJsonString()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
MainWindowViewModel.Dyelot_CALL.Rows.Add(newRow);
|
|
||||||
|
|
||||||
Dictionary<string, object> Product_ = new Dictionary<string, object>();//缓存函数
|
|
||||||
Product_.Add("State", 202);
|
|
||||||
Product_.Add("Dyelot", newRow.Field<string>("Dyelot"));
|
|
||||||
Product_.Add("Step", newRow.Field<int>("Step"));
|
|
||||||
Product_.Add("ProductCode", newRow.Field<string>("ProductCode"));
|
|
||||||
Product_.Add("Amount", newRow.Field<object>("Amount"));
|
|
||||||
Product_.Add("DispenseEndTime", newRow.Field<object>("DispenseEndTime"));
|
|
||||||
|
|
||||||
newRow.BeginEdit();
|
|
||||||
newRow["State"] = 202;
|
|
||||||
newRow.EndEdit();
|
|
||||||
|
|
||||||
MainWindowViewModel.SQLiteHelpers.InsertData("DyelotHistory", MainWindowViewModel.SQLiteHelpers.ToDictionary(newRow));// 执行插入
|
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
||||||
{
|
|
||||||
ID = Convert.ToInt16(MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
|
|
||||||
"ID", "Name='" + newRow.Field<string>("Machine") + "'")),
|
|
||||||
DAT = "SC828" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines,
|
|
||||||
"SYSKEY", "Name='" + newRow.Field<string>("Machine") + "'") + Product_.ToJsonString()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||||
@@ -256,31 +270,36 @@ 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);//反序列化
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
string mac;
|
||||||
drEmployee.BeginEdit();
|
// 首先确保 DataTable 使用线程安全的访问方式
|
||||||
drEmployee["ERR"] = _new.GetValue("ERR");
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
{
|
||||||
drEmployee["Message"] = _new.GetValue("Status");
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||||
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
|
mac = drEmployee["Name"].ToString();
|
||||||
drEmployee["Temperature"] = _new.GetValue("MTT");
|
drEmployee.BeginEdit();
|
||||||
drEmployee["WaterLevel"] = _new.GetValue("MTL");
|
drEmployee["ERR"] = _new.GetValue("ERR");
|
||||||
drEmployee["Process"] = _new.GetValue("Process");
|
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
||||||
drEmployee["Step"] = _new.GetValue("Step");
|
drEmployee["Message"] = _new.GetValue("Status");
|
||||||
drEmployee["UserButton"] = _new.GetValue("UserButton");
|
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
|
||||||
if (_new.GetValue("UserInfoStart").ToString() != "900")
|
drEmployee["Temperature"] = _new.GetValue("MTT");
|
||||||
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); }
|
drEmployee["WaterLevel"] = _new.GetValue("MTL");
|
||||||
drEmployee["UserInfo"] = _new.GetValue("UserInfo");
|
drEmployee["Process"] = _new.GetValue("Process");
|
||||||
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN");
|
drEmployee["Step"] = _new.GetValue("Step");
|
||||||
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID");
|
drEmployee["UserButton"] = _new.GetValue("UserButton");
|
||||||
drEmployee["CALL"] = _new.GetValue("CALL");
|
if (_new.GetValue("UserInfoStart").ToString() != "900")
|
||||||
drEmployee.EndEdit();
|
{ drEmployee["UserInfoStart"] = _new.GetValue("UserInfoStart"); }
|
||||||
drEmployee.AcceptChanges();
|
drEmployee["UserInfo"] = _new.GetValue("UserInfo");
|
||||||
|
drEmployee["WORK_RUN"] = _new.GetValue("WORK_RUN");
|
||||||
|
drEmployee["RUN_STEPID"] = _new.GetValue("RUN_STEPID");
|
||||||
|
drEmployee["CALL"] = _new.GetValue("CALL");
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
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"));
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
+96
-86
@@ -75,95 +75,103 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
if (!string.IsNullOrEmpty(comboBoxMachine.Text))
|
if (!string.IsNullOrEmpty(comboBoxMachine.Text))
|
||||||
{
|
{
|
||||||
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)
|
||||||
dat_.BeginEdit();
|
|
||||||
dat_["Name"] = comboBoxMachine.Text;
|
|
||||||
dat_["Groups"] = TextMachineGroup.Text;
|
|
||||||
dat_["IP"] = IP.Text;
|
|
||||||
dat_["PORT"] = PORT.Text;
|
|
||||||
dat_["Serial"] = comboBoxCOM0.Text;
|
|
||||||
dat_["Model"] = comboBoxtype.Text;
|
|
||||||
dat_["Station"] = Station.Text;
|
|
||||||
dat_["ID"] = 999;
|
|
||||||
dat_["ERR"] = false;
|
|
||||||
dat_["AUTO"] = false;
|
|
||||||
dat_["CALL"] = false;
|
|
||||||
dat_["LOCK"] = false;
|
|
||||||
dat_["State"] = 800;
|
|
||||||
dat_["Temperature"] = 0;
|
|
||||||
dat_["WaterLevel"] = 0;
|
|
||||||
dat_["WORK_RUN"] = -1;
|
|
||||||
dat_["UserInfoStart"] = 900;
|
|
||||||
if (comboBoxtype.Text.Contains( link_model))
|
|
||||||
{
|
{
|
||||||
dat_["Desktop"] = true;
|
DataRow dat_ = MainWindowViewModel.Machines.NewRow();
|
||||||
dat_["Type"] = true;
|
dat_.BeginEdit();
|
||||||
}
|
dat_["Name"] = comboBoxMachine.Text;
|
||||||
else
|
dat_["Groups"] = TextMachineGroup.Text;
|
||||||
{
|
dat_["IP"] = IP.Text;
|
||||||
dat_["Desktop"] = false;
|
dat_["PORT"] = PORT.Text;
|
||||||
dat_["Type"] = false;
|
dat_["Serial"] = comboBoxCOM0.Text;
|
||||||
}
|
dat_["Model"] = comboBoxtype.Text;
|
||||||
dat_.EndEdit();
|
dat_["Station"] = Station.Text;
|
||||||
MainWindowViewModel.Machines.Rows.Add(dat_);
|
dat_["ID"] = 999;
|
||||||
DatSteps(MainWindowViewModel.Machines);
|
dat_["ERR"] = false;
|
||||||
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
|
dat_["AUTO"] = false;
|
||||||
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
|
dat_["CALL"] = false;
|
||||||
{
|
dat_["LOCK"] = false;
|
||||||
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]);
|
dat_["State"] = 800;
|
||||||
Machines_DAT.Add("Name", MainWindowViewModel.Machines.Rows[x]["Name"]);
|
dat_["Temperature"] = 0;
|
||||||
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
|
dat_["WaterLevel"] = 0;
|
||||||
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
|
dat_["WORK_RUN"] = -1;
|
||||||
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
|
dat_["UserInfoStart"] = 900;
|
||||||
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
|
if (comboBoxtype.Text.Contains(link_model))
|
||||||
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
|
{
|
||||||
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
|
dat_["Desktop"] = true;
|
||||||
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
|
dat_["Type"] = true;
|
||||||
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]);
|
}
|
||||||
Machines_DAT.Add("Model", MainWindowViewModel.Machines.Rows[x]["Model"]);
|
else
|
||||||
MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入
|
{
|
||||||
Machines_DAT.Clear();
|
dat_["Desktop"] = false;
|
||||||
|
dat_["Type"] = false;
|
||||||
|
}
|
||||||
|
dat_.EndEdit();
|
||||||
|
MainWindowViewModel.Machines.Rows.Add(dat_);
|
||||||
|
DatSteps(MainWindowViewModel.Machines);
|
||||||
|
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
|
||||||
|
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
|
||||||
|
{
|
||||||
|
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]);
|
||||||
|
Machines_DAT.Add("Name", MainWindowViewModel.Machines.Rows[x]["Name"]);
|
||||||
|
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
|
||||||
|
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
|
||||||
|
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
|
||||||
|
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
|
||||||
|
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
|
||||||
|
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
|
||||||
|
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
|
||||||
|
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]);
|
||||||
|
Machines_DAT.Add("Model", MainWindowViewModel.Machines.Rows[x]["Model"]);
|
||||||
|
MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入
|
||||||
|
Machines_DAT.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DataRow dr = MainWindowViewModel.Machines.Rows[ID_];
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
dr.BeginEdit();
|
|
||||||
dr["Name"] = comboBoxMachine.Text;
|
|
||||||
dr["Groups"] = TextMachineGroup.Text;
|
|
||||||
dr["IP"] = IP.Text;
|
|
||||||
dr["PORT"] = PORT.Text;
|
|
||||||
dr["Serial"] = comboBoxCOM0.Text;
|
|
||||||
dr["Model"] = comboBoxtype.Text;
|
|
||||||
dr["Station"] = Station.Text;
|
|
||||||
if (comboBoxtype.Text.Contains(link_model))
|
|
||||||
{ dr["Desktop"] = true;
|
|
||||||
dr["Type"] = true; }
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
dr["Desktop"] = false;
|
DataRow dr = MainWindowViewModel.Machines.Rows[ID_];
|
||||||
dr["Type"] = false;
|
dr.BeginEdit();
|
||||||
}
|
dr["Name"] = comboBoxMachine.Text;
|
||||||
dr.EndEdit();
|
dr["Groups"] = TextMachineGroup.Text;
|
||||||
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
|
dr["IP"] = IP.Text;
|
||||||
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
|
dr["PORT"] = PORT.Text;
|
||||||
{
|
dr["Serial"] = comboBoxCOM0.Text;
|
||||||
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]);
|
dr["Model"] = comboBoxtype.Text;
|
||||||
Machines_DAT.Add("Name", MainWindowViewModel.Machines.Rows[x]["Name"]);
|
dr["Station"] = Station.Text;
|
||||||
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
|
if (comboBoxtype.Text.Contains(link_model))
|
||||||
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
|
{
|
||||||
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
|
dr["Desktop"] = true;
|
||||||
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
|
dr["Type"] = true;
|
||||||
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
|
}
|
||||||
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
|
else
|
||||||
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
|
{
|
||||||
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]);
|
dr["Desktop"] = false;
|
||||||
Machines_DAT.Add("Model", MainWindowViewModel.Machines.Rows[x]["Model"]);
|
dr["Type"] = false;
|
||||||
Machines_DAT.Add("LOCK", "FALSE");
|
}
|
||||||
MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入
|
dr.EndEdit();
|
||||||
Machines_DAT.Clear();
|
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
|
||||||
|
for (int x = 0; x < MainWindowViewModel.Machines.Rows.Count; x++)
|
||||||
|
{
|
||||||
|
Machines_DAT.Add("ID", MainWindowViewModel.Machines.Rows[x]["ID"]);
|
||||||
|
Machines_DAT.Add("Name", MainWindowViewModel.Machines.Rows[x]["Name"]);
|
||||||
|
Machines_DAT.Add("IP", MainWindowViewModel.Machines.Rows[x]["IP"]);
|
||||||
|
Machines_DAT.Add("PORT", MainWindowViewModel.Machines.Rows[x]["PORT"]);
|
||||||
|
Machines_DAT.Add("Serial", MainWindowViewModel.Machines.Rows[x]["Serial"]);
|
||||||
|
Machines_DAT.Add("Station", MainWindowViewModel.Machines.Rows[x]["Station"]);
|
||||||
|
Machines_DAT.Add("Groups", MainWindowViewModel.Machines.Rows[x]["Groups"]);
|
||||||
|
Machines_DAT.Add("Desktop", MainWindowViewModel.Machines.Rows[x]["Desktop"]);
|
||||||
|
Machines_DAT.Add("Dispense", MainWindowViewModel.Machines.Rows[x]["Dispense"]);
|
||||||
|
Machines_DAT.Add("Type", MainWindowViewModel.Machines.Rows[x]["Type"]);
|
||||||
|
Machines_DAT.Add("Model", MainWindowViewModel.Machines.Rows[x]["Model"]);
|
||||||
|
Machines_DAT.Add("LOCK", "FALSE");
|
||||||
|
MainWindowViewModel.SQLiteHelpers.InsertData("Machines", Machines_DAT);//行插入
|
||||||
|
Machines_DAT.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
||||||
@@ -187,9 +195,11 @@ 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) // 如果是确定,就执行下面代码
|
||||||
{
|
{
|
||||||
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1);
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
DatSteps(MainWindowViewModel.Machines);
|
{
|
||||||
|
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1);
|
||||||
|
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);//
|
||||||
|
|||||||
+541
-190
@@ -146,77 +146,80 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(machine))
|
if (!string.IsNullOrEmpty(machine))
|
||||||
{
|
{
|
||||||
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
|
||||||
Dictionary<string, object> dat_ = new Dictionary<string, object>();
|
|
||||||
dat_.Clear();
|
|
||||||
|
|
||||||
if (!mode)
|
|
||||||
{
|
{
|
||||||
dat_.Add("NAME", "LOCK");
|
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
|
||||||
dat_.Add("VALUE", "True");
|
|
||||||
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "True");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dat_.Add("NAME", "LOCK");
|
|
||||||
dat_.Add("VALUE", "False");
|
|
||||||
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "False");
|
|
||||||
}
|
|
||||||
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
Dictionary<string, object> dat_ = new Dictionary<string, object>();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
dat_.Clear();
|
||||||
|
|
||||||
if (drEmployee.Field<bool>("Type"))
|
if (!mode)
|
||||||
{//网络
|
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
||||||
{
|
{
|
||||||
ID = index,
|
dat_.Add("NAME", "LOCK");
|
||||||
DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
|
dat_.Add("VALUE", "True");
|
||||||
});
|
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "True");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{//串口
|
|
||||||
if (drEmployee.Field<string>("Serial") == "PORT1")
|
|
||||||
{
|
{
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
dat_.Add("NAME", "LOCK");
|
||||||
|
dat_.Add("VALUE", "False");
|
||||||
|
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "False");
|
||||||
|
}
|
||||||
|
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
|
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") == "PORT2")
|
else
|
||||||
{
|
{//串口
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
}
|
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_.ToJsonString()
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
});
|
||||||
{
|
}
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
}
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
});
|
||||||
{
|
}
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
{
|
||||||
});
|
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)
|
||||||
|
{
|
||||||
|
MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!mode)
|
|
||||||
{
|
|
||||||
MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//锁定
|
}//锁定
|
||||||
@@ -224,67 +227,70 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(machine))
|
if (!string.IsNullOrEmpty(machine))
|
||||||
{
|
{
|
||||||
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("AUTO");
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
|
|
||||||
Dictionary<string, object> dat_ = new Dictionary<string, object>();
|
|
||||||
dat_.Clear();
|
|
||||||
|
|
||||||
if (!mode)
|
|
||||||
{
|
{
|
||||||
dat_.Add("NAME", "AUTO");
|
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("AUTO");
|
||||||
dat_.Add("VALUE", "True");
|
|
||||||
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "AUTO", "Name='" + machine + "'", "True");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dat_.Add("NAME", "AUTO");
|
|
||||||
dat_.Add("VALUE", "FALSE");
|
|
||||||
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "AUTO", "Name='" + machine + "'", "False");
|
|
||||||
}
|
|
||||||
|
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
Dictionary<string, object> dat_ = new Dictionary<string, object>();
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
dat_.Clear();
|
||||||
if (drEmployee.Field<bool>("Type"))
|
|
||||||
{//网络
|
if (!mode)
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
||||||
{
|
{
|
||||||
ID = index,
|
dat_.Add("NAME", "AUTO");
|
||||||
DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
|
dat_.Add("VALUE", "True");
|
||||||
});
|
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "AUTO", "Name='" + machine + "'", "True");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{//串口
|
|
||||||
if (drEmployee.Field<string>("Serial") == "PORT1")
|
|
||||||
{
|
{
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
dat_.Add("NAME", "AUTO");
|
||||||
|
dat_.Add("VALUE", "FALSE");
|
||||||
|
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "AUTO", "Name='" + machine + "'", "False");
|
||||||
|
}
|
||||||
|
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if (drEmployee.Field<bool>("Type"))
|
||||||
|
{//网络
|
||||||
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
DAT = "SC829" + drEmployee.Field<string>("SYSKEY") + dat_.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
else
|
||||||
{
|
{//串口
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
}
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
});
|
||||||
{
|
}
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
}
|
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
});
|
||||||
{
|
}
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
DAT = "SC829" + drEmployee.Field<string>("Station") + dat_.ToJsonString()
|
{
|
||||||
});
|
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()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,49 +302,52 @@ 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");
|
||||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
{
|
||||||
if (drEmployee.Field<bool>("Type"))
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
{//网络
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{//串口
|
|
||||||
if (drEmployee.Field<string>("Serial") == "PORT1")
|
|
||||||
{
|
|
||||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
|
||||||
{
|
{
|
||||||
ID = index,
|
ID = index,
|
||||||
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
else
|
||||||
{
|
{//串口
|
||||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||||
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
}
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
});
|
||||||
{
|
}
|
||||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||||
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
}
|
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
||||||
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
});
|
||||||
{
|
}
|
||||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
||||||
{
|
{
|
||||||
ID = index,
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||||
DAT = "SC821" + drEmployee.Field<string>("Station") + dat_821.ToJsonString()
|
{
|
||||||
});
|
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()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -465,12 +474,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}
|
}
|
||||||
|
|
||||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC833" + drEmployee.Field<string>("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;
|
||||||
@@ -498,11 +544,49 @@ 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"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
|
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;
|
||||||
@@ -521,11 +605,49 @@ 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"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
|
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;
|
||||||
@@ -545,11 +667,49 @@ 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"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
|
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)
|
||||||
@@ -607,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"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
|
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)
|
||||||
@@ -635,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"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
|
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;
|
||||||
}//跳步
|
}//跳步
|
||||||
@@ -698,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"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
|
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)
|
||||||
@@ -715,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"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
|
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();
|
||||||
@@ -762,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)//判断鼠标定位是否有效
|
||||||
@@ -775,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"));
|
||||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
if (drEmployee.Field<bool>("Type"))
|
||||||
{
|
{//网络
|
||||||
ID = index,
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
DAT = "SC821" + drEmployee.Field<string>("SYSKEY") + dat_821.ToJsonString()
|
{
|
||||||
});
|
ID = index,
|
||||||
|
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();
|
||||||
|
|||||||
+765
-729
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user