protected DatabaseCopy SaveDBCopy() { TaskLogger.LogEnter(); DatabaseCopy databaseCopy = null; if (this.preExistingDatabase != null) { foreach (DatabaseCopy databaseCopy2 in this.preExistingDatabase.InvalidDatabaseCopies) { if (databaseCopy2.Name.Equals(this.OwnerServer.Name, StringComparison.OrdinalIgnoreCase)) { databaseCopy = databaseCopy2; break; } } } DatabaseCopy databaseCopy3 = databaseCopy ?? new DatabaseCopy(); databaseCopy3.HostServer = (ADObjectId)this.OwnerServer.Identity; if (databaseCopy == null) { databaseCopy3.ActivationPreference = 1; } else { databaseCopy3.ActivationPreference = databaseCopy3.ActivationPreference; } ADRawEntry adrawEntry = databaseCopy3; TDataObject dataObject = this.DataObject; adrawEntry.SetId(dataObject.Id.GetChildId(this.OwnerServer.Name)); databaseCopy3.ParentObjectClass = ((this.DatabaseType == NewDatabaseTask <TDataObject> .ExchangeDatabaseType.Public) ? PublicFolderDatabase.MostDerivedClass : MailboxDatabase.MostDerivedClass); TDataObject dataObject2 = this.DataObject; ActivationPreferenceSetter <DatabaseCopy> activationPreferenceSetter = new ActivationPreferenceSetter <DatabaseCopy>(dataObject2.AllDatabaseCopies, databaseCopy3, (databaseCopy == null) ? EntryAction.Insert : EntryAction.Modify); UpdateResult updateResult = activationPreferenceSetter.UpdateCachedValues(); if (updateResult == UpdateResult.AllChanged) { activationPreferenceSetter.SaveAllUpdatedValues(base.DataSession); } base.DataSession.Save(databaseCopy3); this.forcedReplicationSites = DagTaskHelper.DetermineRemoteSites(base.GlobalConfigSession, databaseCopy3.OriginatingServer, this.OwnerServer); if (this.forcedReplicationSites != null) { ITopologyConfigurationSession session = (ITopologyConfigurationSession)base.DataSession; TDataObject dataObject3 = this.DataObject; string objectIdentity = dataObject3.Identity.ToString(); if (DagTaskHelper.ForceReplication(session, this.DataObject, this.forcedReplicationSites, objectIdentity, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose))) { DagTaskHelper.ForceReplication(session, databaseCopy3, this.forcedReplicationSites, objectIdentity, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } } TaskLogger.LogExit(); return(databaseCopy3); }
protected override void StampChangesOn(IConfigurable dataObject) { DatabaseCopy databaseCopy = dataObject as DatabaseCopy; databaseCopy.InvalidHostServerAllowed = true; if (base.Fields["ActivationPreference"] != null) { Database database = databaseCopy.GetDatabase <Database>(); database.CompleteAllCalculatedProperties(); if (this.ActivationPreference < 1U || (ulong)this.ActivationPreference > (ulong)((long)database.AllDatabaseCopies.Length)) { base.WriteError(new ArgumentException(Strings.ErrorActivationPreferenceInvalid(this.ActivationPreference, database.AllDatabaseCopies.Length)), ErrorCategory.InvalidArgument, null); } DatabaseCopy databaseCopy2 = null; if (this.ActivationPreference == 1U) { databaseCopy2 = databaseCopy; } else if (this.ActivationPreference != 0U) { databaseCopy2 = SetMailboxDatabaseCopy.GetDatabaseCopyOfPreference1(new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), database, databaseCopy); } databaseCopy.ActivationPreference = (int)this.ActivationPreference; this.ValidateHighestActivationPreferenceServerLocation(database); if (databaseCopy2 != null) { base.WriteVerbose(Strings.UpdatingLegDnForDatabaseCopy(databaseCopy.Name)); ITopologyConfigurationSession adSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, base.SessionSettings, 295, "StampChangesOn", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\database\\SetMailboxDatabaseCopy.cs"); SetMailboxDatabaseCopy.UpdateServerLegdnForDatabaseSite(new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), adSession, databaseCopy2); } ActivationPreferenceSetter <DatabaseCopy> activationPreferenceSetter = new ActivationPreferenceSetter <DatabaseCopy>(database.AllDatabaseCopies, databaseCopy, EntryAction.Modify); UpdateResult updateResult = activationPreferenceSetter.UpdateCachedValues(); if (updateResult == UpdateResult.AllChanged) { activationPreferenceSetter.SaveAllUpdatedValues(base.DataSession); } else if (updateResult == UpdateResult.NoChange) { databaseCopy.ResetChangeTracking(); } } this.ClearHostServer; base.StampChangesOn(dataObject); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); base.InternalProcessRecord(); if (this.m_invalidDbCopy == null && !this.m_fConfigOnly) { ReplayState.DeleteState(this.m_server.Fqdn, this.DataObject, true); } DatabaseCopy databaseCopy = this.m_invalidDbCopy ?? new DatabaseCopy(); databaseCopy.HostServer = (ADObjectId)this.m_server.Identity; if (base.Fields["ActivationPreference"] == null) { if (this.m_invalidDbCopy == null) { this.ActivationPreference = (uint)(this.DataObject.AllDatabaseCopies.Length + 1); } else { this.ActivationPreference = (uint)this.m_invalidDbCopy.ActivationPreference; } } databaseCopy.ActivationPreference = (int)this.ActivationPreference; DatabaseCopy databaseCopy2 = null; if (databaseCopy.ActivationPreference == 1) { databaseCopy2 = databaseCopy; } else if (this.ActivationPreference != 0U) { databaseCopy2 = SetMailboxDatabaseCopy.GetDatabaseCopyOfPreference1(new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), this.DataObject, databaseCopy); } ActivationPreferenceSetter <DatabaseCopy> activationPreferenceSetter = new ActivationPreferenceSetter <DatabaseCopy>(this.DataObject.AllDatabaseCopies, databaseCopy, (this.m_invalidDbCopy == null) ? EntryAction.Insert : EntryAction.Modify); UpdateResult updateResult = activationPreferenceSetter.UpdateCachedValues(); if (updateResult == UpdateResult.AllChanged) { activationPreferenceSetter.SaveAllUpdatedValues(base.DataSession); } databaseCopy.ReplayLagTime = this.m_replayLagTime; databaseCopy.TruncationLagTime = this.m_truncationLagTime; databaseCopy.SetId(this.DataObject.Id.GetChildId(this.m_server.Name.ToUpperInvariant())); databaseCopy.ParentObjectClass = (this.DataObject.IsPublicFolderDatabase ? PublicFolderDatabase.MostDerivedClass : MailboxDatabase.MostDerivedClass); if (databaseCopy2 != null) { base.WriteVerbose(Strings.UpdatingLegDnForDatabaseCopy(databaseCopy.Name)); ITopologyConfigurationSession adSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, base.SessionSettings, 338, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\database\\AddMailboxDatabaseCopy.cs"); SetMailboxDatabaseCopy.UpdateServerLegdnForDatabaseSite(new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), adSession, databaseCopy2); } base.WriteVerbose(Strings.UpdatingDatabaseCopyObject(databaseCopy.HostServer.Name, databaseCopy.ReplayLagTime.ToString(), databaseCopy.TruncationLagTime.ToString())); base.DataSession.Save(databaseCopy); MailboxDatabase database = databaseCopy.GetDatabase <MailboxDatabase>(); if (this.m_firstCopy && database.DataMoveReplicationConstraint == DataMoveReplicationConstraintParameter.None) { database.DataMoveReplicationConstraint = DataMoveReplicationConstraintParameter.SecondCopy; base.DataSession.Save(database); base.WriteVerbose(Strings.ConstraintUpgrade(database.Identity.ToString(), DataMoveReplicationConstraintParameter.None, DataMoveReplicationConstraintParameter.SecondCopy)); } ITopologyConfigurationSession topologyConfigurationSession = (ITopologyConfigurationSession)base.DataSession; ADObjectId[] array = DagTaskHelper.DetermineRemoteSites(topologyConfigurationSession, databaseCopy.OriginatingServer, this.m_server); if (array != null) { DagTaskHelper.ForceReplication(topologyConfigurationSession, databaseCopy, array, this.DataObject.Identity.ToString(), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } if (!this.m_fConfigOnly) { this.RunSourceConfigurationUpdaterRpc(); } if (!this.IsThirdPartyReplicationEnabled && !this.m_SeedingPostponedSpecified && !base.SeedingPostponed && !this.m_fConfigOnly) { base.CreateTargetEdbDirectory(); base.PerformSeedIfNecessary(); } if (!this.m_fConfigOnly) { this.RunTargetConfigurationUpdaterRpc(); } this.WriteWarning(Strings.WarnAdministratorToRestartService(this.m_server.Name)); TaskLogger.LogExit(); }