// Token: 0x060003CF RID: 975 RVA: 0x0001B13C File Offset: 0x0001933C
        private void CollectItemsMarkedForExpiration(MailboxSession session)
        {
            base.Assistant.ThrowIfShuttingDown(base.MailboxDataForTags.MailboxSession.MailboxOwner);
            ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer>((long)this.GetHashCode(), "{0}: About to collect items for expiration.", this);
            PropertyIndexHolder propertyIndexHolder = new PropertyIndexHolder(ExpirationTagEnforcer.ItemDataColumns);

            AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(session, AllItemsFolderHelper.SupportedSortBy.RetentionDate, delegate(QueryResult queryResults)
            {
                ComparisonFilter seekFilter = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ItemSchema.RetentionDate, this.MailboxDataForTags.UtcNow.Date);
                if (queryResults.SeekToCondition(SeekReference.OriginBeginning, seekFilter))
                {
                    bool flag = false;
                    while (!flag)
                    {
                        object[][] rows = queryResults.GetRows(100);
                        ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer, int>((long)this.GetHashCode(), "{0}: GetRows returned {1} items.", this, rows.Length);
                        if (rows.Length <= 0)
                        {
                            break;
                        }
                        foreach (object[] array2 in rows)
                        {
                            if (array2[propertyIndexHolder.RetentionDateIndex] == null || array2[propertyIndexHolder.RetentionDateIndex] is PropertyError)
                            {
                                flag = true;
                                break;
                            }
                            this.EnlistItem(array2, propertyIndexHolder.PolicyTagIndex, propertyIndexHolder.RetentionDateIndex, propertyIndexHolder);
                        }
                        this.Assistant.ThrottleStoreCallAndCheckForShutdown(this.MailboxDataForTags.MailboxSession.MailboxOwner);
                    }
                }
                return(true);
            }, ExpirationTagEnforcer.ItemDataColumns);
        }
        // Token: 0x06000FA8 RID: 4008 RVA: 0x0005C9C0 File Offset: 0x0005ABC0
        internal List <ItemScanner> GetItemsToScan()
        {
            List <ItemScanner> itemList = new List <ItemScanner>(10);

            AllItemsFolderHelper.CheckAndCreateDefaultFolders(this.mailboxSession);
            AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(this.mailboxSession, AllItemsFolderHelper.SupportedSortBy.ReceivedTime, delegate(QueryResult queryResults)
            {
                for (;;)
                {
                    object[][] rows = queryResults.GetRows(500);
                    ItemSampler.Tracer.TraceDebug <ItemSampler, int>((long)this.GetHashCode(), "{0}: GetRows returned {1} items.", this, rows.Length);
                    if (rows.Length <= 0)
                    {
                        return(true);
                    }
                    foreach (object[] array2 in rows)
                    {
                        VersionedId versionedId = array2[0] as VersionedId;
                        if (versionedId != null)
                        {
                            itemList.Add(new ItemScanner(this.mailboxSession, versionedId.ObjectId));
                            if (itemList.Count >= 2000)
                            {
                                goto Block_2;
                            }
                        }
                    }
                }
                Block_2:
                return(true);
            }, ItemSampler.dataColumns);
            return(itemList);
        }
        // Token: 0x060003D0 RID: 976 RVA: 0x0001B360 File Offset: 0x00019560
        private void CollectItemsMarkedForMove(MailboxSession session)
        {
            base.Assistant.ThrowIfShuttingDown(base.MailboxDataForTags.MailboxSession.MailboxOwner);
            ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer>((long)this.GetHashCode(), "{0}: About to collect items marked for move via archive tag.", this);
            PropertyIndexHolder propertyIndexHolder = new PropertyIndexHolder(ExpirationTagEnforcer.ItemDataColumns);

            AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(session, AllItemsFolderHelper.SupportedSortBy.ArchiveDate, delegate(QueryResult queryResults)
            {
                ComparisonFilter seekFilter = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, ItemSchema.ArchiveDate, this.MailboxDataForTags.UtcNow.Date);
                if (queryResults.SeekToCondition(SeekReference.OriginBeginning, seekFilter))
                {
                    bool flag = false;
                    while (!flag)
                    {
                        object[][] rows = queryResults.GetRows(100);
                        ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer, int>((long)this.GetHashCode(), "{0}: GetRows returned {1} items.", this, rows.Length);
                        if (rows.Length <= 0)
                        {
                            break;
                        }
                        foreach (object[] array2 in rows)
                        {
                            if (array2[propertyIndexHolder.ArchiveDateIndex] == null || array2[propertyIndexHolder.ArchiveDateIndex] is PropertyError)
                            {
                                flag = true;
                                break;
                            }
                            if (array2[propertyIndexHolder.RetentionDateIndex] != null && array2[propertyIndexHolder.RetentionDateIndex] is ExDateTime && ((ExDateTime)array2[propertyIndexHolder.RetentionDateIndex]).UniversalTime < this.MailboxDataForTags.UtcNow.Date)
                            {
                                ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer>((long)this.GetHashCode(), "{0}: Both retention date and archive date of the item have passed. Then the retention date wins. Skip adding the item to MTA list", this);
                            }
                            else
                            {
                                this.EnlistItem(array2, propertyIndexHolder.ArchiveTagIndex, propertyIndexHolder.ArchiveDateIndex, propertyIndexHolder);
                            }
                        }
                        this.Assistant.ThrottleStoreCallAndCheckForShutdown(this.MailboxDataForTags.MailboxSession.MailboxOwner);
                    }
                }
                return(true);
            }, ExpirationTagEnforcer.ItemDataColumns);
        }
        public override IEnumerable <ComplianceItem> GetNextPage()
        {
            if (this.reachedEnd)
            {
                return(null);
            }
            List <ComplianceItem> items = new List <ComplianceItem>();

            AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(this.mailboxContainer.Session, AllItemsFolderHelper.SupportedSortBy.ReceivedTime, delegate(QueryResult queryResults)
            {
                queryResults.SeekToOffset(SeekReference.OriginBeginning, this.currentPage++ *this.PageSize);
                object[][] rows = queryResults.GetRows(this.PageSize);
                if (rows.Length != this.PageSize)
                {
                    this.reachedEnd = true;
                }
                for (int i = 0; i < rows.Length; i++)
                {
                    items.Add(new ExMailComplianceItem(this.mailboxContainer.Session, rows[i]));
                }
                return(true);
            }, ExMailComplianceItem.MailDataColumns);
            return(items);
        }
 // Token: 0x0600010A RID: 266 RVA: 0x0000677A File Offset: 0x0000497A
 public void ProcessBodyTag()
 {
     ExWatson.SendReportOnUnhandledException(delegate()
     {
         List <IStorePropertyBag> propertyBagList = new List <IStorePropertyBag>(100);
         ExDateTime toProcessDate   = ExDateTime.UtcNow.Subtract(TimeSpan.FromDays(15.0));
         int indexTrackingCounter   = 0;
         bool trackingCheckRequired = true;
         string text  = null;
         string text2 = null;
         string text3 = null;
         bool flag    = false;
         try
         {
             using (MailboxSession session = MailboxSession.OpenAsAdmin(this.principal, CultureInfo.InvariantCulture, "Client=TBA;Action=Conversation Assistant"))
             {
                 text = session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString();
                 AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(session, AllItemsFolderHelper.SupportedSortBy.ReceivedTime, delegate(QueryResult queryResults)
                 {
                     bool flag2 = false;
                     int num    = 0;
                     while (!flag2)
                     {
                         IStorePropertyBag[] propertyBags = queryResults.GetPropertyBags(50);
                         if (propertyBags.Length <= 0)
                         {
                             break;
                         }
                         foreach (IStorePropertyBag storePropertyBag2 in propertyBags)
                         {
                             num++;
                             if (num >= 10000)
                             {
                                 BodyTagProcessor.Tracer.TraceDebug <string>(0L, "Skip querying as we have reached our maximum limit of emails we want to process for {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
                                 flag2 = true;
                                 break;
                             }
                             string text5 = storePropertyBag2.TryGetProperty(StoreObjectSchema.ItemClass) as string;
                             if (!string.IsNullOrEmpty(text5) && ObjectClass.IsMessage(text5, false))
                             {
                                 if (!(BodyTagProcessor.GetProperty <ExDateTime>(storePropertyBag2, ItemSchema.ReceivedTime, ExDateTime.MinValue) >= toProcessDate))
                                 {
                                     flag2 = true;
                                     break;
                                 }
                                 if (trackingCheckRequired && !(storePropertyBag2.TryGetProperty(ItemSchema.ConversationIndexTracking) is PropertyError))
                                 {
                                     indexTrackingCounter++;
                                     if (indexTrackingCounter >= 10)
                                     {
                                         BodyTagProcessor.Tracer.TraceDebug <string>(0L, "Not processing BodyTag for mailbox {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString());
                                         flag2 = true;
                                         break;
                                     }
                                 }
                                 if (storePropertyBag2.TryGetProperty(ItemSchema.BodyTag) is PropertyError || storePropertyBag2.TryGetProperty(ItemSchema.BodyTag) == null)
                                 {
                                     propertyBagList.Add(storePropertyBag2);
                                 }
                             }
                         }
                         trackingCheckRequired = false;
                     }
                     return(true);
                 }, new PropertyDefinition[]
                 {
                     ItemSchema.Id,
                     StoreObjectSchema.ItemClass,
                     ItemSchema.ReceivedTime,
                     ItemSchema.BodyTag,
                     ItemSchema.ConversationIndexTracking
                 });
                 if (propertyBagList.Count == 0 || indexTrackingCounter >= 10)
                 {
                     string text4 = (propertyBagList.Count == 0) ? " 0 messages to process" : " IndexTrackingCounter reached its limit";
                     Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_BodyTagProcessingSkipped, null, new object[]
                     {
                         text,
                         text4
                     });
                     return;
                 }
                 Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_TotalNumberOfItemsForBodyTagProcessing, null, new object[]
                 {
                     propertyBagList.Count,
                     text
                 });
                 foreach (IStorePropertyBag storePropertyBag in propertyBagList)
                 {
                     try
                     {
                         using (MessageItem messageItem = MessageItem.Bind(session, storePropertyBag[ItemSchema.Id] as StoreId))
                         {
                             if (!(messageItem is RightsManagedMessageItem))
                             {
                                 messageItem.OpenAsReadWrite();
                                 messageItem[ItemSchema.BodyTag] = messageItem.Body.CalculateBodyTag();
                                 messageItem.Save(SaveMode.ResolveConflicts);
                             }
                         }
                     }
                     catch (ObjectNotFoundException)
                     {
                         BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "ObjectNotFound exception thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text);
                     }
                     catch (AccessDeniedException)
                     {
                         BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "AccessDenied exception thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text);
                     }
                     catch (CorruptDataException)
                     {
                         BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "Corrupt data exception thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text);
                     }
                     catch (VirusException)
                     {
                         BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "Virus exception thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text);
                     }
                     catch (PropertyErrorException)
                     {
                         BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "PropertyErrorException thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text);
                     }
                     catch (StoragePermanentException ex)
                     {
                         if (!(ex.InnerException is MapiExceptionCallFailed))
                         {
                             throw;
                         }
                         BodyTagProcessor.Tracer.TraceDebug <object, string>(0L, "MapiExceptionCallFailed thrown while processing item - {0} in mailbox - {1}", storePropertyBag[ItemSchema.Id], text);
                     }
                 }
             }
             Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_BodyTagProcessingSucceeded, null, new object[]
             {
                 text
             });
         }
         catch (ObjectNotFoundException ex2)
         {
             flag  = true;
             text2 = ex2.Message;
             text3 = ex2.StackTrace;
         }
         catch (CorruptDataException ex3)
         {
             flag  = true;
             text2 = ex3.Message;
             text3 = ex3.StackTrace;
         }
         catch (QuotaExceededException ex4)
         {
             flag  = true;
             text2 = ex4.Message;
             text3 = ex4.StackTrace;
         }
         catch (MessageSubmissionExceededException ex5)
         {
             flag  = true;
             text2 = ex5.Message;
             text3 = ex5.StackTrace;
         }
         catch (ConnectionFailedPermanentException ex6)
         {
             flag  = true;
             text2 = ex6.Message;
             text3 = ex6.StackTrace;
         }
         catch (MailboxUnavailableException ex7)
         {
             flag  = true;
             text2 = ex7.Message;
             text3 = ex7.StackTrace;
         }
         catch (StorageTransientException ex8)
         {
             flag  = true;
             text2 = ex8.Message;
             text3 = ex8.StackTrace;
         }
         catch (StoragePermanentException ex9)
         {
             if (!(ex9.InnerException is MapiExceptionJetErrorLogDiskFull))
             {
                 throw;
             }
             flag  = true;
             text2 = ex9.Message;
             text3 = ex9.StackTrace;
         }
         finally
         {
             if (flag)
             {
                 Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_BodyTagProcessingFailed, null, new object[]
                 {
                     text,
                     text2 ?? "<null>",
                     text3 ?? "<null>"
                 });
             }
         }
     }, delegate(object exception)
     {
         Exception ex = exception as Exception;
         if (ex != null)
         {
             Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_BodyTagProcessingFailed, null, new object[]
             {
                 this.principal.MailboxInfo.PrimarySmtpAddress.ToString(),
                 ex.Message ?? "<null>",
                 ex.StackTrace ?? "<null>"
             });
         }
         return(true);
     }, ReportOptions.None);
 }
 // Token: 0x060003CC RID: 972 RVA: 0x0001AE68 File Offset: 0x00019068
 private void CollectMigratedItemsMarkedForHoldExpiration()
 {
     base.Assistant.ThrowIfShuttingDown(base.MailboxDataForTags.MailboxSession.MailboxOwner);
     ExpirationTagEnforcer.Tracer.TraceDebug <ExpirationTagEnforcer>((long)this.GetHashCode(), "{0}: About to collect items for expiration.", this);
     AllItemsFolderHelper.RunQueryOnAllItemsFolder <bool>(base.MailboxDataForTags.MailboxSession, AllItemsFolderHelper.SupportedSortBy.EhaMigrationExpiryDate, new AllItemsFolderHelper.DoQueryProcessing <bool>(this.MigratedMessageQueryProcessor), ExpirationTagEnforcer.ItemDataColumnsWithHoldExpirationDate);
 }