Beispiel #1
0
        public bool CheckUserActionPermissionByIntCode(ETEMEnums.SecuritySettings securitySetting)
        {
            if (userProps != null)
            {
                this.userProps.SecuritySetting = securitySetting.ToString();

                if (this.FormContext.DictionaryPermittedActionSetting.FirstOrDefault(s => s.Value.SecuritySetting == securitySetting.ToString()).Value != null)
                {
                    this.userProps.SecuritySettingBG = this.FormContext.DictionaryPermittedActionSetting.FirstOrDefault(s => s.Value.SecuritySetting == securitySetting.ToString()).Value.FrendlyName;
                }
                else
                {
                    this.userProps.SecuritySettingBG = "###" + securitySetting.ToString() + "###";
                }
            }

            if (this.UserProps.Roles.Any(a => a.Name == "SUPPORT"))
            {
                return(true);
            }

            if (this.UserProps.Roles.Any(a => a.Name == "VIEW"))
            {
                return(true);
            }

            int checkCount = (from pa in this.FormContext.DictionaryPermittedActionSetting.Values
                              where pa.SecuritySetting == securitySetting.ToString() &&
                              this.UserProps.ListUserPermittedActionsID.Contains(pa.idPermittedAction)

                              select pa.SecuritySetting).Count();

            return(checkCount > 0 ? true : false);
        }
Beispiel #2
0
        public bool CheckUserActionPermission(ETEMEnums.SecuritySettings securitySetting, bool _MakeRedirect)
        {
            if (userProps != null)
            {
                this.userProps.SecuritySetting   = securitySetting.ToString();
                this.userProps.SecuritySettingBG = this.FormContext.DictionaryPermittedActionSetting.FirstOrDefault(s => s.Value.SecuritySetting == securitySetting.ToString()).Value.FrendlyName;
            }

            if (this.UserProps.Roles.Any(a => a.Name == "SUPPORT"))
            {
                return(true);
            }

            if (this.UserProps.Roles.Any(a => a.Name == "VIEW"))
            {
                return(true);
            }

            bool result = CheckUserActionPermissionByIntCode(securitySetting);

            if (!result)
            {
                if (_MakeRedirect)
                {
                    if (this.Page.Master != null)
                    {
                        Response.Redirect("~/UI/NoPermission.aspx");
                    }
                    else
                    {
                        Response.Redirect("~/UI/NoPermissionWithoutMasterPage.aspx");
                    }
                }
                else
                {
                    ShowMSG("Нямате права за това действие!");
                }
            }

            return(result);
        }