Exemple #1
0
        public string GetMenuButtonAuthority(string roleUid, FapMenuButton menuButton)
        {
            bool isAdministrator = _applicationContext.IsAdministrator;
            var  menu            = GetCurrentMenu();
            //注册多语
            string multilangKey = $"{menu?.Fid}_{menuButton.ButtonID}";

            menuButton.Description = _multiLangService.GetOrAndMultiLangValue(MultiLanguageOriginEnum.ButtonTag, multilangKey, menuButton.Description);
            if (menu != null)
            {
                if (_platformDomain.MenuButtonSet.TryGetValue(menu.Fid, out IEnumerable <FapMenuButton> list))
                {
                    if (list.Any() && list.ToList().Exists(m => m.ButtonID == menuButton.ButtonID))
                    {
                        //检查授权
                        if (!isAdministrator && _platformDomain.RoleButtonSet.TryGetValue(roleUid, out IEnumerable <FapRoleButton> roleButtons))
                        {
                            return(roleButtons.FirstOrDefault(b => b.ButtonId == menuButton.ButtonID)?.ButtonValue);
                        }
                    }
                    else
                    {
                        //注册按钮
                        menuButton.MenuUid = menu.Fid;
                        _dbContext.Insert(menuButton);
                        _platformDomain.MenuButtonSet.Refresh();
                    }
                }
                else
                {
                    //注册按钮
                    menuButton.MenuUid = menu.Fid;
                    _dbContext.Insert(menuButton);
                    _platformDomain.MenuButtonSet.Refresh();
                }
                if (isAdministrator)
                {
                    if (menuButton.ButtonType == FapMenuButtonType.Grid)
                    {
                        return(string.Join(',', typeof(OperEnum).EnumItems().Select(c => c.Key)));
                    }
                    else if (menuButton.ButtonType == FapMenuButtonType.Tree)
                    {
                        return("2,4,8,16");//增删改刷
                    }
                    else
                    {
                        return("1");
                    }
                }
            }
            return(string.Empty);
        }
 private string AuthenticationButton(QuerySet querySet)
 {
     if (RegisterAuthority)
     {
         FapMenuButton menuButton = new FapMenuButton()
         {
             ButtonID    = Id,
             ButtonName  = "表格按钮",
             ButtonType  = FapMenuButtonType.Grid,
             Description = _dbContext.Table(querySet.TableName).TableComment
         };
         //注册按钮
         return(_rbacService.GetMenuButtonAuthority(_applicationContext.CurrentRoleUid, menuButton));
     }
     return(string.Empty);
 }
 private string GetButtonPermission()
 {
     if (RegisterButton)
     {
         FapMenuButton menuButton = new FapMenuButton()
         {
             ButtonID    = Id,
             ButtonName  = "树按钮",
             ButtonType  = FapMenuButtonType.Tree,
             Description = Description,
             Enabled     = 1
         };
         //注册按钮
         return(_rbacService.GetMenuButtonAuthority(_applicationContext.CurrentRoleUid, menuButton));
     }
     return(string.Empty);
 }
        private string AuthenticationButton(QuerySet querySet)
        {
            string btnId = Id;

            if (IsSubgrid)
            {
                btnId = Id.Substring(0, Id.LastIndexOf("_"));
            }
            FapMenuButton menuButton = new FapMenuButton()
            {
                ButtonID    = btnId,
                ButtonName  = "表格按钮",
                Enabled     = 1,
                ButtonType  = FapMenuButtonType.Grid,
                Description = _dbContext.Table(querySet.TableName).TableComment
            };

            //注册按钮
            return(_rbacService.GetMenuButtonAuthority(_applicationContext.CurrentRoleUid, menuButton));
        }