指纹登录数据库连接失败跳转紧急开锁页面
This commit is contained in:
		
							parent
							
								
									804643d035
								
							
						
					
					
						commit
						5269c94399
					
				| 
						 | 
					@ -93,7 +93,7 @@
 | 
				
			||||||
		<!-- 指纹机号码 -->
 | 
							<!-- 指纹机号码 -->
 | 
				
			||||||
		<add  key="machineNumber" value="1"/>
 | 
							<add  key="machineNumber" value="1"/>
 | 
				
			||||||
		<!-- 指纹机ip -->
 | 
							<!-- 指纹机ip -->
 | 
				
			||||||
		<add  key="fingerIp" value="192.168.1.201"/>
 | 
							<add  key="fingerIp" value="192.168.50.201"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		<!-- 多处方取药 0:不启用 1:启用-->
 | 
							<!-- 多处方取药 0:不启用 1:启用-->
 | 
				
			||||||
		<add  key="MultiOrder" value="1"/>
 | 
							<add  key="MultiOrder" value="1"/>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,10 +32,10 @@ namespace DM_Weight.Finger
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
            logger.Info($"进入构造器,开始连接指纹机");
 | 
					            logger.Info($"进入构造器,开始连接指纹机");
 | 
				
			||||||
            Task.Run(() =>
 | 
					           // Task.Run(() =>
 | 
				
			||||||
           {
 | 
					           //{
 | 
				
			||||||
               ConnectionMain();
 | 
					               ConnectionMain();
 | 
				
			||||||
           });
 | 
					           //});
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void ConnectionMain()
 | 
					        public void ConnectionMain()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ using System.Windows.Threading;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace DM_Weight.ViewModels
 | 
					namespace DM_Weight.ViewModels
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public class EmergencyWindowViewModel : BindableBase
 | 
					    public class EmergencyWindowViewModel : BindableBase, IRegionMemberLifetime, INavigationAware
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindowViewModel));
 | 
					        private readonly ILog logger = LogManager.GetLogger(typeof(HomeWindowViewModel));
 | 
				
			||||||
        IEventAggregator _eventAggregator;
 | 
					        IEventAggregator _eventAggregator;
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,6 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            _portUtil = portUtil;
 | 
					            _portUtil = portUtil;
 | 
				
			||||||
            _eventAggregator = eventAggregator;
 | 
					            _eventAggregator = eventAggregator;
 | 
				
			||||||
            _regionManager = regionManager;
 | 
					            _regionManager = regionManager;
 | 
				
			||||||
            CheckDBConnect();
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public DelegateCommand<string> OpenDrawer
 | 
					        public DelegateCommand<string> OpenDrawer
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -62,6 +61,9 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private DelegateCommand? _exitCommand;
 | 
					        private DelegateCommand? _exitCommand;
 | 
				
			||||||
        public DelegateCommand ExitCommand => _exitCommand ??= new DelegateCommand(Exit);
 | 
					        public DelegateCommand ExitCommand => _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public bool KeepAlive => false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void Exit()
 | 
					        void Exit()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Process.GetCurrentProcess().Kill();
 | 
					            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)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					           
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -60,7 +60,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            get => ReadAppSetting("loginUser");
 | 
					            get => ReadAppSetting("loginUser");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private HkcChangeShifts listHkcChangeShifts=new HkcChangeShifts();
 | 
					        private HkcChangeShifts listHkcChangeShifts = new HkcChangeShifts();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private FingerprintUtil _fingerprintUtil;
 | 
					        private FingerprintUtil _fingerprintUtil;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -84,7 +84,7 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
            get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
 | 
					            get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private bool _fingerMsg= CHKFunction.HKUserId>=0;
 | 
					        private bool _fingerMsg = CHKFunction.HKUserId >= 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public bool FingerMsg
 | 
					        public bool FingerMsg
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -99,8 +99,8 @@ namespace DM_Weight.ViewModels
 | 
				
			||||||
        private bool _hikMsg;
 | 
					        private bool _hikMsg;
 | 
				
			||||||
        public bool HIKMsg
 | 
					        public bool HIKMsg
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get=>_hikMsg;
 | 
					            get => _hikMsg;
 | 
				
			||||||
            set=>SetProperty(ref _hikMsg, value);
 | 
					            set => SetProperty(ref _hikMsg, value);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
 | 
					        //public LoginWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, PortUtil portUtil, FingerprintUtil fingerprintUtil)
 | 
				
			||||||
| 
						 | 
					@ -179,7 +179,7 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                        Username = "";
 | 
					                        Username = "";
 | 
				
			||||||
                        Password = "";
 | 
					                        Password = "";
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    else if (userList.Role == null|| userList.Role.Permissions.Count<=0)
 | 
					                    else if (userList.Role == null || userList.Role.Permissions.Count <= 0)
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        AlertMsg alertMsg = new AlertMsg
 | 
					                        AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
| 
						 | 
					@ -200,7 +200,7 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                               .Where(cs => cs.State == "0").First();
 | 
					                               .Where(cs => cs.State == "0").First();
 | 
				
			||||||
                            if (listHkcChangeShifts != null)
 | 
					                            if (listHkcChangeShifts != null)
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                if(!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
 | 
					                                if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
 | 
				
			||||||
                                {
 | 
					                                {
 | 
				
			||||||
                                    AlertMsg alertMsg = new AlertMsg
 | 
					                                    AlertMsg alertMsg = new AlertMsg
 | 
				
			||||||
                                    {
 | 
					                                    {
 | 
				
			||||||
| 
						 | 
					@ -316,9 +316,9 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                    //1仅当班人、审核人可登录
 | 
					                    //1仅当班人、审核人可登录
 | 
				
			||||||
                    if (LoginUserCheck.Equals("1"))
 | 
					                    if (LoginUserCheck.Equals("1"))
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        if(listHkcChangeShifts!=null)
 | 
					                        if (listHkcChangeShifts != null)
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            if(listHkcChangeShifts.FromOperator.Equals(user.UserName))
 | 
					                            if (listHkcChangeShifts.FromOperator.Equals(user.UserName))
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                keys.Add("operator", user);
 | 
					                                keys.Add("operator", user);
 | 
				
			||||||
                                Operator = user;
 | 
					                                Operator = user;
 | 
				
			||||||
| 
						 | 
					@ -348,7 +348,7 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                        RaisePropertyChanged("Reviewer");
 | 
					                        RaisePropertyChanged("Reviewer");
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    Username = string.Empty;
 | 
					                    Username = string.Empty;
 | 
				
			||||||
                    Password =string.Empty;
 | 
					                    Password = string.Empty;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -371,6 +371,9 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (msg.Message.Equals("LOGIN"))
 | 
					                if (msg.Message.Equals("LOGIN"))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
 | 
					                    try
 | 
				
			||||||
 | 
					                    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
 | 
					                        UserList userList = SqlSugarHelper.Db.Queryable<UserList>()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        .Includes<RoleDm>(u => u.Role)
 | 
					                        .Includes<RoleDm>(u => u.Role)
 | 
				
			||||||
| 
						 | 
					@ -425,6 +428,21 @@ _exitCommand ??= new DelegateCommand(Exit);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            SetUser(userList);
 | 
					                            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" />
 | 
				
			||||||
                <ColumnDefinition Width="Auto" />
 | 
					                <ColumnDefinition Width="Auto" />
 | 
				
			||||||
            </Grid.ColumnDefinitions>
 | 
					            </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>
 | 
					                <Grid.Background>
 | 
				
			||||||
                    <ImageBrush ImageSource="/Images/box.png" />
 | 
					                    <ImageBrush ImageSource="/Images/box.png" />
 | 
				
			||||||
                </Grid.Background>
 | 
					                </Grid.Background>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue