处理lock (Machines.Rows.SyncRoot)并发写datatable问题
This commit is contained in:
commit
d3375fd6ac
7 files changed
+917
-108
No files matched your search
@@ -135,6 +135,7 @@
|
||||
<Compile Include="UserClass\CSV.cs" />
|
||||
<Compile Include="UserClass\DataGridHelper.cs" />
|
||||
<Compile Include="UserClass\DataTableForToObservableCollection.cs" />
|
||||
<Compile Include="UserClass\DataTableManager .cs" />
|
||||
<Compile Include="UserClass\get_local_ip_address.cs" />
|
||||
<Compile Include="UserClass\HardwareSN.cs" />
|
||||
<Compile Include="UserClass\IniFile.cs" />
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
@@ -67,7 +68,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
{
|
||||
if (sArray[i].Length>5)
|
||||
{
|
||||
return EasyTask.CompletedTask; ;
|
||||
string SYSAPI = sArray[i].Substring(0, 5);
|
||||
string Station = ClipBetween(sArray[i], '[', ']');
|
||||
string DAT = sArray[i].Substring(sArray[i].IndexOf("]") + 1);
|
||||
@@ -77,13 +77,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
{
|
||||
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
||||
Station + "' AND Serial = 'PORT1'").First();
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "802";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||
@@ -132,8 +134,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
{
|
||||
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" +
|
||||
Station + "' AND Serial = 'PORT1'").First();
|
||||
string mac;
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("Station='" + Station + "' AND Serial = 'PORT1'").First();
|
||||
mac = drEmployee["Name"].ToString();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["ERR"] = _new.GetValue("ERR");
|
||||
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
||||
@@ -152,12 +157,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
drEmployee["CALL"] = _new.GetValue("CALL");
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
}
|
||||
|
||||
if (_new.GetValue("Status").ToString() != "----------")
|
||||
{
|
||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||
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("MST", _new.GetValue("MST"));
|
||||
Chart_new.Add("MTT", _new.GetValue("MTT"));
|
||||
@@ -174,7 +180,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
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")
|
||||
{
|
||||
@@ -416,13 +423,38 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
{
|
||||
try
|
||||
{
|
||||
var t= CRCcheck16.ToCRC16(command);
|
||||
var t = CRCcheck16.ToCRC16(command);
|
||||
_responseEvent.Reset();
|
||||
serialPortClients.Send(command); // 发送指令
|
||||
// 等待500毫秒或直到收到响应
|
||||
_responseEvent.Wait(TimeSpan.FromMilliseconds(1000));
|
||||
// 重置事件状态
|
||||
_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) { }
|
||||
}
|
||||
|
||||
@@ -48,13 +48,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
tcpClient.Connected = (client, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["State"] = "801";
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
|
||||
}
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -67,6 +69,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
tcpClient.Closing = (client, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
@@ -74,7 +78,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
drEmployee["WorkOrder"] = "------";
|
||||
drEmployee["Dyelot"] = "";
|
||||
drEmployee["Temperature"] = 0.0;
|
||||
drEmployee["WaterLevel"] = "----";
|
||||
drEmployee["WaterLevel"] = 0.0;
|
||||
drEmployee["Process"] = "";
|
||||
drEmployee["Step"] = "";
|
||||
drEmployee["Message"] = "";
|
||||
@@ -83,6 +87,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
drEmployee["ERR"] = false;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
}
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -94,6 +99,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
tcpClient.Closed = (client, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
@@ -101,7 +108,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
drEmployee["WorkOrder"] = "------";
|
||||
drEmployee["Dyelot"] = "";
|
||||
drEmployee["Temperature"] = 0.0;
|
||||
drEmployee["WaterLevel"] = "----";
|
||||
drEmployee["WaterLevel"] = 0.0;
|
||||
drEmployee["Process"] = "";
|
||||
drEmployee["Step"] = "";
|
||||
drEmployee["Message"] = "";
|
||||
@@ -110,6 +117,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
drEmployee["ERR"] = false;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
}
|
||||
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -130,6 +138,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||
Chart_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["SYSKEY"] = Chart_new.GetValue("SYSKEY").ToString();
|
||||
@@ -139,6 +149,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++;
|
||||
@@ -212,6 +223,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
DataTable dataTable = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
||||
|
||||
foreach (DataRow sourceRow in dataTable.Rows)
|
||||
{
|
||||
lock (MainWindowViewModel.Dyelot_CALL.Rows.SyncRoot)
|
||||
{
|
||||
// 创建新行(基于目标表结构)
|
||||
DataRow newRow = MainWindowViewModel.Dyelot_CALL.NewRow();
|
||||
@@ -247,6 +260,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; }
|
||||
}//获取呼叫领料单
|
||||
else if (SYSAPI == "SC830")
|
||||
@@ -256,7 +270,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||
Dictionary<string, object> _new = new Dictionary<string, object>();//缓存函数
|
||||
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
|
||||
string mac;
|
||||
// 首先确保 DataTable 使用线程安全的访问方式
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First();
|
||||
mac = drEmployee["Name"].ToString();
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["ERR"] = _new.GetValue("ERR");
|
||||
drEmployee["LOCK"] = _new.GetValue("LOCK");
|
||||
@@ -275,12 +294,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
||||
drEmployee["CALL"] = _new.GetValue("CALL");
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
|
||||
}
|
||||
if (_new.GetValue("Status").ToString() != "----------")
|
||||
{
|
||||
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
|
||||
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("MST", _new.GetValue("MST"));
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
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)
|
||||
{
|
||||
DataRow dat_= MainWindowViewModel.Machines.NewRow();
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow dat_ = MainWindowViewModel.Machines.NewRow();
|
||||
dat_.BeginEdit();
|
||||
dat_["Name"] = comboBoxMachine.Text;
|
||||
dat_["Groups"] = TextMachineGroup.Text;
|
||||
@@ -96,7 +98,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dat_["WaterLevel"] = 0;
|
||||
dat_["WORK_RUN"] = -1;
|
||||
dat_["UserInfoStart"] = 900;
|
||||
if (comboBoxtype.Text.Contains( link_model))
|
||||
if (comboBoxtype.Text.Contains(link_model))
|
||||
{
|
||||
dat_["Desktop"] = true;
|
||||
dat_["Type"] = true;
|
||||
@@ -127,7 +129,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Machines_DAT.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow dr = MainWindowViewModel.Machines.Rows[ID_];
|
||||
dr.BeginEdit();
|
||||
@@ -139,8 +144,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dr["Model"] = comboBoxtype.Text;
|
||||
dr["Station"] = Station.Text;
|
||||
if (comboBoxtype.Text.Contains(link_model))
|
||||
{ dr["Desktop"] = true;
|
||||
dr["Type"] = true; }
|
||||
{
|
||||
dr["Desktop"] = true;
|
||||
dr["Type"] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dr["Desktop"] = false;
|
||||
@@ -166,6 +173,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Machines_DAT.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
||||
comboBoxMachine.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);
|
||||
if (vr == MessageBoxResult.OK) // 如果是确定,就执行下面代码
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
MainWindowViewModel.Machines.Rows.RemoveAt(ID_ - 1);
|
||||
DatSteps(MainWindowViewModel.Machines);
|
||||
|
||||
}
|
||||
Dictionary<string, object> Machines_DAT = new Dictionary<string, object>();//缓存函数
|
||||
|
||||
MainWindowViewModel.SQLiteHelpers.Delete("Machines", null, null);//
|
||||
|
||||
+352
-1
@@ -145,6 +145,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
private void MenuItem_LOCK_XML(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(machine))
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("LOCK");
|
||||
|
||||
@@ -219,10 +221,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
}//锁定
|
||||
private void MenuItem_AUTO_XML(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(machine))
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
bool mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<bool>("AUTO");
|
||||
|
||||
@@ -288,6 +293,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}//手自动
|
||||
private void MenuItem_Stop_XML(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -296,6 +302,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
|
||||
dat_821.Clear();
|
||||
dat_821.Add("INSTRUCTION", "STOP");
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||
if (drEmployee.Field<bool>("Type"))
|
||||
@@ -342,6 +350,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}//停止
|
||||
private void MenuItem_Start_XML(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -465,12 +474,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
}
|
||||
|
||||
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||
if (drEmployee.Field<bool>("Type"))
|
||||
{//网络
|
||||
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||
{
|
||||
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;
|
||||
log.Visibility = Visibility.Collapsed;
|
||||
rdp.Visibility = Visibility.Collapsed;
|
||||
@@ -498,12 +544,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dat_821.Add("INSTRUCTION", "CONTINUE");
|
||||
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,
|
||||
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;
|
||||
edit.IsHitTestVisible = false;
|
||||
Resume.IsHitTestVisible = false;
|
||||
@@ -521,12 +605,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dat_821.Add("INSTRUCTION", "PAUSE");
|
||||
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,
|
||||
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;
|
||||
edit.IsHitTestVisible = true;
|
||||
Paused.IsHitTestVisible = true;
|
||||
@@ -545,12 +667,50 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dat_821.Add("INSTRUCTION", "STOP");
|
||||
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,
|
||||
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)
|
||||
{
|
||||
@@ -607,11 +767,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
|
||||
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,
|
||||
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;
|
||||
}
|
||||
private void ListViewItem_Jump(object sender, MouseButtonEventArgs e)
|
||||
@@ -635,11 +833,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
|
||||
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,
|
||||
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;
|
||||
}//跳步
|
||||
@@ -698,11 +934,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
|
||||
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,
|
||||
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)
|
||||
@@ -715,11 +989,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dat_821.Add("ID", ID);
|
||||
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,
|
||||
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.AcceptChanges();
|
||||
@@ -762,6 +1074,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
}
|
||||
}
|
||||
private void MenuItem_Delete(object sender, RoutedEventArgs e)//右键删除
|
||||
|
||||
{
|
||||
int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量
|
||||
if (rownum != -1)//判断鼠标定位是否有效
|
||||
@@ -775,11 +1088,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
dat_821.Add("ID", ID);
|
||||
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,
|
||||
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.AcceptChanges();
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
public static SQLiteHelper SQLiteChartAdress = null; //定义数据库
|
||||
private static readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
|
||||
public static DataTable Machines = new DataTable(); //设备表缓存
|
||||
//public static DataTableManager Machines = new DataTableManager("MachinesTa");
|
||||
// public static DataRow MachinesROW;
|
||||
public static DataTable USER_data = new DataTable();
|
||||
public static DataTable Dyelot_CALL = new DataTable();
|
||||
@@ -235,6 +236,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
string WorkOrderdata_m = WorkOrderstepdata.Select()[k].Field<object>("Machines").ToString();
|
||||
//string m= WorkOrderstepdata.Rows[k].Field<string>("Machines");
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderdata_m + "'")))
|
||||
{//网络
|
||||
//string WorkOrderdata_m = WorkOrderstepdata.Select()[k].Field<object>("Machines").ToString();
|
||||
@@ -252,7 +255,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
else
|
||||
{//串口
|
||||
DataTable dataTable = SQLiteHelpers.ExecuteDataSet("select * from WorkorderSteps where WorkOrder='" +
|
||||
WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "' AND ReDye ='"+
|
||||
WorkOrderstepdata.Select()[k].Field<object>("WorkOrder").ToString() + "' AND ReDye ='" +
|
||||
WorkOrderstepdata.Select()[k].Field<object>("ReDye").ToString() + "' AND Mode<> '201'", null).Tables[0];
|
||||
|
||||
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
|
||||
@@ -290,6 +293,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*下传工单总览*/
|
||||
DataTable WorkOrderdata = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where (State='100' or State='110') AND EndTime >'" +
|
||||
DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
||||
@@ -297,7 +301,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
||||
//string m = WorkOrderdata.Rows[k].Field<string>("Machines");
|
||||
if (Convert.ToBoolean( Selet_Machines(Machines, "Type", "Name='" + WorkOrderdata_m + "'")))
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderdata_m + "'")))
|
||||
{//网络
|
||||
//string WorkOrderdata_m = WorkOrderdata.Select()[k].Field<object>("Machines").ToString();
|
||||
string State = Selet_Machines(Machines, "State", "Name='" + WorkOrderdata_m + "'").ToString();
|
||||
@@ -376,6 +382,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*下传工单设置*/
|
||||
DataTable WorkOrderset_ = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where (State='113'or State='114') AND EndTime >'" +
|
||||
DateTime.Now.AddHours(-8).ToString("yyyy/MM/dd HH:mm:ss") + "'", null).Tables[0]; //读取表写入缓存
|
||||
@@ -383,6 +390,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString();
|
||||
//string m = WorkOrderset_.Rows[k].Field<string>("Machines");
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
if (Convert.ToBoolean(Selet_Machines(Machines, "Type", "Name='" + WorkOrderset_m + "'")))
|
||||
{//网络
|
||||
//string WorkOrderset_m = WorkOrderset_.Select()[k].Field<object>("Machines").ToString();
|
||||
@@ -456,13 +465,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
SQLiteHelpers.Update("WorkOrder", new Dictionary<string, object> { { "State", 110 } },
|
||||
"WorkOrder ='" + WorkOrderdata.Select()[k].Field<object>("WorkOrder").ToString() + "'", null);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//系统时间
|
||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
//更新机台状态与发送指令
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
foreach (DataRow MachinesRow in Machines.Rows)
|
||||
{
|
||||
if (Convert.ToBoolean(MachinesRow["Type"]))
|
||||
@@ -471,11 +482,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
stringQueue.Enqueue(new QueueString
|
||||
{
|
||||
ID = Convert.ToInt16( MachinesRow["ID"]),
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC830" + MachinesRow["SYSKEY"]
|
||||
});//信息插入队列
|
||||
|
||||
bool mode =Convert.ToBoolean( MachinesRow["LOCK"]) ;//发送锁定状态
|
||||
bool mode = Convert.ToBoolean(MachinesRow["LOCK"]);//发送锁定状态
|
||||
if (mode)
|
||||
{
|
||||
Dictionary<string, object> dat_829 = new Dictionary<string, object>();
|
||||
@@ -493,7 +504,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
|
||||
Updata_Machines(Machines, "State", "ID='" + MachinesRow["ID"] + "'", "101");
|
||||
}
|
||||
int m_run =Convert.ToInt16( MachinesRow["WORK_RUN"]);
|
||||
int m_run = Convert.ToInt16(MachinesRow["WORK_RUN"]);
|
||||
if (m_run == 0)
|
||||
{
|
||||
Updata_Machines(Machines, "State", "ID='" + MachinesRow["ID"] + "'", "101");//停止状态
|
||||
@@ -517,7 +528,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
stringQueueinf.Enqueue(new QueueString
|
||||
{
|
||||
ID = Convert.ToInt16( MachinesRow["ID"]),
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC830" + MachinesRow["SYSKEY"]
|
||||
});//信息插入队列
|
||||
}
|
||||
@@ -615,7 +626,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
int m_run =Convert.ToInt16( MachinesRow["WORK_RUN"]);
|
||||
int m_run = Convert.ToInt16(MachinesRow["WORK_RUN"]);
|
||||
if (m_run == 0)
|
||||
{
|
||||
Updata_Machines(Machines, "State", "ID='" + MachinesRow["ID"] + "'", "101");//停止状态
|
||||
@@ -672,7 +683,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (Time5 > 5)
|
||||
{
|
||||
Tick_Event_5S();
|
||||
@@ -688,86 +699,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
async void Tick_Event_5S()//Tick_Event周期执行事件5S
|
||||
{
|
||||
foreach (DataRow MachinesRow in Machines.Rows)
|
||||
{
|
||||
/**发送800指令**/
|
||||
if (MachinesRow["State"].ToString() == "801")
|
||||
{
|
||||
stringQueue.Enqueue(new QueueString
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC800:SCCM[" + MachinesRow["IP"] + ";" + MachinesRow["PORT"] + "]"
|
||||
});//信息插入队列
|
||||
}
|
||||
|
||||
/**染机用户信息**/
|
||||
try
|
||||
{
|
||||
if (MachinesRow["UserInfoStart"].ToString() == "901")//打开用户提示信息
|
||||
{
|
||||
MainWindow.InfData.Rows.Add(new object[] {
|
||||
MachinesRow["Name"],Properties.Resources.Pequest + MachinesRow["UserInfo"],
|
||||
MachinesRow["SYSKEY"],MachinesRow["ID"]});
|
||||
|
||||
Updata_Machines(Machines, "UserInfoStart", "ID='" + MachinesRow["ID"] + "'", "900");
|
||||
}
|
||||
if (MachinesRow["UserInfoStart"].ToString() == "902")//删除用户提示信息
|
||||
{
|
||||
MainWindow.InfData.Select("ID='" + MachinesRow["ID"] + "'").First().Delete();
|
||||
}
|
||||
}
|
||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||
/**染机呼叫状态**/
|
||||
try
|
||||
{
|
||||
if (Convert.ToBoolean(MachinesRow["CALL"]))
|
||||
{
|
||||
if (Convert.ToBoolean(MachinesRow["Type"]))
|
||||
{//网络
|
||||
stringQueue.Enqueue(new QueueString
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827" + MachinesRow["SYSKEY"]
|
||||
});
|
||||
}
|
||||
else
|
||||
{//串口
|
||||
if (MachinesRow["Serial"].ToString() == "PORT1")
|
||||
{
|
||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
||||
{
|
||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
||||
{
|
||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
||||
{
|
||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||
try
|
||||
{//处理呼叫请求列表完成发送后(202》203)
|
||||
if (Dyelot_CALL.Select("State='202'").Count() > 0)
|
||||
@@ -964,6 +895,89 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
foreach (DataRow MachinesRow in Machines.Rows)
|
||||
{
|
||||
/**发送800指令**/
|
||||
if (MachinesRow["State"].ToString() == "801")
|
||||
{
|
||||
stringQueue.Enqueue(new QueueString
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC800:SCCM[" + MachinesRow["IP"] + ";" + MachinesRow["PORT"] + "]"
|
||||
});//信息插入队列
|
||||
}
|
||||
|
||||
/**染机用户信息**/
|
||||
try
|
||||
{
|
||||
if (MachinesRow["UserInfoStart"].ToString() == "901")//打开用户提示信息
|
||||
{
|
||||
MainWindow.InfData.Rows.Add(new object[] {
|
||||
MachinesRow["Name"],Properties.Resources.Pequest + MachinesRow["UserInfo"],
|
||||
MachinesRow["SYSKEY"],MachinesRow["ID"]});
|
||||
|
||||
Updata_Machines(Machines, "UserInfoStart", "ID='" + MachinesRow["ID"] + "'", "900");
|
||||
}
|
||||
if (MachinesRow["UserInfoStart"].ToString() == "902")//删除用户提示信息
|
||||
{
|
||||
MainWindow.InfData.Select("ID='" + MachinesRow["ID"] + "'").First().Delete();
|
||||
}
|
||||
}
|
||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||
/**染机呼叫状态**/
|
||||
try
|
||||
{
|
||||
if (Convert.ToBoolean(MachinesRow["CALL"]))
|
||||
{
|
||||
if (Convert.ToBoolean(MachinesRow["Type"]))
|
||||
{//网络
|
||||
stringQueue.Enqueue(new QueueString
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827" + MachinesRow["SYSKEY"]
|
||||
});
|
||||
}
|
||||
else
|
||||
{//串口
|
||||
if (MachinesRow["Serial"].ToString() == "PORT1")
|
||||
{
|
||||
stringQueueSerial_1.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT2")
|
||||
{
|
||||
stringQueueSerial_2.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT3")
|
||||
{
|
||||
stringQueueSerial_3.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
}
|
||||
else if (MachinesRow["Serial"].ToString() == "PORT4")
|
||||
{
|
||||
stringQueueSerial_4.Enqueue(new QueueSerial
|
||||
{
|
||||
ID = Convert.ToInt16(MachinesRow["ID"]),
|
||||
DAT = "SC827[" + MachinesRow["Station"] + "]"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||
try
|
||||
{//301列表发送完成至染机(203=>301)
|
||||
foreach (DataRow row in Dyelot_CALL.Select("State='301' OR State='309'"))
|
||||
@@ -1035,9 +1049,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||
}
|
||||
}
|
||||
}
|
||||
void Tick_Event_30S()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
/*曲线图*/
|
||||
for (int i = 0; i < Machines.Rows.Count; i++)//曲线图
|
||||
@@ -1053,6 +1070,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception EX) { LogGing.ERRDATA(EX); }
|
||||
}
|
||||
|
||||
@@ -1060,6 +1078,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
public static SerialPortClient[] MachiensPortClient = new SerialPortClient[4];
|
||||
//public static DataRow[] machinesdata = new DataRow[999];
|
||||
public void ClientNEW()
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
foreach (DataRow dataRow in Machines.Rows)
|
||||
{
|
||||
@@ -1077,7 +1097,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
dataRow.AcceptChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void TcpClientNEW()
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
foreach (DataRow dataRow in Machines.Rows)
|
||||
{
|
||||
@@ -1089,6 +1112,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public async void PortClientNEW()
|
||||
{
|
||||
if (Machines.Select("Type='false' AND Serial='PORT1'").Length > 0)
|
||||
@@ -1162,6 +1186,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT1'"))
|
||||
{
|
||||
@@ -1180,6 +1206,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
@@ -1211,6 +1238,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT2'"))
|
||||
{
|
||||
@@ -1229,6 +1258,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
@@ -1260,6 +1290,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT3'"))
|
||||
{
|
||||
@@ -1278,6 +1310,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
@@ -1309,6 +1342,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
||||
{
|
||||
foreach (DataRow MachinesRow in Machines.Select("Type='false' AND Serial='PORT4'"))
|
||||
{
|
||||
@@ -1327,6 +1362,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user