diff --git a/DM_Weight/App.config b/DM_Weight/App.config
index 73cb96c..8727159 100644
--- a/DM_Weight/App.config
+++ b/DM_Weight/App.config
@@ -55,6 +55,8 @@
+
+
\ No newline at end of file
diff --git a/DM_Weight/App.xaml.cs b/DM_Weight/App.xaml.cs
index 754fe5a..ce4146d 100644
--- a/DM_Weight/App.xaml.cs
+++ b/DM_Weight/App.xaml.cs
@@ -205,6 +205,10 @@ namespace DM_Weight
containerRegistry.RegisterForNavigation();
+ //公共类
+ containerRegistry.RegisterSingleton();
+ //二次验证登录
+ containerRegistry.RegisterForNavigation();
}
}
}
diff --git a/DM_Weight/Models/MachineRecord.cs b/DM_Weight/Models/MachineRecord.cs
index 4b975b6..33acc03 100644
--- a/DM_Weight/Models/MachineRecord.cs
+++ b/DM_Weight/Models/MachineRecord.cs
@@ -142,7 +142,7 @@ namespace DM_Weight.Models
///
/// 药品对应批号库存
///
- [SugarColumn(ColumnName = "manunoQuantity")]
- public int? ManunoQuantity { get; set; }
+ //[SugarColumn(ColumnName = "manunoQuantity")]
+ //public int? ManunoQuantity { get; set; }
}
}
diff --git a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
index 127e62b..a220e43 100644
--- a/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/DrawerTakeDrugWindowViewModel.cs
@@ -21,6 +21,7 @@ using DM_Weight.util;
using Newtonsoft.Json;
using System.Text.RegularExpressions;
using System.Windows.Controls;
+using Prism.Services.Dialogs;
namespace DM_Weight.ViewModels
{
@@ -35,25 +36,28 @@ namespace DM_Weight.ViewModels
get => _channelStocks;
set => SetProperty(ref _channelStocks, value);
}
-
+
private static readonly DateTime Jan1st1970 = new DateTime
(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
-
+
private PortUtil _portUtil;
IEventAggregator _eventAggregator;
+ CommonClass _commonClass;
-
- public DrawerTakeDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator)
+ IDialogService _dialogService;
+ public DrawerTakeDrugWindowViewModel(PortUtil portUtil, IEventAggregator eventAggregator, CommonClass commonClass, IDialogService dialogService)
{
_portUtil = portUtil;
_eventAggregator = eventAggregator;
+ _commonClass = commonClass;
+ _dialogService = dialogService;
}
void DoMyPrismEvent(DeviceMsg msg)
{
- if(msg.WindowName == "DrawerTakeDrugWindow")
+ if (msg.WindowName == "DrawerTakeDrugWindow")
{
switch (msg.EventType)
{
@@ -91,7 +95,7 @@ namespace DM_Weight.ViewModels
break;
}
}
-
+
}
private int _status;
@@ -127,14 +131,39 @@ namespace DM_Weight.ViewModels
}, (DrawerNo) => Status == 0
);
}
-
-
- public DelegateCommand OpenDrawer
+ private DelegateCommand _openDrawer;
+ public DelegateCommand OpenDrawer => _openDrawer ??= new DelegateCommand(OpenDrawerMethod);
+ bool secondCheckFlag = true;
+ private async void OpenDrawerMethod()
{
- get => new DelegateCommand(() =>
+ if (Status == 0)
{
- if (Status == 0)
+ //如果二次验证开启则需要二次验证
+ int loginCheck = Convert.ToInt32(_commonClass.ReadAppSetting("secondCheck"));
+ if (loginCheck == 1)
{
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "SecondCheckDialog", null, CheckDoDialogResult, "RootDialog");
+ if (secondCheckFlag)
+ {
+ Status = 1;
+ _portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
+
+
+ List singleChannels = ChannelStocks.FindAll(it => it.BoardType != 1);
+
+ _portUtil.WindowName = "DrawerTakeDrugWindow";
+ _portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
+ _portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
+ _portUtil.DrawerNo = DrawerNo;
+ Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start());
+ }
+ }
+ else
+ {
+
+
Status = 1;
_portUtil.SpeakAsync("正在打开" + DrawerNo + "号抽屉");
@@ -145,13 +174,24 @@ namespace DM_Weight.ViewModels
_portUtil.BoardType = singleChannels.Count > 0 ? singleChannels[0].BoardType : 1;
_portUtil.ColNos = singleChannels.Select(it => it.ColNo).ToArray();
_portUtil.DrawerNo = DrawerNo;
- Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start())
- ;
+ Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Normal, () => _portUtil.Start());
}
-
- });
+ }
+ }
+ private void CheckDoDialogResult(IDialogResult dialogResult)
+ {
+ // 委托 被动执行 被子窗口执行
+ // dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
+ if (dialogResult.Result == ButtonResult.OK)
+ {
+ secondCheckFlag = true;
+ }
+ else
+ {
+ secondCheckFlag = false;
+ }
+ //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
-
private bool _isFinishClick = false;
// 完成按钮
@@ -198,7 +238,7 @@ namespace DM_Weight.ViewModels
ColNo = it.ColNo,
DrugId = it.DrugId,
ManuNo = it.ManuNo,
- EffDate = !String.IsNullOrEmpty(it.EffDate) ?DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture):null,
+ EffDate = !String.IsNullOrEmpty(it.EffDate) ? DateTime.ParseExact(it.EffDate, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture) : null,
Operator = HomeWindowViewModel.Operator?.Id,
Reviewer = HomeWindowViewModel.Reviewer?.Id,
OperationTime = DateTime.Now,
@@ -246,7 +286,7 @@ namespace DM_Weight.ViewModels
}
}
-
+
});
}
diff --git a/DM_Weight/ViewModels/InvoiceOutWindowViewModel.cs b/DM_Weight/ViewModels/InvoiceOutWindowViewModel.cs
index 1355d3a..d9820e3 100644
--- a/DM_Weight/ViewModels/InvoiceOutWindowViewModel.cs
+++ b/DM_Weight/ViewModels/InvoiceOutWindowViewModel.cs
@@ -66,10 +66,11 @@ namespace DM_Weight.ViewModels
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
-
- public InvoiceOutWindowViewModel(IDialogService DialogService)
+ CommonClass _commonClass;
+ public InvoiceOutWindowViewModel(IDialogService DialogService, CommonClass commonClass)
{
_dialogService = DialogService;
+ _commonClass = commonClass;
}
public static List StaticOrderTakeSelects = new()
@@ -162,17 +163,37 @@ namespace DM_Weight.ViewModels
public List Invoices { get { return _invoices; } set { SetProperty(ref _invoices, value); } }
public bool KeepAlive => false;
-
+ bool secondCheckFlag = true;
public async void OpenOrderDialog()
{
if (SelectedInvoice != null && SelectedInvoice.Status == 0)
{
- // 此处延时1毫秒,等待页面渲染
- await Task.Delay(TimeSpan.FromMilliseconds(1));
- DialogParameters dialogParameters = new DialogParameters();
- dialogParameters.Add("invoice", SelectedInvoice);
- DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
- RequestData();
+ //如果二次验证开启则需要二次验证
+ int loginCheck = Convert.ToInt32(_commonClass.ReadAppSetting("secondCheck"));
+ if (loginCheck == 1)
+ {
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "SecondCheckDialog", null, CheckDoDialogResult, "RootDialog");
+ if (secondCheckFlag)
+ {
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("invoice", SelectedInvoice);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
+ RequestData();
+ }
+ }
+ else
+ {
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("invoice", SelectedInvoice);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "InvoiceTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
+ RequestData();
+ }
}
}
@@ -183,7 +204,20 @@ namespace DM_Weight.ViewModels
RequestData();
});
}
-
+ private void CheckDoDialogResult(IDialogResult dialogResult)
+ {
+ // 委托 被动执行 被子窗口执行
+ // dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
+ if (dialogResult.Result == ButtonResult.OK)
+ {
+ secondCheckFlag = true;
+ }
+ else
+ {
+ secondCheckFlag = false;
+ }
+ //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
+ }
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
diff --git a/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
index 0e526e4..fa90140 100644
--- a/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/OrderTakeDrugWindowViewModel.cs
@@ -18,7 +18,7 @@ using Prism.Events;
namespace DM_Weight.ViewModels
{
- public class OrderTakeDrugWindowViewModel: BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
+ public class OrderTakeDrugWindowViewModel : BindableBase, IConfirmNavigationRequest, IRegionMemberLifetime
{
private int _pageNum = 1;
@@ -65,15 +65,17 @@ namespace DM_Weight.ViewModels
IDialogService _dialogService;
IEventAggregator _eventAggregator;
+ CommonClass _commonClass;
private DelegateCommand _rowSelected;
public DelegateCommand RowSelected => _rowSelected ??= new DelegateCommand(OpenOrderDialog);
- public OrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
+ public OrderTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator, CommonClass commonClass)
{
_dialogService = DialogService;
_eventAggregator = eventAggregator;
+ _commonClass = commonClass;
}
public static List StaticOrderTakeSelects = new()
@@ -133,7 +135,10 @@ namespace DM_Weight.ViewModels
///
/// 查询条件 处方日期
///
- public string OrderDate { get { return _orderDate; } set
+ public string OrderDate
+ {
+ get { return _orderDate; }
+ set
{
if (!String.IsNullOrEmpty(value))
{
@@ -143,7 +148,7 @@ namespace DM_Weight.ViewModels
{
SetProperty(ref _orderDate, value);
}
-
+
RequestData();
}
}
@@ -153,7 +158,8 @@ namespace DM_Weight.ViewModels
///
/// 查询条件 查询字段值
///
- public string? SearchValue {
+ public string? SearchValue
+ {
get { return _searchValue; }
set
{
@@ -167,30 +173,69 @@ namespace DM_Weight.ViewModels
public List OrderInfos { get { return _orderInfos; } set { SetProperty(ref _orderInfos, value); } }
public bool KeepAlive => false;
-
+ bool secondCheckFlag = true;
public async void OpenOrderDialog()
{
if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
{
- // 此处延时1毫秒,等待页面渲染
- await Task.Delay(TimeSpan.FromMilliseconds(1));
- DialogParameters dialogParameters = new DialogParameters();
- dialogParameters.Add("orderInfo", SelectedOrder);
- DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
-
+ //如果二次验证开启则需要二次验证
+ int loginCheck = Convert.ToInt32(_commonClass.ReadAppSetting("secondCheck"));
+ if (loginCheck == 1)
+ {
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("secondCheck", SelectedOrder);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "SecondCheckDialog", dialogParameters, CheckDoDialogResult, "RootDialog");
+ if (secondCheckFlag)
+ {
+ if (SelectedOrder != null && SelectedOrder.DmStatus == 0 && SelectedOrder.CancelFlag == 0 && SelectedOrder.HisDispFlag == 0)
+ {
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogParameters dialogParametersTake = new DialogParameters();
+ dialogParametersTake.Add("orderInfo", SelectedOrder);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeDialog", dialogParametersTake, DoDialogResult, "RootDialog");
+
+ }
+ }
+ }
+ else
+ {
+
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("orderInfo", SelectedOrder);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "OrderTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
+
+ }
}
-
+ }
+ private void CheckDoDialogResult(IDialogResult dialogResult)
+ {
+ // 委托 被动执行 被子窗口执行
+ // dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
+ if (dialogResult.Result == ButtonResult.OK)
+ {
+ secondCheckFlag = true;
+ }
+ else
+ {
+ secondCheckFlag = false;
+ }
+ //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
// dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
- //if(dialogResult.Result == ButtonResult.OK)
- //{
+ if (dialogResult.Result == ButtonResult.OK)
+ {
SelectedOrder = null;
RequestData();
- //}
+ }
//MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
@@ -226,7 +271,7 @@ namespace DM_Weight.ViewModels
.GroupBy(oi => oi.OrderDate)
.Select(oi => oi)
.ToPageList(PageNum, PageSize, ref totalCount);
- //.ToList();
+ //.ToList();
OrderInfos = queryData;
TotalCount = totalCount;
PageCount = (int)Math.Ceiling((double)TotalCount / PageSize);
diff --git a/DM_Weight/ViewModels/SecondCheckDialogViewModel.cs b/DM_Weight/ViewModels/SecondCheckDialogViewModel.cs
new file mode 100644
index 0000000..99975a9
--- /dev/null
+++ b/DM_Weight/ViewModels/SecondCheckDialogViewModel.cs
@@ -0,0 +1,332 @@
+using DM_Weight.Finger;
+using DM_Weight.Models;
+using DM_Weight.msg;
+using DM_Weight.Port;
+using DM_Weight.util;
+using log4net;
+using log4net.Core;
+using log4net.Repository.Hierarchy;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Regions;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Configuration;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DM_Weight.ViewModels
+{
+ public class SecondCheckDialogViewModel : BindableBase, IRegionMemberLifetime, IDialogAware
+ {
+ public bool KeepAlive => false;
+ private readonly ILog logger = LogManager.GetLogger(typeof(LoginWindowViewModel));
+
+ private string username;
+ private string password;
+
+ private Boolean _loginBtnEnable = true;
+
+ IRegionManager _regionManager;
+
+ private int loginMode = Convert.ToInt32(ConfigurationManager.AppSettings["loginMode"]?.ToString() ?? "1");
+ private string firstLogin = ConfigurationManager.AppSettings["firstLogin"]?.ToString() ?? "operator";
+
+ public bool SingleLogin
+ {
+ get => _commonClass.ReadAppSetting("loginMode") == "1";
+ //get => loginMode == 1;
+ }
+ public bool MultiLogin
+ {
+ //get => loginMode == 2;
+ get => _commonClass.ReadAppSetting("loginMode") == "2";
+ }
+ private FingerprintUtil _fingerprintUtil;
+
+ private PortUtil _portUtil;
+
+ public Boolean LoginBtnEnable { get { return _loginBtnEnable; } set { SetProperty(ref _loginBtnEnable, value); } }
+ public string Password { get { return password; } set { SetProperty(ref password, value); } }
+
+ public string Username { get { return username; } set { SetProperty(ref username, value); } }
+
+
+ public bool DrawerPortMsg
+ {
+ get => !_portUtil.drawerSerial.IsOpen;
+ }
+ public bool CanBusPortMsg
+ {
+ get => _portUtil._canBusExsit && !_portUtil.canBusSerial.IsOpen;
+ }
+
+ private bool _fingerMsg;
+
+ public bool FingerMsg
+ {
+ get => _fingerMsg;
+ set => SetProperty(ref _fingerMsg, value);
+ }
+ private DelegateCommand? _loginCommand;
+
+ private DelegateCommand? _exitCommand;
+
+ public DelegateCommand LoginCommand =>
+_loginCommand ??= new DelegateCommand(Login);
+
+ public DelegateCommand ExitCommand =>
+_exitCommand ??= new DelegateCommand(Exit);
+
+ public string Title => throw new NotImplementedException();
+
+ IEventAggregator _eventAggregator;
+ CommonClass _commonClass;
+ public SecondCheckDialogViewModel(IEventAggregator eventAggregator, CommonClass commonClass, PortUtil portUtil)
+ {
+ _portUtil = portUtil;
+ _eventAggregator = eventAggregator;
+ _commonClass = commonClass;
+ }
+ void Login()
+ {
+ LoginBtnEnable = false;
+ if (!string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
+ {
+ if (Username.Equals("hkcadmin") && Password.Equals("hkc123"))
+ {
+ ObservableCollection defaultAll = RoleManagerWindowViewModel.defaultAll;
+ PremissionDm[] a = new PremissionDm[defaultAll.Count];
+ Array.Copy(defaultAll.ToArray(), 0, a, 0, defaultAll.Count);
+ a[4].Children.Add(new PremissionDm()
+ {
+ Id = 54,
+ PremissionName = "调试页面",
+ PremissionPath = "DebugWindow",
+ });
+ //添加参数,键值对格式
+ keys.Add("operator", new UserList()
+ {
+ UserName = Username,
+ Nickname = "华康测试账号",
+ Id = 9999,
+ Role = new RoleDm()
+ {
+ Id = 9999,
+ RoleName = "hkcadmin",
+ Permissions = a.ToList()
+ },
+ });
+ _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys);
+ }
+ else
+ {
+ UserList userList = SqlSugarHelper.Db.Queryable()
+
+ .Includes(u => u.Role)
+ .InnerJoin((u, r) => u.RoleId == r.Id)
+ .First(u => u.UserName == username && ConfigurationManager.AppSettings["machineId"].ToString().Equals(u.MachineId));
+ if (userList == null)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "无此用户",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ Username = "";
+ Password = "";
+ }
+ else if (userList.Role == null)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "用户还未设置权限,请联系管理员",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ Username = "";
+ Password = "";
+ }
+ else
+ {
+ if (userList.PassWord == MD5.GetMD5Hash(Password))
+ {
+
+ SetUser(userList);
+ }
+ else
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "密码错误",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ Password = "";
+ }
+ }
+ }
+ }
+ else
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "请输入账号或密码",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ LoginBtnEnable = true;
+ }
+ public void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback)
+ {
+ continuationCallback(true);
+ }
+
+ public bool IsNavigationTarget(NavigationContext navigationContext)
+ {
+ return true;
+ }
+ private NavigationParameters keys = new NavigationParameters();
+
+ public event Action RequestClose;
+
+ void SetUser(UserList user)
+ {
+ // 单人登录模式
+ if (SingleLogin)
+ {
+ //添加参数,键值对格式
+ keys.Add("operator", user);
+ RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+ }
+ // 双人登录模式
+ else
+ {
+ // 如果已经录入了发药人,已经有一个用户登录
+ if (keys.ContainsKey("operator"))
+ {
+ if (keys.GetValue("operator").Id != user.Id)
+ {
+ keys.Add("reviewer", user);
+ RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+ }
+ else
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "该发药人账号已登录,请输入不同账号",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ }
+ // 如果已经录入了审核人, 已经有一个用户登录
+ else if (keys.ContainsKey("reviewer"))
+ {
+ if (keys.GetValue("reviewer").Id != user.Id)
+ {
+ keys.Add("operator", user);
+ RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+ }
+ else
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "该审核人账号已登录,请输入不同账号",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ }
+ // 第一个用户登录
+ else
+ {
+ if (firstLogin.Equals("operator"))
+ {
+ keys.Add("operator", user);
+ }
+ else
+ {
+ keys.Add("reviewer", user);
+ }
+ Username = string.Empty;
+ Password = string.Empty;
+ }
+ }
+ }
+
+ void Exit()
+ {
+ RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+ }
+ void LoginEvent(FingerprintMsg msg)
+ {
+ logger.Info(msg.ToString());
+ if (msg.Message.Equals("CONNECT"))
+ {
+ FingerMsg = !msg.Result;
+ }
+ if (LoginBtnEnable)
+ {
+ if (msg.Message.Equals("LOGIN"))
+ {
+ UserList userList = SqlSugarHelper.Db.Queryable()
+
+ .Includes(u => u.Role)
+ .First(u => u.Id == msg.Id);
+
+ if (userList == null)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "无此用户",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ Username = "";
+ Password = "";
+ }
+ else if (userList.Role == null)
+ {
+ AlertMsg alertMsg = new AlertMsg
+ {
+ Message = "用户还未设置权限,请联系管理员",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ Username = "";
+ Password = "";
+ }
+ else
+ {
+ SetUser(userList);
+ }
+ }
+ }
+
+ }
+
+ public bool CanCloseDialog()
+ {
+ return true;
+ }
+
+ public void OnDialogClosed()
+ {
+ _eventAggregator.GetEvent().Unsubscribe(LoginEvent);
+ }
+
+ public void OnDialogOpened(IDialogParameters parameters)
+ {
+ FingerMsg = false;
+ _eventAggregator.GetEvent().Subscribe(LoginEvent);
+ }
+ }
+}
diff --git a/DM_Weight/ViewModels/SelfTakeDrugWindowViewModel.cs b/DM_Weight/ViewModels/SelfTakeDrugWindowViewModel.cs
index 178d03f..318dd79 100644
--- a/DM_Weight/ViewModels/SelfTakeDrugWindowViewModel.cs
+++ b/DM_Weight/ViewModels/SelfTakeDrugWindowViewModel.cs
@@ -20,7 +20,7 @@ namespace DM_Weight.ViewModels
{
IDialogService _dialogService;
IEventAggregator _eventAggregator;
-
+ CommonClass _commonClass;
public static List StaticSelects = new()
{
new OrderTakeSelect
@@ -45,10 +45,11 @@ namespace DM_Weight.ViewModels
}
};
- public SelfTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator)
+ public SelfTakeDrugWindowViewModel(IDialogService DialogService, IEventAggregator eventAggregator, CommonClass commonClass)
{
_dialogService = DialogService;
- _eventAggregator= eventAggregator;
+ _eventAggregator = eventAggregator;
+ _commonClass = commonClass;
}
@@ -99,12 +100,38 @@ namespace DM_Weight.ViewModels
public List ChannelStocks { get { return _channelStocks; } set { SetProperty(ref _channelStocks, value); } }
- public DelegateCommand OpenSelfDialog
+ private DelegateCommand _openSelfDialog;
+ public DelegateCommand OpenSelfDialog => _openSelfDialog ??= new DelegateCommand(OpenSelfDialogMethod);
+ bool secondCheckFlag = true;
+ public async void OpenSelfDialogMethod()
{
- get => new DelegateCommand(() =>
+ List takeChannels = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
+ if (takeChannels.Count > 0)
{
- List takeChannels = ChannelStocks.FindAll(it => it.TakeQuantity > 0).ToList();
- if (takeChannels.Count > 0)
+
+ //如果二次验证开启则需要二次验证
+ int loginCheck = Convert.ToInt32(_commonClass.ReadAppSetting("secondCheck"));
+ if (loginCheck == 1)
+ {
+ // 此处延时1毫秒,等待页面渲染
+ await Task.Delay(TimeSpan.FromMilliseconds(1));
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "SecondCheckDialog", null, CheckDoDialogResult, "RootDialog");
+ if (secondCheckFlag)
+ {
+ takeChannels.Sort((a, b) =>
+ {
+ if ((a.DrawerNo - b.DrawerNo) == 0)
+ {
+ return a.ColNo - b.ColNo;
+ }
+ return a.DrawerNo - b.DrawerNo;
+ });
+ DialogParameters dialogParameters = new DialogParameters();
+ dialogParameters.Add("ChannelStocks", takeChannels);
+ DialogServiceExtensions.ShowDialogHost(_dialogService, "SelfTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
+ }
+ }
+ else
{
takeChannels.Sort((a, b) =>
{
@@ -118,19 +145,31 @@ namespace DM_Weight.ViewModels
dialogParameters.Add("ChannelStocks", takeChannels);
DialogServiceExtensions.ShowDialogHost(_dialogService, "SelfTakeDialog", dialogParameters, DoDialogResult, "RootDialog");
}
- else
+ }
+ else
+ {
+ AlertMsg alertMsg = new AlertMsg
{
- AlertMsg alertMsg = new AlertMsg
- {
- Message = "请填写取药数量",
- Type = MsgType.ERROR
- };
- _eventAggregator.GetEvent().Publish(alertMsg);
- }
-
- });
+ Message = "请填写取药数量",
+ Type = MsgType.ERROR
+ };
+ _eventAggregator.GetEvent().Publish(alertMsg);
+ }
+ }
+ private void CheckDoDialogResult(IDialogResult dialogResult)
+ {
+ // 委托 被动执行 被子窗口执行
+ // dialogResult 第一方面可以拿到任意参数 第二方面 可判断关闭状态
+ if (dialogResult.Result == ButtonResult.OK)
+ {
+ secondCheckFlag = true;
+ }
+ else
+ {
+ secondCheckFlag = false;
+ }
+ //MessageBox.Show("返回值:" + dialogResult.Result.ToString());
}
-
private void DoDialogResult(IDialogResult dialogResult)
{
// 委托 被动执行 被子窗口执行
diff --git a/DM_Weight/ViewModels/SettingWindowViewModel.cs b/DM_Weight/ViewModels/SettingWindowViewModel.cs
index 5ea9ec4..f56a6f6 100644
--- a/DM_Weight/ViewModels/SettingWindowViewModel.cs
+++ b/DM_Weight/ViewModels/SettingWindowViewModel.cs
@@ -39,15 +39,37 @@ namespace DM_Weight.ViewModels
get => _firstLogin; set => SetProperty(ref _firstLogin, value);
}
-
+ //二次验证开
+ private bool _secondLoginOpen=true;
+ public bool SecondLoginOpen
+ {
+ get => _secondLoginOpen; set => SetProperty(ref _secondLoginOpen, value);
+ }
+ //二次验证关
+ private bool _secondLoginClose = true;
+ public bool SecondLoginClose
+ {
+ get => _secondLoginClose; set => SetProperty(ref _secondLoginClose, value);
+ }
+
public SettingWindowViewModel()
{
FirstLogin = ReadAppSetting("firstLogin"); //ConfigurationManager.AppSettings["firstLogin"] ?? "operator";
_defaultLoginMode = ReadAppSetting("loginMode");
_defaultFirstLogin = ReadAppSetting("firstLogin");
- _loginMode= _defaultLoginMode.Equals("2");
+ _loginMode = _defaultLoginMode.Equals("2");
+ int SecondLogin = Convert.ToInt32(ReadAppSetting("secondCheck"));
+ if (SecondLogin == 1)
+ {
+ SecondLoginOpen = true;
+ SecondLoginClose = false;
+ }
+ else
+ {
+ SecondLoginOpen = false;
+ SecondLoginClose = true;
+ }
}
-
public DelegateCommand ResetConfigCommand
{
get => new DelegateCommand(() =>
@@ -67,6 +89,23 @@ namespace DM_Weight.ViewModels
_configuration.Save();
ConfigurationManager.RefreshSection("firstLogin");
}
+ if(SecondLoginOpen)
+ {
+ Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
+ _configuration.AppSettings.Settings["secondCheck"].Value = "1";
+ _configuration.Save();
+ ConfigurationManager.RefreshSection("secondCheck");
+
+ }
+ else
+ {
+ Configuration _configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
+ _configuration.AppSettings.Settings["secondCheck"].Value = "0";
+ _configuration.Save();
+ ConfigurationManager.RefreshSection("secondCheck");
+
+ }
+
});
}
//手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
diff --git a/DM_Weight/Views/Dialog/SecondCheckDialog.xaml b/DM_Weight/Views/Dialog/SecondCheckDialog.xaml
new file mode 100644
index 0000000..09d2d8d
--- /dev/null
+++ b/DM_Weight/Views/Dialog/SecondCheckDialog.xaml
@@ -0,0 +1,206 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DM_Weight/Views/Dialog/SecondCheckDialog.xaml.cs b/DM_Weight/Views/Dialog/SecondCheckDialog.xaml.cs
new file mode 100644
index 0000000..1daa976
--- /dev/null
+++ b/DM_Weight/Views/Dialog/SecondCheckDialog.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace DM_Weight.Views.Dialog
+{
+ ///
+ /// SecondCheckDialog.xaml 的交互逻辑
+ ///
+ public partial class SecondCheckDialog : UserControl
+ {
+ public SecondCheckDialog()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/DM_Weight/Views/SettingWindow.xaml b/DM_Weight/Views/SettingWindow.xaml
index da22f59..76868b5 100644
--- a/DM_Weight/Views/SettingWindow.xaml
+++ b/DM_Weight/Views/SettingWindow.xaml
@@ -33,6 +33,16 @@
Style="{StaticResource MaterialDesignChoiceChipPrimaryListBox}"
IsEnabled="{Binding Path=IsChecked, ElementName=MaterialDesignFilledTextBoxEnabledComboBox}">
+
+
+
+
+
+
diff --git a/DM_Weight/util/CommonClass.cs b/DM_Weight/util/CommonClass.cs
new file mode 100644
index 0000000..567960e
--- /dev/null
+++ b/DM_Weight/util/CommonClass.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace DM_Weight.util
+{
+ public class CommonClass
+ {
+ //手动实现调用配置的逻辑 规避修改配置文件后不起作用的问题
+ public string ReadAppSetting(string key)
+ {
+ string xPath = "/configuration/appSettings//add[@key='" + key + "']";
+ XmlDocument doc = new XmlDocument();
+ string exeFileName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
+ doc.Load(exeFileName + ".dll.config");
+ XmlNode node = doc.SelectSingleNode(xPath);
+ return node.Attributes["value"].Value.ToString();
+ }
+ }
+}