public bool ValiddatePermission(ManagerAccount account, string controller, string action, string filePath) { bool bResult = false; string actionName = string.IsNullOrEmpty(ActionName) ? action : ActionName; if (account != null) { List <GetPermissionCode> perm = null; // 测试当前controller是否已赋权限值,如果没有从 // 如果存在区域,Seesion保存(区域+控制器) if (!string.IsNullOrEmpty(_area)) { controller = _area + "/" + controller; } perm = (List <GetPermissionCode>)HttpContext.Current.Session[filePath]; if (perm == null) { using (var channelPermissionBll = new ChannelPermissionBll() { ChannelPermissionRepository = new ChannelPermissionRepository() }) { perm = channelPermissionBll.GetPermission(account.ManagerId, controller); // 获取当前用户的权限列表 HttpContext.Current.Session[filePath] = perm; // 获取的劝降放入会话由Controller调用 } //perm = ChannelPermissionBll.GetPermission(account.ManagerId, controller); //HttpContext.Current.Session[filePath] = perm; } // 当用户访问index时,只要权限大于0就可以访问 if (actionName.ToLower() == "index") { if (perm.Count > 0) { return(true); } } // 查询当前Action 是否有操作权限,大于0表示有,否则没有 int count = perm.Count(a => a.KeyCode.ToLower() == actionName.ToLower()); if (count > 0) { bResult = true; } else { bResult = false; HttpContext.Current.Response.Write("您没有操作权限!"); } } return(bResult); }
public JsonResult GetPermissionByRoleAndMoudle(GridPager pager, string roleId, string moudleId) { pager.Rows = 1000; var permis = ChannelPermissionBll.GetPermissionByRoleAndMoudle(roleId, moudleId); var json = new { total = pager.TotalRows, rows = (from r in permis select new PermissionInfo() { RightOperateId = r.RightId + r.KeyCode, Name = r.Name, KeyCode = r.KeyCode, RightId = r.RightId, IsValid = r.IsValid }).ToArray() }; return(Json(json)); }
public int UpdatePermission(ChannelRightOperate model) { return(ChannelPermissionBll.UpdatePermission(model)); }