private static void UpdateBackupInfo(DatabaseCopyStatusEntry entry, RpcDatabaseCopyStatus2 copyStatus)
        {
            entry.m_latestFullBackupTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LatestFullBackupTime);
            DateTime?dateTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LatestIncrementalBackupTime);

            if (dateTime != null && dateTime.Value >= entry.m_latestFullBackupTime)
            {
                entry.m_latestIncrementalBackupTime = dateTime;
            }
            dateTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LatestDifferentialBackupTime);
            if (dateTime != null && dateTime.Value >= entry.m_latestFullBackupTime)
            {
                entry.m_latestDifferentialBackupTime = dateTime;
            }
            entry.m_latestCopyBackupTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LatestCopyBackupTime);
            if (entry.m_latestFullBackupTime != null)
            {
                entry.m_snapshotLatestFullBackup = new bool?(copyStatus.SnapshotLatestFullBackup);
                entry.m_snapshotBackup           = new bool?(copyStatus.SnapshotLatestFullBackup);
            }
            if (entry.m_latestIncrementalBackupTime != null)
            {
                entry.m_snapshotLatestIncrementalBackup = new bool?(copyStatus.SnapshotLatestIncrementalBackup);
            }
            if (entry.m_latestDifferentialBackupTime != null)
            {
                entry.m_snapshotLatestDifferentialBackup = new bool?(copyStatus.SnapshotLatestDifferentialBackup);
            }
            if (entry.m_latestCopyBackupTime != null)
            {
                entry.m_snapshotLatestCopyBackup = new bool?(copyStatus.SnapshotLatestCopyBackup);
            }
        }
        private DatabaseMoveResult PrepareResultEntryForMoveBack(AmDatabaseMoveResult result)
        {
            DatabaseMoveResult databaseMoveResult = new DatabaseMoveResult();

            databaseMoveResult.Guid = result.DbGuid;
            ConfigObjectId identity = new ConfigObjectId(result.DbName);

            databaseMoveResult.Identity            = identity;
            databaseMoveResult.ActiveServerAtStart = result.FromServerFqdn;
            databaseMoveResult.ActiveServerAtEnd   = result.FinalActiveServerFqdn;
            databaseMoveResult.Status = MoveActiveMailboxDatabase.ConvertToMoveStatus(result.MoveStatus);
            databaseMoveResult.MountStatusAtMoveStart = MoveActiveMailboxDatabase.ConvertToMountStatus(result.MountStatusAtStart);
            databaseMoveResult.MountStatusAtMoveEnd   = MoveActiveMailboxDatabase.ConvertToMountStatus(result.MountStatusAtEnd);
            if (result.AttemptedServerSubStatuses != null)
            {
                AmDbRpcOperationSubStatus amDbRpcOperationSubStatus = result.AttemptedServerSubStatuses.LastOrDefault <AmDbRpcOperationSubStatus>();
                if (amDbRpcOperationSubStatus != null)
                {
                    databaseMoveResult.NumberOfLogsLost       = MoveActiveMailboxDatabase.ToNullableLogGeneration(amDbRpcOperationSubStatus.AcllStatus.NumberOfLogsLost);
                    databaseMoveResult.RecoveryPointObjective = DumpsterStatisticsEntry.ToNullableLocalDateTime(amDbRpcOperationSubStatus.AcllStatus.LastInspectedLogTime);
                }
            }
            Exception exceptionFromMoveResult = this.GetExceptionFromMoveResult(result);

            if (exceptionFromMoveResult != null)
            {
                databaseMoveResult.Exception    = exceptionFromMoveResult;
                databaseMoveResult.ErrorMessage = exceptionFromMoveResult.Message;
            }
            return(databaseMoveResult);
        }
        internal static void GetEntryFromStatus(RpcDatabaseCopyStatus2 copyStatus, DatabaseCopyStatusEntry entry)
        {
            CopyStatusEnum copyStatus2 = copyStatus.CopyStatus;
            CopyStatus     copyStatus3 = GetMailboxDatabaseCopyStatus.TranslateRpcStatusToTaskStatus(copyStatus2);

            entry.Status = copyStatus3;
            entry.m_statusRetrievedTime      = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.StatusRetrievedTime);
            entry.m_lastStatusTransitionTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastStatusTransitionTime);
            entry.InstanceStartTime          = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.InstanceStartTime);
            entry.m_errorMessage             = copyStatus.ErrorMessage;
            entry.m_errorEventId             = ((copyStatus.ErrorEventId != 0U) ? new uint?(copyStatus.ErrorEventId) : null);
            entry.m_extendedErrorInfo        = copyStatus.ExtendedErrorInfo;
            if (copyStatus3 == CopyStatus.Suspended || copyStatus3 == CopyStatus.FailedAndSuspended || copyStatus3 == CopyStatus.Seeding)
            {
                entry.m_suspendMessage = copyStatus.SuspendComment;
            }
            entry.m_singlePageRestore  = copyStatus.SinglePageRestoreNumber;
            entry.m_mailboxServer      = copyStatus.MailboxServer;
            entry.m_activeDatabaseCopy = copyStatus.ActiveDatabaseCopy;
            entry.m_actionInitiator    = copyStatus.ActionInitiator;
            entry.ActiveCopy           = copyStatus.IsActiveCopy();
            if (copyStatus.ActivationPreference > 0)
            {
                entry.ActivationPreference = new int?(copyStatus.ActivationPreference);
            }
            entry.IsLastCopyAvailabilityChecksPassed   = new bool?(copyStatus.IsLastCopyAvailabilityChecksPassed);
            entry.IsLastCopyRedundancyChecksPassed     = new bool?(copyStatus.IsLastCopyRedundancyChecksPassed);
            entry.LastCopyAvailabilityChecksPassedTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastCopyAvailabilityChecksPassedTime);
            entry.LastCopyRedundancyChecksPassedTime   = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastCopyRedundancyChecksPassedTime);
            entry.DiskFreeSpacePercent                 = copyStatus.DiskFreeSpacePercent;
            entry.DiskFreeSpace                        = ByteQuantifiedSize.FromBytes(copyStatus.DiskFreeSpaceBytes);
            entry.DiskTotalSpace                       = ByteQuantifiedSize.FromBytes(copyStatus.DiskTotalSpaceBytes);
            entry.ExchangeVolumeMountPoint             = copyStatus.ExchangeVolumeMountPoint;
            entry.DatabaseVolumeMountPoint             = copyStatus.DatabaseVolumeMountPoint;
            entry.DatabaseVolumeName                   = copyStatus.DatabaseVolumeName;
            entry.DatabasePathIsOnMountedFolder        = new bool?(copyStatus.DatabasePathIsOnMountedFolder);
            entry.LogVolumeMountPoint                  = copyStatus.LogVolumeMountPoint;
            entry.LogVolumeName                        = copyStatus.LogVolumeName;
            entry.LogPathIsOnMountedFolder             = new bool?(copyStatus.LogPathIsOnMountedFolder);
            entry.LastDatabaseVolumeName               = copyStatus.LastDatabaseVolumeName;
            entry.LastDatabaseVolumeNameTransitionTime = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastDatabaseVolumeNameTransitionTime);
            entry.VolumeInfoError                      = copyStatus.VolumeInfoLastError;
            entry.m_activationSuspended                = copyStatus.ActivationSuspended;
            if (copyStatus.ActivationSuspended)
            {
                entry.m_suspendMessage = copyStatus.SuspendComment;
            }
            entry.m_latestAvailableLogTime           = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LatestAvailableLogTime);
            entry.m_latestCopyNotificationTime       = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastCopyNotifiedLogTime);
            entry.m_latestCopyTime                   = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastCopiedLogTime);
            entry.m_latestInspectorTime              = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastInspectedLogTime);
            entry.m_latestReplayTime                 = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastReplayedLogTime);
            entry.m_latestLogGenerationNumber        = copyStatus.LastLogGenerated;
            entry.m_copyNotificationGenerationNumber = copyStatus.LastLogCopyNotified;
            entry.m_copyGenerationNumber             = copyStatus.LastLogCopied;
            entry.m_inspectorGenerationNumber        = copyStatus.LastLogInspected;
            entry.m_replayGenerationNumber           = copyStatus.LastLogReplayed;
            entry.m_contentIndexState                = copyStatus.ContentIndexStatus;
            entry.m_contentIndexErrorMessage         = copyStatus.ContentIndexErrorMessage;
            entry.m_contentIndexErrorCode            = copyStatus.ContentIndexErrorCode;
            entry.m_contentIndexVersion              = copyStatus.ContentIndexVersion;
            entry.m_contentIndexBacklog              = copyStatus.ContentIndexBacklog;
            entry.m_contentIndexRetryQueueSize       = copyStatus.ContentIndexRetryQueueSize;
            entry.m_contentIndexMailboxesToCrawl     = copyStatus.ContentIndexMailboxesToCrawl;
            entry.m_contentIndexSeedingPercent       = copyStatus.ContentIndexSeedingPercent;
            entry.m_contentIndexSeedingSource        = copyStatus.ContentIndexSeedingSource;
            entry.m_logCopyQueueIncreasing           = new bool?(copyStatus.CopyQueueNotKeepingUp);
            entry.m_logReplayQueueIncreasing         = new bool?(copyStatus.ReplayQueueNotKeepingUp);
            entry.m_replaySuspended                  = new bool?(copyStatus.ReplaySuspended);
            entry.ResumeBlocked = new bool?(copyStatus.ResumeBlocked);
            entry.ReseedBlocked = new bool?(copyStatus.ReseedBlocked);
            if (copyStatus.WorkerProcessId != 0)
            {
                entry.m_workerProcessId = new int?(copyStatus.WorkerProcessId);
            }
            entry.LastLogInfoIsStale               = copyStatus.LastLogInfoIsStale;
            entry.LastLogInfoFromCopierTime        = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastLogInfoFromCopierTime);
            entry.LastLogInfoFromClusterTime       = DumpsterStatisticsEntry.ToNullableLocalDateTime(copyStatus.LastLogInfoFromClusterTime);
            entry.LastLogInfoFromClusterGen        = copyStatus.LastLogInfoFromClusterGen;
            entry.LowestLogPresent                 = copyStatus.LowestLogPresent;
            entry.m_logsReplayedSinceInstanceStart = new long?(copyStatus.LogsReplayedSinceInstanceStart);
            entry.m_logsCopiedSinceInstanceStart   = new long?(copyStatus.LogsCopiedSinceInstanceStart);
            entry.ReplicationIsInBlockMode         = copyStatus.ReplicationIsInBlockMode;
            entry.ActivationDisabledAndMoveNow     = copyStatus.ActivationDisabledAndMoveNow;
            entry.AutoActivationPolicy             = (DatabaseCopyAutoActivationPolicyType)copyStatus.AutoActivationPolicy;
            int num = copyStatus.MinimumSupportedDatabaseSchemaVersion;

            if (num > 0)
            {
                entry.MinimumSupportedDatabaseSchemaVersion = string.Format("{0}.{1}", num >> 16, num & 65535);
            }
            num = copyStatus.MaximumSupportedDatabaseSchemaVersion;
            if (num > 0)
            {
                entry.MaximumSupportedDatabaseSchemaVersion = string.Format("{0}.{1}", num >> 16, num & 65535);
            }
            num = copyStatus.RequestedDatabaseSchemaVersion;
            if (num > 0)
            {
                entry.RequestedDatabaseSchemaVersion = string.Format("{0}.{1}", num >> 16, num & 65535);
            }
            GetMailboxDatabaseCopyStatus.UpdateReplayLagStatus(entry, copyStatus);
            GetMailboxDatabaseCopyStatus.UpdateDatabaseSeedStatus(entry, copyStatus);
            GetMailboxDatabaseCopyStatus.UpdateBackupInfo(entry, copyStatus);
            GetMailboxDatabaseCopyStatus.UpdateDumpsterRequests(entry, copyStatus);
            if (copyStatus.OutgoingConnections != null)
            {
                entry.m_outgoingConnections = (ConnectionStatus[])Serialization.BytesToObject(copyStatus.OutgoingConnections);
            }
            if (copyStatus.IncomingLogCopyingNetwork != null)
            {
                entry.m_incomingLogCopyingNetwork = (ConnectionStatus)Serialization.BytesToObject(copyStatus.IncomingLogCopyingNetwork);
            }
            if (copyStatus.SeedingNetwork != null)
            {
                entry.m_seedingNetwork = (ConnectionStatus)Serialization.BytesToObject(copyStatus.SeedingNetwork);
            }
            entry.MaxLogToReplay = copyStatus.MaxLogToReplay;
        }