private List <CustomFilter> LoadCustomFilters(XmlNode rootNode, bool reportErrors)
        {
            List <CustomFilter> list = new List <CustomFilter>();

            if (rootNode != null && rootNode.Name == "customFilters")
            {
                foreach (XmlNode childNode in rootNode.ChildNodes)
                {
                    if (childNode.Name == "filter")
                    {
                        try
                        {
                            CustomFilter item = new CustomFilter(childNode.OuterXml);
                            list.Add(item);
                        }
                        catch (AppSettingsException)
                        {
                            if (reportErrors)
                            {
                                string str = SR.GetString("CF_NoInvalidFilterName");
                                if (childNode["name"] != null && !string.IsNullOrEmpty(childNode["name"].InnerText))
                                {
                                    str = childNode["name"].InnerText;
                                }
                                errorReport.ReportErrorToUser(SR.GetString("CF_InvalidFilter") + str);
                            }
                        }
                    }
                }
                return(list);
            }
            return(list);
        }
 public void RemoveFilter(CustomFilter filter)
 {
     if (CurrentFilters.Contains(filter))
     {
         CurrentFilters.Remove(filter);
     }
 }
Esempio n. 3
0
 private void filterExpression_Validating(object sender, CancelEventArgs e)
 {
     paramGrid.Rows.Clear();
     if (!string.IsNullOrEmpty(XPathExpression))
     {
         if (!CustomFilter.ValidateXPath(XPathExpression))
         {
             errorReport.ReportErrorToUser(SR.GetString("CF_Err3"));
             e.Cancel = true;
         }
         else
         {
             UpdateParameterList();
         }
     }
 }
Esempio n. 4
0
 public void Initialize(CustomFilter filter)
 {
     currentFilter          = filter;
     filterName.Text        = filter.FilterName;
     filterDescription.Text = filter.FilterDescription;
     filterExpression.Text  = filter.Expression;
     foreach (string key in filter.Namespaces.Keys)
     {
         ListViewItem value = new ListViewItem(new string[2]
         {
             key,
             filter.Namespaces[key]
         });
         listNamespace.Items.Add(value);
     }
     UpdateParameterList(filter.Parameters);
 }
Esempio n. 5
0
        private void UpdateParameterList()
        {
            int num = CustomFilter.ExtractXPathParameters(XPathExpression);

            if (num != 0)
            {
                for (int i = 0; i < num; i++)
                {
                    DataGridViewRow dataGridViewRow = new DataGridViewRow();
                    dataGridViewRow.CreateCells(paramGrid);
                    dataGridViewRow.Cells[0].Value = SR.GetString("CF_LeftB") + i.ToString(CultureInfo.InvariantCulture) + SR.GetString("CF_RightB");
                    dataGridViewRow.Cells[1].Value = SR.GetString("CF_Type1");
                    dataGridViewRow.Cells[2].Value = string.Empty;
                    paramGrid.Rows.Add(dataGridViewRow);
                }
            }
            UpdateNamespaceGroupStatus();
        }
Esempio n. 6
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(FilterName))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err1"));
     }
     else if (string.IsNullOrEmpty(XPathExpression))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err2"));
     }
     else if (!string.IsNullOrEmpty(XPathExpression) && XPathExpression.Length > 5120)
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err19"));
     }
     else if (!CustomFilter.ValidateXPath(XPathExpression))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err3"));
     }
     else if (parent.IsDuplicateFilterName(FilterName, (currentFilter == null) ? string.Empty : currentFilter.FilterName))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err4"));
     }
     else
     {
         try
         {
             currentFilter = new CustomFilter(FilterName, FilterDescription, XPathExpression, Namespaces, Parameters);
         }
         catch (AppSettingsException)
         {
             errorReport.ReportErrorToUser(SR.GetString("CF_Err5"));
             return;
         }
         base.DialogResult = DialogResult.OK;
         Close();
     }
 }
 private void btnOk_Click(object sender, EventArgs e)
 {
     if (!UpdateXPathExpression())
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_InvalidLogic"));
     }
     if (string.IsNullOrEmpty(filterName.Text))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err1"));
     }
     else if (string.IsNullOrEmpty(xpathExpression.Text))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err2"));
     }
     else if (!string.IsNullOrEmpty(xpathExpression.Text) && xpathExpression.Text.Length > 5120)
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err19"));
     }
     else if (!CustomFilter.ValidateXPath(xpathExpression.Text.Trim()))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err3"));
     }
     else if (parent.IsDuplicateFilterName(filterName.Text, string.Empty))
     {
         errorReport.ReportErrorToUser(SR.GetString("CF_Err4"));
     }
     else
     {
         try
         {
             Dictionary <string, string> dictionary = new Dictionary <string, string>();
             foreach (string key in nsMap.Keys)
             {
                 dictionary.Add(nsMap[key], key);
             }
             List <CustomFilter.CustomFilterParameter> list = new List <CustomFilter.CustomFilterParameter>();
             int num = -1;
             foreach (DataGridViewRow item in (IEnumerable)logicGrid.Rows)
             {
                 if (item.Cells[3].Value.ToString() != SR.GetString("CF_None"))
                 {
                     int num2 = int.Parse(item.Cells[3].Value.ToString().Substring(1, 1), CultureInfo.InvariantCulture);
                     if (num2 > num)
                     {
                         num = num2;
                     }
                 }
             }
             if (num != -1)
             {
                 for (int i = 0; i <= num; i++)
                 {
                     CustomFilter.CustomFilterParameter customFilterParameter = new CustomFilter.CustomFilterParameter();
                     customFilterParameter.type = CustomFilterParameterValueType.AnyText;
                     list.Add(customFilterParameter);
                 }
             }
             currentFilter = new CustomFilter(filterName.Text, filterDescription.Text, xpathExpression.Text.Trim(), dictionary, list);
         }
         catch (AppSettingsException)
         {
             errorReport.ReportErrorToUser(SR.GetString("CF_Err5"));
             return;
         }
         base.DialogResult = DialogResult.OK;
         Close();
     }
 }