private void CreateCommandsUI(LogicalView view, Block block) { if (view == null) { throw new ArgumentNullException("view"); } if (block == null) { throw new ArgumentNullException("uiInfo"); } var commands = block.ViewMeta.AsWPFView().Commands.Where(c => c.IsVisible).ToList(); if (commands.Count > 0) { if (this.NeedPermission) { commands = commands.Where(c => PermissionMgr.HasCommand(this.PermissionModule, block, c.Name)).ToList(); } //Toolbar view.CommandsContainer = this.CreateCommandsContainer(); this._viewFactory.BlockUIFactory.AppendCommands( view.CommandsContainer, view, commands ); } }
public bool Check(string permissionId) { string areaName = this.ControllerContext.RouteData.GetAreaName(); string controllerName = this.GetType().Name.Replace("Controller", ""); return(PermissionMgr.HasCommand(areaName, controllerName, permissionId)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { //UIShell.RbacManagementPlugin/Users/List //{pluginName}/{controller}/{action} string pluginName = filterContext.RouteData.GetAreaName(); string controller = filterContext.RouteData.GetRequiredString("controller"); string action = filterContext.RouteData.GetRequiredString("action"); if (string.IsNullOrWhiteSpace(Name)) { Name = action; } bool hasPermission = false; hasPermission = PermissionMgr.HasCommand(pluginName, controller, Name); if (hasPermission) { base.OnActionExecuting(filterContext); } else { filterContext.Result = new ViewResult { ViewName = NoPermissionView }; } }