// Token: 0x06000391 RID: 913 RVA: 0x00019028 File Offset: 0x00017228 private void InternalExpireInBatches(List <ItemData> listToSend, ExpirationExecutor.Action retentionActionType, Folder sourcefolder, Folder targetFolder) { int count = listToSend.Count; int num = 0; int i = 0; int num2 = 0; long num3 = 0L; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = 0; int num9 = 0; int num10 = 0; int num11 = 0; int num12 = 0; OperationResult operationResult = OperationResult.Succeeded; Exception ex = null; ItemData[] sourceArray = listToSend.ToArray(); int num13 = 0; int num14 = 0; try { while (i < count) { base.ElcAssistant.ThrottleStoreCallAndCheckForShutdown(base.MailboxData.MailboxSession.MailboxOwner); int num15 = (count - i >= 100) ? 100 : (count - i); switch (retentionActionType) { case ExpirationExecutor.Action.SoftDelete: case ExpirationExecutor.Action.PermanentlyDelete: { VersionedId[] array = new VersionedId[num15]; num3 += (long)base.CopyIdsToTmpArray(sourceArray, i, array, num15); num2 = num15; Dictionary <ItemData.EnforcerType, int> numberOfItemsProcessedByEachEnforcer = ItemData.GetNumberOfItemsProcessedByEachEnforcer(sourceArray, i, num15); AggregateOperationResult aggregateOperationResult; if (retentionActionType == ExpirationExecutor.Action.SoftDelete) { num8 = (numberOfItemsProcessedByEachEnforcer.ContainsKey(ItemData.EnforcerType.ExpirationTagEnforcer) ? numberOfItemsProcessedByEachEnforcer[ItemData.EnforcerType.ExpirationTagEnforcer] : 0); aggregateOperationResult = base.MailboxData.MailboxSession.Delete(DeleteItemFlags.SoftDelete | DeleteItemFlags.SuppressReadReceipt, array); } else { num11 = (numberOfItemsProcessedByEachEnforcer.ContainsKey(ItemData.EnforcerType.DiscoveryHoldEnforcer) ? numberOfItemsProcessedByEachEnforcer[ItemData.EnforcerType.DiscoveryHoldEnforcer] : 0); num9 = (numberOfItemsProcessedByEachEnforcer.ContainsKey(ItemData.EnforcerType.DumpsterExpirationEnforcer) ? numberOfItemsProcessedByEachEnforcer[ItemData.EnforcerType.DumpsterExpirationEnforcer] : 0); num10 = (numberOfItemsProcessedByEachEnforcer.ContainsKey(ItemData.EnforcerType.DumpsterQuotaEnforcer) ? numberOfItemsProcessedByEachEnforcer[ItemData.EnforcerType.DumpsterQuotaEnforcer] : 0); num8 = (numberOfItemsProcessedByEachEnforcer.ContainsKey(ItemData.EnforcerType.ExpirationTagEnforcer) ? numberOfItemsProcessedByEachEnforcer[ItemData.EnforcerType.ExpirationTagEnforcer] : 0); aggregateOperationResult = base.MailboxData.MailboxSession.Delete(DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt, array); } operationResult = aggregateOperationResult.OperationResult; ex = ElcExceptionHelper.ExtractExceptionsFromAggregateOperationResult(aggregateOperationResult); break; } case ExpirationExecutor.Action.MoveToDiscoveryHolds: case ExpirationExecutor.Action.MoveToMigratedMessages: case ExpirationExecutor.Action.MoveToPurges: { VersionedId[] array2 = new VersionedId[num15]; num3 += (long)base.CopyIdsToTmpArray(sourceArray, i, array2, num15); num2 = num15; Dictionary <ItemData.EnforcerType, int> numberOfItemsProcessedByEachEnforcer2 = ItemData.GetNumberOfItemsProcessedByEachEnforcer(sourceArray, i, num15); if (num2 > 0) { if (sourcefolder != null) { StoreObjectId destinationFolderId; if (ExpirationExecutor.Action.MoveToPurges == retentionActionType) { num13 = (numberOfItemsProcessedByEachEnforcer2.ContainsKey(ItemData.EnforcerType.DumpsterExpirationEnforcer) ? numberOfItemsProcessedByEachEnforcer2[ItemData.EnforcerType.DumpsterExpirationEnforcer] : 0); destinationFolderId = base.MailboxData.MailboxSession.GetDefaultFolderId(DefaultFolderType.RecoverableItemsPurges); } else if (ExpirationExecutor.Action.MoveToDiscoveryHolds == retentionActionType) { num9 = (numberOfItemsProcessedByEachEnforcer2.ContainsKey(ItemData.EnforcerType.DumpsterExpirationEnforcer) ? numberOfItemsProcessedByEachEnforcer2[ItemData.EnforcerType.DumpsterExpirationEnforcer] : 0); num10 = (numberOfItemsProcessedByEachEnforcer2.ContainsKey(ItemData.EnforcerType.DumpsterQuotaEnforcer) ? numberOfItemsProcessedByEachEnforcer2[ItemData.EnforcerType.DumpsterQuotaEnforcer] : 0); destinationFolderId = base.MailboxData.MailboxSession.CowSession.CheckAndCreateDiscoveryHoldsFolder(base.MailboxData.MailboxSession); } else { destinationFolderId = base.MailboxData.MailboxSession.CowSession.CheckAndCreateMigratedMessagesFolder(); } if (this.IsMoveClearNrnFlightingEnabled()) { sourcefolder.ClearNotReadNotificationPending(array2); } GroupOperationResult groupOperationResult = sourcefolder.MoveItems(destinationFolderId, array2); if (groupOperationResult.OperationResult == OperationResult.Succeeded) { TagExpirationExecutor.Tracer.TraceDebug <TagExpirationExecutor, string, int>((long)this.GetHashCode(), "{0}: Moved to {1} batch of {2} items.", this, retentionActionType.ToString(), num2); } else { operationResult = groupOperationResult.OperationResult; ex = groupOperationResult.Exception; } } } else { TagExpirationExecutor.Tracer.TraceDebug <TagExpirationExecutor>((long)this.GetHashCode(), "{0}: The tmpList was empty during this loop. Nothing to send, don't do anything.", this); } break; } } i += num15; num += num2; if (operationResult == OperationResult.Failed || operationResult == OperationResult.PartiallySucceeded) { TagExpirationExecutor.Tracer.TraceError((long)this.GetHashCode(), "{0}: An error occured when trying to expire a batch of {1} items. Expiration action is {2}. Result: {3}", new object[] { this, num2, retentionActionType, operationResult }); Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_ExpirationOfCurrentBatchFailed, null, new object[] { base.MailboxData.MailboxSession.MailboxOwner, retentionActionType.ToString(), (sourcefolder == null) ? string.Empty : sourcefolder.DisplayName, (targetFolder == null) ? string.Empty : targetFolder.DisplayName, (sourcefolder == null) ? string.Empty : sourcefolder.Id.ObjectId.ToHexEntryId(), (targetFolder == null) ? string.Empty : targetFolder.Id.ObjectId.ToHexEntryId(), (ex == null) ? string.Empty : ex.ToString() }); num12++; base.MailboxData.ThrowIfErrorsOverLimit(ex); } else { num7 += num11; num5 += num9; num6 += num10; num4 += num8; num14 += num13; } } } finally { ELCPerfmon.TotalItemsExpired.IncrementBy((long)num); ELCPerfmon.TotalSizeItemsExpired.IncrementBy(num3); switch (retentionActionType) { case ExpirationExecutor.Action.SoftDelete: ELCPerfmon.TotalItemsSoftDeleted.IncrementBy((long)num); ELCPerfmon.TotalSizeItemsSoftDeleted.IncrementBy(num3); break; case ExpirationExecutor.Action.PermanentlyDelete: ELCPerfmon.TotalItemsPermanentlyDeleted.IncrementBy((long)num); ELCPerfmon.TotalSizeItemsPermanentlyDeleted.IncrementBy(num3); break; case ExpirationExecutor.Action.MoveToDiscoveryHolds: ELCPerfmon.TotalItemsMovedToDiscoveryHolds.IncrementBy((long)num); ELCPerfmon.TotalSizeItemsMovedToDiscoveryHolds.IncrementBy(num3); break; } base.MailboxData.StatisticsLogEntry.NumberOfItemsActuallyDeletedByDiscoveryHoldEnforcer += (long)num7; base.MailboxData.StatisticsLogEntry.NumberOfItemsActuallyDeletedByDumpsterExpirationEnforcer += (long)num5; base.MailboxData.StatisticsLogEntry.NumberOfItemsActuallyDeletedByDumpsterQuotaEnforcer += (long)num6; base.MailboxData.StatisticsLogEntry.NumberOfItemsActuallyDeletedByTag += (long)num4; base.MailboxData.StatisticsLogEntry.NumberOfBatchesFailedToExpireInExpirationExecutor += (long)num12; base.MailboxData.StatisticsLogEntry.NumberOfItemsActuallyMovedToPurgesByDumpsterExpirationEnforcer += (long)num14; } }
// Token: 0x06000542 RID: 1346 RVA: 0x00028264 File Offset: 0x00026464 private bool ProcessBatch(FolderIdType targetFolderId, out Exception batchException) { RemoteArchiveProcessorBase.Tracer.TraceDebug <MailboxSession, int, uint>((long)this.GetHashCode(), "RemoteArchiveProcessorBase.ProcessBatch: Process items batch for {0}. Count = {1}, Size = {2}.", this.primaryMailboxSession, this.currentBatch.Count, this.currentBatchSize); batchException = null; if (this.currentBatch.Count == 0 || this.currentBatchSize == 0U) { return(true); } bool flag = true; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; OperationResult operationResult = OperationResult.Succeeded; List <Exception> list = new List <Exception>(); try { Exception ex; List <ElcEwsItem> list2 = this.ExportItemsFromPrimaryMailbox(this.currentBatch, out ex); num = list2.Count; if (ex != null) { list.Add(ex); } List <ElcEwsItem> list3 = this.UploadItemsToArchiveMailbox(list2, targetFolderId, out ex); num2 = list3.Count; if (ex != null) { list.Add(ex); } List <ElcEwsItem> list4 = null; list4 = this.VerifyItemsUploadedToArchiveMailbox(list3, out ex); num3 = list4.Count; if (ex != null) { list.Add(ex); } ex = null; VersionedId[] array = (from elcEwsItem in list4 select elcEwsItem.StorageItemData.Id).ToArray <VersionedId>(); if (array.Length > 0) { try { this.primaryMailboxSession.COWSettings.TemporaryDisableHold = true; AggregateOperationResult aggregateOperationResult = this.primaryMailboxSession.Delete(DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt, array); operationResult = aggregateOperationResult.OperationResult; ex = ElcExceptionHelper.ExtractExceptionsFromAggregateOperationResult(aggregateOperationResult); } finally { this.primaryMailboxSession.COWSettings.TemporaryDisableHold = false; } flag = (operationResult != OperationResult.Failed && operationResult != OperationResult.PartiallySucceeded); if (!flag) { if (ex != null) { list.Add(ex); } } else { foreach (ElcEwsItem elcEwsItem2 in list4) { if (elcEwsItem2.StorageItemData != null && elcEwsItem2.StorageItemData.Enforcer == ItemData.EnforcerType.DumpsterExpirationEnforcer) { num4++; } else if (elcEwsItem2.StorageItemData != null && elcEwsItem2.StorageItemData.Enforcer == ItemData.EnforcerType.ExpirationTagEnforcer) { num5++; } } } } flag = (flag && num3 == this.currentBatch.Count); } finally { batchException = new AggregateException(list); RemoteArchiveProcessorBase.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Batch processing summary. Batch count = {1}, Batch size = {2}, Successfully exported = {3}, Successfully uploaded = {4}, Successfully verified = {5}, Delete status = {6}, Failure = {7}", new object[] { this, this.currentBatch.Count, this.currentBatchSize, num, num2, num3, operationResult, batchException }); this.currentBatch.Clear(); this.currentBatchSize = 0U; if (this.statisticsLogEntry != null) { this.statisticsLogEntry.NumberOfItemsActuallyArchivedByDumpsterExpirationEnforcer += (long)num4; this.statisticsLogEntry.NumberOfItemsActuallyArchivedByTag += (long)num5; } } return(flag); }
// Token: 0x0600050E RID: 1294 RVA: 0x00026080 File Offset: 0x00024280 private void ExpireInBatches(List <ItemData> listToSend, Folder sourceFolder, Folder targetFolder, ElcSubAssistant elcSubAssistant, ExpirationExecutor.Action retentionActionType, int totalFailuresSoFar, ref List <Exception> allExceptionsSoFar, out List <string> foldersWithErrors, out int newMoveErrorsTotal) { int count = listToSend.Count; int num = 0; int i = 0; int num2 = 0; int num3 = 0; long num4 = 0L; int num5 = 0; int num6 = 0; int num7 = 0; int num8 = 0; OperationResult operationResult = OperationResult.Succeeded; Exception ex = null; ItemData[] sourceArray = listToSend.ToArray(); foldersWithErrors = new List <string>(); newMoveErrorsTotal = 0; try { while (i < count) { elcSubAssistant.ThrottleStoreCallAndCheckForShutdown(this.archiveMailboxSession.MailboxOwner, ELCHealthMonitor.GetArchiveResourceHealthMonitorKeys(this.archiveMailboxSession, this.primaryMailboxSession)); num2 = ((count - i >= 100) ? 100 : (count - i)); List <VersionedId> list; bool flag; int num9; Dictionary <ItemData.EnforcerType, int> dictionary; num4 += (long)LocalArchiveProcessor.CopyIdsToTmpArray(sourceArray, i, num2, this.MaxMessageSizeInArchive, out list, out flag, out num9, out dictionary); num7 += num9; num3 = list.Count; if (flag) { foldersWithErrors.Add(sourceFolder.DisplayName); LocalArchiveProcessor.Tracer.TraceDebug <LocalArchiveProcessor, string>((long)this.GetHashCode(), "{0}: Added folder {1} to the list of bad folders to be event logged.", this, sourceFolder.DisplayName); } if (num3 > 0) { GroupOperationResult groupOperationResult = sourceFolder.CopyItems(this.archiveMailboxSession, targetFolder.Id, list.ToArray()); if (groupOperationResult.OperationResult == OperationResult.Succeeded) { LocalArchiveProcessor.Tracer.TraceDebug <LocalArchiveProcessor, int>((long)this.GetHashCode(), "{0}: Copied to archive batch of {1} items. Will proceed to hard delete the batch.", this, num3); try { this.primaryMailboxSession.COWSettings.TemporaryDisableHold = true; AggregateOperationResult aggregateOperationResult = this.primaryMailboxSession.Delete(DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt, list.ToArray()); operationResult = aggregateOperationResult.OperationResult; ex = ElcExceptionHelper.ExtractExceptionsFromAggregateOperationResult(aggregateOperationResult); goto IL_18E; } finally { this.primaryMailboxSession.COWSettings.TemporaryDisableHold = false; } } operationResult = groupOperationResult.OperationResult; ex = groupOperationResult.Exception; } else { LocalArchiveProcessor.Tracer.TraceDebug <LocalArchiveProcessor>((long)this.GetHashCode(), "{0}: The tmpList was empty during this loop. Nothing to send, don't do anything.", this); } IL_18E: i += num2; num += num3; if (operationResult == OperationResult.Failed || operationResult == OperationResult.PartiallySucceeded) { LocalArchiveProcessor.Tracer.TraceError((long)this.GetHashCode(), "{0}: An error occured when trying to expire a batch of {1} items. Expiration action is {2}. Result: {3}", new object[] { this, num3, retentionActionType.ToString(), operationResult }); Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_ExpirationOfCurrentBatchFailed, null, new object[] { this.primaryMailboxSession.MailboxOwner, retentionActionType.ToString(), (sourceFolder == null) ? string.Empty : sourceFolder.DisplayName, (targetFolder == null) ? string.Empty : targetFolder.DisplayName, (sourceFolder == null) ? string.Empty : sourceFolder.Id.ObjectId.ToHexEntryId(), (targetFolder == null) ? string.Empty : targetFolder.Id.ObjectId.ToHexEntryId(), (ex == null) ? string.Empty : ex.ToString() }); newMoveErrorsTotal++; num8++; if (ex != null) { allExceptionsSoFar.Add(ex); } if (totalFailuresSoFar + newMoveErrorsTotal > MailboxData.MaxErrorsAllowed) { throw new TransientMailboxException(Strings.descELCEnforcerTooManyErrors(this.primaryMailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), MailboxData.MaxErrorsAllowed), new AggregateException(allExceptionsSoFar), null); } } else { num5 += (dictionary.ContainsKey(ItemData.EnforcerType.DumpsterExpirationEnforcer) ? dictionary[ItemData.EnforcerType.DumpsterExpirationEnforcer] : 0); num6 += (dictionary.ContainsKey(ItemData.EnforcerType.ExpirationTagEnforcer) ? dictionary[ItemData.EnforcerType.ExpirationTagEnforcer] : 0); } } } finally { ELCPerfmon.TotalItemsExpired.IncrementBy((long)num); ELCPerfmon.TotalSizeItemsExpired.IncrementBy(num4); ELCPerfmon.TotalItemsMoved.IncrementBy((long)num); ELCPerfmon.TotalSizeItemsMoved.IncrementBy(num4); if (this.statisticsLogEntry != null) { this.statisticsLogEntry.NumberOfItemsActuallyArchivedByDumpsterExpirationEnforcer += (long)num5; this.statisticsLogEntry.NumberOfItemsActuallyArchivedByTag += (long)num6; this.statisticsLogEntry.NumberOfItemsSkippedDueToSizeRestrictionInArchiveProcessor += (long)num7; this.statisticsLogEntry.NumberOfBatchesFailedToMoveInArchiveProcessor += (long)num8; } } }