Exemple #1
0
        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
                    );
            }
        }
Exemple #2
0
        public bool Check(string permissionId)
        {
            string areaName       = this.ControllerContext.RouteData.GetAreaName();
            string controllerName = this.GetType().Name.Replace("Controller", "");

            return(PermissionMgr.HasCommand(areaName, controllerName, permissionId));
        }
Exemple #3
0
        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
                };
            }
        }