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();
        }