Esempio n. 1
0
    public string[] UpdateRuleGroup_RulesGroupPage(string state, string SelectedRuleGroupID, string RuleGroupName, string RuleGroupParentId)
    {
        this.InitializeCulture();

        string[] retMessage = new string[4];

        try
        {
            AttackDefender.CSRFDefender(this.Page);
            var          rootCategory        = this.RulesGroupBusiness.GetRoot();
            decimal      RuleGroupID         = 0;
            string       StrObjRuleGroup     = string.Empty;
            string       SuccessMessageBody  = string.Empty;
            decimal      selectedRuleGroupID = decimal.Parse(this.StringBuilder.CreateString(SelectedRuleGroupID), CultureInfo.InvariantCulture);
            string       ruleGroupName       = this.StringBuilder.CreateString(RuleGroupName);
            string       ruleGroupParentId   = this.StringBuilder.CreateString(RuleGroupParentId);
            var          s            = this.StringBuilder.CreateString(state);
            ObjRuleGroup objRuleGroup = new ObjRuleGroup();
            UIActionType uam          = UIActionType.ADD;

            RuleCategory ruleGroup = new RuleCategory();
            switch (this.StringBuilder.CreateString(state))
            {
            case "Delete":
                uam = UIActionType.DELETE;
                if (selectedRuleGroupID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoRuleGroupSelectedforDelete").ToString()), retMessage);
                    return(retMessage);
                }
                else
                {
                    ruleGroup.ID = selectedRuleGroupID;
                }

                RuleGroupID = this.RulesGroupBusiness.DeleteRuleGroup(ruleGroup, uam);

                SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString();
                objRuleGroup.ID    = RuleGroupID.ToString();
                StrObjRuleGroup    = this.JsSerializer.Serialize(objRuleGroup);
                break;

            case "Copy":
                if (selectedRuleGroupID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoRuleGroupSelectedforCopy").ToString()), retMessage);
                    return(retMessage);
                }
                else
                {
                    ruleGroup = this.RulesGroupBusiness.CopyRuleCategory(selectedRuleGroupID);

                    SuccessMessageBody = GetLocalResourceObject("CopyComplete").ToString();
                    objRuleGroup.ID    = ruleGroup.ID.ToString();
                    objRuleGroup.Name  = ruleGroup.Name;
                    StrObjRuleGroup    = this.JsSerializer.Serialize(objRuleGroup);
                }
                break;

            case "AddGroup":
                uam = UIActionType.ADD;
                ruleGroup.IsGroup  = true;
                ruleGroup.IsRoot   = false;
                ruleGroup.Name     = ruleGroupName;
                ruleGroup.ParentId = rootCategory.ID;

                selectedRuleGroupID = this.RulesGroupBusiness.InsertRuleGroup(ruleGroup, uam);

                SuccessMessageBody = GetLocalResourceObject("SaveComplete").ToString();
                objRuleGroup.ID    = ruleGroup.ID.ToString();
                objRuleGroup.Name  = ruleGroup.Name;
                StrObjRuleGroup    = this.JsSerializer.Serialize(objRuleGroup);
                break;

            case "Edit":
                uam = UIActionType.EDIT;
                if (selectedRuleGroupID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoItemSelectedforEdit").ToString()), retMessage);
                    return(retMessage);
                }
                else
                {
                    ruleGroup.Name    = ruleGroupName;
                    ruleGroup.ID      = selectedRuleGroupID;
                    ruleGroup.IsRoot  = false;
                    ruleGroup.IsGroup = true;

                    selectedRuleGroupID = this.RulesGroupBusiness.UpdateRuleGroup(ruleGroup, uam);
                    SuccessMessageBody  = GetLocalResourceObject("EditComplete").ToString();
                    objRuleGroup.ID     = ruleGroup.ID.ToString();
                    objRuleGroup.Name   = ruleGroup.Name;
                    StrObjRuleGroup     = this.JsSerializer.Serialize(objRuleGroup);
                }
                break;
            }

            retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
            retMessage[1] = SuccessMessageBody;
            retMessage[2] = "success";
            retMessage[3] = StrObjRuleGroup;
            return(retMessage);
        }
        catch (UIValidationExceptions ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
            return(retMessage);
        }
        catch (UIBaseException ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
            return(retMessage);
        }
        catch (Exception ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
            return(retMessage);
        }
    }
Esempio n. 2
0
    public string[] UpdateRuleGroup_RulesGroupPage(string state, string SelectedRuleGroupID)
    {
        this.InitializeCulture();

        string[] retMessage = new string[4];

        try
        {
            decimal      RuleGroupID         = 0;
            string       StrObjRuleGroup     = string.Empty;
            string       SuccessMessageBody  = string.Empty;
            decimal      selectedRuleGroupID = decimal.Parse(this.StringBuilder.CreateString(SelectedRuleGroupID));
            ObjRuleGroup objRuleGroup        = new ObjRuleGroup();
            UIActionType uam = UIActionType.ADD;

            RuleCategory ruleGroup = new RuleCategory();
            switch (this.StringBuilder.CreateString(state))
            {
            case "Delete":
                uam = UIActionType.DELETE;
                if (selectedRuleGroupID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoRuleGroupSelectedforDelete").ToString()), retMessage);
                    return(retMessage);
                }
                else
                {
                    ruleGroup.ID = selectedRuleGroupID;
                }

                RuleGroupID = this.RulesGroupBusiness.DeleteRuleGroup(ruleGroup, uam);

                SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString();
                objRuleGroup.ID    = RuleGroupID.ToString();
                StrObjRuleGroup    = this.JsSerializer.Serialize(objRuleGroup);
                break;

            case "Copy":
                if (selectedRuleGroupID == 0)
                {
                    retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoRuleGroupSelectedforCopy").ToString()), retMessage);
                    return(retMessage);
                }
                else
                {
                    ruleGroup = this.RulesGroupBusiness.CopyRuleCategory(selectedRuleGroupID);

                    SuccessMessageBody = GetLocalResourceObject("CopyComplete").ToString();
                    objRuleGroup.ID    = ruleGroup.ID.ToString();
                    objRuleGroup.Name  = ruleGroup.Name;
                    StrObjRuleGroup    = this.JsSerializer.Serialize(objRuleGroup);
                }
                break;
            }

            retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
            retMessage[1] = SuccessMessageBody;
            retMessage[2] = "success";
            retMessage[3] = StrObjRuleGroup;
            return(retMessage);
        }
        catch (UIValidationExceptions ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
            return(retMessage);
        }
        catch (UIBaseException ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
            return(retMessage);
        }
        catch (Exception ex)
        {
            retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
            return(retMessage);
        }
    }