Exemple #1
0
 private static bool EvaluateOrFilter(OrFilter filterOr, IReadOnlyPropertyBag propertyBag, bool shouldThrow)
 {
     foreach (QueryFilter filter in filterOr.Filters)
     {
         if (EvaluatableFilter.Evaluate(filter, propertyBag, shouldThrow))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
        private object[][] FilterUnusedRows(int rowCount)
        {
            this.CheckDisposed(null);
            List <object[]> list = new List <object[]>(rowCount);

            while (list.Count < rowCount && this.unusedRows.Count > 0)
            {
                object[] array = this.unusedRows.Dequeue();
                this.aggregationPropertyBag.Bind(array);
                if (EvaluatableFilter.Evaluate(this.aggregationFilter, this.aggregationPropertyBag))
                {
                    if (array.Length > this.columnsRequested)
                    {
                        Array.Resize <object>(ref array, this.columnsRequested);
                    }
                    list.Add(array);
                }
            }
            return(list.ToArray());
        }
Exemple #3
0
 public virtual void UpdateFilterState(SyncOperation syncOperation)
 {
     if (syncOperation.ChangeType == ChangeType.Delete)
     {
         this.entriesInFilter.Remove(syncOperation.Id);
         return;
     }
     try
     {
         try
         {
             bool flag = EvaluatableFilter.Evaluate(this.filter, syncOperation, true);
             if (flag)
             {
                 ServerManifestEntry serverManifestEntry = new ServerManifestEntry(syncOperation.Id);
                 serverManifestEntry.UpdateManifestFromPropertyBag(syncOperation);
                 serverManifestEntry.FirstMessageInConversation = syncOperation.FirstMessageInConversation;
                 this.entriesInFilter[syncOperation.Id]         = serverManifestEntry;
             }
         }
         catch (PropertyErrorException)
         {
             ISyncItem item = syncOperation.GetItem(MailboxSyncProvider.QueryColumns);
             bool      flag = item.IsItemInFilter(this.filter);
             if (flag)
             {
                 ServerManifestEntry serverManifestEntry2 = new ServerManifestEntry(syncOperation.Id);
                 serverManifestEntry2.UpdateManifestFromItem(item);
                 this.entriesInFilter[syncOperation.Id] = serverManifestEntry2;
             }
         }
     }
     catch (ObjectNotFoundException)
     {
     }
 }
            private void BuildResultSet(Folder folder, ItemQueryType itemQueryType, QueryFilter filter, QueryFilter optimizationFilter, SortBy[] sortBy, PropertyDefinition[] queryColumns, bool useSortOrder)
            {
                MailboxSyncPropertyBag mailboxSyncPropertyBag = new MailboxSyncPropertyBag(queryColumns);
                ComparisonFilter       comparisonFilter       = optimizationFilter as ComparisonFilter;

                mailboxSyncPropertyBag.AddColumnsFromFilter(filter);
                this.idxSortColumn = mailboxSyncPropertyBag.AddColumn(sortBy[0].ColumnDefinition);
                SortBy[] sortColumns = null;
                if (comparisonFilter != null && useSortOrder)
                {
                    SortOrder sortOrder;
                    switch (comparisonFilter.ComparisonOperator)
                    {
                    case ComparisonOperator.LessThan:
                    case ComparisonOperator.LessThanOrEqual:
                        sortOrder = SortOrder.Descending;
                        break;

                    default:
                        sortOrder = SortOrder.Ascending;
                        break;
                    }
                    sortColumns = new SortBy[]
                    {
                        new SortBy(comparisonFilter.Property, sortOrder)
                    };
                }
                QueryResult queryResult2;
                QueryResult queryResult = queryResult2 = folder.ItemQuery(itemQueryType, null, sortColumns, mailboxSyncPropertyBag.Columns);

                try
                {
                    bool flag = 0 != queryResult.EstimatedRowCount;
                    if (comparisonFilter != null)
                    {
                        flag = queryResult.SeekToCondition(SeekReference.OriginBeginning, comparisonFilter);
                        int currentRow = queryResult.CurrentRow;
                    }
                    if (flag)
                    {
                        int currentRow = queryResult.CurrentRow;
                        int num        = -1;
                        if (comparisonFilter != null)
                        {
                            QueryFilter seekFilter = MailboxSyncQueryProcessor.InMemoryFilterQueryResult.CreateNegatedComparisonFilter(comparisonFilter);
                            if (queryResult.SeekToCondition(SeekReference.OriginCurrent, seekFilter))
                            {
                                num = queryResult.CurrentRow;
                            }
                            queryResult.SeekToOffset(SeekReference.OriginBeginning, currentRow);
                        }
                        this.result = new List <object[]>(queryResult.EstimatedRowCount);
                        do
                        {
                            int num2 = 10000;
                            if (-1 != num)
                            {
                                num2 = num - currentRow;
                            }
                            if (num2 > 10000)
                            {
                                num2 = 10000;
                            }
                            object[][] rows = queryResult.GetRows(num2);
                            if (rows.Length == 0)
                            {
                                break;
                            }
                            for (int i = 0; i < rows.Length; i++)
                            {
                                mailboxSyncPropertyBag.Bind(rows[i]);
                                if (EvaluatableFilter.Evaluate(filter, mailboxSyncPropertyBag))
                                {
                                    this.result.Add(rows[i]);
                                }
                            }
                        }while (-1 == num || queryResult.CurrentRow < num);
                    }
                }
                finally
                {
                    if (queryResult2 != null)
                    {
                        ((IDisposable)queryResult2).Dispose();
                    }
                }
                if (this.result != null)
                {
                    this.result.Sort(this.GetSortByComparer(sortBy[0]));
                }
            }
Exemple #5
0
 public bool IsItemInFilter(QueryFilter filter)
 {
     this.CheckDisposed("IsItemInFilter");
     return(EvaluatableFilter.Evaluate(filter, this.item));
 }
Exemple #6
0
        public static bool Evaluate(QueryFilter filter, IReadOnlyPropertyBag propertyBag, bool shouldThrow)
        {
            AndFilter andFilter = filter as AndFilter;

            if (andFilter != null)
            {
                return(EvaluatableFilter.EvaluateAndFilter(andFilter, propertyBag, shouldThrow));
            }
            OrFilter orFilter = filter as OrFilter;

            if (orFilter != null)
            {
                return(EvaluatableFilter.EvaluateOrFilter(orFilter, propertyBag, shouldThrow));
            }
            NotFilter notFilter = filter as NotFilter;

            if (notFilter != null)
            {
                return(!EvaluatableFilter.Evaluate(notFilter.Filter, propertyBag, shouldThrow));
            }
            TextFilter textFilter = filter as TextFilter;

            if (textFilter != null)
            {
                return(EvaluatableFilter.EvaluateTextFilter(textFilter, propertyBag, shouldThrow));
            }
            ComparisonFilter comparisonFilter = filter as ComparisonFilter;

            if (comparisonFilter != null)
            {
                return(EvaluatableFilter.EvaluateComparisonFilter(comparisonFilter, propertyBag, shouldThrow));
            }
            if (filter is TrueFilter)
            {
                return(true);
            }
            if (filter is FalseFilter)
            {
                return(false);
            }
            CommentFilter commentFilter = filter as CommentFilter;

            if (commentFilter != null)
            {
                return(EvaluatableFilter.Evaluate(commentFilter.Filter, propertyBag, shouldThrow));
            }
            BitMaskFilter bitMaskFilter = filter as BitMaskFilter;

            if (bitMaskFilter != null)
            {
                return(EvaluatableFilter.EvaluateBitMaskFilter(bitMaskFilter, propertyBag, shouldThrow));
            }
            ExistsFilter existsFilter = filter as ExistsFilter;

            if (existsFilter != null)
            {
                return(EvaluatableFilter.EvaluateExistsFilter(existsFilter, propertyBag));
            }
            PropertyComparisonFilter propertyComparisonFilter = filter as PropertyComparisonFilter;

            if (propertyComparisonFilter != null)
            {
                return(EvaluatableFilter.EvaluatePropertyComparisonFilter(propertyComparisonFilter, propertyBag, shouldThrow));
            }
            throw new NotImplementedException();
        }
Exemple #7
0
 public static bool Evaluate(QueryFilter filter, IReadOnlyPropertyBag propertyBag)
 {
     return(EvaluatableFilter.Evaluate(filter, propertyBag, false));
 }