bool IDestinationFolder.SetSearchCriteria(RestrictionData restriction, byte[][] entryIds, SearchCriteriaFlags flags)
        {
            MrsTracer.Provider.Function("StorageDestinationFolder.SetSearchCriteria: {0}", new object[]
            {
                base.DisplayNameForTracing
            });
            QueryFilter queryFilter = restriction.GetQueryFilter(base.Mailbox.StoreSession);

            StoreId[] array = null;
            if (entryIds != null && entryIds.Length > 0)
            {
                array = new StoreId[entryIds.Length];
                for (int i = 0; i < entryIds.Length; i++)
                {
                    array[i] = StoreObjectId.FromProviderSpecificId(entryIds[i]);
                }
            }
            using (base.Mailbox.RHTracker.Start())
            {
                SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(queryFilter, array);
                base.CoreFolder.SetSearchCriteria(searchFolderCriteria, this.ConvertSearchCriteriaFlags(flags));
            }
            return(true);
        }
 public void SetExtendedProps(PropTag[] promotedProperties, RestrictionData[] restrictions, SortOrderData[] views, ICSViewData[] icsViews)
 {
     MrsTracer.Provider.Function("StorageDestinationFolder.SetExtendedProps: {0}", new object[]
     {
         base.DisplayNameForTracing
     });
     if (promotedProperties != null && promotedProperties.Length > 0)
     {
         ExecutionContext.Create(new DataContext[]
         {
             new OperationDataContext("StorageDestinationFolder.SetPromotedProps", OperationType.None),
             new PropTagsDataContext(promotedProperties)
         }).Execute(delegate
         {
             PropertyDefinition[] dataColumns = this.Mailbox.ConvertPropTagsToDefinitions(promotedProperties);
             using (this.Mailbox.RHTracker.Start())
             {
                 using (QueryResult queryResult = this.CoreFolder.QueryExecutor.ItemQuery(ItemQueryType.None, null, null, dataColumns))
                 {
                     this.GetRowsIgnoreKnownFailures(queryResult);
                 }
             }
         });
     }
     if (restrictions != null && restrictions.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying restrictions.", new object[0]);
         for (int i = 0; i < restrictions.Length; i++)
         {
             RestrictionData rd = restrictions[i];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("StorageDestinationFolder.ApplyRestriction", OperationType.None),
                 new RestrictionDataContext(rd)
             }).Execute(delegate
             {
                 QueryFilter queryFilter          = rd.GetQueryFilter(this.Mailbox.StoreSession);
                 PropertyDefinition[] dataColumns = new PropertyDefinition[]
                 {
                     CoreObjectSchema.EntryId
                 };
                 using (this.Mailbox.RHTracker.Start())
                 {
                     using (new SortLCIDContext(this.Mailbox.StoreSession, rd.LCID))
                     {
                         using (QueryResult queryResult = this.CoreFolder.QueryExecutor.ItemQuery(ItemQueryType.None, queryFilter, null, dataColumns))
                         {
                             this.GetRowsIgnoreKnownFailures(queryResult);
                         }
                     }
                 }
             });
         }
     }
     if (views != null && views.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying views.", new object[0]);
         for (int j = 0; j < views.Length; j++)
         {
             SortOrderData sod = views[j];
             if (sod.Members != null && sod.Members.Length != 0)
             {
                 ExecutionContext.Create(new DataContext[]
                 {
                     new OperationDataContext("StorageDestinationFolder.ApplySortOrder", OperationType.None),
                     new SortOrderDataContext(sod)
                 }).Execute(delegate
                 {
                     List <SortBy> list;
                     List <GroupByAndOrder> list2;
                     int expandCount;
                     this.GetSortBy(sod, out list, out list2, out expandCount);
                     ItemQueryType itemQueryType = ItemQueryType.None;
                     if (sod.FAI)
                     {
                         itemQueryType |= ItemQueryType.Associated;
                     }
                     else if (sod.Conversation)
                     {
                         itemQueryType |= ItemQueryType.ConversationView;
                     }
                     PropertyDefinition[] dataColumns = new PropertyDefinition[]
                     {
                         CoreObjectSchema.EntryId
                     };
                     using (this.Mailbox.RHTracker.Start())
                     {
                         using (new SortLCIDContext(this.Mailbox.StoreSession, sod.LCID))
                         {
                             QueryResult queryResult;
                             if (list2.Count > 0)
                             {
                                 queryResult = this.CoreFolder.QueryExecutor.GroupedItemQuery(null, itemQueryType, list2.ToArray(), expandCount, list.ToArray(), dataColumns);
                             }
                             else
                             {
                                 queryResult = this.CoreFolder.QueryExecutor.ItemQuery(itemQueryType, null, (list.Count == 0) ? null : list.ToArray(), dataColumns);
                             }
                             using (queryResult)
                             {
                                 this.GetRowsIgnoreKnownFailures(queryResult);
                             }
                         }
                     }
                 });
             }
         }
     }
     if (icsViews != null && icsViews.Length > 0)
     {
         MrsTracer.Provider.Debug("Applying ICS views.", new object[0]);
         for (int k = 0; k < icsViews.Length; k++)
         {
             ICSViewData icsView = icsViews[k];
             ExecutionContext.Create(new DataContext[]
             {
                 new OperationDataContext("StorageDestinationFolder.ApplyICSView", OperationType.None),
                 new ICSViewDataContext(icsView)
             }).Execute(delegate
             {
                 using (MailboxSyncProvider mailboxSyncProvider = new MailboxSyncProvider(this.Folder, true, !icsView.Conversation, true, icsView.Conversation, true, false, null))
                 {
                     mailboxSyncProvider.GetMaxItemWatermark(mailboxSyncProvider.CreateNewWatermark());
                 }
             });
         }
     }
 }