diff --git a/CapMachine.Model/HistoryExp.cs b/CapMachine.Model/HistoryExp.cs
index 253b8ba..d45b44d 100644
--- a/CapMachine.Model/HistoryExp.cs
+++ b/CapMachine.Model/HistoryExp.cs
@@ -57,6 +57,12 @@ namespace CapMachine.Model
[Column(Name = "CapNo", IsNullable = true, StringLength = 150)]
public string? CapNo { get; set; }
+ ///
+ /// 压缩机排量
+ ///
+ [Column(Name = "CapDisplacement", IsNullable = true, StringLength = 100)]
+ public string? CapDisplacement { get; set; }
+
///
/// 制冷剂
///
diff --git a/CapMachine.Wpf/App.xaml.cs b/CapMachine.Wpf/App.xaml.cs
index ada0958..8584f2f 100644
--- a/CapMachine.Wpf/App.xaml.cs
+++ b/CapMachine.Wpf/App.xaml.cs
@@ -268,7 +268,7 @@ namespace CapMachine.Wpf
//给MainView的MainViewFooterContentRegion区域设置FooterView具体的信息
regionManager.RequestNavigate("MainViewFooterContentRegion", nameof(FooterView));
- regionManager.RequestNavigate("MainViewContentRegion", nameof(MonitorView));
+ regionManager.RequestNavigate("MainViewContentRegion", nameof(UserManageView));
//调用首页的INavigationAware 接口做一个初始化操作
if (view.DataContext is INavigationAware navigationAware)
diff --git a/CapMachine.Wpf/Dtos/ExpInfoDto.cs b/CapMachine.Wpf/Dtos/ExpInfoDto.cs
index d97c762..302665c 100644
--- a/CapMachine.Wpf/Dtos/ExpInfoDto.cs
+++ b/CapMachine.Wpf/Dtos/ExpInfoDto.cs
@@ -92,6 +92,16 @@ namespace CapMachine.Wpf.Dtos
set { _CapNo = value; RaisePropertyChanged(); }
}
+ private string? _CapDisplacement;
+ ///
+ /// 压缩机排量
+ ///
+ public string? CapDisplacement
+ {
+ get { return _CapDisplacement; }
+ set { _CapDisplacement = value; RaisePropertyChanged(); }
+ }
+
private string? _RfNo;
///
/// 制冷剂
diff --git a/CapMachine.Wpf/Models/CsvRecordModel.cs b/CapMachine.Wpf/Models/CsvRecordModel.cs
index 5a324be..ecb3ab5 100644
--- a/CapMachine.Wpf/Models/CsvRecordModel.cs
+++ b/CapMachine.Wpf/Models/CsvRecordModel.cs
@@ -227,9 +227,9 @@ namespace CapMachine.Wpf.Models
public double Subcooling { get; set; }
///
- /// 制热量Qh[KW]
+ /// 制热量Qh[W]
///
- [Name("制热量Qh[KW]")]
+ [Name("制热量Qh[W]")]
public double HeatingCapacity { get; set; }
///
@@ -245,9 +245,9 @@ namespace CapMachine.Wpf.Models
public double IsentrpEff { get; set; }
///
- /// 制冷量Qc[KW]
+ /// 制冷量Qc[W]
///
- [Name("制冷量Qc[KW]")]
+ [Name("制冷量Qc[W]")]
public double CoolCapacity { get; set; }
///
diff --git a/CapMachine.Wpf/Models/CsvRecordModelMap.cs b/CapMachine.Wpf/Models/CsvRecordModelMap.cs
index faa257a..a5e929a 100644
--- a/CapMachine.Wpf/Models/CsvRecordModelMap.cs
+++ b/CapMachine.Wpf/Models/CsvRecordModelMap.cs
@@ -49,15 +49,15 @@ namespace CapMachine.Wpf.Models
Map(m => m.LiqRefFlow).Name("液冷媒流量[kg/h]");
Map(m => m.InsRes).Name("绝缘电阻[KΩ]");
- Map(m => m.Superheat).Name("过热度[K]").TypeConverterOption.Format("0.00");
- Map(m => m.Subcooling).Name("过冷度[K]").TypeConverterOption.Format("0.00");
+ Map(m => m.Superheat).Name("过热度[K]").TypeConverterOption.Format("0.0");
+ Map(m => m.Subcooling).Name("过冷度[K]").TypeConverterOption.Format("0.0");
- Map(m => m.HeatingCapacity).Name("制热量Qh[KW]").TypeConverterOption.Format("0.00");
- Map(m => m.COPHeat).Name("压缩机性能系数(制热)").TypeConverterOption.Format("0.00");
- Map(m => m.IsentrpEff).Name("等熵效率ns[%]").TypeConverterOption.Format("0.00");
- Map(m => m.CoolCapacity).Name("制冷量Qc[KW]").TypeConverterOption.Format("0.00");
- Map(m => m.COPCool).Name("压缩机性能系数(制冷)").TypeConverterOption.Format("0.00");
- Map(m => m.VoltricEff).Name("容积效率nv[%]").TypeConverterOption.Format("0.00");
+ Map(m => m.HeatingCapacity).Name("制热量Qh[W]").TypeConverterOption.Format("0");
+ Map(m => m.COPHeat).Name("压缩机性能系数(制热)").TypeConverterOption.Format("0.0");
+ Map(m => m.IsentrpEff).Name("等熵效率ns[%]").TypeConverterOption.Format("0.0");
+ Map(m => m.CoolCapacity).Name("制冷量Qc[W]").TypeConverterOption.Format("0");
+ Map(m => m.COPCool).Name("压缩机性能系数(制冷)").TypeConverterOption.Format("0.0");
+ Map(m => m.VoltricEff).Name("容积效率nv[%]").TypeConverterOption.Format("0.0");
//Map(m => m.PTCFlow).Name("PTC流量[L/min]");
//Map(m => m.PTCEntTemp).Name("PTC入水温度[℃]");
diff --git a/CapMachine.Wpf/Models/LightChart/ChartManager.cs b/CapMachine.Wpf/Models/LightChart/ChartManager.cs
index 4ad5f6a..26ac31b 100644
--- a/CapMachine.Wpf/Models/LightChart/ChartManager.cs
+++ b/CapMachine.Wpf/Models/LightChart/ChartManager.cs
@@ -267,13 +267,13 @@ namespace CapMachine.Wpf.Models.LightChart
case "过冷度[K]":
return CurHistoryData.Select(a => new ChartPoint() { Value = a.Subcooling, Time = a.CreateTime }).OrderBy(a => a.Time).ToList();
- case "制热量Qh[KW]":
+ case "制热量Qh[W]":
return CurHistoryData.Select(a => new ChartPoint() { Value = a.HeatingCapacity, Time = a.CreateTime }).OrderBy(a => a.Time).ToList();
case "压缩机性能系数(制热)":
return CurHistoryData.Select(a => new ChartPoint() { Value = a.COPHeat, Time = a.CreateTime }).OrderBy(a => a.Time).ToList();
case "等熵效率ns[%]":
return CurHistoryData.Select(a => new ChartPoint() { Value = a.IsentrpEff, Time = a.CreateTime }).OrderBy(a => a.Time).ToList();
- case "制冷量Qc[KW]":
+ case "制冷量Qc[W]":
return CurHistoryData.Select(a => new ChartPoint() { Value = a.CoolCapacity, Time = a.CreateTime }).OrderBy(a => a.Time).ToList();
case "压缩机性能系数(制冷)":
return CurHistoryData.Select(a => new ChartPoint() { Value = a.COPCool, Time = a.CreateTime }).OrderBy(a => a.Time).ToList();
diff --git a/CapMachine.Wpf/Services/ConfigService.cs b/CapMachine.Wpf/Services/ConfigService.cs
index 6b0348f..085b2c1 100644
--- a/CapMachine.Wpf/Services/ConfigService.cs
+++ b/CapMachine.Wpf/Services/ConfigService.cs
@@ -144,6 +144,16 @@ namespace CapMachine.Wpf.Services
set { _CurUserDto = value; RaisePropertyChanged(); }
}
+ private bool _IsUserLoggedIn;
+ ///
+ /// 当前用户是否已登录
+ ///
+ public bool IsUserLoggedIn
+ {
+ get { return _IsUserLoggedIn; }
+ set { _IsUserLoggedIn = value; RaisePropertyChanged(); }
+ }
+
public IEventAggregator EventAggregator { get; }
public PPCService PPCService { get; }
public IDialogService DialogService { get; }
diff --git a/CapMachine.Wpf/Services/DataRecordService.cs b/CapMachine.Wpf/Services/DataRecordService.cs
index 39bcab5..5e0eb83 100644
--- a/CapMachine.Wpf/Services/DataRecordService.cs
+++ b/CapMachine.Wpf/Services/DataRecordService.cs
@@ -138,10 +138,10 @@ namespace CapMachine.Wpf.Services
new Columns(){ Name="过热度[K]",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
new Columns(){ Name="过冷度[K]",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
- new Columns(){ Name="制热量Qh[KW]",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
+ new Columns(){ Name="制热量Qh[W]",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
new Columns(){ Name="压缩机性能系数(制热)",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
new Columns(){ Name="等熵效率ns[%]",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
- new Columns(){ Name="制冷量Qc[KW]",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
+ new Columns(){ Name="制冷量Qc[W]",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
new Columns(){ Name="压缩机性能系数(制冷)",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
new Columns(){ Name="容积效率nv[%]",MapType=typeof(float).ToString(),IsIdentity=false,IsPrimary=false},
diff --git a/CapMachine.Wpf/Services/MachineRtDataService.cs b/CapMachine.Wpf/Services/MachineRtDataService.cs
index 11aefbf..be90ef1 100644
--- a/CapMachine.Wpf/Services/MachineRtDataService.cs
+++ b/CapMachine.Wpf/Services/MachineRtDataService.cs
@@ -198,10 +198,10 @@ namespace CapMachine.Wpf.Services
TagManger.AddTag(new Tag("过热度", "过热度[K]", "Superheat", "程序", "", 100, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag("过冷度", "过冷度[K]", "Subcooling", "程序", "", 100, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
- TagManger.AddTag(new Tag("制热量Qh", "制热量Qh[KW]", "HeatingCapacity", "程序", "", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
+ TagManger.AddTag(new Tag("制热量Qh", "制热量Qh[W]", "HeatingCapacity", "程序", "", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag("压缩机性能系数(制热)", "压缩机性能系数(制热)", "COPHeat", "程序", "", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag("等熵效率ns", "等熵效率ns[%]", "IsentrpEff", "程序", "", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
- TagManger.AddTag(new Tag("制冷量Qc", "制冷量Qc[KW]", "CoolCapacity", "程序", "", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
+ TagManger.AddTag(new Tag("制冷量Qc", "制冷量Qc[W]", "CoolCapacity", "程序", "", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag("压缩机性能系数(制冷)", "压缩机性能系数(制冷)", "COPCool", "程序", "", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
TagManger.AddTag(new Tag("容积效率nv", "容积效率nv[%]", "VoltricEff", "程序", "", 1000, 0, 1, "K", new ShortTagValue(), false) { DecimalPoint = 1 });
diff --git a/CapMachine.Wpf/Services/PPCService.cs b/CapMachine.Wpf/Services/PPCService.cs
index b5551f5..2f2ef55 100644
--- a/CapMachine.Wpf/Services/PPCService.cs
+++ b/CapMachine.Wpf/Services/PPCService.cs
@@ -106,10 +106,10 @@ namespace CapMachine.Wpf.Services
Subcool = TagManager.DicTags.GetValueOrDefault("过冷度[K]");
- HeatingCapacity = TagManager.DicTags.GetValueOrDefault("制热量Qh[KW]");
+ HeatingCapacity = TagManager.DicTags.GetValueOrDefault("制热量Qh[W]");
COPHeat = TagManager.DicTags.GetValueOrDefault("压缩机性能系数(制热)");
IsentrpEff = TagManager.DicTags.GetValueOrDefault("等熵效率ns[%]");
- CoolCapacity = TagManager.DicTags.GetValueOrDefault("制冷量Qc[KW]");
+ CoolCapacity = TagManager.DicTags.GetValueOrDefault("制冷量Qc[W]");
COPCool = TagManager.DicTags.GetValueOrDefault("压缩机性能系数(制冷)");
VoltricEff = TagManager.DicTags.GetValueOrDefault("容积效率nv[%]");
diff --git a/CapMachine.Wpf/ViewModels/DialogUserViewModel.cs b/CapMachine.Wpf/ViewModels/DialogUserViewModel.cs
index 0cea35d..f703ba1 100644
--- a/CapMachine.Wpf/ViewModels/DialogUserViewModel.cs
+++ b/CapMachine.Wpf/ViewModels/DialogUserViewModel.cs
@@ -23,6 +23,7 @@ namespace CapMachine.Wpf.ViewModels
FreeSql = freeSql;
this.Mapper = mapper;
MachineRtDataService = machineRtDataService;
+ UserLevelOptions = new ObservableCollection { "操作员", "管理员" };
}
@@ -54,6 +55,11 @@ namespace CapMachine.Wpf.ViewModels
///
public MachineRtDataService MachineRtDataService { get; }
+ ///
+ /// 用户等级可选项
+ ///
+ public ObservableCollection UserLevelOptions { get; }
+
private UserDto _CurSelectedItem;
///
@@ -136,6 +142,7 @@ namespace CapMachine.Wpf.ViewModels
UserDtoItems.Add(new UserDto()
{
IsEnable = true,
+ Level = "操作员"
});
}
@@ -269,6 +276,11 @@ namespace CapMachine.Wpf.ViewModels
MessageBox.Show("请确认等级是否正确", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
return;
}
+ if (!UserLevelOptions.Contains(item.Level))
+ {
+ MessageBox.Show("等级仅支持【操作员】或【管理员】", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
+ return;
+ }
}
//检查数据是否正常
diff --git a/CapMachine.Wpf/ViewModels/MainViewModel.cs b/CapMachine.Wpf/ViewModels/MainViewModel.cs
index 9b37bb1..b3c634e 100644
--- a/CapMachine.Wpf/ViewModels/MainViewModel.cs
+++ b/CapMachine.Wpf/ViewModels/MainViewModel.cs
@@ -6,24 +6,28 @@ using CapMachine.Wpf.Services;
using Prism.Commands;
using Prism.Events;
using Prism.Regions;
+using System;
+using System.Windows;
using System.Windows.Input;
namespace CapMachine.Wpf.ViewModels
{
public class MainViewModel : NavigationViewModel
{
- public MainViewModel(IRegionManager region, INavigationMenuService menuService, SysRunService sysService, IEventAggregator eventAggregator)
+ public MainViewModel(IRegionManager region, INavigationMenuService menuService, SysRunService sysService, IEventAggregator eventAggregator, ConfigService configService)
{
this.region = region;
MenuService = menuService;
SysService = sysService;
EventAggregator = eventAggregator;
+ ConfigService = configService;
NavigateCommand = new DelegateCommand(Navigate);
}
public INavigationMenuService MenuService { get; }
public SysRunService SysService { get; }
public IEventAggregator EventAggregator { get; }
+ public ConfigService ConfigService { get; }
public DelegateCommand NavigateCommand { get; private set; }
private int selectedIndex = -1;
@@ -59,11 +63,43 @@ namespace CapMachine.Wpf.ViewModels
return;
}
+ if (!CanNavigate(item.PageName))
+ {
+ IsTopDrawerOpen = false;
+ return;
+ }
+
NavigatePage(item.PageName);
IsTopDrawerOpen = false;
}
+ ///
+ /// 校验当前页面是否允许导航
+ ///
+ /// 目标页面名称
+ /// true允许导航,false禁止导航
+ private bool CanNavigate(string pageName)
+ {
+ if (string.IsNullOrWhiteSpace(pageName))
+ {
+ return false;
+ }
+
+ if (pageName.Equals("UserManageView", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+
+ if (ConfigService.IsUserLoggedIn)
+ {
+ return true;
+ }
+
+ MessageBox.Show("请先登录用户,再切换到其他界面!", "提示");
+ return false;
+ }
+
private DelegateCommand _TopDrawerCmd;
///
/// 顶部弹窗按钮命令
diff --git a/CapMachine.Wpf/ViewModels/UserManageViewModel.cs b/CapMachine.Wpf/ViewModels/UserManageViewModel.cs
index 54b9c66..45b14fb 100644
--- a/CapMachine.Wpf/ViewModels/UserManageViewModel.cs
+++ b/CapMachine.Wpf/ViewModels/UserManageViewModel.cs
@@ -5,6 +5,7 @@ using CapMachine.Wpf.Services;
using Masuit.Tools;
using Prism.Commands;
using Prism.Events;
+using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
@@ -17,19 +18,21 @@ namespace CapMachine.Wpf.ViewModels
{
public class UserManageViewModel : NavigationViewModel
{
- public UserManageViewModel(IEventAggregator eventAggregator, IFreeSql freeSql, ConfigService configService, IDialogService dialogService)
+ public UserManageViewModel(IEventAggregator eventAggregator, IFreeSql freeSql, ConfigService configService, IDialogService dialogService, IRegionManager regionManager)
{
//事件服务
_EventAggregator = eventAggregator;
FreeSql = freeSql;
ConfigService = configService;
DialogService = dialogService;
+ RegionManager = regionManager;
CurUserDto = new UserDto() { IsEnable = true };
}
private IEventAggregator _EventAggregator { get; set; }
public IFreeSql FreeSql { get; }
public ConfigService ConfigService { get; }
public IDialogService DialogService { get; }
+ public IRegionManager RegionManager { get; }
@@ -81,18 +84,30 @@ namespace CapMachine.Wpf.ViewModels
if (ListUser.FirstOrDefault().Password == CurUserDto.Password.Trim())
{
MessageBox.Show("登录成功!", "提示");
- CurUserDto.Level = ListUser.FirstOrDefault().Level;
+
+ var loginUser = ListUser.FirstOrDefault();
+ CurUserDto.Id = loginUser.Id;
+ CurUserDto.Name = loginUser.Name;
+ CurUserDto.Level = loginUser.Level;
+ CurUserDto.IsEnable = loginUser.IsEnable;
CurUserDto.Password = "";
ConfigService.CurUserDto = CurUserDto;
+ ConfigService.IsUserLoggedIn = true;
+ _UserManageCmd?.RaiseCanExecuteChanged();
+ RegionManager.RequestNavigate("MainViewContentRegion", "MonitorView");
}
else
{
+ ConfigService.IsUserLoggedIn = false;
+ _UserManageCmd?.RaiseCanExecuteChanged();
MessageBox.Show("密码错误!", "提示");
}
}
else
{
+ ConfigService.IsUserLoggedIn = false;
+ _UserManageCmd?.RaiseCanExecuteChanged();
MessageBox.Show("当前用户不存在!", "提示");
}
@@ -115,19 +130,36 @@ namespace CapMachine.Wpf.ViewModels
{
if (_UserManageCmd == null)
{
- _UserManageCmd = new DelegateCommand(() => UserManageCmdMethod());
+ _UserManageCmd = new DelegateCommand(() => UserManageCmdMethod(), () => CanUserManage());
}
return _UserManageCmd;
}
}
+ ///
+ /// 判断当前用户是否可以进行用户管理
+ ///
+ /// true可管理,false不可管理
+ private bool CanUserManage()
+ {
+ return ConfigService.IsUserLoggedIn &&
+ ConfigService.CurUserDto != null &&
+ ConfigService.CurUserDto.Level == "管理员";
+ }
+
///
/// 用户管理
///
///
private void UserManageCmdMethod()
{
- if (CurUserDto != null && CurUserDto.Level == "管理员")
+ if (!ConfigService.IsUserLoggedIn)
+ {
+ MessageBox.Show("请先登录后再进行用户管理!", "提示");
+ return;
+ }
+
+ if (ConfigService.CurUserDto != null && ConfigService.CurUserDto.Level == "管理员")
{
ShowDialogExpInfo();
}
@@ -157,5 +189,15 @@ namespace CapMachine.Wpf.ViewModels
});
}
+
+ ///
+ /// 导航到当前页面时刷新用户管理按钮状态
+ ///
+ /// 导航上下文
+ public override void OnNavigatedTo(NavigationContext navigationContext)
+ {
+ _UserManageCmd?.RaiseCanExecuteChanged();
+ base.OnNavigatedTo(navigationContext);
+ }
}
}
diff --git a/CapMachine.Wpf/Views/DialogExpInfoView.xaml b/CapMachine.Wpf/Views/DialogExpInfoView.xaml
index ae87d4c..b364101 100644
--- a/CapMachine.Wpf/Views/DialogExpInfoView.xaml
+++ b/CapMachine.Wpf/Views/DialogExpInfoView.xaml
@@ -125,6 +125,10 @@
Binding="{Binding CapNo}"
Header="压缩机编号"
IsReadOnly="{Binding Source={StaticResource Proxy}, Path=Data.IsComplete}" />
+
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+