예제 #1
0
        internal static bool IsActionAccessible(string actionCode, out BackendAction action)
        {
            using (new QPConnectionScope())
            {
                action = BackendActionRepository.GetByCode(actionCode);
                if (action == null)
                {
                    throw new ApplicationException($"Action is not found: {actionCode}");
                }

                if (QPContext.IsAdmin)
                {
                    return(true);
                }

                var actionType = BackendActionTypeRepository.GetById(action.TypeId);
                if (actionType == null)
                {
                    throw new ApplicationException($"Action Type is not found: {action.TypeId}");
                }

                var userPLevel = GetActionPermissionLevelForUser(action, QPContext.CurrentUserId);
                if (userPLevel == null)
                {
                    return(false);
                }

                return(userPLevel >= actionType.RequiredPermissionLevel);
            }
        }
예제 #2
0
        private static ToolbarButtonDAL CreateRefreshButton(int actionId)
        {
            var refreshAction = BackendActionRepository.GetByCode(ActionCode.RefreshCustomAction);

            if (refreshAction == null)
            {
                throw new ApplicationException($"Action is not found: {ActionCode.RefreshCustomAction}");
            }

            var refreshBtnDal = new ToolbarButtonDAL
            {
                ParentActionId = actionId,
                ActionId       = refreshAction.Id,
                Name           = "Refresh",
                Icon           = "refresh.gif",
                IsCommand      = true,
                Order          = 1
            };

            return(refreshBtnDal);
        }