protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     if (base.HasErrors)
     {
         TaskLogger.LogExit();
         return;
     }
     ReplicationCheckGlobals.WriteVerboseDelegate = new Task.TaskVerboseLoggingDelegate(base.WriteVerbose);
     try
     {
         base.WriteVerbose(Strings.StartingToRunChecks(this.m_serverName));
         this.RunChecks();
         if (this.MonitoringContext && !this.m_eventManager.HasMomEvents())
         {
             base.WriteVerbose(Strings.NoMonitoringErrorsInTestReplicationHealth(this.m_serverName));
             this.m_eventManager.LogEvent(10000, Strings.NoMonitoringErrorsInTestReplicationHealth(this.m_serverName));
         }
     }
     finally
     {
         if (this.MonitoringContext)
         {
             this.WriteMonitoringData();
         }
         ReplicationCheckGlobals.ResetState();
         TaskLogger.LogExit();
     }
 }
 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 InternalStateReset()
 {
     base.InternalStateReset();
     this.ResetPrivateState();
     ReplicationCheckGlobals.ResetState();
 }