diff --git a/DM_Weight/App.config b/DM_Weight/App.config index 4e54c67..c7db2fb 100644 --- a/DM_Weight/App.config +++ b/DM_Weight/App.config @@ -37,7 +37,7 @@ - + diff --git a/DM_Weight/Common/TemperatureRangeRule.cs b/DM_Weight/Common/TemperatureRangeRule.cs index 111c8b2..7a6786b 100644 --- a/DM_Weight/Common/TemperatureRangeRule.cs +++ b/DM_Weight/Common/TemperatureRangeRule.cs @@ -23,10 +23,17 @@ namespace DM_Weight.Common string[] rang = value.ToString().Split('-'); if (rang.Length >= 2) { - bool bSRange = int.TryParse(rang[0], out int sRange); - bool bERange = int.TryParse(rang[1], out int eRange); + bool bSRange = float.TryParse(rang[0], out float sRange); + bool bERange = float.TryParse(rang[1], out float eRange); if (bSRange && bERange) { + string[] sList= sRange.ToString().Split('.'); + string[] eList= eRange.ToString().Split("."); + if ((sList.Length > 1 && sList[1].Length > 1) || (eList.Length > 1 && eList[1].Length>1)) + { + tips = "小数点后保留1位"; + return new ValidationResult(flag, tips); + } if ((sRange < 2 || eRange > 8||sRange>8||eRange<2)) { tips = "温度区间设置2-8度,请检查输入"; diff --git a/DM_Weight/Finger/FingerprintUtil.cs b/DM_Weight/Finger/FingerprintUtil.cs index 0aae4d8..349ff39 100644 --- a/DM_Weight/Finger/FingerprintUtil.cs +++ b/DM_Weight/Finger/FingerprintUtil.cs @@ -32,10 +32,10 @@ namespace DM_Weight.Finger { _eventAggregator = eventAggregator; logger.Info($"进入构造器,开始连接指纹机"); - Task.Run(() => - { + // Task.Run(() => + //{ ConnectionMain(); - }); + //}); } public void ConnectionMain() diff --git a/DM_Weight/ViewModels/HomeWindowViewModel.cs b/DM_Weight/ViewModels/HomeWindowViewModel.cs index b1f7a2e..68283f8 100644 --- a/DM_Weight/ViewModels/HomeWindowViewModel.cs +++ b/DM_Weight/ViewModels/HomeWindowViewModel.cs @@ -23,6 +23,7 @@ using System.Windows.Threading; using Newtonsoft.Json.Linq; using DM_Weight.msg; using System.Threading; +using DM_Weight.Common; namespace DM_Weight.ViewModels { @@ -301,17 +302,17 @@ namespace DM_Weight.ViewModels _regionManager.RequestNavigate("ContentRegion", "ReturnDrugWindow"); } } - else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow")) - { - //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"])>0) - //{ - // _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow"); - //} - //else - { - _regionManager.RequestNavigate("ContentRegion", "SettingWindow"); - } - } + //else if (SelectedChildMenu.PremissionPath.Equals("SettingMainWindow") || SelectedChildMenu.PremissionPath.Equals("SettingWindow")) + //{ + // if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0) + // { + // _regionManager.RequestNavigate("ContentRegion", "SettingMainWindow"); + // } + // else + // { + // _regionManager.RequestNavigate("ContentRegion", "SettingWindow"); + // } + //} else { _regionManager.RequestNavigate("ContentRegion", SelectedChildMenu.PremissionPath); @@ -341,6 +342,7 @@ namespace DM_Weight.ViewModels private PortUtil _portUtil; //private CHKFunction _chkFunction; IEventAggregator _eventAggregator; + bool IsLeave = false; public HomeWindowViewModel(IRegionManager iRegionManager, PortUtil portUtil, IDialogService dialogService, IUnityContainer container, IEventAggregator eventAggregator) { _portUtil = portUtil; @@ -426,7 +428,7 @@ namespace DM_Weight.ViewModels byte[] data = null; float retT = await _portUtil.GetFridgeTemperature(1); Thread.Sleep(80); - WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃"; + WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃"; } } @@ -438,13 +440,14 @@ namespace DM_Weight.ViewModels byte[] data = null; float retT = await _portUtil.GetFridgeTemperature(1); Thread.Sleep(80); - WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT - 1.5), 2)}℃;"; - if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1) - { - float retTemp = await _portUtil.GetFridgeTemperature(2); - Thread.Sleep(80); - WD += $"{retTemp}℃"; - } + WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃"; + logger.Info(WD); + //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1) + //{ + // float retTemp = await _portUtil.GetFridgeTemperature(2); + // Thread.Sleep(80); + // WD += $"{retTemp}℃"; + //} } } /// @@ -532,7 +535,7 @@ namespace DM_Weight.ViewModels //.ToTree(pd => pd.Children, pd => pd.ParentId, 0); PremissionDmList = premissions; SelectedMenu = premissions[0]; - PreSelectedMenu= premissions[0]; + PreSelectedMenu = premissions[0]; SelectedChildMenu = premissions[0].Children[0]; _regionManager.RequestNavigate("ContentRegion", premissions[0].Children[0].PremissionPath); FindDrawerCount(); @@ -550,7 +553,7 @@ namespace DM_Weight.ViewModels if ((DateTime.Now - _portUtil.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit) { logger.Info($"设备{autoExit}内无人操作,用户【{Operator?.Nickname}】自动退出登录,_portUtil.Operate:{_portUtil.Operate},totalSecond:{(DateTime.Now - _portUtil.dateTime).TotalSeconds},lastInputTime:{CheckComputerFreeState.GetLastInputTime()},autoExit:{autoExit}"); - + Operator = null; Reviewer = null; //Application.Current.Dispatcher.Invoke(() => @@ -648,6 +651,46 @@ namespace DM_Weight.ViewModels ////获取录像机的时间 //_chkFunction.HIK_DVR_TIME(); //_chkFunction.HIKStartDVRRecord(); + + new PromiseUtil().taskAsyncLoop(60000, 0, async (options, next, stop) => + { + try + { + if (!_portUtil.FridgeOperate) + { + string retStr = string.Empty; + byte[] data = null; + float retT = await _portUtil.GetFridgeTemperature(1); + Thread.Sleep(80); + WD = $"恒温冷藏抽屉当前温度:{Math.Round((retT), 2)}℃"; + logger.Info(WD); + //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 1) + //{ + // float retTemp = await _portUtil.GetFridgeTemperature(2); + // Thread.Sleep(80); + // WD += $"{retTemp}℃"; + //} + if (IsLeave) + { + stop(); + } + else + { + next(); + } + } + else + { + stop(); + } + } + catch (Exception ex) + { + logger.Info($"获取冰箱异常:{ex.Message}"); + next(); + } + }); + } //每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建 @@ -659,7 +702,8 @@ namespace DM_Weight.ViewModels //这个方法用于拦截请求 public void OnNavigatedFrom(NavigationContext navigationContext) { - + IsLeave = true; + navigationContext.NavigationService.Region.RegionManager.Regions.Remove(PrismManager.SettingViewRegionName); } } } diff --git a/DM_Weight/ViewModels/LoginWindowViewModel.cs b/DM_Weight/ViewModels/LoginWindowViewModel.cs index e5b9b28..2ef107e 100644 --- a/DM_Weight/ViewModels/LoginWindowViewModel.cs +++ b/DM_Weight/ViewModels/LoginWindowViewModel.cs @@ -191,28 +191,28 @@ _exitCommand ??= new DelegateCommand(Exit); else { //1仅当班人、审核人可登录 - if (LoginUserCheck.Equals("1")) - { - //检查当前登录人是否是值班人 (审核人与发药人) - listHkcChangeShifts = SqlSugarHelper.Db.Queryable() - .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().Publish(alertMsg); - Username = ""; - Password = ""; - return; - } + //if (LoginUserCheck.Equals("1")) + //{ + // //检查当前登录人是否是值班人 (审核人与发药人) + // listHkcChangeShifts = SqlSugarHelper.Db.Queryable() + // .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().Publish(alertMsg); + // Username = ""; + // Password = ""; + // return; + // } - } - } + // } + //} if (userList.PassWord == MD5.GetMD5Hash(Password)) { @@ -247,6 +247,7 @@ _exitCommand ??= new DelegateCommand(Exit); void SetUser(UserList user) { + logger.Info("SetUser"); // 单人登录模式 if (SingleLogin) { @@ -254,6 +255,7 @@ _exitCommand ??= new DelegateCommand(Exit); keys.Add("operator", user); System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() => { + logger.Info("跳转Home"); _regionManager.RequestNavigate("MainRegion", "HomeWindow", keys); })); } @@ -364,6 +366,7 @@ _exitCommand ??= new DelegateCommand(Exit); { FingerMsg = !msg.Result; } + logger.Info($"LoginBtnEnable:{LoginBtnEnable}"); if (LoginBtnEnable) { if (msg.Message.Equals("LOGIN")) @@ -398,28 +401,28 @@ _exitCommand ??= new DelegateCommand(Exit); else { //1仅当班人、审核人可登录 - if (LoginUserCheck.Equals("1")) - { + //if (LoginUserCheck.Equals("1")) + //{ //检查当前登录人是否是值班人 (审核人与发药人) - listHkcChangeShifts = SqlSugarHelper.Db.Queryable() - .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().Publish(alertMsg); - Username = ""; - Password = ""; - return; - } + //listHkcChangeShifts = SqlSugarHelper.Db.Queryable() + // .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().Publish(alertMsg); + // Username = ""; + // Password = ""; + // return; + // } - } - } + //} + //} SetUser(userList); } } diff --git a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs index 9aa6fb5..bdecefa 100644 --- a/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs +++ b/DM_Weight/ViewModels/RoleManagerWindowViewModel.cs @@ -555,18 +555,18 @@ namespace DM_Weight.ViewModels PremissionPath = "RoleManagerWindow", }; PremissionDm sysset3; - //if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0) - //{ - // //有冰箱,需要冰箱设置(两个冰箱) - // sysset3 = new PremissionDm - // { - // Id = 53, - // PremissionName = "设置", - // PremissionPath = "SettingMainWindow", - // }; + if (Convert.ToInt32(ConfigurationManager.AppSettings["hasFridge"]) > 0) + { + //有冰箱,需要冰箱设置(两个冰箱) + sysset3 = new PremissionDm + { + Id = 53, + PremissionName = "设置", + PremissionPath = "SettingMainWindow", + }; - //} - //else + } + else { sysset3 = new PremissionDm { diff --git a/DM_Weight/Views/HomeWindow.xaml b/DM_Weight/Views/HomeWindow.xaml index f10190c..56c76c7 100644 --- a/DM_Weight/Views/HomeWindow.xaml +++ b/DM_Weight/Views/HomeWindow.xaml @@ -123,7 +123,7 @@