protected override void InternalValidate() { TaskLogger.LogEnter(); try { this.ConfigurationSession.ServerTimeout = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout)); ((IDirectorySession)base.DataSession).ServerTimeout = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout)); if (this.Identity == null) { this.m_serverName = Environment.MachineName; this.Identity = ServerIdParameter.Parse(this.m_serverName); } base.InternalValidate(); if (base.HasErrors) { TaskLogger.LogExit(); } else { ADServerWrapper server = ADObjectWrapperFactory.CreateWrapper(this.DataObject); ReplicationCheckGlobals.Server = server; this.m_serverName = this.DataObject.Name; ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "serverName is '{0}'.", this.m_serverName ?? "null"); this.m_isLocal = SharedHelper.StringIEquals(this.m_serverName, Environment.MachineName); if (!this.m_isLocal && this.MonitoringContext) { this.WriteErrorAndMonitoringEvent(new CannotRunMonitoringTaskRemotelyException(this.m_serverName), ErrorCategory.InvalidOperation, this.Identity, 10011, "MSExchange Monitoring ReplicationHealth"); } ReplicationCheckGlobals.RunningInMonitoringContext = this.MonitoringContext; if (this.m_isLocal && !this.CheckLocalServerRegistryRoles()) { ExTraceGlobals.CmdletsTracer.TraceDebug((long)this.GetHashCode(), "Local server does not have Exchange 2009 Mailbox Role in the registry."); } else { this.CheckServerObject(); if (this.DataObject.DatabaseAvailabilityGroup != null) { this.m_serverConfigBitfield |= ServerConfig.DagMember; this.m_dag = this.ConfigurationSession.Read <DatabaseAvailabilityGroup>(this.DataObject.DatabaseAvailabilityGroup); if (this.m_dag.StoppedMailboxServers.Contains(new AmServerName(this.m_serverName).Fqdn)) { this.m_serverConfigBitfield |= ServerConfig.Stopped; } } else { ExTraceGlobals.CmdletsTracer.TraceDebug <string>((long)this.GetHashCode(), "{0} is a Standalone non-DAG Mailbox server.", this.DataObject.Name); } try { this.BuildReplayConfigurations(this.m_dag, server); } catch (ClusterException exception) { this.WriteErrorAndMonitoringEvent(exception, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth"); return; } catch (TransientException exception2) { this.WriteErrorAndMonitoringEvent(exception2, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth"); return; } catch (DataSourceOperationException exception3) { this.WriteErrorAndMonitoringEvent(exception3, ErrorCategory.InvalidOperation, null, 10003, "MSExchange Monitoring ReplicationHealth"); return; } catch (DataValidationException exception4) { this.WriteErrorAndMonitoringEvent(exception4, ErrorCategory.InvalidData, null, 10003, "MSExchange Monitoring ReplicationHealth"); return; } ReplicationCheckGlobals.ServerConfiguration = this.m_serverConfigBitfield; if (this.DataObject != null) { this.m_useReplayRpc = ReplayRpcVersionControl.IsGetCopyStatusEx2RpcSupported(this.DataObject.AdminDisplayVersion); } this.CheckIfTaskCanRun(); } } } finally { if (base.HasErrors) { if (this.MonitoringContext) { this.WriteMonitoringData(); } ReplicationCheckGlobals.ResetState(); } TaskLogger.LogExit(); } }
protected override void WriteResult <T>(IEnumerable <T> dataObjects) { TaskLogger.LogEnter(new object[] { dataObjects }); Dictionary <string, Collection <DatabaseCopy> > dictionary = new Dictionary <string, Collection <DatabaseCopy> >(); foreach (T t in dataObjects) { IConfigurable configurable = t; DatabaseCopy databaseCopy = configurable as DatabaseCopy; string key; if (this.m_server != null) { key = this.m_server.Name; } else { key = databaseCopy.HostServerName; } Collection <DatabaseCopy> collection; if (!dictionary.TryGetValue(key, out collection)) { collection = new Collection <DatabaseCopy>(); dictionary.Add(key, collection); } collection.Add(databaseCopy); } using (Dictionary <string, Collection <DatabaseCopy> > .KeyCollection.Enumerator enumerator2 = dictionary.Keys.GetEnumerator()) { while (enumerator2.MoveNext()) { string dbCopyServerName = enumerator2.Current; Collection <DatabaseCopy> collection2 = dictionary[dbCopyServerName]; Server server2; if (this.m_server != null) { server2 = this.m_server; } else { MailboxServerIdParameter mailboxServerIdParameter = MailboxServerIdParameter.Parse(dbCopyServerName); IEnumerable <Server> objects = mailboxServerIdParameter.GetObjects <Server>(this.RootId, this.ConfigurationSession); server2 = objects.FirstOrDefault((Server server) => server.Name.Equals(dbCopyServerName, StringComparison.OrdinalIgnoreCase)); } if (server2 != null) { if (ReplayRpcVersionControl.IsGetCopyStatusEx2RpcSupported(server2.AdminDisplayVersion)) { DatabaseCopyStatusEntry[] array = this.PrepareStatusEntryFromRpc(server2, collection2); for (int i = 0; i < array.Length; i++) { this.WriteCopyStatusResultIfAppropriate(array[i]); } } else { this.WriteError(new InvalidOperationException(Strings.GetDbcsRpcNotSupported(server2.Name, server2.AdminDisplayVersion.ToString(), ReplayRpcVersionControl.GetCopyStatusEx2SupportVersion.ToString())), ErrorCategory.InvalidOperation, server2.Identity, false); } } else { foreach (DatabaseCopy databaseCopy2 in collection2) { DatabaseCopyStatusEntry databaseCopyStatusEntry = this.ConstructNewSatusEntry(databaseCopy2); this.UpdateMisconfiguredCopyStatusEntry(databaseCopyStatusEntry, databaseCopy2); this.WriteCopyStatusResultIfAppropriate(databaseCopyStatusEntry); } } } } TaskLogger.LogExit(); }