指纹登录数据库连接失败跳转紧急开锁页面
This commit is contained in:
parent
804643d035
commit
5269c94399
|
@ -93,7 +93,7 @@
|
|||
<!-- 指纹机号码 -->
|
||||
<add key="machineNumber" value="1"/>
|
||||
<!-- 指纹机ip -->
|
||||
<add key="fingerIp" value="192.168.1.201"/>
|
||||
<add key="fingerIp" value="192.168.50.201"/>
|
||||
|
||||
<!-- 多处方取药 0:不启用 1:启用-->
|
||||
<add key="MultiOrder" value="1"/>
|
||||
|
|
|
@ -32,10 +32,10 @@ namespace DM_Weight.Finger
|
|||
{
|
||||
_eventAggregator = eventAggregator;
|
||||
logger.Info($"进入构造器,开始连接指纹机");
|
||||
Task.Run(() =>
|
||||
{
|
||||
// Task.Run(() =>
|
||||
//{
|
||||
ConnectionMain();
|
||||
});
|
||||
//});
|
||||
}
|
||||
|
||||
public void ConnectionMain()
|
||||
|
|
|
@ -18,7 +18,7 @@ using System.Windows.Threading;
|
|||
|
||||
namespace DM_Weight.ViewModels
|
||||
{
|
||||
public class EmergencyWindowViewModel : BindableBase
|
||||
public class EmergencyWindowViewModel : BindableBase, IRegionMemberLifetime, INavigationAware
|
||||
{
|
||||
private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindowViewModel));
|
||||
IEventAggregator _eventAggregator;
|
||||
|
@ -34,7 +34,6 @@ namespace DM_Weight.ViewModels
|
|||
_portUtil = portUtil;
|
||||
_eventAggregator = eventAggregator;
|
||||
_regionManager = regionManager;
|
||||
CheckDBConnect();
|
||||
}
|
||||
public DelegateCommand<string> OpenDrawer
|
||||
{
|
||||
|
@ -62,6 +61,9 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
private DelegateCommand? _exitCommand;
|
||||
public DelegateCommand ExitCommand => _exitCommand ??= new DelegateCommand(Exit);
|
||||
|
||||
public bool KeepAlive => false;
|
||||
|
||||
void Exit()
|
||||
{
|
||||
Process.GetCurrentProcess().Kill();
|
||||
|
@ -86,5 +88,22 @@ namespace DM_Weight.ViewModels
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
DBConnectionStatus = !App.DbConnectionFail;
|
||||
CheckDBConnect();
|
||||
}
|
||||
|
||||
public bool IsNavigationTarget(NavigationContext navigationContext)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnNavigatedFrom(NavigationContext navigationContext)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,6 +371,9 @@ _exitCommand ??= new DelegateCommand(Exit);
|
|||
{
|
||||
if (msg.Message.Equals("LOGIN"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
|
||||
|
||||
.Includes<RoleDm>(u => u.Role)
|
||||
|
@ -425,6 +428,21 @@ _exitCommand ??= new DelegateCommand(Exit);
|
|||
}
|
||||
SetUser(userList);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if(ex.Message.Contains("连接数据库过程中发生错误"))
|
||||
{
|
||||
App.DbConnectionFail = true;
|
||||
_regionManager.RequestNavigate("MainRegion", "EmergencyWindow");
|
||||
//System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
//{
|
||||
// _regionManager.RequestNavigate("MainRegion", "EmergencyWindow");
|
||||
//}));
|
||||
}
|
||||
logger.Info(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Margin="0" Grid.Column="0" Width="280" Visibility="{Binding Is8Drawer, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<Grid Margin="0" Grid.Column="0" Width="280">
|
||||
<Grid.Background>
|
||||
<ImageBrush ImageSource="/Images/box.png" />
|
||||
</Grid.Background>
|
||||
|
|
Loading…
Reference in New Issue