diff --git a/DM_Weight/Port/PortUtil.cs b/DM_Weight/Port/PortUtil.cs index edfbea5..d402da0 100644 --- a/DM_Weight/Port/PortUtil.cs +++ b/DM_Weight/Port/PortUtil.cs @@ -635,8 +635,8 @@ namespace DM_Weight.Port private byte[] GetBufferByPort(SerialPort serialPort, int length, int timeout) { byte[] buffer = new byte[length]; - try - { + // try + // { int _length = 0; DateTime start = DateTime.Now; DateTime end = DateTime.Now; @@ -650,11 +650,11 @@ namespace DM_Weight.Port throw new TimeoutException($"串口【{serialPort.PortName}】交互超时"); } serialPort.Read(buffer, 0, length); - } - catch (Exception ex) - { - logger.Error($"GetBufferByPort:{ex.Message}"); - } + // } + // catch (Exception ex) + // { + // logger.Error($"GetBufferByPort:{ex.Message}"); + // } return buffer; } private Task GetBufferByPort(SerialPort serialPort, int length) @@ -1128,8 +1128,8 @@ namespace DM_Weight.Port try { canBusSerial.DiscardInBuffer(); - //byte[] buffer = new byte[] { 0xAA, 0x9A, (byte)(ColNos[0] > 3 ? 2 : 1), 0x00, 0x00, 0x00, 0x00, 0xEE }; - byte[] buffer = new byte[] { 0xAA, 0x9A, 01, (byte)(ColNos[0] > 3 ? 2 : 1), 0x00, 0x00, 0x00, 0xEE }; + byte[] buffer = new byte[] { 0xAA, 0x9A, (byte)(ColNos[0] > 3 ? 2 : 1), 0x00, 0x00, 0x00, 0x00, 0xEE }; + //byte[] buffer = new byte[] { 0xAA, 0x9A, 01, (byte)(ColNos[0] > 3 ? 2 : 1), 0x00, 0x00, 0x00, 0xEE }; canBusSerial.Write(buffer, 0, 8); return await GetBufferByPort(canBusSerial, 8); diff --git a/DM_Weight/ViewModels/AddDrugControlViewModel.cs b/DM_Weight/ViewModels/AddDrugControlViewModel.cs index 7a4d819..adf493b 100644 --- a/DM_Weight/ViewModels/AddDrugControlViewModel.cs +++ b/DM_Weight/ViewModels/AddDrugControlViewModel.cs @@ -296,6 +296,7 @@ namespace DM_Weight.ViewModels ManuNo = it.ManuNo, 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, Quantity = it.AddQuantity, Type = 1, diff --git a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs index 9cbde8f..cb924d7 100644 --- a/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs +++ b/DM_Weight/ViewModels/DrawerAddDrugWindowViewModel.cs @@ -198,6 +198,7 @@ namespace DM_Weight.ViewModels ManuNo = it.ManuNo, 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, Quantity = it.AddQuantity, Type = 1, diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs index fad7459..cec589c 100644 --- a/DM_Weight/ViewModels/HomeWindowViewModel.cs +++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs @@ -21,6 +21,7 @@ using System.Timers; using Unity; using System.Windows.Threading; using Newtonsoft.Json.Linq; +using DM_Weight.msg; namespace DM_Weight.ViewModels { @@ -127,20 +128,20 @@ namespace DM_Weight.ViewModels get { return _selectedMenu; } set { - if (value != null) - { - if (value.PremissionName == "退出") - { - logger.Info($"用户【{Operator?.Nickname}】退出登录"); - Operator = null; - Reviewer = null; - _regionManager.RequestNavigate("MainRegion", "LoginWindow"); - } - else - { - SelectedChildMenu = value.Children[0]; - } - } + //if (value != null) + //{ + // if (value.PremissionName == "退出") + // { + // logger.Info($"用户【{Operator?.Nickname}】退出登录"); + // Operator = null; + // Reviewer = null; + // _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + // } + // else + // { + // SelectedChildMenu = value.Children[0]; + // } + //} SetProperty(ref _selectedMenu, value); } } @@ -162,7 +163,7 @@ namespace DM_Weight.ViewModels } else { - SelectedMenu.Children = SelectedMenu.Children; + //SelectedMenu.Children = SelectedMenu.Children; SelectedChildMenu = SelectedMenu.Children[0]; } } @@ -182,12 +183,14 @@ namespace DM_Weight.ViewModels public bool Is16Drawer { get => _is16Drawer; set => SetProperty(ref _is16Drawer, value); } public bool KeepAlive => false; private PortUtil _portUtil; - public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container) + IEventAggregator _eventAggregator; + public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator) { _portUtil = portUtil; _regionManager = iRegionManager; _dialogService = dialogService; _container = container; + this._eventAggregator = eventAggregator; } public DelegateCommand OpenFingerDialog @@ -276,11 +279,27 @@ namespace DM_Weight.ViewModels } List premissions = UserList.Role.Permissions; - + if (premissions.Count <= 0) + { + Operator = null; + Reviewer = null; + Application.Current.Dispatcher.Invoke(() => + { + _regionManager.RequestNavigate("MainRegion", "LoginWindow"); + }); + AlertMsg alertMsg = new AlertMsg + { + Message = $"用户{UserList.Nickname}或还未设置权限,请联系管理员", + Type = MsgType.ERROR + }; + _eventAggregator.GetEvent().Publish(alertMsg); + return; + } //SqlSugarHelper.Db.SqlQueryable(sql) //.ToTree(pd => pd.Children, pd => pd.ParentId, 0); PremissionDmList = premissions; SelectedMenu = premissions[0]; + SelectedChildMenu = premissions[0].Children[0]; FindDrawerCount(); int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0"); diff --git a/DM_Weight/ViewModels/LoginWindowViewModel.cs b/DM_Weight/ViewModels/LoginWindowViewModel.cs index 9b70830..9af3a31 100644 --- a/DM_Weight/ViewModels/LoginWindowViewModel.cs +++ b/DM_Weight/ViewModels/LoginWindowViewModel.cs @@ -155,7 +155,7 @@ _exitCommand ??= new DelegateCommand(Exit); Username = ""; Password = ""; } - else if (userList.Role == null) + else if (userList.Role == null|| userList.Role.Permissions.Count<=0) { AlertMsg alertMsg = new AlertMsg {