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();
                }
            }
        }
Beispiel #2
0
        private string GetInnerText(IncidentBoxRule ibr)
        {
            string retVal = "";

            switch (ibr.RuleType)
            {
            case IncidentBoxRuleType.Contains:
            case IncidentBoxRuleType.IsEqual:
            case IncidentBoxRuleType.RegexMatch:
            case IncidentBoxRuleType.NotContains:
            case IncidentBoxRuleType.NotIsEqual:
                string sKey = ibr.Key;
                sKey    = (sKey == "TypeId") ? "Type" : sKey;
                sKey    = (sKey == "PriorityId") ? "Priority" : sKey;
                sKey    = (sKey == "SeverityId") ? "Severity" : sKey;
                sKey    = (sKey == "TypeId") ? "Type" : sKey;
                sKey    = (sKey == "CreatorId") ? "Creator" : sKey;
                sKey    = (sKey == "ProjectId") ? "Project" : sKey;
                sKey    = (sKey == "EMailBox") ? "E-mail Box" : sKey;
                sKey    = (sKey == "TitleOrDescriptionOrEMailBody") ? "Title or Description or EMailBody" : sKey;
                retVal += "<font color='#0000ff'>[" + sKey + "]</font>&nbsp;&nbsp;";
                retVal += "<b>" + GetRuleType(ibr.RuleType) + "</b>";
                if (ibr.Value.Length > 0)
                {
                    if (sKey == "Type")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Mediachase.IBN.Business.Common.GetIncidentType(int.Parse(ibr.Value)) + "'</font>";
                    }
                    else if (sKey == "E-mail Box")
                    {
                        // OZ 2008-11-27 Fix Problem if Pop3Box has been deleted.
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'";

                        try
                        {
                            retVal += Mediachase.IBN.Business.EMail.EMailRouterPop3Box.Load(int.Parse(ibr.Value)).Name;
                        }
                        catch
                        {
                            retVal += "Error: Wrong POP3 box id.";
                        }

                        retVal += "'</font>";
                    }
                    else if (sKey == "Creator")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Util.CommonHelper.GetUserStatusPureName(int.Parse(ibr.Value)) + "'</font>";
                    }
                    else if (sKey == "Project")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Task.GetProjectTitle(int.Parse(ibr.Value)) + "'</font>";
                    }
                    else if (sKey == "Priority")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Mediachase.IBN.Business.Common.GetPriority(int.Parse(ibr.Value)) + "'</font>";
                    }
                    else if (sKey == "Severity")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Mediachase.IBN.Business.Common.GetIncidentSeverity(int.Parse(ibr.Value)) + "'</font>";
                    }
                    else if (sKey == "GeneralCategories" && ibr.Value.Length > 0)
                    {
                        retVal += "&nbsp;&nbsp;<font color='red'>";
                        string[] _values = ibr.Value.Split(';');
                        for (int i = 0; i < _values.Length; i++)
                        {
                            string sId = _values[i];
                            if (i > 0)
                            {
                                if (ibr.RuleType == IncidentBoxRuleType.Contains ||
                                    ibr.RuleType == IncidentBoxRuleType.NotContains)
                                {
                                    retVal += "&nbsp;&nbsp;" + LocRM.GetString("tAND") + "&nbsp;&nbsp;";
                                }
                                if (ibr.RuleType == IncidentBoxRuleType.IsEqual ||
                                    ibr.RuleType == IncidentBoxRuleType.NotIsEqual)
                                {
                                    retVal += "&nbsp;&nbsp;" + LocRM.GetString("tOR") + "&nbsp;&nbsp;";
                                }
                            }
                            retVal += "'" +
                                      Mediachase.IBN.Business.Common.GetGeneralCategory(int.Parse(sId))
                                      + "'&nbsp;&nbsp;";
                        }
                        retVal += "</font>";
                    }
                    else if (sKey == "IncidentCategories" && ibr.Value.Length > 0)
                    {
                        retVal += "&nbsp;&nbsp;<font color='red'>";
                        string[] _values = ibr.Value.Split(';');
                        for (int i = 0; i < _values.Length; i++)
                        {
                            string sId = _values[i];
                            if (i > 0)
                            {
                                if (ibr.RuleType == IncidentBoxRuleType.Contains ||
                                    ibr.RuleType == IncidentBoxRuleType.NotContains)
                                {
                                    retVal += "&nbsp;&nbsp;" + LocRM.GetString("tAND") + "&nbsp;&nbsp;";
                                }
                                if (ibr.RuleType == IncidentBoxRuleType.IsEqual ||
                                    ibr.RuleType == IncidentBoxRuleType.NotIsEqual)
                                {
                                    retVal += "&nbsp;&nbsp;" + LocRM.GetString("tOR") + "&nbsp;&nbsp;";
                                }
                            }
                            retVal += "'" +
                                      Mediachase.IBN.Business.Common.GetIncidentCategory(int.Parse(sId))
                                      + "'&nbsp;&nbsp;";
                        }
                        retVal += "</font>";
                    }
                    else
                    {
                        if (ibr.RuleType == IncidentBoxRuleType.Contains ||
                            ibr.RuleType == IncidentBoxRuleType.IsEqual ||
                            ibr.RuleType == IncidentBoxRuleType.NotContains ||
                            ibr.RuleType == IncidentBoxRuleType.NotIsEqual)
                        {
                            retVal += "&nbsp;&nbsp;<font color='red'>";
                            string[] _values = ibr.Value.Split(';');
                            for (int i = 0; i < _values.Length; i++)
                            {
                                string sId = _values[i];
                                if (i > 0)
                                {
                                    if (ibr.RuleType == IncidentBoxRuleType.Contains ||
                                        ibr.RuleType == IncidentBoxRuleType.NotContains)
                                    {
                                        retVal += "&nbsp;&nbsp;" + LocRM.GetString("tAND") + "&nbsp;&nbsp;";
                                    }
                                    if (ibr.RuleType == IncidentBoxRuleType.IsEqual ||
                                        ibr.RuleType == IncidentBoxRuleType.NotIsEqual)
                                    {
                                        retVal += "&nbsp;&nbsp;" + LocRM.GetString("tOR") + "&nbsp;&nbsp;";
                                    }
                                }
                                retVal += "'" + sId + "'&nbsp;&nbsp;";
                            }
                            retVal += "</font>";
                        }
                        else
                        {
                            retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" + ibr.Value + "'</font>";
                        }
                    }
                }
                break;

            case IncidentBoxRuleType.Function:
                retVal += "<b>" + GetRuleType(ibr.RuleType) + "</b>";
                IncidentBoxRuleFunction brf = IncidentBoxRuleFunction.Load(int.Parse(ibr.Key));
                retVal += "&nbsp;&nbsp;<font color='#0000ff'>" + brf.Name + "(&nbsp;</font>";
                retVal += "<font color='#ff0000'>" + ibr.Value + "</font><font color='#0000ff'>&nbsp;)</font>";
                break;

            default:
                break;
            }
            return(retVal);
        }
        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;
            }
        }
Beispiel #4
0
        protected string GetLabel(object _type, object _key, object _value, object _index, object _level)
        {
            string retVal = "";
            int    iLevel = Util.CommonHelper.CountOf(_level.ToString(), ".") - 1;

            if (iLevel > 0)
            {
                iLevel  = iLevel * 40;
                retVal += String.Format("<img alt='' src='{1}' width='{0}px' height='1px' border='0' />",
                                        iLevel, this.Page.ResolveUrl("~/layouts/images/blank.gif"));
            }

            string sAnd_OR = "&nbsp;";

            if (_level.ToString() == ".")
            {
                if ((int)_index > 0)
                {
                    sAnd_OR = LocRM.GetString("tAND");
                }
            }
            else
            {
                string sLevel = _level.ToString();
                if (sLevel.EndsWith("."))
                {
                    sLevel = sLevel.Substring(0, sLevel.Length - 1);
                }
                sLevel = sLevel.Substring(sLevel.LastIndexOf(".") + 1);
                int             iNum = int.Parse(sLevel);
                IncidentBoxRule ibr  = IncidentBoxRule.Load(iNum);
                if (ibr.RuleType == IncidentBoxRuleType.OrBlock && (int)_index > ibr.OutlineIndex + 1)
                {
                    sAnd_OR = LocRM.GetString("tOR");
                }
                if (ibr.RuleType == IncidentBoxRuleType.AndBlock && (int)_index > ibr.OutlineIndex + 1)
                {
                    sAnd_OR = LocRM.GetString("tAND");
                }
            }
            retVal += "<span style='width:40px;'><font color='green'><b>" + sAnd_OR + "</b></font>&nbsp;</span>";
            switch ((IncidentBoxRuleType)_type)
            {
            case IncidentBoxRuleType.Contains:
            case IncidentBoxRuleType.IsEqual:
            case IncidentBoxRuleType.RegexMatch:
            case IncidentBoxRuleType.NotContains:
            case IncidentBoxRuleType.NotIsEqual:
                string sKey = _key.ToString();
                sKey    = (sKey == "TypeId") ? "Type" : sKey;
                sKey    = (sKey == "PriorityId") ? "Priority" : sKey;
                sKey    = (sKey == "SeverityId") ? "Severity" : sKey;
                sKey    = (sKey == "TypeId") ? "Type" : sKey;
                sKey    = (sKey == "CreatorId") ? "Creator" : sKey;
                sKey    = (sKey == "ProjectId") ? "Project" : sKey;
                sKey    = (sKey == "EMailBox") ? "E-mail Box" : sKey;
                sKey    = (sKey == "TitleOrDescriptionOrEMailBody") ? "Title or Description or EMailBody" : sKey;
                retVal += "<font color='#0000ff'>[" + sKey + "]</font>&nbsp;&nbsp;";
                retVal += "<b>" + GetRuleType((IncidentBoxRuleType)_type) + "</b>";
                if (_value.ToString().Length > 0)
                {
                    if (sKey == "Type")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Mediachase.IBN.Business.Common.GetIncidentType(int.Parse(_value.ToString())) + "'</font>";
                    }
                    else if (sKey == "E-mail Box")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Mediachase.IBN.Business.EMail.EMailRouterPop3Box.Load(int.Parse(_value.ToString())).Name + "'</font>";
                    }
                    else if (sKey == "Creator")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Util.CommonHelper.GetUserStatusPureName(int.Parse(_value.ToString())) + "'</font>";
                    }
                    else if (sKey == "Project")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Task.GetProjectTitle(int.Parse(_value.ToString())) + "'</font>";
                    }
                    else if (sKey == "Priority")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Mediachase.IBN.Business.Common.GetPriority(int.Parse(_value.ToString())) + "'</font>";
                    }
                    else if (sKey == "Severity")
                    {
                        retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" +
                                  Mediachase.IBN.Business.Common.GetIncidentSeverity(int.Parse(_value.ToString())) + "'</font>";
                    }
                    else if (sKey == "GeneralCategories" && _value.ToString().Length > 0)
                    {
                        retVal += "&nbsp;&nbsp;<font color='red'>";
                        string[] _values = _value.ToString().Split(';');
                        for (int i = 0; i < _values.Length; i++)
                        {
                            string sId = _values[i];
                            if (i > 0)
                            {
                                if ((IncidentBoxRuleType)_type == IncidentBoxRuleType.Contains ||
                                    (IncidentBoxRuleType)_type == IncidentBoxRuleType.NotContains)
                                {
                                    retVal += "&nbsp;&nbsp;" + LocRM.GetString("tAND") + "&nbsp;&nbsp;";
                                }
                                if ((IncidentBoxRuleType)_type == IncidentBoxRuleType.IsEqual ||
                                    (IncidentBoxRuleType)_type == IncidentBoxRuleType.NotIsEqual)
                                {
                                    retVal += "&nbsp;&nbsp;" + LocRM.GetString("tOR") + "&nbsp;&nbsp;";
                                }
                            }
                            retVal += "'" +
                                      Mediachase.IBN.Business.Common.GetGeneralCategory(int.Parse(sId))
                                      + "'&nbsp;&nbsp;";
                        }
                        retVal += "</font>";
                    }
                    else if (sKey == "IncidentCategories" && _value.ToString().Length > 0)
                    {
                        retVal += "&nbsp;&nbsp;<font color='red'>";
                        string[] _values = _value.ToString().Split(';');
                        for (int i = 0; i < _values.Length; i++)
                        {
                            string sId = _values[i];
                            if (i > 0)
                            {
                                if ((IncidentBoxRuleType)_type == IncidentBoxRuleType.Contains ||
                                    (IncidentBoxRuleType)_type == IncidentBoxRuleType.NotContains)
                                {
                                    retVal += "&nbsp;&nbsp;" + LocRM.GetString("tAND") + "&nbsp;&nbsp;";
                                }
                                if ((IncidentBoxRuleType)_type == IncidentBoxRuleType.IsEqual ||
                                    (IncidentBoxRuleType)_type == IncidentBoxRuleType.NotIsEqual)
                                {
                                    retVal += "&nbsp;&nbsp;" + LocRM.GetString("tOR") + "&nbsp;&nbsp;";
                                }
                            }
                            retVal += "'" +
                                      Mediachase.IBN.Business.Common.GetIncidentCategory(int.Parse(sId))
                                      + "'&nbsp;&nbsp;";
                        }
                        retVal += "</font>";
                    }
                    else
                    {
                        if ((IncidentBoxRuleType)_type == IncidentBoxRuleType.Contains ||
                            (IncidentBoxRuleType)_type == IncidentBoxRuleType.IsEqual ||
                            (IncidentBoxRuleType)_type == IncidentBoxRuleType.NotContains ||
                            (IncidentBoxRuleType)_type == IncidentBoxRuleType.NotIsEqual)
                        {
                            retVal += "&nbsp;&nbsp;<font color='red'>";
                            string[] _values = _value.ToString().Split(';');
                            for (int i = 0; i < _values.Length; i++)
                            {
                                string sId = _values[i];
                                if (i > 0)
                                {
                                    if ((IncidentBoxRuleType)_type == IncidentBoxRuleType.Contains ||
                                        (IncidentBoxRuleType)_type == IncidentBoxRuleType.NotContains)
                                    {
                                        retVal += "&nbsp;&nbsp;" + LocRM.GetString("tAND") + "&nbsp;&nbsp;";
                                    }
                                    if ((IncidentBoxRuleType)_type == IncidentBoxRuleType.IsEqual ||
                                        (IncidentBoxRuleType)_type == IncidentBoxRuleType.NotIsEqual)
                                    {
                                        retVal += "&nbsp;&nbsp;" + LocRM.GetString("tOR") + "&nbsp;&nbsp;";
                                    }
                                }
                                retVal += "'" + sId + "'&nbsp;&nbsp;";
                            }
                            retVal += "</font>";
                        }
                        else
                        {
                            retVal += "&nbsp;&nbsp;<font color='#ff0000'>'" + _value.ToString() + "'</font>";
                        }
                    }
                }
                break;

            case IncidentBoxRuleType.AndBlock:
            case IncidentBoxRuleType.OrBlock:
                retVal += "<b>" + GetRuleType((IncidentBoxRuleType)_type) + "</b>";
                break;

            case IncidentBoxRuleType.Function:
                retVal += "<b>" + GetRuleType((IncidentBoxRuleType)_type) + "</b>";
                IncidentBoxRuleFunction brf = IncidentBoxRuleFunction.Load(int.Parse(_key.ToString()));
                retVal += "&nbsp;&nbsp;<font color='#0000ff'>" + brf.Name + "(&nbsp;</font>";
                retVal += "<font color='#ff0000'>" + _value.ToString() + "</font><font color='#0000ff'>&nbsp;)</font>";
                break;

            default:
                break;
            }
            return(retVal);
        }