指纹登录添加连不上数据库跳转紧急开锁页面
This commit is contained in:
parent
3254fcd621
commit
36b573c12b
|
@ -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
|
||||||
{
|
{
|
||||||
|
@ -86,5 +85,21 @@ namespace DM_Weight.ViewModels
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public bool KeepAlive => false;
|
||||||
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
||||||
|
{
|
||||||
|
DBConnectionStatus = !App.DbConnectionFail;
|
||||||
|
CheckDBConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnNavigatedFrom(NavigationContext navigationContext)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,63 +375,77 @@ _exitCommand ??= new DelegateCommand(Exit);
|
||||||
logger.Info($"msg.Message:{msg.Message};{msg.Message.Equals("LOGIN")}");
|
logger.Info($"msg.Message:{msg.Message};{msg.Message.Equals("LOGIN")}");
|
||||||
if (msg.Message.Equals("LOGIN"))
|
if (msg.Message.Equals("LOGIN"))
|
||||||
{
|
{
|
||||||
UserList userList = new UserList();
|
try
|
||||||
userList = SqlSugarHelper.Db.Queryable<UserList>()
|
{
|
||||||
.Includes<RoleDm>(u => u.Role)
|
|
||||||
.Where(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString())
|
|
||||||
.WithCacheIF(false).First();
|
|
||||||
//.First(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString());
|
|
||||||
|
|
||||||
|
|
||||||
logger.Info($"userList==null?{userList == null}");
|
UserList userList = new UserList();
|
||||||
if (userList == null)
|
userList = SqlSugarHelper.Db.Queryable<UserList>()
|
||||||
{
|
.Includes<RoleDm>(u => u.Role)
|
||||||
AlertMsg alertMsg = new AlertMsg
|
.Where(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString())
|
||||||
|
.WithCacheIF(false).First();
|
||||||
|
//.First(u => u.Id == msg.Id && u.MachineId == ConfigurationManager.AppSettings["machineId"].ToString());
|
||||||
|
|
||||||
|
|
||||||
|
logger.Info($"userList==null?{userList == null}");
|
||||||
|
if (userList == null)
|
||||||
{
|
{
|
||||||
Message = "无此用户",
|
AlertMsg alertMsg = new AlertMsg
|
||||||
Type = MsgType.ERROR
|
|
||||||
};
|
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
|
||||||
Username = "";
|
|
||||||
Password = "";
|
|
||||||
}
|
|
||||||
else if (userList.Role == null)
|
|
||||||
{
|
|
||||||
AlertMsg alertMsg = new AlertMsg
|
|
||||||
{
|
|
||||||
Message = "用户还未设置权限,请联系管理员",
|
|
||||||
Type = MsgType.ERROR
|
|
||||||
};
|
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
|
||||||
Username = "";
|
|
||||||
Password = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//1仅当班人、审核人可登录
|
|
||||||
if (LoginUserCheck.Equals("1"))
|
|
||||||
{
|
|
||||||
//检查当前登录人是否是值班人 (审核人与发药人)
|
|
||||||
listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
|
|
||||||
.Where(cs => cs.State == "0").First();
|
|
||||||
if (listHkcChangeShifts != null)
|
|
||||||
{
|
{
|
||||||
if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
|
Message = "无此用户",
|
||||||
{
|
Type = MsgType.ERROR
|
||||||
AlertMsg alertMsg = new AlertMsg
|
};
|
||||||
{
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
Message = "仅值班人可登录,当前登录人非值班人",
|
Username = "";
|
||||||
Type = MsgType.ERROR
|
Password = "";
|
||||||
};
|
|
||||||
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
|
||||||
Username = "";
|
|
||||||
Password = "";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SetUser(userList);
|
else if (userList.Role == null)
|
||||||
|
{
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "用户还未设置权限,请联系管理员",
|
||||||
|
Type = MsgType.ERROR
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
Username = "";
|
||||||
|
Password = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//1仅当班人、审核人可登录
|
||||||
|
if (LoginUserCheck.Equals("1"))
|
||||||
|
{
|
||||||
|
//检查当前登录人是否是值班人 (审核人与发药人)
|
||||||
|
listHkcChangeShifts = SqlSugarHelper.Db.Queryable<HkcChangeShifts>()
|
||||||
|
.Where(cs => cs.State == "0").First();
|
||||||
|
if (listHkcChangeShifts != null)
|
||||||
|
{
|
||||||
|
if (!listHkcChangeShifts.FromOperator.Equals(userList.UserName) && !listHkcChangeShifts.FromRviewer.Equals(userList.UserName))
|
||||||
|
{
|
||||||
|
AlertMsg alertMsg = new AlertMsg
|
||||||
|
{
|
||||||
|
Message = "仅值班人可登录,当前登录人非值班人",
|
||||||
|
Type = MsgType.ERROR
|
||||||
|
};
|
||||||
|
_eventAggregator.GetEvent<SnackbarEvent>().Publish(alertMsg);
|
||||||
|
Username = "";
|
||||||
|
Password = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetUser(userList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (ex.Message.Contains("连接数据库过程中发生错误"))
|
||||||
|
{
|
||||||
|
App.DbConnectionFail = true;
|
||||||
|
_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