Пример #1
0
        private void BindValues()
        {
            if (IssRuleId > 0 && !IsNewIn)
            {
                IncidentBoxRule ibr = IncidentBoxRule.Load(IssRuleId);
                Util.CommonHelper.SafeSelect(ddKey, ibr.Key);
                if (ibr.Key == "TypeId")
                {
                    Util.CommonHelper.SafeSelect(ddType, ibr.Value);
                }
                else if (ibr.Key == "EMailBox")
                {
                    Util.CommonHelper.SafeSelect(ddEmailBoxes, ibr.Value);
                }
                else if (ibr.Key == "CreatorId")
                {
                    Util.CommonHelper.SafeSelect(ddCreator, ibr.Value);
                }
                else if (ibr.Key == "ProjectId")
                {
                    Util.CommonHelper.SafeSelect(ddProject, ibr.Value);
                }
                else if (ibr.Key == "PriorityId")
                {
                    Util.CommonHelper.SafeSelect(ddPriority, ibr.Value);
                }
                else if (ibr.Key == "SeverityId")
                {
                    Util.CommonHelper.SafeSelect(ddSeverity, ibr.Value);
                }
                else if (ibr.Key == "GeneralCategories")
                {
                    string[] _values = ibr.Value.Split(';');
                    foreach (string sId in _values)
                    {
                        Util.CommonHelper.SafeMultipleSelect(lbGenCats, sId);
                    }
                }
                else if (ibr.Key == "IncidentCategories")
                {
                    string[] _values = ibr.Value.Split(';');
                    foreach (string sId in _values)
                    {
                        Util.CommonHelper.SafeMultipleSelect(lbIssCats, sId);
                    }
                }
                else
                {
                    txtValue.Text = ibr.Value;
                }

                if (ddRuleType.SelectedValue == "4")                    //Block
                {
                    Util.CommonHelper.SafeSelect(ddKey, ((int)ibr.RuleType).ToString());
                }
                if (ddRuleType.SelectedValue == "6")                    //Function
                {
                    Util.CommonHelper.SafeSelect(ddKey, ibr.Key);
                    int funcId = int.Parse(ibr.Key);
                    IncidentBoxRuleFunction brf = IncidentBoxRuleFunction.Load(funcId);

                    ArrayList paramItems = new ArrayList();

                    foreach (Match match in Regex.Matches(ibr.Value, "\"(?<Param>[^\"]+)\";?", RegexOptions.IgnoreCase | RegexOptions.Singleline))
                    {
                        string Value = match.Groups["Param"].Value;
                        paramItems.Add(Value);
                    }

                    System.Reflection.ParameterInfo[] paramsList = brf.GetParameters();
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("Position", typeof(int)));
                    dt.Columns.Add(new DataColumn("Name", typeof(string)));
                    dt.Columns.Add(new DataColumn("DefaultValue", typeof(string)));
                    DataRow dr;
                    foreach (System.Reflection.ParameterInfo par in paramsList)
                    {
                        dr                 = dt.NewRow();
                        dr["Position"]     = par.Position;
                        dr["Name"]         = par.Name;
                        dr["DefaultValue"] = paramItems[par.Position];
                        dt.Rows.Add(dr);
                    }
                    dgParams.DataSource = dt.DefaultView;
                    dgParams.DataBind();
                }
            }
        }
Пример #2
0
        private void BindKeys()
        {
            ddKey.Items.Clear();
            txtValue.Text       = "";
            dgParams.DataSource = null;
            dgParams.DataBind();
            lblNoFunction.Text    = LocRM.GetString("tNoFunction");
            lblNoFunction.Visible = false;
            tblMain.Visible       = true;

            switch (int.Parse(ddRuleType.SelectedValue))
            {
            case 0:                             //Operator
                ddKey.Attributes.Add("onchange", "ChangeKey(this)");
                trValue.Visible    = true;
                trOperator.Visible = true;

                ddKey.Items.Add(new ListItem("[MailSenderEmail]", "MailSenderEmail"));
                ddKey.Items.Add(new ListItem("[EMailBox]", "EMailBox"));
                ddKey.Items.Add(new ListItem("[EMailBody]", "EMailBody"));
                ddKey.Items.Add(new ListItem("[Title]", "Title"));
                ddKey.Items.Add(new ListItem("[Description]", "Description"));
                ddKey.Items.Add(new ListItem("[Title or Description or EMailBody]", "TitleOrDescriptionOrEMailBody"));
                ddKey.Items.Add(new ListItem("[Type]", "TypeId"));
                ddKey.Items.Add(new ListItem("[Priority]", "PriorityId"));
                ddKey.Items.Add(new ListItem("[Severity]", "SeverityId"));
                ddKey.Items.Add(new ListItem("[GeneralCategories]", "GeneralCategories"));
                ddKey.Items.Add(new ListItem("[IncidentCategories]", "IncidentCategories"));
                ddKey.Items.Add(new ListItem("[Creator]", "CreatorId"));
                if (Configuration.ProjectManagementEnabled)
                {
                    ddKey.Items.Add(new ListItem("[Project]", "ProjectId"));
                }

                //					MetaClass mc = MetaClass.Load("IncidentsEx");
                //					foreach(MetaField mf in mc.UserMetaFields)
                //						ddKey.Items.Add(new ListItem("["+mf.FriendlyName+"]",mf.Name));

                //ddKey.Items.Add(new ListItem(LocRM.GetString("tTypeYour"),"0"));
                Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                        "ChangeKey2('" + ddKey.ClientID + "');", true);
                break;

            case 4:                             //Block
                ddKey.Attributes.Remove("onchange");
                trValue.Visible    = false;
                trOperator.Visible = false;
                ddKey.Items.Add(new ListItem(GetRuleType(IncidentBoxRuleType.OrBlock), "4"));
                ddKey.Items.Add(new ListItem(GetRuleType(IncidentBoxRuleType.AndBlock), "5"));
                break;

            case 6:                             //Function
                ddKey.Attributes.Remove("onchange");
                trValue.Visible    = false;
                trOperator.Visible = false;

                IncidentBoxRuleFunction[] funcList = IncidentBoxRuleFunction.List();
                foreach (IncidentBoxRuleFunction fun in funcList)
                {
                    ddKey.Items.Add(new ListItem(fun.Name, fun.IncidentBoxRuleFunctionId.ToString()));
                }

                if (ddKey.Items.Count == 0)
                {
                    lblNoFunction.Visible = true;
                    tblMain.Visible       = false;
                }
                else
                {
                    IncidentBoxRuleFunction           brf        = IncidentBoxRuleFunction.Load(int.Parse(ddKey.SelectedValue));
                    System.Reflection.ParameterInfo[] paramsList = brf.GetParameters();
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("Position", typeof(int)));
                    dt.Columns.Add(new DataColumn("Name", typeof(string)));
                    dt.Columns.Add(new DataColumn("DefaultValue", typeof(string)));
                    DataRow dr;
                    foreach (System.Reflection.ParameterInfo par in paramsList)
                    {
                        dr             = dt.NewRow();
                        dr["Position"] = par.Position;
                        dr["Name"]     = par.Name;
                        dt.Rows.Add(dr);
                    }
                    dgParams.DataSource = dt.DefaultView;
                    dgParams.DataBind();
                }
                break;

            default:
                break;
            }
        }