protected override void WriteResult()
        {
            TaskLogger.LogEnter();
            this.dbCopy = base.SaveDBCopy();
            if (this.preExistingDatabase != null)
            {
                TaskLogger.LogExit();
                return;
            }
            MailboxDatabase mailboxDatabase = (MailboxDatabase)base.GetDataObject(new DatabaseIdParameter((ADObjectId)this.DataObject.Identity));

            try
            {
                int maximumSupportedDatabaseSchemaVersion = DatabaseTasksHelper.GetMaximumSupportedDatabaseSchemaVersion((ITopologyConfigurationSession)base.DataSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskErrorLoggingDelegate(base.WriteError), mailboxDatabase);
                DatabaseTasksHelper.SetRequestedDatabaseSchemaVersion((ITopologyConfigurationSession)base.DataSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning), null, mailboxDatabase, maximumSupportedDatabaseSchemaVersion);
            }
            catch (ClusterException)
            {
            }
            mailboxDatabase.CompleteAllCalculatedProperties();
            this.RunConfigurationUpdaterRpc(mailboxDatabase);
            this.systemMailbox = NewMailboxDatabase.SaveSystemMailbox(mailboxDatabase, base.OwnerServer, base.RootOrgContainerId, (ITopologyConfigurationSession)this.ConfigurationSession, this.RecipientSessionForSystemMailbox, this.forcedReplicationSites, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
            base.WriteObject(mailboxDatabase);
            TaskLogger.LogExit();
        }
Esempio n. 2
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     try
     {
         try
         {
             MailboxDatabase mailboxDatabase  = this.ConfigurationSession.Read <MailboxDatabase>((ADObjectId)this.DataObject.Identity);
             Server          server           = null;
             ADComputer      adcomputer       = null;
             bool            useConfigNC      = this.ConfigurationSession.UseConfigNC;
             bool            useGlobalCatalog = this.ConfigurationSession.UseGlobalCatalog;
             if (mailboxDatabase != null)
             {
                 server = mailboxDatabase.GetServer();
                 try
                 {
                     this.ConfigurationSession.UseConfigNC      = false;
                     this.ConfigurationSession.UseGlobalCatalog = true;
                     adcomputer = ((ITopologyConfigurationSession)this.ConfigurationSession).FindComputerByHostName(server.Name);
                 }
                 finally
                 {
                     this.ConfigurationSession.UseConfigNC      = useConfigNC;
                     this.ConfigurationSession.UseGlobalCatalog = useGlobalCatalog;
                 }
                 if (adcomputer == null)
                 {
                     base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorDBOwningServerNotFound(mailboxDatabase.Identity.ToString())), ErrorCategory.ObjectNotFound, server.Identity);
                 }
                 ADObjectId adobjectId = adcomputer.Id.DomainId;
                 adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects");
                 adobjectId = adobjectId.GetChildId("SystemMailbox" + mailboxDatabase.Guid.ToString("B"));
                 string identity = adobjectId.ToDNString();
                 GeneralMailboxIdParameter generalMailboxIdParameter = GeneralMailboxIdParameter.Parse(identity);
                 base.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(generalMailboxIdParameter, this.RecipientSession, typeof(ADRecipient), null));
                 IEnumerable <ADSystemMailbox> objects = generalMailboxIdParameter.GetObjects <ADSystemMailbox>(adobjectId, this.RecipientSession);
                 using (IEnumerator <ADSystemMailbox> enumerator = objects.GetEnumerator())
                 {
                     if (enumerator.MoveNext())
                     {
                         ADSystemMailbox adsystemMailbox = enumerator.Current;
                     }
                     else
                     {
                         NewMailboxDatabase.SaveSystemMailbox(mailboxDatabase, mailboxDatabase.GetServer(), base.RootOrgContainerId, (ITopologyConfigurationSession)this.ConfigurationSession, this.RecipientSession, null, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                     }
                 }
             }
             base.WriteVerbose(Strings.VerboseMountDatabase(this.Identity.ToString()));
             this.RequestMount(MountFlags.None);
             if (!this.DataObject.DatabaseCreated)
             {
                 this.DataObject.DatabaseCreated = true;
                 base.InternalProcessRecord();
             }
         }
         catch (AmServerException ex)
         {
             Exception ex2;
             if (ex.TryGetInnerExceptionOfType(out ex2))
             {
                 TaskLogger.Trace("Database already mounted (database={0}, exception={1})", new object[]
                 {
                     this.DataObject.Name,
                     ex2.Message
                 });
             }
             else if (ex.TryGetInnerExceptionOfType(out ex2) || ex.TryGetInnerExceptionOfType(out ex2))
             {
                 this.AttemptForcedMountIfNecessary(this.Force, Strings.ContinueMountWhenDBFilesNotExist, Strings.VerboseMountDatabaseForcely(this.Identity.ToString()), Strings.ErrorFailedToMountReplicatedDbWithMissingEdbFile(this.Identity.ToString()), ex, MountFlags.ForceDatabaseCreation);
             }
             else if (ex.TryGetInnerExceptionOfType(out ex2))
             {
                 this.PromptForMountIfNecessary(this.AcceptDataLoss, Strings.ContinueMountWithDataLoss, Strings.VerboseMountDatabaseDataLoss(this.Identity.ToString()), MountFlags.AcceptDataLoss);
             }
             else
             {
                 TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
                 {
                     ex.Message
                 });
                 base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex.Message), ex), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
         }
     }
     catch (AmServerException ex3)
     {
         TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
         {
             ex3.Message
         });
         base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex3.Message), ex3), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     catch (AmServerTransientException ex4)
     {
         TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
         {
             ex4.Message
         });
         base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex4.Message), ex4), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }