public override void Apply(CoreFolder folder)
        {
            using (UserConfiguration mailboxConfiguration = this.GetMailboxConfiguration(folder))
            {
                IDictionary dictionary = mailboxConfiguration.GetDictionary();
                dictionary["OlcIsVisible"]                     = this.IsVisible;
                dictionary["OlcIsHidden"]                      = this.IsHidden;
                dictionary["OlcColorIndex"]                    = this.ColorIndex;
                dictionary["OlcIsDailySummaryEnabled"]         = this.IsDailySummaryEnabled;
                dictionary["ConsumerTaskPermissionLevel"]      = this.ConsumerTaskPermissionLevel;
                dictionary["OlcConsecutiveErrorCount"]         = this.ConsecutiveErrorCount;
                dictionary["OlcTotalErrorCount"]               = this.TotalErrorCount;
                dictionary["OlcPollingInterval"]               = this.PollingInterval;
                dictionary["OlcEntityTag"]                     = (this.EntityTag ?? string.Empty);
                dictionary["OlcImportedEventCount"]            = this.ImportedEventCount;
                dictionary["OlcTotalEventCount"]               = this.TotalEventCount;
                dictionary["OlcUpdateStatus"]                  = this.UpdateStatus;
                dictionary["OlcMissingUidCount"]               = this.MissingUidCount;
                dictionary["OlcConsecutiveCriticalErrorCount"] = this.ConsecutiveCriticalErrorCount;
                dictionary["OlcPersonIdMigrated"]              = this.PersonIdMigrated;
                ConflictResolutionResult conflictResolutionResult = mailboxConfiguration.Save(SaveMode.ResolveConflicts);
                if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict)
                {
                    throw new ConversionFailedException(ConversionFailureReason.ConverterInternalFailure, MrsStrings.ReportCalendarFolderFaiSaveFailed, null);
                }
                MrsTracer.Provider.Debug("Calendar folder user configuration has been updated.", new object[0]);
            }
            folder.PropertyBag.Load(CalendarFolderSchema.Instance.AutoloadProperties);
            if (this.OlcCalendarType != OlcCalendarType.RegularEvents)
            {
                folder.PropertyBag[FolderSchema.DisplayName] = (this.Name ?? string.Empty);
            }
            folder.PropertyBag[CalendarFolderSchema.CharmId] = (this.CharmId ?? string.Empty);
            FolderSaveResult folderSaveResult = folder.Save(SaveMode.NoConflictResolution);

            if (folderSaveResult.OperationResult == OperationResult.Failed)
            {
                throw new ConversionFailedException(ConversionFailureReason.ConverterInternalFailure, MrsStrings.ReportCalendarFolderSaveFailed, null);
            }
            MrsTracer.Provider.Debug("Calendar folder has been updated with settings.", new object[0]);
            folder.PropertyBag.Load(CalendarFolderSchema.Instance.AutoloadProperties);
        }
Ejemplo n.º 2
0
 private void ExecuteSyncStateOperation(Action <StoreSession, CoreFolder> operation)
 {
     using (base.RHTracker.Start())
     {
         if (base.IsPublicFolderMove || base.IsPublicFolderMailboxRestore)
         {
             PublicFolderSession publicFolderSession = this.GetPublicFolderSession();
             using (CoreFolder coreFolder = CoreFolder.Bind(publicFolderSession, publicFolderSession.GetTombstonesRootFolderId()))
             {
                 operation(publicFolderSession, coreFolder);
                 goto IL_A9;
             }
         }
         MailboxSession mailboxSession = null;
         bool           flag           = false;
         try
         {
             if (base.UseHomeMDB)
             {
                 mailboxSession = this.GetMailboxSession();
             }
             else
             {
                 mailboxSession = this.OpenSystemMailbox();
                 flag           = true;
             }
             using (CoreFolder coreFolder2 = CoreFolder.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Configuration), false, "MailboxReplicationService SyncStates", CreateMode.OpenIfExists))
             {
                 coreFolder2.Save(SaveMode.FailOnAnyConflict);
                 operation(mailboxSession, coreFolder2);
             }
         }
         finally
         {
             if (flag && mailboxSession != null)
             {
                 mailboxSession.Dispose();
             }
         }
         IL_A9 :;
     }
 }
Ejemplo n.º 3
0
 protected override void InternalProcessRecord()
 {
     try
     {
         if (this.Path != null)
         {
             PublicFolder publicFolder = (PublicFolder)base.GetDataObject <PublicFolder>(this.Path, base.DataSession, null, new LocalizedString?(Strings.ErrorPublicFolderNotFound(this.Path.ToString())), new LocalizedString?(Strings.ErrorPublicFolderNotUnique(this.Path.ToString())));
             using (this.publicFolderDataProvider.PublicFolderSession.GetRestrictedOperationToken())
             {
                 using (CoreFolder coreFolder = CoreFolder.Bind(this.publicFolderDataProvider.PublicFolderSession, publicFolder.InternalFolderIdentity.ObjectId))
                 {
                     coreFolder.MoveFolder(coreFolder, this.DataObject.InternalFolderIdentity.ObjectId);
                     this.folderUpdated = true;
                 }
             }
         }
         if (this.OverrideContentMailbox != null && (this.Force || base.ShouldContinue(Strings.ConfirmationMessageOverrideContentMailbox)))
         {
             PublicFolder publicFolder2 = (PublicFolder)base.GetDataObject <PublicFolder>(this.Identity, base.DataSession, null, new LocalizedString?(Strings.ErrorPublicFolderNotFound(this.Identity.ToString())), new LocalizedString?(Strings.ErrorPublicFolderNotUnique(this.Identity.ToString())));
             using (this.publicFolderDataProvider.PublicFolderSession.GetRestrictedOperationToken())
             {
                 using (CoreFolder coreFolder2 = CoreFolder.Bind(this.publicFolderDataProvider.PublicFolderSession, publicFolder2.InternalFolderIdentity.ObjectId))
                 {
                     coreFolder2.PropertyBag.SetProperty(CoreFolderSchema.ReplicaList, new string[]
                     {
                         this.contentMailboxGuid.ToString()
                     });
                     coreFolder2.PropertyBag.SetProperty(CoreFolderSchema.LastMovedTimeStamp, ExDateTime.UtcNow);
                     coreFolder2.Save(SaveMode.NoConflictResolution);
                     this.folderUpdated = true;
                 }
             }
         }
         base.InternalProcessRecord();
     }
     catch (NotSupportedException exception)
     {
         base.WriteError(exception, ErrorCategory.InvalidType, this.Identity);
     }
 }
Ejemplo n.º 4
0
        void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId)
        {
            MrsTracer.Provider.Function("StorageDestinationMailbox.CreateFolder(\"{0}\")", new object[]
            {
                sourceFolder.FolderName
            });
            base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None);
            FolderRec folderRec = null;

            newFolderId = null;
            bool   isSearchFolder = sourceFolder.FolderType == FolderType.Search;
            string text           = sourceFolder.FolderName;

            if (string.IsNullOrWhiteSpace(text))
            {
                text = Guid.NewGuid().ToString();
            }
            using (base.RHTracker.Start())
            {
                if (sourceFolder.EntryId != null)
                {
                    using (StorageDestinationFolder folder = base.GetFolder <StorageDestinationFolder>(sourceFolder.EntryId))
                    {
                        if (folder != null)
                        {
                            MrsTracer.Provider.Debug("Source folder '{0}' already exists in destination.", new object[]
                            {
                                sourceFolder.FolderName
                            });
                            if (createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists))
                            {
                                throw new FolderAlreadyExistsException(sourceFolder.FolderName);
                            }
                            folderRec   = ((IFolder)folder).GetFolderRec(null, GetFolderRecFlags.None);
                            newFolderId = folderRec.EntryId;
                        }
                    }
                }
                if (newFolderId == null)
                {
                    CreateMode createMode = CreateMode.OverrideFolderCreationBlock;
                    if (createFolderFlags.HasFlag(CreateFolderFlags.CreatePublicFolderDumpster))
                    {
                        createMode |= CreateMode.CreatePublicFolderDumpster;
                    }
                    using (CoreFolder coreFolder = createFolderFlags.HasFlag(CreateFolderFlags.InternalAccess) ? CoreFolder.CreateSecure(base.StoreSession, base.GetFolderId(sourceFolder.ParentId), isSearchFolder, text, createMode) : CoreFolder.Create(base.StoreSession, base.GetFolderId(sourceFolder.ParentId), isSearchFolder, text, createMode))
                    {
                        if (sourceFolder.EntryId != null)
                        {
                            coreFolder.PropertyBag[StoreObjectSchema.EntryId] = sourceFolder.EntryId;
                        }
                        string value;
                        if (!string.IsNullOrEmpty(sourceFolder.FolderClass) && StorageDestinationMailbox.folderClassMap.TryGetValue(sourceFolder.FolderClass, out value))
                        {
                            coreFolder.PropertyBag[StoreObjectSchema.ContainerClass] = value;
                        }
                        coreFolder.Save(SaveMode.FailOnAnyConflict);
                        coreFolder.PropertyBag.Load(FolderSchema.Instance.AutoloadProperties);
                        newFolderId = coreFolder.Id.ObjectId.ProviderLevelItemId;
                        goto IL_225;
                    }
                }
                if (!CommonUtils.IsSameEntryId(folderRec.ParentId, sourceFolder.ParentId))
                {
                    MrsTracer.Common.Debug("Existing folder is under the wrong parent. Moving it.", new object[0]);
                    ((IDestinationMailbox)this).MoveFolder(sourceFolder.EntryId, folderRec.ParentId, sourceFolder.ParentId);
                }
IL_225:
                PropTag[] promotedProperties = sourceFolder.GetPromotedProperties();
                if ((promotedProperties != null && promotedProperties.Length > 0) || (sourceFolder.Restrictions != null && sourceFolder.Restrictions.Length > 0) || (sourceFolder.Views != null && sourceFolder.Views.Length > 0) || (sourceFolder.ICSViews != null && sourceFolder.ICSViews.Length > 0))
                {
                    using (StorageDestinationFolder folder2 = base.GetFolder <StorageDestinationFolder>(sourceFolder.EntryId))
                    {
                        folder2.SetExtendedProps(promotedProperties, sourceFolder.Restrictions, sourceFolder.Views, sourceFolder.ICSViews);
                    }
                }
            }
        }