Beispiel #1
0
        // Token: 0x060002DB RID: 731 RVA: 0x00011F20 File Offset: 0x00010120
        private ContentSetting GetDestinationPolicy(ProvisionedFolder destProvisionedFolder, string itemClass)
        {
            ContentSetting applyingPolicy = ElcPolicySettings.GetApplyingPolicy(destProvisionedFolder.ElcPolicies, itemClass, destProvisionedFolder.ItemClassToPolicyMapping);

            if (applyingPolicy == null || !ElcPolicySettings.ArePolicyPropertiesValid(applyingPolicy, TraceContext.Get(), this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()))
            {
                return(null);
            }
            return(applyingPolicy);
        }
        // Token: 0x060002F6 RID: 758 RVA: 0x00012AE4 File Offset: 0x00010CE4
        private void SetDestPolicyType(StoreObjectId destFolderId, string itemClass)
        {
            ContentSetting    contentSetting = null;
            ProvisionedFolder folderFromId   = this.mailboxData.FolderProcessor.GetFolderFromId(destFolderId);

            if (folderFromId != null)
            {
                contentSetting = ElcPolicySettings.GetApplyingPolicy(folderFromId.ElcPolicies, itemClass, folderFromId.ItemClassToPolicyMapping);
            }
            if (contentSetting != null && contentSetting.RetentionEnabled && contentSetting.TriggerForRetention == RetentionDateType.WhenMoved && contentSetting.AgeLimitForRetention != null && contentSetting.AgeLimitForRetention.Value.TotalDays > 0.0)
            {
                this.setDateWhileMoving = true;
            }
        }
        // Token: 0x06000421 RID: 1057 RVA: 0x0001D6B8 File Offset: 0x0001B8B8
        private ContentSetting GetContentSettingForMsgClassBasedOnTag(Guid updatedTagGuid, string messageClass)
        {
            ContentSetting result = null;

            if (updatedTagGuid.Equals(this.defaultAdTag))
            {
                result = ElcPolicySettings.GetApplyingPolicy(this.defaultContentSettingList, messageClass, this.tagAndClassToPolicyMapping, this.defaultAdTag.ToString() + messageClass);
            }
            else if (updatedTagGuid.Equals(this.defaultVmAdTag))
            {
                result = ElcPolicySettings.GetApplyingPolicy(this.defaultContentSettingList, messageClass, this.tagAndClassToPolicyMapping, this.defaultVmAdTag.ToString() + messageClass);
            }
            else if (updatedTagGuid.Equals(this.defaultArchiveAdTag))
            {
                result = ElcPolicySettings.GetApplyingPolicy(this.defaultArchiveContentSettingList, messageClass, this.tagAndClassToPolicyMapping, this.defaultArchiveAdTag.ToString() + messageClass);
            }
            return(result);
        }
 // Token: 0x06000303 RID: 771 RVA: 0x00012F24 File Offset: 0x00011124
 internal override void Invoke(ProvisionedFolder provisionedFolder, List <object[]> items, PropertyIndexHolder propertyIndexHolder)
 {
     AutoCopyEnforcer.TracerPfd.TracePfd <int, Folder>((long)this.GetHashCode(), "PFD IWE {0} {1} AutoCopyEnforcer Invoked", 18711, provisionedFolder.Folder);
     using (Folder folder = Folder.Bind(base.MailboxData.MailboxSession, this.SendFolderId))
     {
         foreach (object[] array in items)
         {
             if (array[propertyIndexHolder.IdIndex] is VersionedId)
             {
                 VersionedId versionedId = (VersionedId)array[propertyIndexHolder.IdIndex];
                 provisionedFolder.CurrentItems = new VersionedId[]
                 {
                     versionedId
                 };
                 object obj = array[propertyIndexHolder.AutoCopiedIndex];
                 if (obj is byte[])
                 {
                     AutoCopyEnforcer.Tracer.TraceDebug <object, VersionedId>((long)this.GetHashCode(), "{0}: ignoring item '{1}' because it has been copied already.", TraceContext.Get(), versionedId);
                 }
                 else
                 {
                     string text = array[propertyIndexHolder.ItemClassIndex] as string;
                     text = ((text == null) ? string.Empty : text.ToLower());
                     ContentSetting applyingPolicy = ElcPolicySettings.GetApplyingPolicy(provisionedFolder.ElcPolicies, text, provisionedFolder.ItemClassToPolicyMapping);
                     if (applyingPolicy != null && applyingPolicy.JournalingEnabled)
                     {
                         ItemAuditLogData itemAuditLogData = null;
                         if (base.MailboxData.ElcAuditLog.AutocopyLoggingEnabled)
                         {
                             itemAuditLogData = new ItemAuditLogData(array, propertyIndexHolder, new FolderAuditLogData(provisionedFolder, base.MailboxData, ELCAction.Journaling.ToString(), this.GetOfficialFileParticipant(applyingPolicy).EmailAddress));
                         }
                         ItemData      itemData = new ItemData(versionedId, (array[propertyIndexHolder.ReceivedTimeIndex] is ExDateTime) ? ((DateTime)((ExDateTime)array[propertyIndexHolder.ReceivedTimeIndex])) : DateTime.MinValue, itemAuditLogData, (int)array[propertyIndexHolder.SizeIndex]);
                         StoreObjectId storeObjectId;
                         bool          flag = this.SendItemAsAttachement(applyingPolicy, itemData, out storeObjectId);
                         if (flag)
                         {
                             this.MarkItemAsCopied(itemData, provisionedFolder);
                             ELCPerfmon.TotalItemsAutoCopied.Increment();
                         }
                         else
                         {
                             Exception       ex = null;
                             OperationResult operationResult = OperationResult.Succeeded;
                             try
                             {
                                 operationResult = folder.DeleteObjects(DeleteItemFlags.HardDelete, new StoreObjectId[]
                                 {
                                     storeObjectId
                                 }).OperationResult;
                             }
                             catch (Exception ex2)
                             {
                                 operationResult = OperationResult.Failed;
                                 ex = ex2;
                             }
                             if (operationResult != OperationResult.Succeeded)
                             {
                                 AutoCopyEnforcer.Tracer.TraceDebug <object, string, string>((long)this.GetHashCode(), "{0}: Failed to delete the journal message '{1}'. Exception: '{2}'.", TraceContext.Get(), storeObjectId.ToString(), (ex == null) ? "" : ex.Message);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        // Token: 0x0600037C RID: 892 RVA: 0x000180B4 File Offset: 0x000162B4
        internal override void Invoke(ProvisionedFolder provisionedFolder, List <object[]> items, PropertyIndexHolder propertyIndexHolder)
        {
            FolderExpirationExecutor folderExpirationExecutor = new FolderExpirationExecutor(provisionedFolder, base.MailboxData, base.Assistant);

            ExpirationEnforcer.Tracer.TraceDebug <object, string, int>((long)this.GetHashCode(), "{0}: Number of items found in folder '{1}' is {2}.", TraceContext.Get(), provisionedFolder.DisplayName, items.Count);
            DefaultFolderType folderType = DefaultFolderType.None;

            if (provisionedFolder.FolderId.Equals(base.MailboxData.MailboxSession.GetDefaultFolderId(DefaultFolderType.DeletedItems)))
            {
                folderType = DefaultFolderType.DeletedItems;
            }
            else if (provisionedFolder.ContainerClass != null && ObjectClass.IsCalendarFolder(provisionedFolder.ContainerClass))
            {
                folderType = DefaultFolderType.Calendar;
            }
            else if (provisionedFolder.ContainerClass != null && ObjectClass.IsTaskFolder(provisionedFolder.ContainerClass))
            {
                folderType = DefaultFolderType.Tasks;
            }
            ItemStartDateCalculator itemStartDateCalculator = new ItemStartDateCalculator(propertyIndexHolder, provisionedFolder.Folder.DisplayName, folderType, base.MailboxData.MailboxSession, ExpirationEnforcer.Tracer);
            FolderAuditLogData      folderAuditLogData      = null;

            if (base.MailboxData.ElcAuditLog.ExpirationLoggingEnabled)
            {
                folderAuditLogData = new FolderAuditLogData(provisionedFolder, base.MailboxData, ELCAction.Retention.ToString());
            }
            foreach (object[] array in items)
            {
                VersionedId versionedId = array[propertyIndexHolder.IdIndex] as VersionedId;
                string      text        = array[propertyIndexHolder.ItemClassIndex] as string;
                if (versionedId == null)
                {
                    ExpirationEnforcer.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Current item in folder {1} is null. Skipping it.", TraceContext.Get(), provisionedFolder.DisplayName);
                }
                else
                {
                    provisionedFolder.CurrentItems = new VersionedId[]
                    {
                        versionedId
                    };
                    text = ((text == null) ? string.Empty : text.ToLower());
                    ContentSetting contentSetting = null;
                    contentSetting = ElcPolicySettings.GetApplyingPolicy(provisionedFolder.ElcPolicies, text, provisionedFolder.ItemClassToPolicyMapping);
                    if (contentSetting == null)
                    {
                        ExpirationEnforcer.Tracer.TraceDebug <object, string, string>((long)this.GetHashCode(), "{0}: Policy for item class {1} in folder {2} is null. Skipping item.", TraceContext.Get(), text, provisionedFolder.DisplayName);
                    }
                    else if (!base.MailboxData.FolderProcessor.IsPolicyValid(provisionedFolder, contentSetting, text, base.MailboxData))
                    {
                        ExpirationEnforcer.Tracer.TraceDebug <object, string, string>((long)this.GetHashCode(), "{0}: Removing policy {1} from the list in folder {2} because it is invalid.", TraceContext.Get(), contentSetting.Name, provisionedFolder.DisplayName);
                        provisionedFolder.RemovePolicy(contentSetting);
                    }
                    else
                    {
                        double totalDays = contentSetting.AgeLimitForRetention.Value.TotalDays;
                        int    num;
                        if (contentSetting.TriggerForRetention == RetentionDateType.WhenMoved)
                        {
                            ExpirationEnforcer.Tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Applying policy. Policy '{1}' expires based on move date.", TraceContext.Get(), contentSetting.Name);
                            CompositeProperty compositeProperty = null;
                            if (ElcMailboxHelper.Exists(array[propertyIndexHolder.MoveDateIndex]))
                            {
                                try
                                {
                                    compositeProperty = CompositeProperty.Parse((byte[])array[propertyIndexHolder.MoveDateIndex]);
                                }
                                catch (ArgumentException ex)
                                {
                                    ExpirationEnforcer.Tracer.TraceError((long)this.GetHashCode(), "{0}: Could not parse move date property of item. Folder: {1} ItemClass: {2} Exception: {3}.", new object[]
                                    {
                                        TraceContext.Get(),
                                        provisionedFolder.DisplayName,
                                        text,
                                        ex
                                    });
                                    base.MailboxData.ThrowIfErrorsOverLimit();
                                }
                            }
                            if (compositeProperty == null)
                            {
                                string arg = "Stamped Move date is null.";
                                ExpirationEnforcer.Tracer.TraceDebug <object, VersionedId, string>((long)this.GetHashCode(), "{0}: Move date needs to be stamped on item {1}. {2}", TraceContext.Get(), versionedId, arg);
                                folderExpirationExecutor.AddToMoveDateStampingList(new ItemData(versionedId, (int)array[propertyIndexHolder.SizeIndex]));
                                continue;
                            }
                            ExpirationEnforcer.Tracer.TraceDebug <object, VersionedId>((long)this.GetHashCode(), "{0}: Calculating age of item {1} based on move date", TraceContext.Get(), versionedId);
                            num = (int)base.MailboxData.Now.Subtract(compositeProperty.Date.Value).TotalDays;
                        }
                        else
                        {
                            DateTime startDate = itemStartDateCalculator.GetStartDate(versionedId, text, array);
                            if (startDate == DateTime.MinValue)
                            {
                                num = 0;
                            }
                            else
                            {
                                num = (int)base.MailboxData.UtcNow.Subtract(startDate).TotalDays;
                            }
                        }
                        try
                        {
                            if ((double)num >= totalDays)
                            {
                                if (contentSetting.RetentionAction == RetentionActionType.MarkAsPastRetentionLimit && array[propertyIndexHolder.ExpiryTimeIndex] != null && !(array[propertyIndexHolder.ExpiryTimeIndex] is PropertyError))
                                {
                                    ExpirationEnforcer.Tracer.TraceDebug <object, VersionedId>((long)this.GetHashCode(), "{0}: Item {1} is already tagged with expiry time, hence will not tag again.", TraceContext.Get(), versionedId);
                                }
                                else
                                {
                                    ExpirationEnforcer.Tracer.TraceDebug <object, VersionedId>((long)this.GetHashCode(), "{0}: Adding item {1} to list to be expired.", TraceContext.Get(), versionedId);
                                    ItemAuditLogData itemAuditLogData = null;
                                    if (base.MailboxData.ElcAuditLog.ExpirationLoggingEnabled)
                                    {
                                        folderAuditLogData.ExpirationAction = contentSetting.RetentionAction.ToString();
                                        itemAuditLogData = new ItemAuditLogData(array, propertyIndexHolder, folderAuditLogData);
                                    }
                                    ItemData itemData = new ItemData(versionedId, (array[propertyIndexHolder.ReceivedTimeIndex] is ExDateTime) ? ((DateTime)((ExDateTime)array[propertyIndexHolder.ReceivedTimeIndex])) : DateTime.MinValue, itemAuditLogData, (int)array[propertyIndexHolder.SizeIndex]);
                                    folderExpirationExecutor.AddToReportAndDoomedList(array, propertyIndexHolder, contentSetting, itemData, text, this.allPolicyTags);
                                }
                            }
                        }
                        catch (InvalidExpiryDestinationException ex2)
                        {
                            ExpirationEnforcer.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Removing policy '{1}', that applies to folder '{2}' from list of policies to process. Exception: {3}", new object[]
                            {
                                TraceContext.Get(),
                                contentSetting.Name,
                                contentSetting.ManagedFolderName,
                                ex2
                            });
                            provisionedFolder.RemovePolicy(contentSetting);
                        }
                        catch (SkipFolderException ex3)
                        {
                            ExpirationEnforcer.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Policy '{1}', that applies to folder '{2}' will be skipped for the current folder. Exception: {3}", new object[]
                            {
                                TraceContext.Get(),
                                contentSetting.Name,
                                contentSetting.ManagedFolderName,
                                ex3
                            });
                            return;
                        }
                    }
                }
            }
            ExpirationEnforcer.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Done identifying items for expiration. Proceed to expire.", new object[]
            {
                TraceContext.Get()
            });
            ExpirationEnforcer.TracerPfd.TracePfd <int, object>((long)this.GetHashCode(), "PFD IWE {0} {1}: Done identifying items for expiration. Calling ExpirationExecutor to expire.", 26903, TraceContext.Get());
            folderExpirationExecutor.ExecuteTheDoomed();
        }