/// <summary> /// 获取用户角色 /// </summary> private void GetUserRolesByUserID() { _curUserRoles = _userRolesBll.GetModel(_user.UserID); if (!string.IsNullOrEmpty(_curUserRoles.RoleID)) { string[] strRoles = _curUserRoles.RoleID.Split(','); for (int i = 0; i < strRoles.Length; i++) { _arrRoles.Add(Convert.ToInt32(strRoles[i])); } } }
/// <summary> /// 获取用户权限 /// </summary> /// <param name="userID"></param> /// <returns></returns> private bool GetUserRoleMenus(int userID) { _dicRoleMenus = new Dictionary <int, UserPermissions>(); UserRoles userRoles = null; RoleMenus roleMenus = null; string[] ayyRoles = new string[0] { }; //获取用户角色 userRoles = _userRolesBll.GetModel(userID); if (userRoles == null || string.IsNullOrEmpty(userRoles.RoleID)) { return(false); } ayyRoles = userRoles.RoleID.Split(','); for (int i = 0; i < ayyRoles.Length; i++) { //获取角色权限 roleMenus = _roleMenusBll.GetModel(Convert.ToInt32(ayyRoles[i])); foreach (int key in roleMenus.DicPermissions.Keys) { if (!_dicRoleMenus.ContainsKey(key)) { //添加到权限字典 _dicRoleMenus.Add(key, roleMenus.DicPermissions[key]); } } } return(true); }