diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index fbb4b445..c1e5a623 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -109,6 +109,8 @@ + + @@ -146,6 +148,7 @@ + @@ -188,6 +191,7 @@ + @@ -212,7 +216,10 @@ PreserveNewest + + + @@ -245,7 +252,6 @@ - diff --git a/BPASmartClient.CustomResource/Fonts/iconfont.ttf b/BPASmartClient.CustomResource/Fonts/iconfont.ttf index a7a3e323..0730867b 100644 Binary files a/BPASmartClient.CustomResource/Fonts/iconfont.ttf and b/BPASmartClient.CustomResource/Fonts/iconfont.ttf differ diff --git a/BPASmartClient.CustomResource/Image/登录界面背景.jpg b/BPASmartClient.CustomResource/Image/登录界面背景.jpg new file mode 100644 index 00000000..ca2431ce Binary files /dev/null and b/BPASmartClient.CustomResource/Image/登录界面背景.jpg differ diff --git a/BPASmartClient.CustomResource/Image/登录界面背景1.jpg b/BPASmartClient.CustomResource/Image/登录界面背景1.jpg new file mode 100644 index 00000000..1eab1f9f Binary files /dev/null and b/BPASmartClient.CustomResource/Image/登录界面背景1.jpg differ diff --git a/BPASmartClient.CustomResource/Image/背景3.jpg b/BPASmartClient.CustomResource/Image/背景3.jpg new file mode 100644 index 00000000..c94e3e9c Binary files /dev/null and b/BPASmartClient.CustomResource/Image/背景3.jpg differ diff --git a/BPASmartClient.CustomResource/Pages/Enums/Permission.cs b/BPASmartClient.CustomResource/Pages/Enums/Permission.cs new file mode 100644 index 00000000..04c560f9 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Enums/Permission.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.CustomResource.Pages.Enums +{ + public enum Permission : int + { + 管理员 = 1, + 操作员 = 2, + 观察员 = 3, + 技术员 = 4 + } +} diff --git a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs index 96bdab04..f24df307 100644 --- a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs +++ b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs @@ -1,5 +1,5 @@ using BPASmartClient.Helper; -using BPASmartClient.Message; +//using BPASmartClient.Message; using BPASmartClient.Model; using System; using System.Collections.Concurrent; @@ -98,7 +98,6 @@ namespace BPASmartClient.CustomResource.Pages.Model AddAction?.Invoke(AlarmInfo);//添加报警通知 ChangeAction?.Invoke();//更改报警通知 - MessageLog.GetInstance.AddDeviceAlarmLogShow(tempAlarm.Info, Guid.NewGuid().ToString()); } } diff --git a/DosingSystem/Model/Config.cs b/BPASmartClient.CustomResource/Pages/Model/Config.cs similarity index 90% rename from DosingSystem/Model/Config.cs rename to BPASmartClient.CustomResource/Pages/Model/Config.cs index 6c4dda70..16abf147 100644 --- a/DosingSystem/Model/Config.cs +++ b/BPASmartClient.CustomResource/Pages/Model/Config.cs @@ -1,4 +1,5 @@ using BPA.Message; +using BPASmartClient.CustomResource.Pages.Enums; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -7,16 +8,14 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BPASmartClient.DosingSystem.Model +namespace BPASmartClient.CustomResource.Pages.Model { public class Config { - private volatile static Config _Instance; public static Config GetInstance => _Instance ?? (_Instance = new Config()); private Config() { } - public void Init() { if (File.Exists("up.hbl")) @@ -43,6 +42,11 @@ namespace BPASmartClient.DosingSystem.Model Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.操作员, UserName = "czy", Password = "123456" }); Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.观察员, UserName = "gcy", Password = "654321" }); Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.技术员, UserName = "jsy", Password = "88888888" }); + SaveUser(); + } + + public void SaveUser() + { File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); } } diff --git a/DosingSystem/Model/Global.cs b/BPASmartClient.CustomResource/Pages/Model/Global.cs similarity index 53% rename from DosingSystem/Model/Global.cs rename to BPASmartClient.CustomResource/Pages/Model/Global.cs index fc697e0c..cd0a6548 100644 --- a/DosingSystem/Model/Global.cs +++ b/BPASmartClient.CustomResource/Pages/Model/Global.cs @@ -1,13 +1,17 @@ -using System; +using BPASmartClient.CustomResource.Pages.Enums; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BPASmartClient.DosingSystem.Model +namespace BPASmartClient.CustomResource.Pages.Model { public class Global { public static UserManager userManager { get; set; } = new UserManager(); + + public static UserInfo userInfo { get; set; } = new UserInfo(); + } } diff --git a/BPASmartClient.CustomResource/Pages/Model/MenuManage.cs b/BPASmartClient.CustomResource/Pages/Model/MenuManage.cs new file mode 100644 index 00000000..143f5b24 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Model/MenuManage.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Collections.ObjectModel; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPASmartClient.CustomResource.Pages.Enums; +using System.Windows; + +namespace BPASmartClient.CustomResource.Pages.Model +{ + /// + /// 在启动界面之前设置菜单项 + /// + public class MenuManage : ObservableObject + { + private volatile static MenuManage _Instance; + public static MenuManage GetInstance => _Instance ?? (_Instance = new MenuManage()); + private MenuManage() { } + + public ObservableCollection menuModels { get; set; } = new ObservableCollection(); + } + + public class MenuModel : ObservableObject + { + /// + /// 主菜单权限 + /// + public Permission[] MainMenuPermission { get { return _mMainMenuPermission; } set { _mMainMenuPermission = value; OnPropertyChanged(); } } + private Permission[] _mMainMenuPermission; + + /// + /// 主菜单图标 + /// + public string MainMenuIcon { get { return _mMainMenuIcon; } set { _mMainMenuIcon = value; OnPropertyChanged(); } } + private string _mMainMenuIcon = string.Empty; + + /// + /// 主菜单名称 + /// + public string MainMenuName { get { return _mMainMenuName; } set { _mMainMenuName = value; OnPropertyChanged(); } } + private string _mMainMenuName = string.Empty; + + /// + /// 别名(英文名) + /// + public string Alias { get { return _mAlias; } set { _mAlias = value; OnPropertyChanged(); } } + private string _mAlias = string.Empty; + + /// + /// 主菜单的显示隐藏设置 + /// + public Visibility MainMenuVisibility { get { return _mMainMenuVisibility; } set { _mMainMenuVisibility = value; OnPropertyChanged(); } } + private Visibility _mMainMenuVisibility; + + /// + /// 子菜单集合 + /// + public ObservableCollection subMenumodels { get; set; } = new ObservableCollection(); + + } + + public class SubMenumodel : ObservableObject + { + /// + /// 子菜单名称 + /// + public string SubMenuName { get { return _mSubMenuName; } set { _mSubMenuName = value; OnPropertyChanged(); } } + private string _mSubMenuName = string.Empty; + + /// + /// 子菜单权限管理 + /// + public Permission[] SubMenuPermission { get { return _mSubMenuPermission; } set { _mSubMenuPermission = value; OnPropertyChanged(); } } + private Permission[] _mSubMenuPermission; + + /// + /// 切换界面路径 + /// + public string ToggleWindowPath { get { return _mToggleWindowPath; } set { _mToggleWindowPath = value; OnPropertyChanged(); } } + private string _mToggleWindowPath = string.Empty; + + /// + /// 程序集名称 + /// + public string AssemblyName { get { return _mAssemblyName; } set { _mAssemblyName = value; OnPropertyChanged(); } } + private string _mAssemblyName = string.Empty; + + /// + /// 子菜单的显示隐藏设置 + /// + public Visibility SubMenuVisibility { get { return _mSubMenuVisibility; } set { _mSubMenuVisibility = value; OnPropertyChanged(); } } + private Visibility _mSubMenuVisibility; + + } + +} diff --git a/BPASmartClient.CustomResource/Pages/Model/MessageLog.cs b/BPASmartClient.CustomResource/Pages/Model/MessageLog.cs new file mode 100644 index 00000000..6205c71f --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Model/MessageLog.cs @@ -0,0 +1,67 @@ +using BPASmartClient.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Collections.ObjectModel; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace BPASmartClient.CustomResource.Pages.Model +{ + public class MessageLog + { + private volatile static MessageLog _Instance; + public static MessageLog GetInstance => _Instance ?? (_Instance = new MessageLog()); + private MessageLog() { } + + public Action UserLog { get; set; } + + public Action RunLog { get; set; } + + public ObservableCollection runLogs { get; set; } = new ObservableCollection(); + + public ObservableCollection userLogs { get; set; } = new ObservableCollection(); + + public void LogSave() + { + Sqlite.GetInstance.Save(); + Sqlite.GetInstance.Save(); + } + + //public void GetLog() + //{ + // Sqlite.GetInstance.GetData(); + // Sqlite.GetInstance.GetData(); + //} + + public void ShowUserLog(string info) + { + UserLog userLog = new UserLog() + { + Date = DateTime.Now.ToString("yyyy-MM-dd"), + Time = DateTime.Now.ToString("HH:mm:ss"), + Permission = Global.userInfo.permission.ToString(), + LogInfo = info + }; + Sqlite.GetInstance.Base.Add(userLog); + Application.Current.Dispatcher.Invoke(new Action(() => { userLogs.Insert(0, userLog); })); + UserLog?.Invoke(info); + } + + public void ShowRunLog(string info) + { + RunLog runLog = new RunLog() + { + Date = DateTime.Now.ToString("yyyy-MM-dd"), + Time = DateTime.Now.ToString("HH:mm:ss"), + RunLogInfo = info + }; + Sqlite.GetInstance.Base.Add(runLog); + Application.Current.Dispatcher.Invoke(new Action(() => { runLogs.Insert(0, runLog); })); + RunLog?.Invoke(info); + } + + + } +} diff --git a/BPASmartClient.CustomResource/Pages/Model/PasswordHelper.cs b/BPASmartClient.CustomResource/Pages/Model/PasswordHelper.cs new file mode 100644 index 00000000..5cf350d7 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Model/PasswordHelper.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace BPASmartClient.CustomResource.Pages.Model +{ + /// + /// 给PasswordBox添加一个可以绑定的附加类 + /// + public class PasswordHelper + { + + static bool IsUpdete = false; + + #region PasswordProperty + public static readonly DependencyProperty PasswordProperty = DependencyProperty.RegisterAttached("Password", typeof(string), + typeof(PasswordHelper), new FrameworkPropertyMetadata("", new PropertyChangedCallback(OnPropertyChanged))); + + + public static string GetPassword(DependencyObject d) + { + return d.GetValue(PasswordProperty).ToString(); + } + + public static void SetPassword(DependencyObject d, string value) + { + d.SetValue(PasswordProperty, value); + } + + private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + PasswordBox password = d as PasswordBox; + password.PasswordChanged -= password_PasswordChanged; + if (!IsUpdete) password.Password = e.NewValue?.ToString(); + password.PasswordChanged += password_PasswordChanged; + } + #endregion + + #region AttachProperty + public static readonly DependencyProperty AttachProperty = DependencyProperty.RegisterAttached("Attach", typeof(bool), + typeof(PasswordHelper), new FrameworkPropertyMetadata(default(bool), new PropertyChangedCallback(OnAttachChanged))); + + public static bool GetAttach(DependencyObject d) + { + return (bool)d.GetValue(AttachProperty); + } + + public static void SetAttach(DependencyObject d, bool value) + { + d.SetValue(AttachProperty, value); + } + + private static void OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + PasswordBox password = d as PasswordBox; + password.PasswordChanged += password_PasswordChanged; + } + + private static void password_PasswordChanged(object sender, RoutedEventArgs e) + { + PasswordBox passwordBox = sender as PasswordBox; + IsUpdete = true; + SetPassword(passwordBox, passwordBox.Password); + IsUpdete = false; + } + + #endregion + } +} diff --git a/BPASmartClient.CustomResource/Pages/Model/RunLog.cs b/BPASmartClient.CustomResource/Pages/Model/RunLog.cs new file mode 100644 index 00000000..f3be25c3 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Model/RunLog.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; + +namespace BPASmartClient.CustomResource.Pages.Model +{ + public class RunLog : ObservableObject + { + [Key] + public int Id { get; set; } + + //public string Date { get { return _mDate; } set { _mDate = value; OnPropertyChanged(); } } + //private string _mDate; + + //public string Time { get { return _mTime; } set { _mTime = value; OnPropertyChanged(); } } + //private string _mTime; + + //public string RunLogInfo { get { return _mRunLogInfo; } set { _mRunLogInfo = value; OnPropertyChanged(); } } + //private string _mRunLogInfo; + + public string Date { get; set; } + + public string Time { get; set; } + + public string RunLogInfo { get; set; } + + } +} diff --git a/BPASmartClient.CustomResource/Pages/Model/UserInfo.cs b/BPASmartClient.CustomResource/Pages/Model/UserInfo.cs new file mode 100644 index 00000000..1164d95f --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Model/UserInfo.cs @@ -0,0 +1,17 @@ +using BPASmartClient.CustomResource.Pages.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.CustomResource.Pages.Model +{ + public class UserInfo + { + public Permission permission { get; set; } + public string UserName { get; set; } + public string Password { get; set; } + + } +} diff --git a/BPASmartClient.CustomResource/Pages/Model/UserLog.cs b/BPASmartClient.CustomResource/Pages/Model/UserLog.cs new file mode 100644 index 00000000..2082d188 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Model/UserLog.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; + +namespace BPASmartClient.CustomResource.Pages.Model +{ + public class UserLog : ObservableObject + { + [Key] + public int Id { get; set; } + + //public string Permission { get { return _mPermission; } set { _mPermission = value; OnPropertyChanged(); } } + //private string _mPermission; + + //public string Date { get { return _mDate; } set { _mDate = value; OnPropertyChanged(); } } + //private string _mDate; + + //public string Time { get { return _mTime; } set { _mTime = value; OnPropertyChanged(); } } + //private string _mTime; + + //public string LogInfo { get { return _mLogInfo; } set { _mLogInfo = value; OnPropertyChanged(); } } + //private string _mLogInfo; + + public string Permission { get; set; } + + public string Date { get; set; } + + public string Time { get; set; } + + public string LogInfo { get; set; } + + } +} diff --git a/BPASmartClient.CustomResource/Pages/Model/UserManager.cs b/BPASmartClient.CustomResource/Pages/Model/UserManager.cs new file mode 100644 index 00000000..258199e9 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/Model/UserManager.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.CustomResource.Pages.Model +{ + public class UserManager + { + public List userInfos { get; set; } = new List(); + } +} diff --git a/BPASmartClient.CustomResource/Pages/View/LoginView.xaml b/BPASmartClient.CustomResource/Pages/View/LoginView.xaml index 0dd17295..e6a01f0f 100644 --- a/BPASmartClient.CustomResource/Pages/View/LoginView.xaml +++ b/BPASmartClient.CustomResource/Pages/View/LoginView.xaml @@ -2,15 +2,17 @@ x:Class="BPASmartClient.CustomResource.Pages.View.LoginView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:common="clr-namespace:BPASmartClient.CustomResource.Pages.Model" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel" Title="LoginView" - Width="800" - Height="450" + Width="500" + Height="300" AllowsTransparency="True" Background="{x:Null}" + Topmost="True" WindowStartupLocation="CenterScreen" WindowStyle="None" mc:Ignorable="d"> @@ -26,9 +28,400 @@ + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml.cs b/BPASmartClient.CustomResource/Pages/View/RunLogView.xaml.cs new file mode 100644 index 00000000..810e1626 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/View/RunLogView.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 BPASmartClient.CustomResource.Pages.View +{ + /// + /// RunLogView.xaml 的交互逻辑 + /// + public partial class RunLogView : UserControl + { + public RunLogView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml b/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml new file mode 100644 index 00000000..75e020c7 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml.cs b/BPASmartClient.CustomResource/Pages/View/UserLogView.xaml.cs new file mode 100644 index 00000000..1149bcbd --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/View/UserLogView.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 BPASmartClient.CustomResource.Pages.View +{ + /// + /// UserLogView.xaml 的交互逻辑 + /// + public partial class UserLogView : UserControl + { + public UserLogView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs index b3c58e0d..1238f0c0 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs @@ -137,4 +137,6 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel } + + } diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs index 0d805e67..9e19a23a 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; +using BPASmartClient.CustomResource.Pages.Model; +using BPASmartClient.Helper; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; @@ -12,7 +15,64 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel { public LoginViewModel() { + LoginCommand = new RelayCommand(() => + { + var res = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == UserName && p.Password == Password); + if (res != null) + { + Global.userInfo.permission = res.permission; + Global.userInfo.UserName = res.UserName; + Global.userInfo.Password = res.Password; + for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++) + { + if (MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuPermission.Contains(res.permission)) + MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Visible; + else + MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; + if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.SubMenuPermission.Contains(res.permission)) == null) + MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; + + for (int m = 0; m < MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.Count; m++) + { + if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuPermission.Contains(res.permission)) + MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Visible; + else + MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Collapsed; + } + } + ActionManage.GetInstance.Send("LoginOk"); + } + else + { + ErrorInfo = "用户名或密码错误!"; + } + + }); + + ExitCommand = new RelayCommand(() => + { + ActionManage.GetInstance.Send("ExitAction"); + }); } + + public RelayCommand LoginCommand { get; set; } + + public RelayCommand ExitCommand { get; set; } + + + + public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } + private string _mErrorInfo; + + + public string UserName { get { return _mUserName; } set { _mUserName = value; OnPropertyChanged(); } } + private string _mUserName = "admin"; + + + public string Password { get { return _mPassword; } set { _mPassword = value; OnPropertyChanged(); } } + private string _mPassword; + + } } diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs new file mode 100644 index 00000000..2416c422 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/ViewModel/MainViewModel.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using BPASmartClient.CustomResource.Pages.Model; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; + +namespace BPASmartClient.CustomResource.Pages.ViewModel +{ + public class MainViewModel : ObservableObject + { + public MainViewModel() + { + NavChangedCommand = new RelayCommand(DoNavChanged); + menuModels = MenuManage.GetInstance.menuModels; + } + public ObservableCollection menuModels { get; set; } + + private void DoNavChanged(object obj) + { + for (int i = 0; i < menuModels.Count; i++) + { + var res = menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.ToggleWindowPath == obj.ToString()); + if (res != null) + { + DisplayName = res.SubMenuName; + var end = res.AssemblyName.Substring(res.AssemblyName.Length - 1); + var start = res.ToggleWindowPath.Substring(0, 1); + bool isAddPoint = end != "." && start != "."; + string point = isAddPoint ? "." : ""; + Type type = Assembly.Load(res.AssemblyName)?.GetType($"{res.AssemblyName }{point}{ res.ToggleWindowPath}"); + ConstructorInfo cti = type?.GetConstructor(System.Type.EmptyTypes); + if (type?.BaseType.Name == "Window") + { + ((Window)cti?.Invoke(null)).ShowDialog(); + break; + } + else if (type?.BaseType.Name == "UserControl") + { + //ConstructorInfo cti = type?.GetConstructor(System.Type.EmptyTypes); + MainContent = (FrameworkElement)cti?.Invoke(null); + break; + } + } + } + } + + public RelayCommand NavChangedCommand { get; set; } + + public FrameworkElement MainContent { get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } } + private FrameworkElement _mMainContent; + + public string DisplayName { get { return _mDisplayName; } set { _mDisplayName = value; OnPropertyChanged(); } } + private string _mDisplayName; + + + + } +} diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/PasswordChangeViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/PasswordChangeViewModel.cs new file mode 100644 index 00000000..2acd2f58 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/ViewModel/PasswordChangeViewModel.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BPASmartClient.CustomResource.Pages.Model; +using BPASmartClient.Helper; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; + +namespace BPASmartClient.CustomResource.Pages.ViewModel +{ + public class PasswordChangeViewModel : ObservableObject + { + public PasswordChangeViewModel() + { + LoginCommand = new RelayCommand(() => + { + if (Global.userInfo.Password == OldPassword) + { + if (NewPassword1 == NewPassword2) + { + Global.userInfo.Password = NewPassword2; + int index = Array.FindIndex(Global.userManager.userInfos.ToArray(), p => p.UserName == Global.userInfo.UserName); + if (index >= 0 && index < Global.userManager.userInfos.Count) + Global.userManager.userInfos.ElementAt(index).Password = NewPassword1; + Config.GetInstance.SaveUser(); + ActionManage.GetInstance.Send("PasswordChangeViewconfirm"); + } + else + { + ErrorInfo = "新密码不匹配"; + } + } + else + { + ErrorInfo = "原密码错误"; + } + }); + + ExitCommand = new RelayCommand(() => + { + ActionManage.GetInstance.Send("PasswordChangeViewCancel"); + }); + } + + public RelayCommand LoginCommand { get; set; } + + public RelayCommand ExitCommand { get; set; } + + + + public string ErrorInfo { get { return _mErrorInfo; } set { _mErrorInfo = value; OnPropertyChanged(); } } + private string _mErrorInfo; + + public string OldPassword { get { return _mOldPassword; } set { _mOldPassword = value; OnPropertyChanged(); } } + private string _mOldPassword; + + + public string NewPassword1 { get { return _mNewPassword1; } set { _mNewPassword1 = value; OnPropertyChanged(); } } + private string _mNewPassword1; + + + public string NewPassword2 { get { return _mNewPassword2; } set { _mNewPassword2 = value; OnPropertyChanged(); } } + private string _mNewPassword2; + + + } +} diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/RunLogViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/RunLogViewModel.cs new file mode 100644 index 00000000..d70defe2 --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/ViewModel/RunLogViewModel.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using System.Collections.ObjectModel; +using BPASmartClient.CustomResource.Pages.Model; +using System.Windows; +using BPASmartClient.Helper; + +namespace BPASmartClient.CustomResource.Pages.ViewModel +{ + public class RunLogViewModel : ObservableObject + { + public RunLogViewModel() + { + Sqlite.GetInstance.Save(); + SwitchCommand = new RelayCommand(() => + { + if (ButContent == "历史日志") + { + GetHistoryRunLog(); + CurrentDataVis = Visibility.Hidden; + HistoryDataVis = Visibility.Visible; + IsVisibility = Visibility.Visible; + ControlButText = "开始查询"; + ButContent = "实时日志"; + return; + } + + if (ButContent == "实时日志") + { + HistoryDataVis = Visibility.Hidden; + CurrentDataVis = Visibility.Visible; + IsVisibility = Visibility.Hidden; + ButContent = "历史日志"; + return; + } + + }); + + ControlCommand = new RelayCommand(() => + { + + if (ControlButText == "报警复位") return; + if (ControlButText == "开始查询") + { + var lists = Sqlite.GetInstance.GetData(); + var res = lists.Where(p => Convert.ToDateTime(p.Date) >= StartDateTime && Convert.ToDateTime(p.Date) <= EndDateTime).ToList(); + if (res != null) + { + HistoryRunLog.Clear(); + foreach (var item in res) + { + HistoryRunLog.Add(item); + } + } + } + + }); + } + + private void GetHistoryRunLog() + { + var data = Sqlite.GetInstance.GetData(); + if (data != null) + { + HistoryRunLog.Clear(); + foreach (var item in data) + { + int day = DateTime.Now.Subtract(Convert.ToDateTime(item.Date)).Days; + if (day == 0) + { + HistoryRunLog.Add(item); + } + } + } + } + + public RelayCommand SwitchCommand { get; set; } + + public RelayCommand ControlCommand { get; set; } + + public Visibility CurrentDataVis { get { return _mCurrentDataVis; } set { _mCurrentDataVis = value; OnPropertyChanged(); } } + private Visibility _mCurrentDataVis = Visibility.Visible; + + public Visibility HistoryDataVis { get { return _mHistoryDataVis; } set { _mHistoryDataVis = value; OnPropertyChanged(); } } + private Visibility _mHistoryDataVis = Visibility.Hidden; + + /// + /// 是否显示 + /// + public Visibility IsVisibility { get { return _mIsVisibility; } set { _mIsVisibility = value; OnPropertyChanged(); } } + private Visibility _mIsVisibility = Visibility.Hidden; + + /// + /// 文字显示 + /// + public string ButContent { get { return _mButContent; } set { _mButContent = value; OnPropertyChanged(); } } + private string _mButContent = "历史日志"; + + /// + /// 控制按钮文本显示 + /// + public string ControlButText { get { return _mControlButText; } set { _mControlButText = value; OnPropertyChanged(); } } + private string _mControlButText = "报警复位"; + + /// + /// 开始时间 + /// + public DateTime StartDateTime { get { return _mStartDateTime; } set { _mStartDateTime = value; OnPropertyChanged(); } } + private DateTime _mStartDateTime = DateTime.Now; + + /// + /// 结束时间 + /// + public DateTime EndDateTime { get { return _mEndDateTime; } set { _mEndDateTime = value; OnPropertyChanged(); } } + private DateTime _mEndDateTime = DateTime.Now; + + public ObservableCollection HistoryRunLog { get; set; } = new ObservableCollection(); + + public ObservableCollection Log { get; set; } = MessageLog.GetInstance.runLogs; + } +} diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/UserLogViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/UserLogViewModel.cs new file mode 100644 index 00000000..e901492f --- /dev/null +++ b/BPASmartClient.CustomResource/Pages/ViewModel/UserLogViewModel.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System.Collections.ObjectModel; +using BPASmartClient.CustomResource.Pages.Model; +using System.Windows; +using Microsoft.Toolkit.Mvvm.Input; +using BPASmartClient.Helper; + +namespace BPASmartClient.CustomResource.Pages.ViewModel +{ + public class UserLogViewModel : ObservableObject + { + public UserLogViewModel() + { + Sqlite.GetInstance.Save(); + UserLogs = MessageLog.GetInstance.userLogs; + SwitchCommand = new RelayCommand(() => + { + if (ButContent == "历史日志") + { + GetHistoryUserLog(); + CurrentDataVis = Visibility.Hidden; + HistoryDataVis = Visibility.Visible; + IsVisibility = Visibility.Visible; + ControlButText = "开始查询"; + ButContent = "实时日志"; + return; + } + + if (ButContent == "实时日志") + { + HistoryDataVis = Visibility.Hidden; + CurrentDataVis = Visibility.Visible; + IsVisibility = Visibility.Hidden; + ButContent = "历史日志"; + return; + } + + }); + + ControlCommand = new RelayCommand(() => + { + if (ControlButText == "报警复位") return; + if (ControlButText == "开始查询") + { + var lists = Sqlite.GetInstance.GetData(); + var res = lists.Where(p => Convert.ToDateTime(p.Date) >= StartDateTime && Convert.ToDateTime(p.Date) <= EndDateTime).ToList(); + if (res != null) + { + HistoryUserLog.Clear(); + foreach (var item in res) + { + HistoryUserLog.Add(item); + } + } + } + }); + } + + private void GetHistoryUserLog() + { + var data = Sqlite.GetInstance.GetData(); + if (data != null) + { + HistoryUserLog.Clear(); + foreach (var item in data) + { + int day = DateTime.Now.Subtract(Convert.ToDateTime(item.Date)).Days; + if (day == 0) + { + HistoryUserLog.Add(item); + } + } + } + } + + public RelayCommand SwitchCommand { get; set; } + + public RelayCommand ControlCommand { get; set; } + + public Visibility CurrentDataVis { get { return _mCurrentDataVis; } set { _mCurrentDataVis = value; OnPropertyChanged(); } } + private Visibility _mCurrentDataVis = Visibility.Visible; + + public Visibility HistoryDataVis { get { return _mHistoryDataVis; } set { _mHistoryDataVis = value; OnPropertyChanged(); } } + private Visibility _mHistoryDataVis = Visibility.Hidden; + + /// + /// 是否显示 + /// + public Visibility IsVisibility { get { return _mIsVisibility; } set { _mIsVisibility = value; OnPropertyChanged(); } } + private Visibility _mIsVisibility = Visibility.Hidden; + + /// + /// 文字显示 + /// + public string ButContent { get { return _mButContent; } set { _mButContent = value; OnPropertyChanged(); } } + private string _mButContent = "历史日志"; + + /// + /// 控制按钮文本显示 + /// + public string ControlButText { get { return _mControlButText; } set { _mControlButText = value; OnPropertyChanged(); } } + private string _mControlButText = "报警复位"; + + /// + /// 开始时间 + /// + public DateTime StartDateTime { get { return _mStartDateTime; } set { _mStartDateTime = value; OnPropertyChanged(); } } + private DateTime _mStartDateTime = DateTime.Now; + + /// + /// 结束时间 + /// + public DateTime EndDateTime { get { return _mEndDateTime; } set { _mEndDateTime = value; OnPropertyChanged(); } } + private DateTime _mEndDateTime = DateTime.Now; + + public ObservableCollection HistoryUserLog { get; set; } = new ObservableCollection(); + + public ObservableCollection UserLogs { get; set; } + + } +} diff --git a/BPASmartClient.ZhuoDian/App.xaml b/BPASmartClient.ZhuoDian/App.xaml new file mode 100644 index 00000000..ad5046f6 --- /dev/null +++ b/BPASmartClient.ZhuoDian/App.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.ZhuoDian/App.xaml.cs b/BPASmartClient.ZhuoDian/App.xaml.cs new file mode 100644 index 00000000..14c09ddd --- /dev/null +++ b/BPASmartClient.ZhuoDian/App.xaml.cs @@ -0,0 +1,173 @@ +using BPASmartClient.CustomResource.Pages.Enums; +using BPASmartClient.CustomResource.Pages.Model; +using BPASmartClient.CustomResource.Pages.View; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace BPASmartClient.ZhuoDian +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + MenuInit(); + DataInit(); + + MainView mv = new MainView(); + LoginView lv = new LoginView(); + var res = lv.ShowDialog(); + if (res != null && res == true) + mv.Show(); + else + mv.Close(); + } + + protected override void OnExit(ExitEventArgs e) + { + base.OnExit(e); + MessageLog.GetInstance.LogSave(); + } + + private void MenuInit() + { + + #region 配方管理菜单 + ObservableCollection RecipeManage = new ObservableCollection(); + RecipeManage.Add(new SubMenumodel() + { + SubMenuName = "配方管理", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.RecipeSettingsView" + }); + + RecipeManage.Add(new SubMenumodel() + { + SubMenuName = "配方下发", + SubMenuPermission = new Permission[] { Permission.操作员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.RecipeControlView" + }); + + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "配方管理", + Alias = "Recipe Management", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员 }, + subMenumodels = RecipeManage, + }); + #endregion + + #region 消息日志 + ObservableCollection InfoLog = new ObservableCollection(); + InfoLog.Add(new SubMenumodel() + { + SubMenuName = "操作日志", + SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.UserLogView" + }); + + InfoLog.Add(new SubMenumodel() + { + SubMenuName = "运行日志", + SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.RunLogView" + }); + + InfoLog.Add(new SubMenumodel() + { + SubMenuName = "报警记录", + SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.AlarmView" + }); + + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "消息日志", + Alias = "Message Log", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + subMenumodels = InfoLog, + }); + #endregion + + #region 硬件设备监控 + ObservableCollection DeviceMonitor = new ObservableCollection(); + DeviceMonitor.Add(new SubMenumodel() + { + SubMenuName = "原料设备列表", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.DeviceListView" + }); + + DeviceMonitor.Add(new SubMenumodel() + { + SubMenuName = "设备状态", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.HardwareStatusView" + }); + + + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "设备监控", + Alias = "Device Monitor", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + subMenumodels = DeviceMonitor, + }); + #endregion + + #region 用户管理 + ObservableCollection UserManager = new ObservableCollection(); + UserManager.Add(new SubMenumodel() + { + SubMenuName = "用户登录", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.LoginView" + }); + + UserManager.Add(new SubMenumodel() + { + SubMenuName = "密码修改", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.PasswordChangeView" + }); + + + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "用户管理", + Alias = "User Management", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + subMenumodels = UserManager, + }); + #endregion + } + + private void DataInit() + { + Config.GetInstance.Init(); + } + + } +} diff --git a/BPASmartClient.ZhuoDian/AssemblyInfo.cs b/BPASmartClient.ZhuoDian/AssemblyInfo.cs new file mode 100644 index 00000000..8b5504ec --- /dev/null +++ b/BPASmartClient.ZhuoDian/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/BPASmartClient.ZhuoDian/BPASmartClient.ZhuoDian.csproj b/BPASmartClient.ZhuoDian/BPASmartClient.ZhuoDian.csproj new file mode 100644 index 00000000..f15bf5a1 --- /dev/null +++ b/BPASmartClient.ZhuoDian/BPASmartClient.ZhuoDian.csproj @@ -0,0 +1,23 @@ + + + + WinExe + net6.0-windows + enable + true + + + + + + + + + + + + + + + + diff --git a/DosingSystem/App.xaml b/DosingSystem/App.xaml index adb19107..b4732c63 100644 --- a/DosingSystem/App.xaml +++ b/DosingSystem/App.xaml @@ -23,6 +23,7 @@ + diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index f8df83f7..e590be97 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -1,12 +1,17 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Configuration; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Windows; +using BPASmartClient.CustomResource.Pages.Enums; +using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.CustomResource.Pages.View; +using BPASmartClient.DosingSystem.Model; using BPASmartClient.DosingSystem.View; +using BPASmartClient.Helper; namespace BPASmartClient.DosingSystem { @@ -15,15 +20,169 @@ namespace BPASmartClient.DosingSystem /// public partial class App : Application { - MainWindow mw = new MainWindow(); - protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); - mw.Show(); + MenuInit(); + DataInit(); + + MainView mv = new MainView(); + LoginView lv = new LoginView(); + var res = lv.ShowDialog(); + if (res != null && res == true) + mv.Show(); + else + mv.Close(); + + + + //MainWindow mw = new MainWindow(); //LoginView lv = new LoginView(); //var res = lv.ShowDialog(); - //if (res != null && res == true) mw.Show(); + //if (res != null && res == true) + // mw.Show(); + //else + // mw.Close(); + } + + protected override void OnExit(ExitEventArgs e) + { + base.OnExit(e); + Json.Save(); + MessageLog.GetInstance.LogSave(); + } + + private void MenuInit() + { + + #region 配方管理菜单 + ObservableCollection RecipeManage = new ObservableCollection(); + RecipeManage.Add(new SubMenumodel() + { + SubMenuName = "配方管理", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.RecipeSettingsView" + }); + + RecipeManage.Add(new SubMenumodel() + { + SubMenuName = "配方下发", + SubMenuPermission = new Permission[] { Permission.操作员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.RecipeControlView" + }); + + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "配方管理", + Alias = "Recipe Management", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员 }, + subMenumodels = RecipeManage, + }); + #endregion + + #region 消息日志 + ObservableCollection InfoLog = new ObservableCollection(); + InfoLog.Add(new SubMenumodel() + { + SubMenuName = "操作日志", + SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.UserLogView" + }); + + InfoLog.Add(new SubMenumodel() + { + SubMenuName = "运行日志", + SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.RunLogView" + }); + + InfoLog.Add(new SubMenumodel() + { + SubMenuName = "报警记录", + SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.AlarmView" + }); + + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "消息日志", + Alias = "Message Log", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + subMenumodels = InfoLog, + }); + #endregion + + #region 硬件设备监控 + ObservableCollection DeviceMonitor = new ObservableCollection(); + DeviceMonitor.Add(new SubMenumodel() + { + SubMenuName = "原料设备列表", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.DeviceListView" + }); + + DeviceMonitor.Add(new SubMenumodel() + { + SubMenuName = "设备状态", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.DosingSystem", + ToggleWindowPath = "View.HardwareStatusView" + }); + + + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "设备监控", + Alias = "Device Monitor", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + subMenumodels = DeviceMonitor, + }); + #endregion + + #region 用户管理 + ObservableCollection UserManager = new ObservableCollection(); + UserManager.Add(new SubMenumodel() + { + SubMenuName = "用户登录", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.LoginView" + }); + + UserManager.Add(new SubMenumodel() + { + SubMenuName = "密码修改", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.PasswordChangeView" + }); + + + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "用户管理", + Alias = "User Management", + MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + subMenumodels = UserManager, + }); + #endregion } + + private void DataInit() + { + Config.GetInstance.Init(); + Json.Read(); + } + } } diff --git a/DosingSystem/Model/ActionMenu.cs b/DosingSystem/Model/ActionMenu.cs index 428bede8..00113337 100644 --- a/DosingSystem/Model/ActionMenu.cs +++ b/DosingSystem/Model/ActionMenu.cs @@ -13,8 +13,8 @@ namespace BPASmartClient.DosingSystem.Model public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } } private string _mCommandParameter; - public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } } - private Permission[] _mpermission; + //public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } } + //private Permission[] _mpermission; public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } private string _mMenuName; diff --git a/DosingSystem/Model/RecipeModel.cs b/DosingSystem/Model/RecipeModel.cs index ce4513c3..203d4658 100644 --- a/DosingSystem/Model/RecipeModel.cs +++ b/DosingSystem/Model/RecipeModel.cs @@ -15,6 +15,7 @@ namespace BPASmartClient.DosingSystem.Model /// public class RecipeModel : ObservableObject { + [Newtonsoft.Json.JsonIgnore] public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } private bool _mIsEnable = true; diff --git a/DosingSystem/Model/UserManager.cs b/DosingSystem/Model/UserManager.cs deleted file mode 100644 index 234eb09e..00000000 --- a/DosingSystem/Model/UserManager.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BPASmartClient.DosingSystem.Model -{ - public class UserManager - { - public List userInfos { get; set; } = new List(); - } - - public class UserInfo - { - public Permission permission { get; set; } - public string UserName { get; set; } - public string Password { get; set; } - - } - - public enum Permission : int - { - 管理员 = 1, - 操作员 = 2, - 观察员 = 3, - 技术员 = 4 - } - -} diff --git a/DosingSystem/View/DeviceListView.xaml b/DosingSystem/View/DeviceListView.xaml index 002d3266..f232d604 100644 --- a/DosingSystem/View/DeviceListView.xaml +++ b/DosingSystem/View/DeviceListView.xaml @@ -101,7 +101,6 @@ Foreground="#00BEFA" Text="{Binding DeviceName}" /> - - + diff --git a/DosingSystem/ViewModel/MainViewModel.cs b/DosingSystem/ViewModel/MainViewModel.cs index d8085a54..abba5ca8 100644 --- a/DosingSystem/ViewModel/MainViewModel.cs +++ b/DosingSystem/ViewModel/MainViewModel.cs @@ -18,28 +18,28 @@ namespace BPASmartClient.DosingSystem.ViewModel { public class MainViewModel : ObservableObject { - ObservableCollection menus = new ObservableCollection(); - - private Permission _permission; - public Permission permission - { - get { return _permission; } - set - { - var res = menus.Where(p => Array.FindIndex(p.permission, s => s == value) >= 0).ToList(); - if (res != null && res.Count > 0) - { - Menus.Clear(); - res.ForEach((item) => { Menus.Add(item); }); - } - _permission = value; - } - } + //ObservableCollection menus = new ObservableCollection(); + + //private Permission _permission; + //public Permission permission + //{ + // get { return _permission; } + // set + // { + // var res = menus.Where(p => Array.FindIndex(p.permission, s => s == value) >= 0).ToList(); + // if (res != null && res.Count > 0) + // { + // Menus.Clear(); + // res.ForEach((item) => { Menus.Add(item); }); + // } + // _permission = value; + // } + //} public MainViewModel() { - Json.Read(); + //Json.Read(); TogglePag = new RelayCommand(DoNavChanged); Login = new RelayCommand(() => { DoNavChanged("BPASmartClient.DosingSystem.View.AdminstratorsView_用户登录"); UserManagement = false; }); PasswordChange = new RelayCommand(() => @@ -53,11 +53,11 @@ namespace BPASmartClient.DosingSystem.ViewModel //DoNavChanged("LoginView.退出登录"); UserManagement = false; }); - Config.GetInstance.Init(); + //Config.GetInstance.Init(); LoginRegister(); MenuInit(); - permission = Permission.管理员; - if (Menus.Count > 0) DoNavChanged(Menus.ElementAt(0).CommandParameter); + //permission = Permission.管理员; + //if (Menus.Count > 0) DoNavChanged(Menus.ElementAt(0).CommandParameter); DeviceInquire.GetInstance.Init(); } @@ -66,55 +66,55 @@ namespace BPASmartClient.DosingSystem.ViewModel { ActionManage.GetInstance.Register(new Func((o) => { - if (o != null && o is string str) - { - var strs = str.Split("-="); - if (strs != null && strs.Length == 3) - { - var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0]); - if (us != null && strs[1] == us.Password && strs[2] == us.permission.ToString()) - { - permission = us.permission; - return string.Empty; - } - } - } + //if (o != null && o is string str) + //{ + // var strs = str.Split("-="); + // if (strs != null && strs.Length == 3) + // { + // var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0]); + // if (us != null && strs[1] == us.Password && strs[2] == us.permission.ToString()) + // { + // permission = us.permission; + // return string.Empty; + // } + // } + //} return "用户名或密码错误"; }), "LoginBPASmartClient.DosingSystem"); } private void MenuInit() { - menus.Add(new ActionMenu() - { - MenuName = "配方设置", - CommandParameter = "BPASmartClient.DosingSystem.View.RecipeSettingsView_配方设置", - permission = new Permission[] { Permission.管理员, Permission.技术员 }, - }); - menus.Add(new ActionMenu() - { - MenuName = "设备列表", - CommandParameter = "BPASmartClient.DosingSystem.View.DeviceListView_设备列表", - permission = new Permission[] { Permission.管理员, Permission.技术员 }, - }); - menus.Add(new ActionMenu() - { - MenuName = "硬件状态", - CommandParameter = "BPASmartClient.DosingSystem.View.HardwareStatusView_硬件状态", - permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - }); - menus.Add(new ActionMenu() - { - MenuName = "报警记录", - CommandParameter = "BPASmartClient.CustomResource.Pages.View.AlarmView_报警记录", - permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, - }); - menus.Add(new ActionMenu() - { - MenuName = "配方下发", - CommandParameter = "BPASmartClient.DosingSystem.View.RecipeControlView_配方控制", - permission = new Permission[] { Permission.管理员, Permission.操作员 }, - }); + //menus.Add(new ActionMenu() + //{ + // MenuName = "配方设置", + // CommandParameter = "BPASmartClient.DosingSystem.View.RecipeSettingsView_配方设置", + // permission = new Permission[] { Permission.管理员, Permission.技术员 }, + //}); + //menus.Add(new ActionMenu() + //{ + // MenuName = "设备列表", + // CommandParameter = "BPASmartClient.DosingSystem.View.DeviceListView_设备列表", + // permission = new Permission[] { Permission.管理员, Permission.技术员 }, + //}); + //menus.Add(new ActionMenu() + //{ + // MenuName = "硬件状态", + // CommandParameter = "BPASmartClient.DosingSystem.View.HardwareStatusView_硬件状态", + // permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, + //}); + //menus.Add(new ActionMenu() + //{ + // MenuName = "报警记录", + // CommandParameter = "BPASmartClient.CustomResource.Pages.View.AlarmView_报警记录", + // permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, + //}); + //menus.Add(new ActionMenu() + //{ + // MenuName = "配方下发", + // CommandParameter = "BPASmartClient.DosingSystem.View.RecipeControlView_配方控制", + // permission = new Permission[] { Permission.管理员, Permission.操作员 }, + //}); } public void DoNavChanged(object obj) diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs index 47fec52f..66716975 100644 --- a/DosingSystem/ViewModel/RecipeControlViewModel.cs +++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs @@ -11,6 +11,7 @@ using BPASmartClient.Helper; using Microsoft.Toolkit.Mvvm.Input; using BPASmartClient.DosingSystem.Model; using System.Threading; +using BPASmartClient.CustomResource.Pages.Model; namespace BPASmartClient.DosingSystem.ViewModel { @@ -37,6 +38,7 @@ namespace BPASmartClient.DosingSystem.ViewModel //} } //})); + MessageLog.GetInstance.ShowUserLog($"下发工单 { Recipes.ElementAt(index).RecipeName}"); devices.Enqueue(deviceName); } }); diff --git a/SmartClient.sln b/SmartClient.sln index ff853afa..2767262e 100644 --- a/SmartClient.sln +++ b/SmartClient.sln @@ -100,7 +100,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkT_Show", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Show.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkT_Show", "BPASmartClient.MorkT_Show\BPASmartClient.MorkT_Show.csproj", "{3653724D-3683-4722-B978-EB88DD4AE5DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.ZhuoDian", "BPASmartClient.ZhuoDian\BPASmartClient.ZhuoDian.csproj", "{C5D53928-34F6-4FA0-A8E6-261BAC1A659C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -936,6 +938,26 @@ Global {3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x64.Build.0 = Release|Any CPU {3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.ActiveCfg = Release|Any CPU {3653724D-3683-4722-B978-EB88DD4AE5DB}.Release|x86.Build.0 = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|ARM.Build.0 = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|ARM64.Build.0 = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|x64.ActiveCfg = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|x64.Build.0 = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|x86.ActiveCfg = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Debug|x86.Build.0 = Debug|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|Any CPU.Build.0 = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|ARM.ActiveCfg = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|ARM.Build.0 = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|ARM64.ActiveCfg = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|ARM64.Build.0 = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|x64.ActiveCfg = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|x64.Build.0 = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|x86.ActiveCfg = Release|Any CPU + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -982,6 +1004,7 @@ Global {724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} {507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} {3653724D-3683-4722-B978-EB88DD4AE5DB} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} + {C5D53928-34F6-4FA0-A8E6-261BAC1A659C} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}