public static G RunQueryOnAllItemsFolder <G>(MailboxSession session, AllItemsFolderHelper.SupportedSortBy supportedSortBy, AllItemsFolderHelper.DoQueryProcessing <G> queryProcessor, ICollection <PropertyDefinition> properties, ItemQueryType itemQueryType)
        {
            AllItemsFolderHelper.CheckAndCreateDefaultFolders(session);
            G result;

            using (SearchFolder searchFolder = SearchFolder.Bind(session, DefaultFolderType.AllItems))
            {
                using (QueryResult queryResult = searchFolder.ItemQuery(itemQueryType, null, AllItemsFolderHelper.sortOrderMap[supportedSortBy], properties))
                {
                    result = queryProcessor(queryResult);
                }
            }
            return(result);
        }
Пример #2
0
 private static void UnsetStaleReminders(DefaultFolderContext context, SearchFolder reminders)
 {
     ExTraceGlobals.DefaultFoldersTracer.TraceDebug(-1L, "RemindersSearchFolderValidation::UnsetStaleReminders.");
     using (QueryResult queryResult = reminders.ItemQuery(ItemQueryType.None, null, new SortBy[]
     {
         new SortBy(InternalSchema.ReminderIsSet, SortOrder.Descending),
         new SortBy(InternalSchema.ReminderNextTime, SortOrder.Descending)
     }, new PropertyDefinition[]
     {
         InternalSchema.ItemId,
         InternalSchema.ParentItemId,
         InternalSchema.ReminderIsSet
     }))
     {
         ExDateTime now         = ExDateTime.GetNow(context.Session.ExTimeZone);
         StoreId[]  folderScope = RemindersSearchFolderValidation.CreateRemindersQueryForO11(context).FolderScope;
         queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.LessThan, InternalSchema.ReminderNextTime, now));
         bool       flag = false;
         object[][] rows;
         while (!flag && (rows = queryResult.GetRows(2147483647)).Length > 0)
         {
             foreach (object[] array2 in rows)
             {
                 bool flag2;
                 if (Util.TryConvertTo <bool>(array2[2], out flag2) && !flag2)
                 {
                     flag = true;
                     break;
                 }
                 StoreObjectId storeObjectId = PropertyBag.CheckPropertyValue <StoreObjectId>(StoreObjectSchema.ParentItemId, array2[1]);
                 bool          flag3         = false;
                 foreach (StoreId id in folderScope)
                 {
                     if (storeObjectId.Equals(id))
                     {
                         flag3 = true;
                         break;
                     }
                 }
                 if (!flag3)
                 {
                     try
                     {
                         VersionedId storeId = PropertyBag.CheckPropertyValue <VersionedId>(ItemSchema.Id, array2[0]);
                         using (Item item = Item.Bind(context.Session, storeId))
                         {
                             if (item.Reminder != null)
                             {
                                 item.Reminder.IsSet = false;
                                 item.Save(SaveMode.NoConflictResolution);
                             }
                         }
                     }
                     catch (StoragePermanentException arg)
                     {
                         ExTraceGlobals.DefaultFoldersTracer.TraceDebug <object, StoragePermanentException>(-1L, "RemindersSearchFolderValidation::UnsetStaleReminders. Unable to unset a stale reminder of the item {0}: {1}", array2[0], arg);
                     }
                     catch (StorageTransientException arg2)
                     {
                         ExTraceGlobals.DefaultFoldersTracer.TraceDebug <object, StorageTransientException>(-1L, "RemindersSearchFolderValidation::UnsetStaleReminders. Unable to unset a stale reminder of the item {0}: {1}", array2[0], arg2);
                     }
                 }
             }
         }
     }
 }