Browse Source

锁定功能

master
sc 6 months ago
parent
commit
54addaff17
  1. 59
      ERR/ERR2025-07-02.txt
  2. 12
      View/MonitorView.xaml
  3. 30
      View/MonitorView.xaml.cs
  4. 19
      ViewModel/MainWindowViewModel.cs

59
ERR/ERR2025-07-02.txt

@ -0,0 +1,59 @@
[2025-07-02 21:49:42];[Error] ||
[2025-07-02 21:49:42];[Error source] ||.Net SqlClient Data Provider
[2025-07-02 21:49:42];[Error message] ||在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - 无法打开到 SQL Server 的连接)
[2025-07-02 21:49:42];[Error area] || 在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
在 System.Data.SqlClient.SqlConnection.Open()
在 SunlightCentralizedControlManagement_SCCM_.ViewModel.ManualDyelotModel..ctor() 位置 C:\Users\Administrator\source\repos\SunlightCentralizedControlManagement(SCCM)\ViewModel\ManualDyelotModel.cs:行号 35
[2025-07-02 21:50:08];[Error] ||
[2025-07-02 21:50:08];[Error source] ||System.Data.SqlClient.SqlException (0x80131904): 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - 无法打开到 SQL Server 的连接) ---> System.ComponentModel.Win32Exception (0x80004005): 系统找不到指定的文件。
在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
在 System.Data.SqlClient.SqlConnection.Open()
在 SunlightCentralizedControlManagement_SCCM_.ViewModel.ManualDyelotModel..ctor() 位置 C:\Users\Administrator\source\repos\SunlightCentralizedControlManagement(SCCM)\ViewModel\ManualDyelotModel.cs:行号 35
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:2,State:0,Class:20
[2025-07-02 21:50:08];[Error message] ||在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - 无法打开到 SQL Server 的连接)
[2025-07-02 21:50:08];[Error area] ||System.Data.SqlClient.SqlException (0x80131904): 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: Named Pipes Provider, error: 40 - 无法打开到 SQL Server 的连接) ---> System.ComponentModel.Win32Exception (0x80004005): 系统找不到指定的文件。
在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
在 System.Data.SqlClient.SqlConnection.Open()
在 SunlightCentralizedControlManagement_SCCM_.ViewModel.ManualDyelotModel..ctor() 位置 C:\Users\Administrator\source\repos\SunlightCentralizedControlManagement(SCCM)\ViewModel\ManualDyelotModel.cs:行号 35
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:2,State:0,Class:20

12
View/MonitorView.xaml

@ -107,8 +107,8 @@
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White"
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" BorderBrush="{x:Null}"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" ContextMenuOpening="Gridstep_ContextMenuOpening">
<DataGrid.RowStyle>
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" >
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="IsHitTestVisible" Value="{Binding DataContext.IsInteractive,
RelativeSource={RelativeSource AncestorType=DataGrid}}"/>
@ -210,6 +210,14 @@
</StackPanel>
</ListViewItem>
</ListView>
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_LOCK_XML" IsEnabled="False" x:Name="LOCK_XML">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="LinkLock" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
<TextBlock Text="{x:Static lang:Resources._lock}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
</StackPanel>
</ListViewItem>
</ListView>
</StackPanel>
<StackPanel Grid.Row="3" x:Name="scr" VerticalAlignment="Bottom" Height="60" Background="#FF00204E" Orientation="Horizontal" Margin="700,0,0,0">

30
View/MonitorView.xaml.cs

@ -88,6 +88,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
Curve.IsEnabled = true;
Screen.IsEnabled = true;
Receipt.IsEnabled = true;
LOCK_XML.IsEnabled = true;
TechnologicalProcess_bool = true;
IsInteractive = false;
@ -202,6 +203,33 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dyelotView.Dyelot(workOrder);
Picture.Content = dyelotView;
}//单据
private void ListViewItem_LOCK_XML(object sender, MouseButtonEventArgs e)
{
string mode = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First().Field<string>("LOCK");
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
if (mode != "TRUE")
{
dat_821.Add("LOCK", "TRUE");
MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "TRUE");
}
else
{
dat_821.Add("LOCK", "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"));
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
{
ID = index,
DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
});
}//锁定
private void ListViewItem_Curve(object sender, MouseButtonEventArgs e)
{
log.Visibility = Visibility.Collapsed;
@ -579,8 +607,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
RaisePropertyChanged("TechnologicalProcess_View");
}
}
public ObservableCollection<TechnologicalM> TechnologicalMachine_View
{
get { return technologicalMachine_View; }

19
ViewModel/MainWindowViewModel.cs

@ -129,7 +129,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
}
}
public static async void SQL_LINK()//连接dbc数据库
{
if (conn_SC.State == ConnectionState.Open) conn_SC.Close();
@ -164,7 +163,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{
Interval = TimeSpan.FromMilliseconds(10) //毫秒
};
dis50ms.Tick += new EventHandler(DisTimer_50MS);//每一秒执行的方法
dis50ms.Tick += new EventHandler(DisTimer_50MS);//每执行的方法
dis50ms.Start();//计时开始
}//时间周期初始化
void DisTimer_50MS(object sender, EventArgs e)//Tick_Event周期执行事件50MS
@ -176,7 +175,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
}
}
void Tick_Main_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{
DATA_view();
@ -240,6 +238,21 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
DAT = "SC830" + Selet_Machines(Machines, "SYSKEY", "ID='" + i + "'").ToString()
});//信息插入队列
string mode = Machines.Select("NAME='" + machine + "'").First().Field<string>("LOCK");
if (mode == "TRUE")
{
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
dat_821.Add("LOCK", "TRUE");
DataRow drEmployee = Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
stringQueue.Enqueue(new QueueString
{
ID = index,
DAT = "SC829" + Selet_Machines(Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString()
});
}
Updata_Machines(Machines, "State", "ID='" + i + "'", "101");
}
}

Loading…
Cancel
Save