コード例 #1
0
        internal static void ApplyPolicy(MailboxSession mailboxSession, object policy, object flags, object period, object archivePolicy, object archivePeriod, object compactDefaultPolicy, MessageItem messageItem, bool keepRetentionTag)
        {
            if (policy == null && compactDefaultPolicy == null)
            {
                using (Folder folder = Folder.Bind(mailboxSession, messageItem.ParentId, new PropertyDefinition[]
                {
                    StoreObjectSchema.PolicyTag,
                    StoreObjectSchema.RetentionPeriod,
                    StoreObjectSchema.RetentionFlags,
                    StoreObjectSchema.ArchiveTag,
                    StoreObjectSchema.ArchivePeriod,
                    FolderSchema.RetentionTagEntryId
                }))
                {
                    RetentionTagHelper.ReadPolicyFromFolder(folder, out policy, out flags, out period, out archivePolicy, out archivePeriod, out compactDefaultPolicy);
                }
            }
            bool       flag  = false;
            bool       flag2 = false;
            ExDateTime d     = messageItem.ReceivedTime;

            if (d == ExDateTime.MinValue)
            {
                d = messageItem.SentTime;
                if (d == ExDateTime.MinValue)
                {
                    d = ExDateTime.Now;
                }
            }
            if (archivePolicy != null && archivePolicy is byte[] && archivePeriod != null && archivePeriod is int)
            {
                flag2 = true;
            }
            if (policy != null && policy is byte[] && period != null && period is int)
            {
                flag = true;
            }
            if (flag2)
            {
                try
                {
                    messageItem[ItemSchema.ArchiveDate] = d.AddDays((double)((int)archivePeriod));
                }
                catch (ArgumentOutOfRangeException)
                {
                    messageItem[ItemSchema.ArchiveDate] = DateTime.MaxValue;
                }
                messageItem[StoreObjectSchema.ArchiveTag] = (archivePolicy as byte[]);
            }
            else
            {
                messageItem.DeleteProperties(new PropertyDefinition[]
                {
                    StoreObjectSchema.ArchiveTag
                });
                messageItem.DeleteProperties(new PropertyDefinition[]
                {
                    ItemSchema.ArchiveDate
                });
            }
            Guid guid;
            int  num;

            RetentionTagHelper.GetDefaultPolicyInfo(mailboxSession, messageItem, compactDefaultPolicy, out guid, out num);
            if (!keepRetentionTag)
            {
                if (flag)
                {
                    try
                    {
                        messageItem[ItemSchema.RetentionDate] = d.AddDays((double)((int)period));
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        messageItem[ItemSchema.RetentionDate] = DateTime.MaxValue;
                    }
                    messageItem[StoreObjectSchema.PolicyTag] = (policy as byte[]);
                }
                else
                {
                    if (num > 0)
                    {
                        try
                        {
                            messageItem[ItemSchema.RetentionDate] = d.AddDays((double)num);
                            goto IL_223;
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            messageItem[ItemSchema.RetentionDate] = DateTime.MaxValue;
                            goto IL_223;
                        }
                    }
                    messageItem.DeleteProperties(new PropertyDefinition[]
                    {
                        ItemSchema.RetentionDate
                    });
IL_223:
                    if (!guid.Equals(Guid.Empty))
                    {
                        messageItem[StoreObjectSchema.PolicyTag] = guid.ToByteArray();
                    }
                    else
                    {
                        messageItem.DeleteProperties(new PropertyDefinition[]
                        {
                            StoreObjectSchema.PolicyTag
                        });
                        if (!flag2)
                        {
                            return;
                        }
                    }
                }
            }
            else if (!flag2)
            {
                return;
            }
            CompositeProperty compositeProperty = new CompositeProperty(num, d.UniversalTime);

            messageItem[ItemSchema.StartDateEtc]          = compositeProperty.GetBytes(true);
            messageItem[StoreObjectSchema.RetentionFlags] = 0;
        }
コード例 #2
0
 internal static void ApplyPolicy(MailboxSession mailboxSession, object policy, object flags, object period, object archivePolicy, object archivePeriod, object compactDefaultPolicy, MessageItem messageItem)
 {
     RetentionTagHelper.ApplyPolicy(mailboxSession, policy, flags, period, archivePolicy, archivePeriod, compactDefaultPolicy, messageItem, false);
 }