internal ExchangeServicesStatus(ServerRole roleBitfiedFlag, bool requiredServicesRunning, string[] servicesNotRunning, string[] servicesRunning) : base(new SimpleProviderPropertyBag())
 {
     if (servicesNotRunning == null)
     {
         throw new ArgumentNullException("servicesNotRunning");
     }
     if (servicesRunning == null)
     {
         throw new ArgumentNullException("servicesRunning");
     }
     this.Role = MpServerRoles.DisplayRoleName(roleBitfiedFlag);
     this.RequiredServicesRunning = requiredServicesRunning;
     this.ServicesNotRunning      = new MultiValuedProperty <string>(servicesNotRunning);
     this.ServicesRunning         = new MultiValuedProperty <string>(servicesRunning);
 }
Пример #2
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         Dictionary <ServerRole, List <string> > dictionary  = new Dictionary <ServerRole, List <string> >();
         Dictionary <ServerRole, List <string> > dictionary2 = new Dictionary <ServerRole, List <string> >();
         foreach (TestServiceHealth.MonitoredService monitoredService in this.monitoredServicesArray)
         {
             if ((monitoredService.Roles & this.serverRolesBitfield) != ServerRole.None)
             {
                 try
                 {
                     using (ManagementObject serviceObject = WmiWrapper.GetServiceObject(this.serverName, monitoredService.Name))
                     {
                         if (serviceObject != null)
                         {
                             string strA = serviceObject["State"] as string;
                             if (string.Compare(strA, "Running", true, CultureInfo.InvariantCulture) == 0)
                             {
                                 using (List <ServerRole> .Enumerator enumerator = this.serverRolesList.GetEnumerator())
                                 {
                                     while (enumerator.MoveNext())
                                     {
                                         ServerRole serverRole = enumerator.Current;
                                         if ((monitoredService.Roles & serverRole) != ServerRole.None)
                                         {
                                             List <string> list = null;
                                             if (!dictionary2.TryGetValue(serverRole, out list))
                                             {
                                                 list = new List <string>();
                                                 dictionary2[serverRole] = list;
                                             }
                                             list.Add(monitoredService.Name);
                                         }
                                     }
                                     goto IL_18C;
                                 }
                             }
                             string strA2 = serviceObject["StartMode"] as string;
                             if (string.Compare(strA2, "Auto", true, CultureInfo.InvariantCulture) == 0 || monitoredService.IsRequired)
                             {
                                 foreach (ServerRole serverRole2 in this.serverRolesList)
                                 {
                                     if ((serverRole2 & monitoredService.Roles) != ServerRole.None)
                                     {
                                         List <string> list2 = null;
                                         if (!dictionary.TryGetValue(serverRole2, out list2))
                                         {
                                             list2 = new List <string>();
                                             dictionary[serverRole2] = list2;
                                         }
                                         list2.Add(monitoredService.Name);
                                     }
                                 }
                             }
                             IL_18C :;
                         }
                     }
                 }
                 catch (WmiException ex)
                 {
                     ServiceHealthWmiFailureException exception = new ServiceHealthWmiFailureException(ex.Message, ex);
                     base.WriteError(exception, ErrorCategory.ReadError, null);
                 }
             }
         }
         foreach (ServerRole serverRole3 in this.serverRolesList)
         {
             List <string> list3 = null;
             List <string> list4 = null;
             string[]      servicesRunning;
             if (dictionary2.TryGetValue(serverRole3, out list3))
             {
                 servicesRunning = list3.ToArray();
             }
             else
             {
                 servicesRunning = new string[0];
             }
             ExchangeServicesStatus sendToPipeline;
             if (dictionary.TryGetValue(serverRole3, out list4))
             {
                 string[] array2 = list4.ToArray();
                 this.monitoringData.Events.Add(new MonitoringEvent("MSExchange Monitoring ServiceHealth", (int)(11000 + serverRole3), EventTypeEnumeration.Error, Strings.SomeEssentialServicesForTheRoleNotRunning(MpServerRoles.DisplayRoleName(serverRole3), string.Join("\n", array2))));
                 sendToPipeline = new ExchangeServicesStatus(serverRole3, false, array2, servicesRunning);
             }
             else
             {
                 this.monitoringData.Events.Add(new MonitoringEvent("MSExchange Monitoring ServiceHealth", (int)(12000 + serverRole3), EventTypeEnumeration.Information, Strings.AllEssentialServicesForTheRoleRunning(MpServerRoles.DisplayRoleName(serverRole3))));
                 sendToPipeline = new ExchangeServicesStatus(serverRole3, true, new string[0], servicesRunning);
             }
             base.WriteObject(sendToPipeline);
         }
         this.monitoringData.Events.Add(new MonitoringEvent("MSExchange Monitoring ServiceHealth", 10000, EventTypeEnumeration.Information, Strings.NoMonitoringErrorsInTestServiceHealthTask));
     }
     finally
     {
         if (this.MonitoringContext)
         {
             base.WriteObject(this.monitoringData);
         }
         TaskLogger.LogExit();
     }
 }