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;
        }
 private static void UpdateReplayLagStatus(DatabaseCopyStatusEntry entry, RpcDatabaseCopyStatus2 copyStatus)
 {
     if (copyStatus.ReplayLagEnabled != ReplayLagEnabledEnum.Unknown)
     {
         ReplayLagStatus replayLagStatus = new ReplayLagStatus(copyStatus.ReplayLagEnabled == ReplayLagEnabledEnum.Enabled, copyStatus.ConfiguredReplayLagTime, copyStatus.ActualReplayLagTime, copyStatus.ReplayLagPercentage, GetMailboxDatabaseCopyStatus.ConvertLagPlayDownReason(copyStatus.ReplayLagPlayDownReason), copyStatus.ReplayLagDisabledReason);
         entry.m_replayLagStatus = replayLagStatus;
     }
 }
        private DatabaseCopyStatusEntry[] PrepareStatusEntryFromRpc(Server server, Collection <DatabaseCopy> databaseCopies)
        {
            DatabaseCopyStatusEntry[] array = new DatabaseCopyStatusEntry[databaseCopies.Count];
            Guid[] array2 = new Guid[databaseCopies.Count];
            for (int i = 0; i < databaseCopies.Count; i++)
            {
                DatabaseCopy databaseCopy3 = databaseCopies[i];
                Database     database      = databaseCopy3.GetDatabase <Database>();
                array2[i] = database.Guid;
                array[i]  = this.ConstructNewSatusEntry(databaseCopy3);
            }
            RpcGetDatabaseCopyStatusFlags2 rpcGetDatabaseCopyStatusFlags = RpcGetDatabaseCopyStatusFlags2.None;

            if (!this.UseServerCache)
            {
                rpcGetDatabaseCopyStatusFlags |= RpcGetDatabaseCopyStatusFlags2.ReadThrough;
            }
            try
            {
                IEnumerable <string> source = from databaseCopy in databaseCopies
                                              select databaseCopy.DatabaseName;
                base.WriteVerbose(Strings.GetDbcsRpcQuery(server.Fqdn, string.Join(",", source.ToArray <string>())));
                RpcDatabaseCopyStatus2[] copyStatus = ReplayRpcClientHelper.GetCopyStatus(server.Fqdn, rpcGetDatabaseCopyStatusFlags, array2);
                if (copyStatus != null && copyStatus.Length > 0)
                {
                    base.WriteVerbose(Strings.GetDbcsRpcQueryAllDone(copyStatus.Length));
                    Dictionary <Guid, RpcDatabaseCopyStatus2> dictionary = new Dictionary <Guid, RpcDatabaseCopyStatus2>(copyStatus.Length);
                    for (int j = 0; j < copyStatus.Length; j++)
                    {
                        dictionary[copyStatus[j].DBGuid] = copyStatus[j];
                    }
                    for (int k = 0; k < array2.Length; k++)
                    {
                        RpcDatabaseCopyStatus2 copyStatus2;
                        if (dictionary.TryGetValue(array2[k], out copyStatus2))
                        {
                            GetMailboxDatabaseCopyStatus.GetEntryFromStatus(copyStatus2, array[k]);
                        }
                        else if (!databaseCopies[k].IsValid)
                        {
                            ExTraceGlobals.CmdletsTracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "GetCopyStatus() didn't find replica instance for database {0} on server {1}. The DatabaseCopy is misconfigured in the Active Directory!", array2[k], server.Fqdn);
                            this.UpdateMisconfiguredCopyStatusEntry(array[k], databaseCopies[k]);
                        }
                        else
                        {
                            ExTraceGlobals.CmdletsTracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "GetCopyStatus() didn't find replica instance for database {0} on server {1}.", array2[k], server.Fqdn);
                            this.UpdateCopyStatusNoReplicaInstance(array[k]);
                        }
                    }
                }
            }
            catch (ArgumentException ex)
            {
                ExTraceGlobals.CmdletsTracer.TraceError <ArgumentException>((long)this.GetHashCode(), "GetMailboxDatabaseCopyStatus: ArgumentException: {0}", ex);
                this.WriteError(ex, ErrorCategory.ReadError, null, false);
            }
            catch (TaskServerTransientException ex2)
            {
                ExTraceGlobals.CmdletsTracer.TraceError <TaskServerTransientException>((long)this.GetHashCode(), "GetMailboxDatabaseCopyStatus: ArgumentException: {0}", ex2);
                this.WriteError(ex2, ErrorCategory.ReadError, null, false);
            }
            catch (TaskServerException ex3)
            {
                ExTraceGlobals.CmdletsTracer.TraceError <TaskServerException>((long)this.GetHashCode(), "GetMailboxDatabaseCopyStatus: ReplayServiceRpcException: {0}", ex3);
                if (ex3 is ReplayServiceDownException)
                {
                    base.WriteVerbose(Strings.GetDbcsDetectReplayServiceDown(server.Fqdn, ex3.Message));
                    for (int l = 0; l < array.Length; l++)
                    {
                        DatabaseCopyStatusEntry databaseCopyStatusEntry = array[l];
                        DatabaseCopy            databaseCopy2           = databaseCopies[l];
                        if (!databaseCopy2.IsValid)
                        {
                            this.UpdateMisconfiguredCopyStatusEntry(databaseCopyStatusEntry, databaseCopy2);
                        }
                        else
                        {
                            databaseCopyStatusEntry.Status              = CopyStatus.ServiceDown;
                            databaseCopyStatusEntry.m_errorMessage      = ex3.Message;
                            databaseCopyStatusEntry.m_extendedErrorInfo = new ExtendedErrorInfo(ex3);
                        }
                    }
                }
                else if (ex3 is ReplayServiceRpcUnknownInstanceException)
                {
                    ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "GetCopyStatus() was not able to find any replica instances on server {0}.", server.Fqdn);
                    for (int m = 0; m < array.Length; m++)
                    {
                        if (!databaseCopies[m].IsValid)
                        {
                            this.UpdateMisconfiguredCopyStatusEntry(array[m], databaseCopies[m]);
                        }
                        else
                        {
                            this.UpdateCopyStatusNoReplicaInstance(array[m]);
                        }
                    }
                }
                else
                {
                    this.WriteError(ex3, ErrorCategory.ReadError, null, false);
                }
            }
            return(array);
        }