// Token: 0x06000EF5 RID: 3829 RVA: 0x00059578 File Offset: 0x00057778
        private static void CatchAndLogStorageExceptions(PublicFolderAssistantLogger assistantLogger, PublicFolderItemProcessor.FolderRec folderRec, string context, Action actionDelegate)
        {
            Exception ex = null;

            try
            {
                actionDelegate();
            }
            catch (StoragePermanentException ex2)
            {
                ex = ex2;
            }
            catch (StorageTransientException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                assistantLogger.LogEvent(LogEventType.Error, string.Format(CultureInfo.InvariantCulture, "[ErrorContext:{0}.{1}] {2}", new object[]
                {
                    context,
                    folderRec.FolderId.ToHexEntryId(),
                    PublicFolderMailboxLoggerBase.GetExceptionLogString(ex, PublicFolderMailboxLoggerBase.ExceptionLogOption.All)
                }));
            }
        }
        // Token: 0x06000EF1 RID: 3825 RVA: 0x00058A20 File Offset: 0x00056C20
        public override void Invoke()
        {
            PublicFolderAssistantLogger publicFolderAssistantLogger = null;

            try
            {
                publicFolderAssistantLogger = new PublicFolderAssistantLogger(this.publicFolderSession);
                using (Folder folder = PublicFolderItemProcessor.xsoFactory.BindToFolder(this.publicFolderSession, this.publicFolderSession.GetPublicFolderRootId()) as Folder)
                {
                    using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal | FolderQueryFlags.NoNotifications, null, null, PublicFolderItemProcessor.FolderRec.PropertiesToLoad))
                    {
                        for (;;)
                        {
                            object[][] rows = queryResult.GetRows(100);
                            if (rows.Length <= 0)
                            {
                                break;
                            }
                            foreach (object[] properties in rows)
                            {
                                PublicFolderItemProcessor.FolderRec folderRec = new PublicFolderItemProcessor.FolderRec(this.publicFolderSession, properties);
                                if (folderRec.FolderId != null && !folderRec.FolderId.Equals(this.publicFolderSession.GetTombstonesRootFolderId()))
                                {
                                    if ((folderRec.FolderId.Equals(this.publicFolderSession.GetAsyncDeleteStateFolderId()) || folderRec.IsDumpsterFolder) && folderRec.SubfolderCount > 0 && this.publicFolderSession.IsPrimaryHierarchySession)
                                    {
                                        int?retentionAgeLimit = folderRec.RetentionAgeLimit;
                                        if (retentionAgeLimit == null && this.Organization.DefaultPublicFolderDeletedItemRetention != null)
                                        {
                                            retentionAgeLimit = new int?((int)this.Organization.DefaultPublicFolderDeletedItemRetention.Value.TotalSeconds);
                                        }
                                        if (retentionAgeLimit != null)
                                        {
                                            this.HardDeleteSubFolders(folderRec, this.now.Subtract(EnhancedTimeSpan.FromSeconds((double)retentionAgeLimit.Value)), publicFolderAssistantLogger);
                                        }
                                    }
                                    if (folderRec.TotalItemCount != 0)
                                    {
                                        if (folderRec.ContentMailboxGuid != this.publicFolderSession.MailboxGuid)
                                        {
                                            ExDateTime?lastMovedTimeStamp = folderRec.LastMovedTimeStamp;
                                            if (lastMovedTimeStamp != null)
                                            {
                                                int?   num          = new int?((int)this.Organization.DefaultPublicFolderMovedItemRetention.Value.TotalSeconds);
                                                double totalSeconds = this.now.Subtract(lastMovedTimeStamp.Value).TotalSeconds;
                                                int?   num2         = num;
                                                if (totalSeconds >= (double)num2.GetValueOrDefault() && num2 != null)
                                                {
                                                    this.HardDeleteItems(folderRec, ExDateTime.MaxValue, publicFolderAssistantLogger, "PublicFolderContentsFromMove");
                                                }
                                            }
                                        }
                                        else if (folderRec.IsDumpsterFolder)
                                        {
                                            int?retentionAgeLimit2 = folderRec.RetentionAgeLimit;
                                            if (retentionAgeLimit2 == null && this.Organization.DefaultPublicFolderDeletedItemRetention != null)
                                            {
                                                retentionAgeLimit2 = new int?((int)this.Organization.DefaultPublicFolderDeletedItemRetention.Value.TotalSeconds);
                                            }
                                            if (retentionAgeLimit2 != null)
                                            {
                                                this.HardDeleteItems(folderRec, this.now.Subtract(EnhancedTimeSpan.FromSeconds((double)retentionAgeLimit2.Value)), publicFolderAssistantLogger, "PublicFolderDeletedItemExpiration");
                                            }
                                        }
                                        else
                                        {
                                            int?overallAgeLimit = folderRec.OverallAgeLimit;
                                            if (overallAgeLimit == null && this.Organization.DefaultPublicFolderAgeLimit != null)
                                            {
                                                overallAgeLimit = new int?((int)this.Organization.DefaultPublicFolderAgeLimit.Value.TotalSeconds);
                                            }
                                            if (overallAgeLimit != null && folderRec.DumpsterId != null)
                                            {
                                                this.SoftDeleteItems(folderRec, this.now.Subtract(EnhancedTimeSpan.FromSeconds((double)overallAgeLimit.Value)), publicFolderAssistantLogger);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                publicFolderAssistantLogger.TrySave();
            }
            catch (StoragePermanentException ex)
            {
                if (publicFolderAssistantLogger != null)
                {
                    publicFolderAssistantLogger.ReportError("Error occurred while processing items", ex);
                    publicFolderAssistantLogger.TrySave();
                }
                else
                {
                    PublicFolderAssistantLogger.LogOnServer(ex);
                }
            }
            catch (StorageTransientException ex2)
            {
                if (publicFolderAssistantLogger != null)
                {
                    publicFolderAssistantLogger.ReportError("Error occurred while processing items", ex2);
                    publicFolderAssistantLogger.TrySave();
                }
                else
                {
                    PublicFolderAssistantLogger.LogOnServer(ex2);
                }
            }
            catch (Exception ex3)
            {
                if (publicFolderAssistantLogger != null)
                {
                    publicFolderAssistantLogger.ReportError("Error occurred while processing items", ex3);
                    publicFolderAssistantLogger.TrySave();
                }
                else
                {
                    PublicFolderAssistantLogger.LogOnServer(ex3);
                }
                throw;
            }
            finally
            {
                if (publicFolderAssistantLogger != null)
                {
                    publicFolderAssistantLogger.Dispose();
                    publicFolderAssistantLogger = null;
                }
            }
        }
 // Token: 0x06000EF4 RID: 3828 RVA: 0x00059524 File Offset: 0x00057724
 private void HardDeleteSubFolders(PublicFolderItemProcessor.FolderRec folderRec, ExDateTime expiration, PublicFolderAssistantLogger assistantLogger)
 {
     PublicFolderItemProcessor.CatchAndLogStorageExceptions(assistantLogger, folderRec, "HardDeleteSubFolders", delegate
     {
         using (Folder folder = PublicFolderItemProcessor.xsoFactory.BindToFolder(this.publicFolderSession, folderRec.FolderId) as Folder)
         {
             using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.NoNotifications, null, null, PublicFolderItemProcessor.FolderRec.PropertiesToLoad))
             {
                 for (;;)
                 {
                     object[][] rows = queryResult.GetRows(100);
                     if (rows == null || rows.Length == 0)
                     {
                         break;
                     }
                     List <StoreObjectId> list = null;
                     foreach (object[] properties in rows)
                     {
                         PublicFolderItemProcessor.FolderRec folderRec2 = new PublicFolderItemProcessor.FolderRec(this.publicFolderSession, properties);
                         if (folderRec2.FolderId != null && folderRec2.LastModifiedTime < expiration)
                         {
                             if (list == null)
                             {
                                 list = new List <StoreObjectId>(rows.Length);
                             }
                             list.Add(folderRec2.FolderId);
                         }
                     }
                     if (list != null)
                     {
                         folder.DeleteObjects(DeleteItemFlags.HardDelete, list.ToArray());
                         assistantLogger.LogEvent(LogEventType.Success, string.Format(CultureInfo.InvariantCulture, "HardDeleteSubFolders. {0}. {1}", new object[]
                         {
                             folderRec.FolderId.ToHexEntryId(),
                             list.Count
                         }));
                     }
                 }
             }
         }
     });
 }
 // Token: 0x06000EF3 RID: 3827 RVA: 0x00059338 File Offset: 0x00057538
 private void HardDeleteItems(PublicFolderItemProcessor.FolderRec folderRec, ExDateTime expiration, PublicFolderAssistantLogger assistantLogger, string operation)
 {
     PublicFolderItemProcessor.CatchAndLogStorageExceptions(assistantLogger, folderRec, operation, delegate
     {
         using (Folder folder = PublicFolderItemProcessor.xsoFactory.BindToFolder(this.publicFolderSession, folderRec.FolderId) as Folder)
         {
             using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, new SortBy[]
             {
                 new SortBy(CoreObjectSchema.LastModifiedTime, SortOrder.Descending)
             }, PublicFolderItemProcessor.MessageRec.PropertiesToLoad))
             {
                 ComparisonFilter seekFilter = new ComparisonFilter(ComparisonOperator.LessThanOrEqual, CoreObjectSchema.LastModifiedTime, expiration);
                 if (queryResult.SeekToCondition(SeekReference.OriginBeginning, seekFilter))
                 {
                     for (;;)
                     {
                         object[][] rows = queryResult.GetRows(100);
                         if (rows.Length <= 0)
                         {
                             break;
                         }
                         List <StoreObjectId> list = null;
                         foreach (object[] properties in rows)
                         {
                             PublicFolderItemProcessor.MessageRec messageRec = new PublicFolderItemProcessor.MessageRec(properties);
                             ExDateTime?exDateTime = (messageRec.LastModifiedTime != null) ? messageRec.LastModifiedTime : messageRec.ReceivedTime;
                             if (exDateTime == null)
                             {
                                 exDateTime = ((messageRec.CreationTime != null) ? messageRec.CreationTime : new ExDateTime?(ExDateTime.MinValue));
                             }
                             if (exDateTime < expiration)
                             {
                                 if (list == null)
                                 {
                                     list = new List <StoreObjectId>(rows.Length);
                                 }
                                 list.Add(messageRec.ItemId.ObjectId);
                             }
                         }
                         if (list != null)
                         {
                             folder.DeleteObjects(DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt, list.ToArray());
                             assistantLogger.LogEvent(LogEventType.Success, string.Format(CultureInfo.InvariantCulture, "HardDeleteItems. {0}. {1}. {2}", new object[]
                             {
                                 folderRec.FolderId.ToHexEntryId(),
                                 list.Count,
                                 operation
                             }));
                         }
                     }
                 }
             }
         }
     });
 }