Browse Source

用户权限管理控制

样式分支
pry 2 years ago
parent
commit
ec683bd2fe
4 changed files with 77 additions and 32 deletions
  1. +2
    -2
      BPASmartClient.CustomResource/Pages/Model/MenuManage.cs
  2. +1
    -1
      BPASmartClient.CustomResource/Pages/Model/UserInfo.cs
  3. +53
    -14
      BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs
  4. +21
    -15
      DosingSystem/App.xaml.cs

+ 2
- 2
BPASmartClient.CustomResource/Pages/Model/MenuManage.cs View File

@@ -75,7 +75,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
/// 主菜单的显示隐藏设置 /// 主菜单的显示隐藏设置
/// </summary> /// </summary>
public Visibility MainMenuVisibility { get { return _mMainMenuVisibility; } set { _mMainMenuVisibility = value; OnPropertyChanged(); } } public Visibility MainMenuVisibility { get { return _mMainMenuVisibility; } set { _mMainMenuVisibility = value; OnPropertyChanged(); } }
private Visibility _mMainMenuVisibility;
private Visibility _mMainMenuVisibility = Visibility.Visible;


/// <summary> /// <summary>
/// 子菜单集合 /// 子菜单集合
@@ -114,7 +114,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
/// 子菜单的显示隐藏设置 /// 子菜单的显示隐藏设置
/// </summary> /// </summary>
public Visibility SubMenuVisibility { get { return _mSubMenuVisibility; } set { _mSubMenuVisibility = value; OnPropertyChanged(); } } public Visibility SubMenuVisibility { get { return _mSubMenuVisibility; } set { _mSubMenuVisibility = value; OnPropertyChanged(); } }
private Visibility _mSubMenuVisibility = Visibility.Collapsed;
private Visibility _mSubMenuVisibility = Visibility.Visible;








+ 1
- 1
BPASmartClient.CustomResource/Pages/Model/UserInfo.cs View File

@@ -22,7 +22,7 @@ namespace BPASmartClient.CustomResource.Pages.Model
private Permission _perimission; private Permission _perimission;


public string UserName { get { return _userName; } set { _userName = value; OnPropertyChanged(); } } public string UserName { get { return _userName; } set { _userName = value; OnPropertyChanged(); } }
private string _userName ;
private string _userName;


public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } } public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } }
private string _password; private string _password;


+ 53
- 14
BPASmartClient.CustomResource/Pages/ViewModel/LoginViewModel.cs View File

@@ -85,25 +85,52 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
Global.userInfo.LastLogInTime = DateTime.Now.ToString(); Global.userInfo.LastLogInTime = DateTime.Now.ToString();
res.LastLogInTime = DateTime.Now.ToString(); res.LastLogInTime = DateTime.Now.ToString();
Config.GetInstance.SaveUser(); Config.GetInstance.SaveUser();

//permission权限 //permission权限
for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++)
if (res.userTreeViewModels != null)
{ {
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++)
VisibilityState(Visibility.Collapsed);
for (int i = 0; i < res.userTreeViewModels?.Count; i++)
{ {
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;
var menName = res.userTreeViewModels.ElementAt(i).Name;//获取子菜单的名称

var res1 = MenuManage.GetInstance.menuModels.FirstOrDefault(p => p.subMenumodels.FirstOrDefault(s => s.SubMenuName.Equals(menName)) != null);//通过子菜单获取主菜单的信息
if (res1 != null)
{
res1.MainMenuVisibility = Visibility.Visible;
var res2 = res1.subMenumodels.FirstOrDefault(p => p.SubMenuName.Equals(menName));
if (res2 != null) res2.SubMenuVisibility = Visibility.Visible;
}
} }
} }
else
{
VisibilityState(Visibility.Visible);
}





//permission权限
//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;
// }
//}


////分配后的权限 ////分配后的权限
//if (res.permission == Enums.Permission.管理员) //if (res.permission == Enums.Permission.管理员)
@@ -149,6 +176,18 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel
} }
} }


private void VisibilityState(Visibility tempVisibility)
{
for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++)
{
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = tempVisibility;
for (int m = 0; m < MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.Count; m++)
{
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = tempVisibility;
}
}
}

public RelayCommand LoginCommand { get; set; } public RelayCommand LoginCommand { get; set; }


public RelayCommand ExitCommand { get; set; } public RelayCommand ExitCommand { get; set; }


+ 21
- 15
DosingSystem/App.xaml.cs View File

@@ -62,7 +62,7 @@ namespace BPASmartClient.DosingSystem
RecipeManage.Add(new SubMenumodel() RecipeManage.Add(new SubMenumodel()
{ {
SubMenuName = "配方管理", SubMenuName = "配方管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem", AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.RecipeSettingsView" ToggleWindowPath = "View.RecipeSettingsView"
}); });
@@ -70,7 +70,7 @@ namespace BPASmartClient.DosingSystem
RecipeManage.Add(new SubMenumodel() RecipeManage.Add(new SubMenumodel()
{ {
SubMenuName = "配方下发", SubMenuName = "配方下发",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem", AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.RecipeControlView" ToggleWindowPath = "View.RecipeControlView"
}); });
@@ -78,6 +78,7 @@ namespace BPASmartClient.DosingSystem
MenuManage.GetInstance.menuModels.Add(new MenuModel() MenuManage.GetInstance.menuModels.Add(new MenuModel()
{ {
MainMenuIcon = "&#xe683;", MainMenuIcon = "&#xe683;",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
MainMenuName = "配方管理", MainMenuName = "配方管理",
Alias = "Recipe Management", Alias = "Recipe Management",
subMenumodels = RecipeManage, subMenumodels = RecipeManage,
@@ -89,7 +90,7 @@ namespace BPASmartClient.DosingSystem
ParSet.Add(new SubMenumodel() ParSet.Add(new SubMenumodel()
{ {
SubMenuName = "原料参数设置", SubMenuName = "原料参数设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem", AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.DeviceMaterialParView" ToggleWindowPath = "View.DeviceMaterialParView"
}); });
@@ -97,7 +98,7 @@ namespace BPASmartClient.DosingSystem
ParSet.Add(new SubMenumodel() ParSet.Add(new SubMenumodel()
{ {
SubMenuName = "设备参数设置", SubMenuName = "设备参数设置",
SubMenuPermission = new Permission[] { Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem", AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.CommParSetView" ToggleWindowPath = "View.CommParSetView"
}); });
@@ -113,6 +114,7 @@ namespace BPASmartClient.DosingSystem
MenuManage.GetInstance.menuModels.Add(new MenuModel() MenuManage.GetInstance.menuModels.Add(new MenuModel()
{ {
MainMenuIcon = "&#xe62d;", MainMenuIcon = "&#xe62d;",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
MainMenuName = "参数设置", MainMenuName = "参数设置",
Alias = "Parameter Set", Alias = "Parameter Set",
subMenumodels = ParSet, subMenumodels = ParSet,
@@ -124,7 +126,7 @@ namespace BPASmartClient.DosingSystem
ManualControl.Add(new SubMenumodel() ManualControl.Add(new SubMenumodel()
{ {
SubMenuName = "气缸手动控制", SubMenuName = "气缸手动控制",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem", AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.ManualControlView" ToggleWindowPath = "View.ManualControlView"
}); });
@@ -132,7 +134,7 @@ namespace BPASmartClient.DosingSystem
ManualControl.Add(new SubMenumodel() ManualControl.Add(new SubMenumodel()
{ {
SubMenuName = "输送带手动控制", SubMenuName = "输送带手动控制",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem", AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.ConveyerBeltManualView" ToggleWindowPath = "View.ConveyerBeltManualView"
}); });
@@ -147,6 +149,7 @@ namespace BPASmartClient.DosingSystem
{ {
MainMenuIcon = "&#xe622;", MainMenuIcon = "&#xe622;",
MainMenuName = "手动控制", MainMenuName = "手动控制",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "Parameter Set", Alias = "Parameter Set",
subMenumodels = ManualControl, subMenumodels = ManualControl,
}); });
@@ -157,7 +160,7 @@ namespace BPASmartClient.DosingSystem
InfoLog.Add(new SubMenumodel() InfoLog.Add(new SubMenumodel()
{ {
SubMenuName = "操作日志", SubMenuName = "操作日志",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource", AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.UserLogView" ToggleWindowPath = "Pages.View.UserLogView"
}); });
@@ -165,7 +168,7 @@ namespace BPASmartClient.DosingSystem
InfoLog.Add(new SubMenumodel() InfoLog.Add(new SubMenumodel()
{ {
SubMenuName = "运行日志", SubMenuName = "运行日志",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource", AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.RunLogView" ToggleWindowPath = "Pages.View.RunLogView"
}); });
@@ -173,7 +176,7 @@ namespace BPASmartClient.DosingSystem
InfoLog.Add(new SubMenumodel() InfoLog.Add(new SubMenumodel()
{ {
SubMenuName = "报警记录", SubMenuName = "报警记录",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource", AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.AlarmView" ToggleWindowPath = "Pages.View.AlarmView"
}); });
@@ -181,7 +184,7 @@ namespace BPASmartClient.DosingSystem
InfoLog.Add(new SubMenumodel() InfoLog.Add(new SubMenumodel()
{ {
SubMenuName = "调试日志", SubMenuName = "调试日志",
SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员, Permission.技术员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource", AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.DebugLogView" ToggleWindowPath = "Pages.View.DebugLogView"
}); });
@@ -198,6 +201,7 @@ namespace BPASmartClient.DosingSystem
{ {
MainMenuIcon = "&#xe668;", MainMenuIcon = "&#xe668;",
MainMenuName = "消息日志", MainMenuName = "消息日志",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "Message Log", Alias = "Message Log",
subMenumodels = InfoLog, subMenumodels = InfoLog,
}); });
@@ -208,7 +212,7 @@ namespace BPASmartClient.DosingSystem
DeviceMonitor.Add(new SubMenumodel() DeviceMonitor.Add(new SubMenumodel()
{ {
SubMenuName = "原料设备列表", SubMenuName = "原料设备列表",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem", AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.DeviceListView" ToggleWindowPath = "View.DeviceListView"
}); });
@@ -216,7 +220,7 @@ namespace BPASmartClient.DosingSystem
DeviceMonitor.Add(new SubMenumodel() DeviceMonitor.Add(new SubMenumodel()
{ {
SubMenuName = "设备状态", SubMenuName = "设备状态",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.DosingSystem", AssemblyName = "BPASmartClient.DosingSystem",
ToggleWindowPath = "View.HardwareStatusView" ToggleWindowPath = "View.HardwareStatusView"
}); });
@@ -225,6 +229,7 @@ namespace BPASmartClient.DosingSystem
{ {
MainMenuIcon = "&#xe603;", MainMenuIcon = "&#xe603;",
MainMenuName = "设备监控", MainMenuName = "设备监控",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "Device Monitor", Alias = "Device Monitor",
subMenumodels = DeviceMonitor, subMenumodels = DeviceMonitor,
}); });
@@ -235,7 +240,7 @@ namespace BPASmartClient.DosingSystem
UserManager.Add(new SubMenumodel() UserManager.Add(new SubMenumodel()
{ {
SubMenuName = "用户登录", SubMenuName = "用户登录",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource", AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.SubPagLoginView" ToggleWindowPath = "Pages.View.SubPagLoginView"
}); });
@@ -243,14 +248,14 @@ namespace BPASmartClient.DosingSystem
UserManager.Add(new SubMenumodel() UserManager.Add(new SubMenumodel()
{ {
SubMenuName = "密码修改", SubMenuName = "密码修改",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource", AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.PasswordChangeView" ToggleWindowPath = "Pages.View.PasswordChangeView"
}); });
UserManager.Add(new SubMenumodel() UserManager.Add(new SubMenumodel()
{ {
SubMenuName = "用户管理", SubMenuName = "用户管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
AssemblyName = "BPASmartClient.CustomResource", AssemblyName = "BPASmartClient.CustomResource",
ToggleWindowPath = "Pages.View.UserManagerView" ToggleWindowPath = "Pages.View.UserManagerView"
}); });
@@ -267,6 +272,7 @@ namespace BPASmartClient.DosingSystem
{ {
MainMenuIcon = "&#xe66d;", MainMenuIcon = "&#xe66d;",
MainMenuName = "用户管理", MainMenuName = "用户管理",
MainMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 },
Alias = "User Management", Alias = "User Management",
subMenumodels = UserManager, subMenumodels = UserManager,
}); });


Loading…
Cancel
Save