From b7747e788a7d9bcbaf4ae8c0d32e2b04ebbf04d9 Mon Sep 17 00:00:00 2001 From: SL <123@123.com> Date: Mon, 4 Sep 2023 11:51:05 +0800 Subject: [PATCH] =?UTF-8?q?[Common]=20=E4=BC=98=E5=8C=96AppMenu=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E3=80=82=20AppMenu=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E6=96=B0=E5=A2=9EDescription=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E3=80=82=20=E4=BC=98=E5=8C=96MenuLoad=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D=E3=80=82=20=E4=BC=98=E5=8C=96RoleLoad=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=90=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [UI.Client] 修正RoleManager保存Role后,UI中仍然显示未为保存状态的问题。 移除RoleManager的RoleContainer属性,将其变更为私有变量。 重命名RoleManager的GetRoleByID方法和GetRoleByName方法,变更为FindRoleByID和FindRoleByName。 移除PermissionControlItem中的ComboBoxSaved属性。 PermissionControlItem新增Update方法,用于Save后更新保存状态。 [Sicentury.Core] BindableBase对象增加Serializable属性标签。 --- .../Aitex/Core/Account/IAccountService.cs | 6 +- .../MECF.Framework.Common.csproj | 6 + .../Common/Account/Extends/AppMenu.cs | 237 +++++++++------ .../Common/Account/Extends/MenuLoader.cs | 42 ++- .../Framework/Common/Account/Extends/Role.cs | 16 +- .../Common/Account/Extends/RoleLoader.cs | 33 +- .../Configs/Roles/PermissionControlItem.cs | 18 +- .../CenterViews/Configs/Roles/RoleItem.cs | 28 +- .../CenterViews/Configs/Roles/RoleManager.cs | 282 ++++++++++-------- .../CenterViews/Configs/Roles/RoleView.xaml | 8 +- .../Configs/Roles/RoleViewModel.cs | 40 +-- .../Editors/Recipe/RecipeEditorViewModel.cs | 2 +- .../ClientBase/BaseApp.cs | 2 +- .../RecipeEditorLib/RecipeModel/RecipeData.cs | 8 +- .../RecipeModel/RecipeFormatBuilder.cs | 6 +- Sicentury.Core/BindableBase.cs | 2 + 16 files changed, 405 insertions(+), 331 deletions(-) diff --git a/MECF.Framework.Common/Aitex/Core/Account/IAccountService.cs b/MECF.Framework.Common/Aitex/Core/Account/IAccountService.cs index 0412c70..f4112dc 100644 --- a/MECF.Framework.Common/Aitex/Core/Account/IAccountService.cs +++ b/MECF.Framework.Common/Aitex/Core/Account/IAccountService.cs @@ -50,9 +50,6 @@ namespace Aitex.Core.Account [OperationContract] SerializableDictionary GetAllViewList(); - [OperationContract] - IEnumerable GetAllRoles(); - [OperationContract] void CheckAlive(string accountId); @@ -68,6 +65,9 @@ namespace Aitex.Core.Account [OperationContract] List GetAllAccountExList(); + [OperationContract] + IEnumerable GetAllRoles(); + [OperationContract] List GetRoles(); diff --git a/MECF.Framework.Common/MECF.Framework.Common.csproj b/MECF.Framework.Common/MECF.Framework.Common.csproj index e95714c..3a1748e 100644 --- a/MECF.Framework.Common/MECF.Framework.Common.csproj +++ b/MECF.Framework.Common/MECF.Framework.Common.csproj @@ -973,5 +973,11 @@ + + + {a78b3f87-4601-43f7-a941-edb339ce35a9} + Sicentury.Core + + \ No newline at end of file diff --git a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AppMenu.cs b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AppMenu.cs index 3de3abf..d57c3fd 100644 --- a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AppMenu.cs +++ b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AppMenu.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel; +using Sicentury.Core; namespace MECF.Framework.Common.Account.Extends { @@ -8,114 +8,139 @@ namespace MECF.Framework.Common.Account.Extends /// /// [Serializable] - public class AppMenu : INotifyPropertyChanged + public class AppMenu : BindableBase { - #region Variables + #region Variables - private string _mStrMenuId; - private string _mStrViewModel; - private string _mStrResKey; - private string _system; - private int _permission; - private AppMenu _parent; - private List _menuItems; - private bool _selected; - private bool _isAlarm; - private string _alarmModule; + private string _menuID; + private string _menuViewModel; + private string _resKey; + private string _system; + private int _permission; + private AppMenu _parent; + private List _subMenus; + private bool _selected; + private bool _isAlarm; + private string _alarmModule; + private string _description; - #endregion - - - - public string MenuID - { - get => _mStrMenuId; - set => _mStrMenuId = value; - } - - public string ResKey - { - get => _mStrResKey; - set => _mStrResKey = value; - } - - public List MenuItems - { - get => _menuItems; - set => _menuItems = value; - } - - public string ViewModel - { - get => _mStrViewModel; - set => _mStrViewModel = value; - } - - public int Permission - { - get => _permission; - set => _permission = value; - } - - public string System - { - get => _system; - set => _system = value; - } - - public AppMenu Parent - { - get => _parent; - set => _parent = value; - } - - public bool Selected - { - get => _selected; - set - { - _selected = value; - OnPropertyChanged("Selected"); - } - } - - public bool IsAlarm - { - get => _isAlarm; - set - { - _isAlarm = value; - OnPropertyChanged("IsAlarm"); - } - } - - public string AlarmModule - { - get => _alarmModule; - set => _alarmModule = value; - } - - public object Model { get; set; } - - public AppMenu LastSelectedSubMenu { get; set; } - - public event PropertyChangedEventHandler PropertyChanged; + #endregion + + #region Constructors public AppMenu() { } - public AppMenu(string p_strMenuID, string p_strMenuViewModel, string p_strResKey, List p_menuItems) + public AppMenu(string menuID, string menuViewModel, string resKey, List subMenus, string description = "") { - _mStrMenuId = p_strMenuID; - _mStrViewModel = p_strMenuViewModel; - _mStrResKey = p_strResKey; - _menuItems = p_menuItems; + _menuID = menuID; + _menuViewModel = menuViewModel; + _resKey = resKey; + _subMenus = subMenus; + _description = description; } + + #endregion + + #region Properties + + public string MenuID + { + get => _menuID; + set => _menuID = value; + } + + public string ResKey + { + get => _resKey; + set => _resKey = value; + } + + public List MenuItems + { + get => _subMenus; + set => _subMenus = value; + } + + public string ViewModel + { + get => _menuViewModel; + set => _menuViewModel = value; + } + + public int Permission + { + get => _permission; + set => _permission = value; + } + + public string System + { + get => _system; + set => _system = value; + } + + /// + /// 设置或返回当前菜单的父菜单。 + /// + public AppMenu Parent + { + get => _parent; + set => _parent = value; + } + + /// + /// 设置或返回当前菜单是否被选中。 + /// + public bool Selected + { + get => _selected; + set => Set(ref _selected, value); + } + + /// + /// 设置或返回是否在当前菜单是否有报警。 + /// + public bool IsAlarm + { + get => _isAlarm; + set => Set(ref _isAlarm, value); + } + + /// + /// 设置或返回报警模组。 + /// + public string AlarmModule + { + get => _alarmModule; + set => Set(ref _alarmModule, value); + } + + public object Model { get; set; } + + /// + /// 设置或返回被选中的子菜单。 + /// + public AppMenu LastSelectedSubMenu { get; set; } + + /// + /// 返回当前菜单的描述。 + /// + public string Description + { + get => _description; + set => _description = value; + } + + #endregion + + #region Methods + public object Clone(AppMenu parent) { - AppMenu appMenu = new AppMenu(); + var appMenu = new AppMenu(); appMenu.MenuID = MenuID; appMenu.ResKey = ResKey; appMenu.ViewModel = ViewModel; @@ -125,20 +150,34 @@ namespace MECF.Framework.Common.Account.Extends appMenu.Parent = parent; appMenu.IsAlarm = IsAlarm; appMenu.AlarmModule = AlarmModule; + appMenu.Description = Description; if (MenuItems != null) { appMenu.MenuItems = new List(); - foreach (AppMenu menuItem in MenuItems) + foreach (var menuItem in MenuItems) { appMenu.MenuItems.Add((AppMenu)menuItem.Clone(appMenu)); } } + return appMenu; } - protected virtual void OnPropertyChanged(string propertyName) + #endregion + + /*public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { - this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + + protected bool Set(ref T field, T value, [CallerMemberName] string propertyName = null) + { + if (EqualityComparer.Default.Equals(field, value)) return false; + field = value; + OnPropertyChanged(propertyName); + return true; + }*/ } } diff --git a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/MenuLoader.cs b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/MenuLoader.cs index ad33a95..4d6f247 100644 --- a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/MenuLoader.cs +++ b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/MenuLoader.cs @@ -35,44 +35,40 @@ namespace MECF.Framework.Common.Account.Extends private List TranslateMenus(XElement pElement) { - List list = new List(); - IEnumerable enumerable = from r in pElement.Elements("menuItem") + var list = new List(); + var enumerable = from r in pElement.Elements("menuItem") select (r); - foreach (XElement item in enumerable) + foreach (var item in enumerable) { - string empty = string.Empty; - string empty2 = string.Empty; - string empty3 = string.Empty; + var menuId = ""; + var menuViewModel = ""; + var resKey = ""; + var desc = ""; if (!item.HasElements) { - empty = item.Attribute("id").Value; - empty2 = item.Attribute("viewmodel").Value; - empty3 = item.Attribute("resKey").Value; - AppMenu appMenu = new AppMenu(empty, empty2, empty3, null); + menuId = item.Attribute("id").Value; + menuViewModel = item.Attribute("viewmodel").Value; + resKey = item.Attribute("resKey").Value; + if (item.Attribute("Description") != null) + desc = item.Attribute("Description").Value; + + var appMenu = new AppMenu(menuId, menuViewModel, resKey, null, desc); if (item.Attribute("System") != null) - { appMenu.System = item.Attribute("System").Value; - } if (item.Attribute("AlarmModule") != null) - { appMenu.AlarmModule = item.Attribute("AlarmModule").Value; - } list.Add(appMenu); continue; } - empty = item.Attribute("id").Value; - empty3 = item.Attribute("resKey").Value; - List list2 = new List(); - list2 = TranslateMenus(item); - AppMenu appMenu2 = new AppMenu(empty, empty2, empty3, list2); + menuId = item.Attribute("id").Value; + resKey = item.Attribute("resKey").Value; + var subMenus = new List(); + subMenus = TranslateMenus(item); + var appMenu2 = new AppMenu(menuId, menuViewModel, resKey, subMenus, desc); if (item.Attribute("System") != null) - { appMenu2.System = item.Attribute("System").Value; - } if (item.Attribute("AlarmModule") != null) - { appMenu2.AlarmModule = item.Attribute("AlarmModule").Value; - } list.Add(appMenu2); } return list; diff --git a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/Role.cs b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/Role.cs index 3abeee3..f0e971d 100644 --- a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/Role.cs +++ b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/Role.cs @@ -2,6 +2,10 @@ using System; namespace MECF.Framework.Common.Account.Extends { + + /// + /// 角色对象。Sic系统中对于各个操作权限以“角色”为单位进行设置。 + /// [Serializable] public class Role { @@ -11,7 +15,7 @@ namespace MECF.Framework.Common.Account.Extends private string _roleName; private bool _autoLogout; private int _logoutTime; - private string _menuPermission; + private string _permissionContent; private string _description; #endregion @@ -34,7 +38,7 @@ namespace MECF.Framework.Common.Account.Extends _autoLogout = isAutoLogout; _logoutTime = autoLogoutTime; _description = description; - _menuPermission = permission; + _permissionContent = permission; IsSuper = false; } @@ -79,12 +83,12 @@ namespace MECF.Framework.Common.Account.Extends } /// - /// 设置或返回当前角色菜单访问权限。 + /// 设置或返回描述当前角色权限的字串。 /// - public string MenuPermission + public string PermissionContent { - get => _menuPermission; - set => _menuPermission = value; + get => _permissionContent; + set => _permissionContent = value; } /// diff --git a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/RoleLoader.cs b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/RoleLoader.cs index ad845ef..ec55c64 100644 --- a/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/RoleLoader.cs +++ b/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/RoleLoader.cs @@ -172,13 +172,13 @@ namespace MECF.Framework.Common.Account.Extends { list[0].Attribute("description").Value = newRole.Description; } - list[0].Value = newRole.MenuPermission; + list[0].Value = newRole.PermissionContent; } else { var content = new XElement("roleItem", new XAttribute("id", newRole.RoleId), new XAttribute("name", newRole.RoleName), new XAttribute("autologout", newRole.IsAutoLogout ? "1" : "0"), new XAttribute("logouttime", newRole.LogoutTime), new XAttribute("description", newRole.Description)) { - Value = newRole.MenuPermission + Value = newRole.PermissionContent }; doc.Root.Element("roles").Add(content); } @@ -229,7 +229,7 @@ namespace MECF.Framework.Common.Account.Extends { if (item.RoleId == roleId) { - result = item.MenuPermission.Split(';').ToList(); + result = item.PermissionContent.Split(';').ToList(); break; } } @@ -252,32 +252,37 @@ namespace MECF.Framework.Common.Account.Extends return 1; //MP_NONE } - public List GetMenusByRole(string roleid, List menulist) + public List GetMenusByRole(string roleId, List menuList) { var list = new List(); - var rolePermission = GetRolePermission(roleid); - foreach (var item in menulist) + var rolePermission = GetRolePermission(roleId); + foreach (var menu in menuList) { var list2 = new List(); - foreach (var menuItem in item.MenuItems) + foreach (var menuItem in menu.MenuItems) { - var appMenu = new AppMenu(menuItem.MenuID, menuItem.ViewModel, menuItem.ResKey, null); - appMenu.System = menuItem.System; - appMenu.AlarmModule = menuItem.AlarmModule; - appMenu.Permission = GetMenuPermission(rolePermission, menuItem.MenuID); + var appMenu = new AppMenu(menuItem.MenuID, menuItem.ViewModel, menuItem.ResKey, null, + menuItem.Description) + { + System = menuItem.System, + AlarmModule = menuItem.AlarmModule, + Permission = GetMenuPermission(rolePermission, menuItem.MenuID) + }; if (appMenu.Permission > 1) { list2.Add(appMenu); } } + if (list2.Count > 0) { - var appMenu2 = new AppMenu(item.MenuID, item.ViewModel, item.ResKey, list2); - appMenu2.System = item.System; - appMenu2.AlarmModule = item.AlarmModule; + var appMenu2 = new AppMenu(menu.MenuID, menu.ViewModel, menu.ResKey, list2, menu.Description); + appMenu2.System = menu.System; + appMenu2.AlarmModule = menu.AlarmModule; list.Add(appMenu2); } } + return list; } diff --git a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/PermissionControlItem.cs b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/PermissionControlItem.cs index 40ac707..2cc0f21 100644 --- a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/PermissionControlItem.cs +++ b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/PermissionControlItem.cs @@ -12,7 +12,6 @@ public sealed class PermissionControlItem : PropertyChangedBase, ICloneable private string _description; private PermissionType _myPermission; private PermissionType _previousPermission; - private bool _comboBoxSaved; #endregion @@ -57,18 +56,6 @@ public sealed class PermissionControlItem : PropertyChangedBase, ICloneable } } - public bool ComboBoxSaved - { - get => _comboBoxSaved; - set - { - if (_comboBoxSaved != value) - { - _comboBoxSaved = value; - NotifyOfPropertyChange(); - } - } - } public string Name { @@ -98,6 +85,11 @@ public sealed class PermissionControlItem : PropertyChangedBase, ICloneable { return new PermissionControlItem(Name, Permission, ID, Description); } + + internal void Update() + { + _previousPermission = _myPermission; + } #endregion diff --git a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleItem.cs b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleItem.cs index 224308e..5a4ff87 100644 --- a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleItem.cs +++ b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleItem.cs @@ -12,6 +12,10 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles public RoleItem(Role role) { Role = role; + DisplayRoleName = RoleName; + DisplayAutoLogoutTime = AutoLogoutTime; + DisplayIsAutoLogout = IsAutoLogout; + DisplayDescription = Description; } public RoleItem(string roleId) @@ -137,13 +141,13 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles } } - public ObservableCollection MenuCollection { get; } = new(); + public ObservableCollection MenuPermCollection { get; } = new(); - public ObservableCollection RecipeCollection { get; } = new(); + public ObservableCollection RecipePermCollection { get; } = new(); - public ObservableCollection RecipeStepCollection { get; } = new(); + public ObservableCollection RecipeStepPermCollection { get; } = new(); - public ObservableCollection ContentCollection { get; } = new(); + public ObservableCollection ContentPermCollection { get; } = new(); #endregion @@ -154,7 +158,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles if (null == pInfo) return; - MenuCollection.Add(pInfo); + MenuPermCollection.Add(pInfo); } public void AddRecipeInfo(PermissionControlItem pInfo) @@ -162,7 +166,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles if (null == pInfo) return; - RecipeCollection.Add(pInfo); + RecipePermCollection.Add(pInfo); } public void AddStepInfo(PermissionControlItem pInfo) @@ -170,7 +174,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles if (null == pInfo) return; - RecipeStepCollection.Add(pInfo); + RecipeStepPermCollection.Add(pInfo); } public void AddContentInfo(PermissionControlItem pInfo) @@ -178,7 +182,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles if (null == pInfo) return; - ContentCollection.Add(pInfo); + ContentPermCollection.Add(pInfo); } public bool IsRoleChanged() @@ -195,22 +199,22 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles if (DisplayDescription != Role.Description) return true; - if (MenuCollection.Any(item => item.IsChanged)) + if (MenuPermCollection.Any(item => item.IsChanged)) { return true; } - if (RecipeCollection.Any(item => item.IsChanged)) + if (RecipePermCollection.Any(item => item.IsChanged)) { return true; } - if (RecipeStepCollection.Any(item => item.IsChanged)) + if (RecipeStepPermCollection.Any(item => item.IsChanged)) { return true; } - if (ContentCollection.Any(item => item.IsChanged)) + if (ContentPermCollection.Any(item => item.IsChanged)) { return true; } diff --git a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleManager.cs b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleManager.cs index 08af180..7fbd40a 100644 --- a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleManager.cs +++ b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleManager.cs @@ -8,34 +8,47 @@ using MECF.Framework.Common.DataCenter; using MECF.Framework.UI.Client.CenterViews.Editors; using MECF.Framework.UI.Client.ClientBase; using MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel; +using OpenSEMI.ClientBase; namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles { public class RoleManager : Singleton { - public RoleManager() - { + #region Variables - } + private static int _roleNum; + private List _appMenuPermSource; + private List _recipeColumnPermSource; + private List _recipeStepPermSource; + private List _contentPermSource; + + private readonly RecipeFormatBuilder _recipeBuilder = new(); + private readonly ObservableCollection _roleContainer = new(); - private readonly RecipeFormatBuilder _recipeBuilder = new RecipeFormatBuilder(); + #endregion + + #region Properties public ObservableCollection ChamberType { get; set; } public ObservableCollection ProcessTypeFileList { get; set; } + #endregion + + #region Methods + public bool Initialize() { - RoleContainer.Clear(); - List roles = RoleAccountProvider.Instance.GetRoles(); + _roleContainer.Clear(); + var roles = RoleAccountProvider.Instance.GetRoles(); if (roles == null) { LOG.Error("GetRoles method failed,in RoleManager"); return false; } - List menus = BaseApp.Instance.MenuLoader.MenuList; - this._appMenuPermSource = menus; + var menus = BaseApp.Instance.MenuLoader.MenuList; + _appMenuPermSource = menus; if (menus == null) { LOG.Error("GetMenus method failed,in RoleManager"); @@ -64,27 +77,22 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles var recipeProcessType = ((string)processType).Split(','); _recipeColumnPermSource = _recipeBuilder.GetRecipeColumnPermSource($"{ChamberType[0]}\\{recipeProcessType[0]}", "PM1"); - _recipeStepPermSource = _recipeBuilder.GetRecipeStepPermSource(); - _contentPermSource = _recipeBuilder.GetContentPermSource($"{ChamberType[0]}\\Content", "PM1"); - foreach (var r in roles) + // 根据系统中已存在的角色创建Role编辑器左侧的树状列表。 + foreach (var role in roles) { - var role = new RoleItem(r); - role.DisplayRoleName = role.RoleName; - role.DisplayAutoLogoutTime = role.AutoLogoutTime; - role.DisplayIsAutoLogout = role.IsAutoLogout; - role.DisplayDescription = role.Description; + var ri = new RoleItem(role); - //Parse menu permission - var menuPermissionParse = new PermissionHelper(); - menuPermissionParse.ParsePermission(r.MenuPermission); + // 从Role的权限字串创建权限列表。 + var permHelper = new PermissionHelper(); + permHelper.ParsePermission(role.PermissionContent); - var headerPerm = RolePermissionMapper.FromMenuPermissionEnum(menuPermissionParse.GetPermissionByID("Header")); - var mp = new PermissionControlItem("Header", headerPerm); + var headerPerm = RolePermissionMapper.FromMenuPermissionEnum(permHelper.GetPermissionByID("Header")); + var mp = new PermissionControlItem("Header", headerPerm, "Header"); - role.AddMenuInfo(mp); + ri.AddMenuInfo(mp); //Get Menu information foreach (var topMenuItem in menus) @@ -94,126 +102,152 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles var appName = topMenuItem.ResKey + "." + subMenuItem.ResKey; var id = subMenuItem.MenuID; var appPerm = RolePermissionMapper.FromMenuPermissionEnum( - menuPermissionParse.GetPermissionByID(id)); + permHelper.GetPermissionByID(id)); var perm = new PermissionControlItem(appName, appPerm, id); - role.AddMenuInfo(perm); + ri.AddMenuInfo(perm); } } foreach (var recipeInfo in _recipeColumnPermSource) { var recipePerm = RolePermissionMapper.FromMenuPermissionEnum( - menuPermissionParse.GetPermissionByID(recipeInfo.Name.Replace(" ", ""))); + permHelper.GetPermissionByID(recipeInfo.Name)); var perm = new PermissionControlItem(recipeInfo.Name, recipePerm); - recipeInfo.Name = recipeInfo.Name.Replace(" ", ""); - role.AddRecipeInfo(perm); + ri.AddRecipeInfo(perm); } foreach (var stepInfo in _recipeStepPermSource) { var stepPerm = RolePermissionMapper.FromMenuPermissionEnum( - menuPermissionParse.GetPermissionByID(stepInfo.Name.Replace(" ", ""))); + permHelper.GetPermissionByID(stepInfo.Name)); var perm = new PermissionControlItem(stepInfo.Name, stepPerm); - stepInfo.Name = stepInfo.Name.Replace(" ", ""); - role.AddStepInfo(perm); + ri.AddStepInfo(perm); } foreach (var contentInfo in _contentPermSource) { var contentPerm = RolePermissionTrueFalseMapper.FromMenuPermissionEnum( - menuPermissionParse.GetPermissionByID(contentInfo.Name)); + permHelper.GetPermissionByID(contentInfo.Name)); var perm = new PermissionControlItem(contentInfo.Name, contentPerm, description:contentInfo.Description); - role.AddContentInfo(perm); + ri.AddContentInfo(perm); } - RoleContainer.Add(role); + _roleContainer.Add(ri); } return true; } - + + /// + /// 返回包含所有角色的列表。 + /// + /// public List GetAllRoles() { - return RoleContainer.ToList(); + return _roleContainer.ToList(); } - public bool AddRole(RoleItem r) + /// + /// 新建角色。 + /// + /// + /// 新增角色失败的原因。 + /// + public bool AddRole(RoleItem ri, out string reason) { - RoleItem existRole = GetRoleByName(r.RoleName); + reason = ""; + var existRole = FindRoleByName(ri.RoleName); if (existRole != null) { - LOG.Info("the role already exists, in RoleManager"); + reason = $"the role name {ri.RoleName} already exists in RoleManager"; + LOG.Info($"Add Role failed, {reason}"); return false; } - existRole = GetRoleByID(r.RoleId); + existRole = FindRoleByID(ri.RoleId); if (existRole != null) { - LOG.Info("the role already exists, in RoleManager"); + reason = $"the role ID {ri.RoleId} already exists in RoleManager"; + LOG.Info($"Add Role failed, {reason}"); return false; } - RoleContainer.Add(r); + + _roleContainer.Add(ri); return true; } - + + /// + /// 创建角色ID。 + /// + /// public string GenerateRoleID() { - RoleItem r = GetRoleByID(_RoleNum.ToString()); - while (r != null) + var ri = FindRoleByID(_roleNum.ToString()); + while (ri != null) { - _RoleNum++; - r = GetRoleByID(_RoleNum.ToString()); + _roleNum++; + ri = FindRoleByID(_roleNum.ToString()); } - return _RoleNum.ToString(); + return _roleNum.ToString(); } - - public RoleItem GetRoleByID(string ID) + + /// + /// 查找指定ID的角色。 + /// + /// + /// + public RoleItem FindRoleByID(string ID) { - return RoleContainer.FirstOrDefault(t => t.RoleId == ID); + return _roleContainer.FirstOrDefault(t => t.RoleId == ID); } - public RoleItem GetRoleByName(string name) + /// + /// 查找指定名称的角色。 + /// + /// + /// + public RoleItem FindRoleByName(string name) { - return RoleContainer.FirstOrDefault(t => t.RoleName == name); + return _roleContainer.FirstOrDefault(t => t.RoleName == name); } - + public RoleItem CreateRole() { - RoleItem r = new RoleItem(GenerateRoleID()); + var r = new RoleItem(GenerateRoleID()); r.DisplayRoleName = r.RoleName = string.Empty; r.DisplayAutoLogoutTime = r.AutoLogoutTime = 10; r.DisplayIsAutoLogout = r.IsAutoLogout = false; r.DisplayDescription = r.Description = string.Empty; - r.MenuCollection.Add(new PermissionControlItem( "Header", RolePermissionMapper.None, "Header")); + r.MenuPermCollection.Add(new PermissionControlItem( "Header", RolePermissionMapper.None, "Header")); - foreach (AppMenu topMenuItem in _appMenuPermSource) + foreach (var topMenuItem in _appMenuPermSource) { - foreach (AppMenu subMenuItem in topMenuItem.MenuItems) + foreach (var subMenuItem in topMenuItem.MenuItems) { var mp = new PermissionControlItem(topMenuItem.ResKey + "." + subMenuItem.ResKey, RolePermissionMapper.None, subMenuItem.MenuID); - r.MenuCollection.Add(mp); + r.MenuPermCollection.Add(mp); } } - foreach (var recipeInfo in _recipeColumnPermSource) + foreach (var perm in _recipeColumnPermSource) { - var recipe = new PermissionControlItem(recipeInfo.Name, RolePermissionMapper.None); + var recipe = new PermissionControlItem(perm.Name, RolePermissionMapper.None, perm.Name, perm.Description); r.AddRecipeInfo(recipe); } - foreach (var sInfo in _recipeStepPermSource) + foreach (var perm in _recipeStepPermSource) { - var step = new PermissionControlItem(sInfo.Name, RolePermissionMapper.None); + var step = new PermissionControlItem(perm.Name, RolePermissionMapper.None, perm.Name, perm.Description); r.AddStepInfo(step); } - foreach (PermissionControlItem permissionInfo in _contentPermSource) + foreach (var perm in _contentPermSource) { - var permission = new PermissionControlItem(permissionInfo.Name, RolePermissionTrueFalseMapper.No); + var permission = new PermissionControlItem(perm.Name, RolePermissionTrueFalseMapper.No, perm.Name, perm.Description); r.AddContentInfo(permission); } @@ -222,7 +256,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles public RoleItem CreateRole(RoleItem role) { - RoleItem newRole = new RoleItem(GenerateRoleID()) + var newRole = new RoleItem(GenerateRoleID()) { RoleName = role.RoleName, AutoLogoutTime = role.AutoLogoutTime, @@ -234,22 +268,22 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles DisplayDescription = role.DisplayDescription }; - foreach (var mInfo in role.MenuCollection) + foreach (var mInfo in role.MenuPermCollection) { newRole.AddMenuInfo((PermissionControlItem)mInfo.Clone()); } - foreach (var rInfo in role.RecipeCollection) + foreach (var rInfo in role.RecipePermCollection) { newRole.AddRecipeInfo((PermissionControlItem)rInfo.Clone()); } - foreach (var sInfo in role.RecipeStepCollection) + foreach (var sInfo in role.RecipeStepPermCollection) { newRole.AddStepInfo((PermissionControlItem)sInfo.Clone()); } - foreach (var pInfo in role.ContentCollection) + foreach (var pInfo in role.ContentPermCollection) { newRole.AddContentInfo((PermissionControlItem)pInfo.Clone()); } @@ -271,22 +305,22 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles DisplayDescription = role.DisplayDescription }; - foreach (var mInfo in role.MenuCollection) + foreach (var mInfo in role.MenuPermCollection) { newRole.AddMenuInfo((PermissionControlItem)mInfo.Clone()); } - foreach (var rInfo in role.RecipeCollection) + foreach (var rInfo in role.RecipePermCollection) { newRole.AddRecipeInfo((PermissionControlItem)rInfo.Clone()); } - foreach (var sInfo in role.RecipeStepCollection) + foreach (var sInfo in role.RecipeStepPermCollection) { newRole.AddStepInfo((PermissionControlItem)sInfo.Clone()); } - foreach (var pInfo in role.ContentCollection) + foreach (var pInfo in role.ContentPermCollection) { newRole.AddContentInfo((PermissionControlItem)pInfo.Clone()); } @@ -296,11 +330,11 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles public RoleItem CloneRole(string strRoleID) { - RoleItem orignalRole = GetRoleByID(strRoleID); + var orignalRole = FindRoleByID(strRoleID); if (null == orignalRole) return null; - RoleItem newRole = new RoleItem(strRoleID) + var newRole = new RoleItem(strRoleID) { AutoLogoutTime = orignalRole.AutoLogoutTime, IsAutoLogout = orignalRole.IsAutoLogout, @@ -312,22 +346,22 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles DisplayDescription = orignalRole.DisplayDescription }; - foreach (var mInfo in orignalRole.MenuCollection) + foreach (var mInfo in orignalRole.MenuPermCollection) { newRole.AddMenuInfo((PermissionControlItem)mInfo.Clone()); } - foreach (var rInfo in orignalRole.RecipeCollection) + foreach (var rInfo in orignalRole.RecipePermCollection) { newRole.AddRecipeInfo((PermissionControlItem)rInfo.Clone()); } - foreach (var pInfo in orignalRole.ContentCollection) + foreach (var pInfo in orignalRole.ContentPermCollection) { newRole.AddContentInfo((PermissionControlItem)pInfo.Clone()); } - foreach (var sInfo in orignalRole.RecipeStepCollection) + foreach (var sInfo in orignalRole.RecipeStepPermCollection) { newRole.AddStepInfo((PermissionControlItem)sInfo.Clone()); } @@ -340,7 +374,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles if (role == null) return false; - foreach (RoleItem r in RoleContainer) + foreach (var r in _roleContainer) { if (role.RoleName == r.RoleName && role.RoleId != r.RoleId) { @@ -352,59 +386,51 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles return true; } - public bool SaveRole(RoleItem pRoletoSave) + public bool SaveRole(RoleItem ri) { - if (!CheckAvailable(pRoletoSave)) + if (!CheckAvailable(ri)) return false; - var r = new Role( - pRoletoSave.RoleId, - pRoletoSave.RoleName, - pRoletoSave.IsAutoLogout, - pRoletoSave.AutoLogoutTime, - PermissionHelper.PermissionToString(pRoletoSave.MenuCollection, pRoletoSave.RecipeCollection, - pRoletoSave.ContentCollection,pRoletoSave.RecipeStepCollection), - pRoletoSave.Description + ri.RoleId, + ri.RoleName, + ri.IsAutoLogout, + ri.AutoLogoutTime, + PermissionHelper.PermissionToString(ri.MenuPermCollection, ri.RecipePermCollection, + ri.ContentPermCollection,ri.RecipeStepPermCollection), + ri.Description ); if (RoleAccountProvider.Instance.UpdateRole(r)) { - var oldRole = GetRoleByID(pRoletoSave.RoleId); - if (null == oldRole) + if (null == FindRoleByID(ri.RoleId)) { - var NewRole = CloneRole(pRoletoSave); - AddRole(NewRole); - return true; + // 如果是新建角色 + var newRole = CloneRole(ri); + var ret = AddRole(newRole, out var reason); + if (!ret) + DialogBox.ShowError($"Add Role failed, {reason}"); + return ret; } - - oldRole.RoleName = pRoletoSave.RoleName; - oldRole.IsAutoLogout = pRoletoSave.IsAutoLogout; - oldRole.AutoLogoutTime = pRoletoSave.AutoLogoutTime; - oldRole.Description = pRoletoSave.Description; - oldRole.MenuCollection.Clear(); - foreach (var mInfo in pRoletoSave.MenuCollection) + else { - oldRole.AddMenuInfo((PermissionControlItem)mInfo.Clone()); - mInfo.ComboBoxSaved = true; - } + // 刷新当前RoleItem,将保存状态置为已保存。 + ri.RoleName = ri.RoleName; + ri.IsAutoLogout = ri.IsAutoLogout; + ri.AutoLogoutTime = ri.AutoLogoutTime; + ri.Description = ri.Description; + + foreach (var perm in ri.MenuPermCollection) + perm.Update(); - foreach (var rInfo in pRoletoSave.RecipeCollection) - { - oldRole.AddRecipeInfo((PermissionControlItem)rInfo.Clone()); - rInfo.ComboBoxSaved = true; - } - - foreach (var pInfo in pRoletoSave.ContentCollection) - { - oldRole.AddContentInfo((PermissionControlItem)pInfo.Clone()); - pInfo.ComboBoxSaved = true; - } - - foreach (var sInfo in pRoletoSave.RecipeStepCollection) - { - oldRole.AddStepInfo((PermissionControlItem)sInfo.Clone()); - sInfo.ComboBoxSaved = true; + foreach (var perm in ri.RecipePermCollection) + perm.Update(); + + foreach (var perm in ri.RecipeStepPermCollection) + perm.Update(); + + foreach (var perm in ri.ContentPermCollection) + perm.Update(); } } else @@ -418,12 +444,12 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles public bool DeleteRole(string strRoleID) { - RoleItem r = GetRoleByID(strRoleID); + var r = FindRoleByID(strRoleID); if (r != null) { if (RoleAccountProvider.Instance.DeleteRole(strRoleID)) { - RoleContainer.Remove(r); + _roleContainer.Remove(r); return true; } else @@ -439,13 +465,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles return false; } - public ObservableCollection RoleContainer { get; } = new(); - - private static int _RoleNum; - private List _appMenuPermSource; - private List _recipeColumnPermSource; - private List _recipeStepPermSource; - private List _contentPermSource; + + #endregion + } diff --git a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleView.xaml b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleView.xaml index ddeeb75..04c3822 100644 --- a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleView.xaml +++ b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleView.xaml @@ -325,7 +325,7 @@ VerticalAlignment="Top" AlternationCount="2" IsEnabled="{Binding IsPermission}" - ItemsSource="{Binding Path=TreeSelectedRole.MenuCollection}" + ItemsSource="{Binding Path=TreeSelectedRole.MenuPermCollection}" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"> @@ -368,7 +368,7 @@ VerticalAlignment="Top" AlternationCount="2" IsEnabled="{Binding IsPermission}" - ItemsSource="{Binding Path=TreeSelectedRole.RecipeCollection}" + ItemsSource="{Binding Path=TreeSelectedRole.RecipePermCollection}" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"> @@ -411,7 +411,7 @@ VerticalAlignment="Top" AlternationCount="2" IsEnabled="{Binding IsPermission}" - ItemsSource="{Binding Path=TreeSelectedRole.RecipeStepCollection}" + ItemsSource="{Binding Path=TreeSelectedRole.RecipeStepPermCollection}" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"> @@ -454,7 +454,7 @@ VerticalAlignment="Top" AlternationCount="2" IsEnabled="{Binding IsPermission}" - ItemsSource="{Binding Path=TreeSelectedRole.ContentCollection}" + ItemsSource="{Binding Path=TreeSelectedRole.ContentPermCollection}" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"> diff --git a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleViewModel.cs b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleViewModel.cs index 9ceb224..5ca5d1c 100644 --- a/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleViewModel.cs +++ b/MECF.Framework.UI.Client/CenterViews/Configs/Roles/RoleViewModel.cs @@ -41,7 +41,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles public bool IsEnabledRoleName { get => _isEnabledRoleName; - set { _isEnabledRoleName = value; NotifyOfPropertyChange("IsEnabledRoleName"); } + set { _isEnabledRoleName = value; NotifyOfPropertyChange(); } } public static RoleManager RoleManager => RoleManager.Instance; @@ -57,14 +57,18 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles set { _treeSelectedRole = value; - NotifyOfPropertyChange("TreeSelectedRole"); + NotifyOfPropertyChange(); } } public CtrlMode ControlMode { get => _controlMode; - set { _controlMode = value; NotifyOfPropertyChange(); } + set + { + _controlMode = value; + NotifyOfPropertyChange(); + } } #endregion @@ -87,7 +91,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles { if (DialogBox.Confirm("The data has been modified. Do you want to save the change(s)?")) { - if (SaveChanged()) + if (SaveChanges()) { ControlMode = CtrlMode.VIEW; DialogBox.ShowInfo("Operated successfully."); @@ -124,9 +128,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles return ((CheckBox)(sender)).IsChecked.Value; } - private bool SaveChanged() + private bool SaveChanges() { - if (String.IsNullOrWhiteSpace(TreeSelectedRole.DisplayRoleName)) + if (string.IsNullOrWhiteSpace(TreeSelectedRole.DisplayRoleName)) { DialogBox.ShowWarning("{0} cannot be empty.", "Role name"); //TreeSelectedRole.DisplayRoleName = "No Name"; @@ -197,7 +201,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles TreeSelectedRole = roleItem; } - private void OnBtnAddRoleCommand(Object arg) + private void OnBtnAddRoleCommand(object arg) { var newRole = RoleManager.CreateRole(); if (newRole != null) @@ -209,7 +213,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles ControlMode = CtrlMode.EDIT; } - private void OnBtnDeleteRoleCommand(Object arg) + private void OnBtnDeleteRoleCommand(object arg) { var lstRoleCanNotDelete = new List() { "管理员", "设备工程师", "工艺工程师", "操作员" }; if (TreeSelectedRole == null) return; @@ -255,7 +259,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles } } - private void OnBtnCloneRoleCommand(Object arg) + private void OnBtnCloneRoleCommand(object arg) { if (_treeSelectedRole != null) { @@ -271,14 +275,14 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles } } - private void OnBtnSaveCommand(Object arg) + private void OnBtnSaveCommand(object arg) { try { - if (SaveChanged()) + if (SaveChanges()) { - ControlMode = CtrlMode.VIEW; DialogBox.ShowInfo("Operated successfully."); + ControlMode = CtrlMode.VIEW; } else DialogBox.ShowInfo("Operation failed."); @@ -290,7 +294,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles } } - private void OnBtnCancelRoleCommand(Object arg) + private void OnBtnCancelRoleCommand(object arg) { LoadRoleList(); ControlMode = CtrlMode.VIEW; @@ -317,7 +321,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles get { if (_btnSaveCommand == null) - _btnSaveCommand = new BaseCommand((Object arg) => OnBtnSaveCommand(arg)); + _btnSaveCommand = new BaseCommand((object arg) => OnBtnSaveCommand(arg)); return _btnSaveCommand; } } @@ -328,7 +332,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles get { if (_btnAddRoleCommand == null) - _btnAddRoleCommand = new BaseCommand((Object arg) => OnBtnAddRoleCommand(arg)); + _btnAddRoleCommand = new BaseCommand((object arg) => OnBtnAddRoleCommand(arg)); return _btnAddRoleCommand; } } @@ -339,7 +343,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles get { if (_btnDeleteRoleCommand == null) - _btnDeleteRoleCommand = new BaseCommand((Object arg) => OnBtnDeleteRoleCommand(arg)); + _btnDeleteRoleCommand = new BaseCommand((object arg) => OnBtnDeleteRoleCommand(arg)); return _btnDeleteRoleCommand; } } @@ -350,7 +354,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles get { if (_btnCloneRoleCommand == null) - _btnCloneRoleCommand = new BaseCommand((Object arg) => OnBtnCloneRoleCommand(arg)); + _btnCloneRoleCommand = new BaseCommand((object arg) => OnBtnCloneRoleCommand(arg)); return _btnCloneRoleCommand; } } @@ -360,7 +364,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles get { if (_btnCancelRoleCommand == null) - _btnCancelRoleCommand = new BaseCommand((Object arg) => OnBtnCancelRoleCommand(arg)); + _btnCancelRoleCommand = new BaseCommand((object arg) => OnBtnCancelRoleCommand(arg)); return _btnCancelRoleCommand; } } diff --git a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs index 16965a9..30e6a91 100644 --- a/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs +++ b/MECF.Framework.UI.Client/CenterViews/Editors/Recipe/RecipeEditorViewModel.cs @@ -451,7 +451,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe }; //得到当前登录的RoleItem - var role = _roleManager.GetRoleByName(BaseApp.Instance.UserContext.Role.RoleName); + var role = _roleManager.FindRoleByName(BaseApp.Instance.UserContext.Role.RoleName); recipeData.ReloadRolePermission(role); CurrentRecipe = recipeData; diff --git a/MECF.Framework.UI.Client/ClientBase/BaseApp.cs b/MECF.Framework.UI.Client/ClientBase/BaseApp.cs index 068b9d5..a1bb6ef 100644 --- a/MECF.Framework.UI.Client/ClientBase/BaseApp.cs +++ b/MECF.Framework.UI.Client/ClientBase/BaseApp.cs @@ -90,7 +90,7 @@ namespace MECF.Framework.UI.Client.ClientBase int per = 1; if (UserContext != null) { - string[] list = UserContext.Role.MenuPermission.Split(';'); + string[] list = UserContext.Role.PermissionContent.Split(';'); var result = from r in list where r.Split(',')[0] == menuid select r; diff --git a/MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/RecipeData.cs b/MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/RecipeData.cs index ca3f132..a8b05ef 100644 --- a/MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/RecipeData.cs +++ b/MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/RecipeData.cs @@ -322,7 +322,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel var roleManager = new RoleManager(); roleManager.Initialize(); - var role = roleManager.GetRoleByName(BaseApp.Instance.UserContext.Role.RoleName); + var role = roleManager.FindRoleByName(BaseApp.Instance.UserContext.Role.RoleName); ReloadRolePermission(role); } @@ -559,8 +559,8 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel if (processType.Contains("Process")) { roleManager.Initialize(); - var roleItem = roleManager.GetRoleByName(BaseApp.Instance.UserContext.Role.RoleName); - menuPermission.ParsePermission(roleItem.Role.MenuPermission); + var roleItem = roleManager.FindRoleByName(BaseApp.Instance.UserContext.Role.RoleName); + menuPermission.ParsePermission(roleItem.Role.PermissionContent); } using (Steps.BeginLoading()) @@ -1817,7 +1817,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel _formatBuilder.ReloadColumnsPermission(role); var mp = new PermissionHelper(); - mp.ParsePermission(role.Role.MenuPermission); + mp.ParsePermission(role.Role.PermissionContent); foreach (var step in Steps) { diff --git a/MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/RecipeFormatBuilder.cs b/MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/RecipeFormatBuilder.cs index e037c48..7157de1 100644 --- a/MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/RecipeFormatBuilder.cs +++ b/MECF.Framework.UI.Client/RecipeEditorLib/RecipeModel/RecipeFormatBuilder.cs @@ -409,10 +409,10 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel roleManager.Initialize(); //得到当前登录的RoleItem - var roleItem = roleManager.GetRoleByName(roleName); + var roleItem = roleManager.FindRoleByName(roleName); var menuPermission = new PermissionHelper(); - menuPermission.ParsePermission(roleItem.Role.MenuPermission); + menuPermission.ParsePermission(roleItem.Role.PermissionContent); var columns = new List(); @@ -847,7 +847,7 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel public void ReloadColumnsPermission(RoleItem role) { var perm = new PermissionHelper(); - perm.ParsePermission(role.Role.MenuPermission); + perm.ParsePermission(role.Role.PermissionContent); foreach (var col in Columns) { diff --git a/Sicentury.Core/BindableBase.cs b/Sicentury.Core/BindableBase.cs index 8b44a9b..d98052e 100644 --- a/Sicentury.Core/BindableBase.cs +++ b/Sicentury.Core/BindableBase.cs @@ -1,8 +1,10 @@ +using System; using System.ComponentModel; using System.Runtime.CompilerServices; namespace Sicentury.Core { + [Serializable] public abstract class BindableBase : INotifyPropertyChanged {