Esempio n. 1
0
        internal static UpgradeStatus UpgradeElcFolder(bool userIsOnRetentionPolcyTags, MailboxSession mailboxSession, Folder folder, Dictionary <Guid, AdTagData> allAdTags)
        {
            UpgradeStatus result    = UpgradeStatus.None;
            AdTagData     adTagData = null;

            if (allAdTags != null)
            {
                object obj = folder.TryGetProperty(FolderSchema.ELCPolicyIds);
                if (obj is string)
                {
                    string g     = obj as string;
                    Guid   empty = Guid.Empty;
                    if (GuidHelper.TryParseGuid(g, out empty))
                    {
                        foreach (AdTagData adTagData2 in allAdTags.Values)
                        {
                            if (adTagData2.Tag != null && adTagData2.Tag.LegacyManagedFolder != null && adTagData2.Tag.LegacyManagedFolder.Value == empty)
                            {
                                ElcMailboxHelper.Tracer.TraceDebug <IExchangePrincipal, string, string>(0L, "Mailbox:{0}. Folder {1} was upgraded to tag {2} because they were linked match.", (mailboxSession != null) ? mailboxSession.MailboxOwner : null, (folder != null) ? folder.DisplayName : null, (adTagData != null && adTagData.Tag != null) ? adTagData.Tag.Name : null);
                                adTagData = adTagData2;
                            }
                        }
                    }
                }
            }
            mailboxSession.IsDefaultFolderType(folder.Id);
            ElcMailboxHelper.DeleteElcFolderProperties(folder);
            if (adTagData != null && adTagData.Tag.Type != ElcFolderType.All)
            {
                foreach (ContentSetting contentSetting in adTagData.ContentSettings.Values)
                {
                    if (contentSetting.RetentionEnabled)
                    {
                        folder[StoreObjectSchema.RetentionPeriod] = (int)contentSetting.AgeLimitForRetention.Value.TotalDays;
                        break;
                    }
                }
                folder[StoreObjectSchema.PolicyTag]      = adTagData.Tag.RetentionId.ToByteArray();
                folder[StoreObjectSchema.RetentionFlags] = 1;
                result = UpgradeStatus.AppliedFolderTag;
            }
            return(result);
        }