internal static TenantRelocationStatus GetRelocationStatusFromStatusDetails(RelocationStatusDetails r)
        {
            if (r <= RelocationStatusDetails.SynchronizationFinishedDeltaSync)
            {
                if (r > RelocationStatusDetails.InitializationFinished)
                {
                    if (r <= RelocationStatusDetails.SynchronizationFinishedFullSync)
                    {
                        if (r != RelocationStatusDetails.SynchronizationStartedFullSync && r != RelocationStatusDetails.SynchronizationFinishedFullSync)
                        {
                            goto IL_9E;
                        }
                    }
                    else if (r != RelocationStatusDetails.SynchronizationStartedDeltaSync && r != RelocationStatusDetails.SynchronizationFinishedDeltaSync)
                    {
                        goto IL_9E;
                    }
                    return(TenantRelocationStatus.Synchronization);
                }
                if (r == RelocationStatusDetails.NotStarted || r == RelocationStatusDetails.InitializationStarted || r == RelocationStatusDetails.InitializationFinished)
                {
                    return(TenantRelocationStatus.NotStarted);
                }
            }
            else
            {
                if (r <= RelocationStatusDetails.LockdownSwitchedGLS)
                {
                    if (r <= RelocationStatusDetails.LockdownStartedFinalDeltaSync)
                    {
                        if (r != RelocationStatusDetails.LockdownStarted && r != RelocationStatusDetails.LockdownStartedFinalDeltaSync)
                        {
                            goto IL_9E;
                        }
                    }
                    else if (r != RelocationStatusDetails.LockdownFinishedFinalDeltaSync && r != RelocationStatusDetails.LockdownSwitchedGLS)
                    {
                        goto IL_9E;
                    }
                    return(TenantRelocationStatus.Lockdown);
                }
                if (r <= RelocationStatusDetails.RetiredUpdatedTargetForest)
                {
                    if (r == RelocationStatusDetails.RetiredUpdatedSourceForest || r == RelocationStatusDetails.RetiredUpdatedTargetForest)
                    {
                        return(TenantRelocationStatus.Retired);
                    }
                }
                else
                {
                    if (r == RelocationStatusDetails.Arriving)
                    {
                        return(TenantRelocationStatus.Arriving);
                    }
                    if (r == RelocationStatusDetails.Active)
                    {
                        return(TenantRelocationStatus.Active);
                    }
                }
            }
IL_9E:
            throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("RelocationStatus", new ArgumentOutOfRangeException(r.ToString()).Message), TenantRelocationRequestSchema.RelocationStatus, r));
        }
        protected override void InternalProcessRecord()
        {
            string forestFQDN = this.DataObject.OrganizationId.PartitionId.ForestFQDN;

            if (this.applyTransitionFromCmdlet)
            {
                LocalizedString?localizedString = null;
                if (!this.DataObject.AutoCompletionEnabled && this.DataObject.RelocationStatusDetailsSource != (RelocationStatusDetailsSource)this.DataObject.RelocationStateRequested)
                {
                    localizedString = new LocalizedString?(Strings.WarningApplyingTransitionWhileRelocationStatusNotReachedStateRequested(this.Identity.ToString(), this.DataObject.RelocationStateRequested.ToString(), this.DataObject.RelocationStatusDetailsSource.ToString()));
                }
                else if (this.DataObject.AutoCompletionEnabled && this.DataObject.RelocationStatusDetailsSource != RelocationStatusDetailsSource.RetiredUpdatedTargetForest)
                {
                    localizedString = new LocalizedString?(Strings.WarningApplyingTransitionWhileRelocationStatusNotReachedStateRequested(this.Identity.ToString(), this.DataObject.RelocationStateRequested.ToString(), this.DataObject.RelocationStatusDetailsSource.ToString()));
                }
                if (localizedString != null && !base.ShouldContinue(localizedString.Value))
                {
                    return;
                }
                if (this.RollbackGls && this.DataObject.RelocationStatusDetailsSource == RelocationStatusDetailsSource.RetiredUpdatedTargetForest)
                {
                    localizedString = new LocalizedString?(Strings.WarningPossibleDataLossWithGlsRollback(this.Identity.ToString(), this.DataObject.TargetForest, forestFQDN));
                    if (!base.ShouldContinue(localizedString.Value))
                    {
                        return;
                    }
                }
            }
            if (this.Suspend && this.DataObject.RelocationStatusDetailsSource > RelocationStatusDetailsSource.SynchronizationStartedDeltaSync)
            {
                LocalizedString?localizedString2 = new LocalizedString?(Strings.WarningSuspendSupportedOnlyDuringSync(this.DataObject.RelocationStatusDetailsSource.ToString(), RelocationStatusDetailsSource.SynchronizationStartedFullSync.ToString(), RelocationStatusDetailsSource.SynchronizationStartedDeltaSync.ToString()));
                if (!base.ShouldContinue(localizedString2.Value))
                {
                    return;
                }
            }
            this.DataObject.RelocationLastError = RelocationError.None;
            if (base.Fields.IsChanged(TenantRelocationRequestSchema.RelocationStateRequested))
            {
                this.DataObject.RelocationStateRequested = (RelocationStateRequested)this.RelocationStateRequested;
            }
            if (base.Fields.IsChanged(TenantRelocationRequestSchema.LargeTenantModeEnabled))
            {
                this.DataObject.LargeTenantModeEnabled = this.LargeTenantModeEnabled;
            }
            if (base.Fields.IsChanged(TenantRelocationRequestSchema.AutoCompletionEnabled))
            {
                this.DataObject.AutoCompletionEnabled = this.AutoCompletionEnabled;
                if (this.AutoCompletionEnabled)
                {
                    this.DataObject.RelocationStateRequested = Microsoft.Exchange.Data.Directory.SystemConfiguration.RelocationStateRequested.None;
                }
            }
            if (base.Fields.IsChanged(TenantRelocationRequestSchema.SafeLockdownSchedule))
            {
                this.DataObject.SafeLockdownSchedule = this.SafeLockdownSchedule;
            }
            if (this.Suspend)
            {
                this.DataObject.Suspended = true;
            }
            else if (this.Resume)
            {
                this.DataObject.Suspended = false;
            }
            if (this.applyTransitionFromCmdlet)
            {
                Exception ex;
                TenantRelocationRequest.PopulatePresentationObject(this.DataObject, null, out ex);
                if (ex != null)
                {
                    throw ex;
                }
                RelocationStatusDetails relocationStatusDetailsRaw = this.DataObject.RelocationStatusDetailsRaw;
                this.DataObject.RelocationStatusDetailsRaw = RelocationStatusDetails.SynchronizationFinishedFullSync;
                this.DataObject.AutoCompletionEnabled      = false;
                if (this.RollbackGls)
                {
                    this.RevertGlsAccountForestToSource(forestFQDN);
                    this.RevertTargetTenantStateToArriving();
                    this.DataObject.IncrementTransitionCounter(TenantRelocationTransition.RetiredToSync);
                    this.DataObject.OrganizationStatus = OrganizationStatus.Active;
                    TenantRelocationRequest.SetRelocationCompletedOnOU((ITenantConfigurationSession)base.DataSession, this.DataObject.OrganizationId);
                }
                else
                {
                    TenantRelocationTransition transition;
                    if (relocationStatusDetailsRaw == RelocationStatusDetails.SynchronizationFinishedDeltaSync)
                    {
                        transition = TenantRelocationTransition.DeltaSyncToSync;
                    }
                    else
                    {
                        transition = TenantRelocationTransition.LockdownToSync;
                    }
                    this.DataObject.IncrementTransitionCounter(transition);
                }
            }
            if (this.ResetTransitionCounter)
            {
                this.DataObject.TransitionCounter = new MultiValuedProperty <TransitionCount>();
            }
            if (this.ResetPermanentError)
            {
                this.DataObject.RelocationLastError = RelocationError.None;
            }
            if (this.ResetStartSyncTime)
            {
                this.DataObject.LastSuccessfulRelocationSyncStart = new DateTime?(DateTime.UtcNow);
            }
            ((IDirectorySession)base.DataSession).SessionSettings.RetiredTenantModificationAllowed = true;
            base.InternalProcessRecord();
            string ridMasterName = ForestTenantRelocationsCache.GetRidMasterName(new PartitionId(forestFQDN));

            if (this.DataObject.OriginatingServer != ridMasterName)
            {
                this.WriteWarning(Strings.WarningShouldWriteToRidMaster(this.DataObject.OriginatingServer, ridMasterName));
            }
        }
        internal static object GetRelocationStatus(IPropertyBag propertyBag)
        {
            RelocationStatusDetails r = (RelocationStatusDetails)propertyBag[TenantRelocationRequestSchema.RelocationStatusDetailsRaw];

            return(TenantRelocationRequest.GetRelocationStatusFromStatusDetails(r));
        }