예제 #1
0
 private void ApplyFilter()
 {
     if (this.UseDataTableLoaderSideFilter)
     {
         string text = (this.QueryFilter != null) ? this.QueryFilter.GenerateInfixString(FilterLanguage.Monad) : string.Empty;
         if (string.IsNullOrEmpty(text))
         {
             text = this.additionalFilter;
         }
         else if (!string.IsNullOrEmpty(this.additionalFilter))
         {
             text = string.Format(CultureInfo.InvariantCulture, "(({0}) -and ({1}))", new object[]
             {
                 text,
                 this.additionalFilter
             });
         }
         this.DataTableLoader.InputValue("Filter", text);
         this.DataTableLoader.Refresh(this.CreateProgress(this.DataTableLoader.RefreshCommandText));
     }
     else
     {
         string text2 = (this.QueryFilter != null) ? DataTableLoaderView.AdaptQueryFilterForAdo(this.GetTransformedFilter()).GenerateInfixString(FilterLanguage.Ado) : string.Empty;
         if (string.IsNullOrEmpty(text2))
         {
             text2 = this.additionalFilter;
         }
         else if (!string.IsNullOrEmpty(this.additionalFilter))
         {
             text2 = string.Format(CultureInfo.InvariantCulture, "({0} AND {1})", new object[]
             {
                 text2,
                 this.additionalFilter
             });
         }
         this.DataView.RowFilter = text2;
     }
     if (this.DataTableLoader.ResultsLoaderProfile != null && this.DataTableLoader.ResultsLoaderProfile.PostRefreshAction != null)
     {
         this.DataTableLoader.ResultsLoaderProfile.PostRefreshAction.FilteredDataView = this.DataView;
     }
 }
예제 #2
0
        public static QueryFilter AdaptQueryFilterForAdo(QueryFilter filter)
        {
            QueryFilter queryFilter = filter;

            if (filter is CompositeFilter)
            {
                CompositeFilter    compositeFilter = (CompositeFilter)filter;
                List <QueryFilter> list            = new List <QueryFilter>(compositeFilter.FilterCount);
                for (int i = 0; i < compositeFilter.FilterCount; i++)
                {
                    list.Add(DataTableLoaderView.AdaptQueryFilterForAdo(compositeFilter.Filters[i]));
                }
                if (filter is AndFilter)
                {
                    queryFilter = new AndFilter(compositeFilter.IgnoreWhenVerifyingMaxDepth, list.ToArray());
                }
                else if (filter is OrFilter)
                {
                    queryFilter = new OrFilter(compositeFilter.IgnoreWhenVerifyingMaxDepth, list.ToArray());
                }
            }
            else if (filter is TextFilter)
            {
                TextFilter textFilter = filter as TextFilter;
                queryFilter = new TextFilter(textFilter.Property, DataTableLoaderView.EscapeStringForADOLike(textFilter.Text), textFilter.MatchOptions, textFilter.MatchFlags);
            }
            else if (filter is ComparisonFilter)
            {
                ComparisonFilter comparisonFilter  = filter as ComparisonFilter;
                ComparisonFilter comparisonFilter2 = new ComparisonFilter(comparisonFilter.ComparisonOperator, comparisonFilter.Property, comparisonFilter.PropertyValue);
                if (comparisonFilter.ComparisonOperator == ComparisonOperator.NotEqual || comparisonFilter.ComparisonOperator == ComparisonOperator.LessThanOrEqual || comparisonFilter.ComparisonOperator == ComparisonOperator.LessThan)
                {
                    queryFilter = new OrFilter(new QueryFilter[]
                    {
                        comparisonFilter2,
                        new NotFilter(new ExistsFilter(comparisonFilter.Property))
                    });
                }
                else
                {
                    queryFilter = comparisonFilter2;
                }
            }
            else if (filter is NotFilter)
            {
                NotFilter   notFilter    = filter as NotFilter;
                QueryFilter queryFilter2 = DataTableLoaderView.AdaptQueryFilterForAdo(notFilter.Filter);
                TextFilter  textFilter2  = queryFilter2 as TextFilter;
                if (textFilter2 != null)
                {
                    queryFilter = new OrFilter(new QueryFilter[]
                    {
                        new NotFilter(queryFilter2),
                        new NotFilter(new ExistsFilter(textFilter2.Property))
                    });
                }
                else
                {
                    queryFilter = new NotFilter(queryFilter2);
                }
            }
            else if (filter is ExistsFilter)
            {
                ExistsFilter existsFilter = filter as ExistsFilter;
                queryFilter = new ExistsFilter(existsFilter.Property);
                if (existsFilter.Property.Type == typeof(string) || existsFilter.Property.Type == typeof(MultiValuedProperty <string>))
                {
                    queryFilter = new AndFilter(new QueryFilter[]
                    {
                        queryFilter,
                        new NotFilter(new TextFilter(existsFilter.Property, string.Empty, MatchOptions.ExactPhrase, MatchFlags.Default))
                    });
                }
            }
            return(queryFilter);
        }