コード例 #1
0
 internal void RefreshCounters(bool updateDatabases, bool updateStatistics)
 {
     if (updateDatabases)
     {
         IEnumerable <MailboxDatabase> enumerable;
         if (MailboxDatabase.TryDiscoverLocalMailboxDatabases(out enumerable))
         {
             this.currentDatabases = enumerable;
         }
         else
         {
             this.lastMailboxDatabaseNameRefresh = DateTime.MinValue;
             Log.LogErrorMessage("Unable to discover any mailbox databases in AD for the '{0}' server.", new object[]
             {
                 Environment.MachineName
             });
         }
     }
     if (updateStatistics && this.currentDatabases != null)
     {
         Dictionary <MailboxDatabase, List <MailboxDatabaseCalculatedCounters.DiagnosticMeasurementValue> > dictionary;
         if (MailboxDatabaseCalculatedCounters.TryCreateCounters(this.currentDatabases, out dictionary))
         {
             this.currentCounters = dictionary;
         }
         else
         {
             this.lastStatisticsRefresh = DateTime.MinValue;
             Log.LogErrorMessage("Unable to create counters.", new object[0]);
         }
     }
     this.doingWork = false;
 }
コード例 #2
0
        static MailboxDatabaseCalculatedCounters()
        {
            Dictionary <string, Func <float[], float> > dictionary = new Dictionary <string, Func <float[], float> >(StringComparer.OrdinalIgnoreCase);

            dictionary.Add("Consumed Megabytes", (float[] propertyValues) => MailboxDatabaseCalculatedCounters.ConvertBytesToMegabytes(propertyValues[0]));
            dictionary.Add("Available New Mailbox Space In Megabytes", (float[] propertyValues) => MailboxDatabaseCalculatedCounters.ConvertBytesToMegabytes(propertyValues[0]));
            dictionary.Add("Logical Consumed Megabytes", (float[] propertyValues) => MailboxDatabaseCalculatedCounters.ConvertBytesToMegabytes(propertyValues[0]));
            dictionary.Add("Disconnected Logical Consumed Megabytes", (float[] propertyValues) => MailboxDatabaseCalculatedCounters.ConvertBytesToMegabytes(propertyValues[0] + propertyValues[1]));
            dictionary.Add("Mailbox Count", (float[] propertyValues) => propertyValues[0]);
            dictionary.Add("Disconnected Mailbox Count", (float[] propertyValues) => propertyValues[0]);
            dictionary.Add("Log Consumed Megabytes", (float[] propertyValues) => MailboxDatabaseCalculatedCounters.ConvertBytesToMegabytes(propertyValues[0]));
            dictionary.Add("Catalog Consumed Megabytes", (float[] propertyValues) => MailboxDatabaseCalculatedCounters.ConvertBytesToMegabytes(propertyValues[0]));
            dictionary.Add("Logical To Physical Size Ratio", (float[] propertyValues) => propertyValues[0]);
            MailboxDatabaseCalculatedCounters.CounterLogic = dictionary;
        }
コード例 #3
0
        internal static bool TryCreateCounters(IEnumerable <MailboxDatabase> databases, out Dictionary <MailboxDatabase, List <MailboxDatabaseCalculatedCounters.DiagnosticMeasurementValue> > counters)
        {
            if (databases == null)
            {
                throw new ArgumentNullException("databases");
            }
            counters = null;
            Dictionary <MailboxDatabase, List <MailboxDatabaseCalculatedCounters.DiagnosticMeasurementValue> > dictionary = MailboxDatabaseCalculatedCounters.CreateCounters(databases);
            List <MailboxDatabase> list = new List <MailboxDatabase>(dictionary.Count);

            foreach (KeyValuePair <MailboxDatabase, List <MailboxDatabaseCalculatedCounters.DiagnosticMeasurementValue> > keyValuePair in dictionary)
            {
                Dictionary <string, float> dictionary2;
                if (!keyValuePair.Key.TryLoadStatistics(out dictionary2))
                {
                    list.Add(keyValuePair.Key);
                }
                else
                {
                    foreach (MailboxDatabaseCalculatedCounters.DiagnosticMeasurementValue diagnosticMeasurementValue in keyValuePair.Value)
                    {
                        string[] array;
                        Func <float[], float> func;
                        if (MailboxDatabaseCalculatedCounters.CounterProperties.TryGetValue(diagnosticMeasurementValue.Measure.CounterName, out array) && MailboxDatabaseCalculatedCounters.CounterLogic.TryGetValue(diagnosticMeasurementValue.Measure.CounterName, out func))
                        {
                            bool    flag   = true;
                            float[] array2 = new float[array.Length];
                            for (int i = 0; i < array.Length; i++)
                            {
                                if (!dictionary2.TryGetValue(array[i], out array2[i]))
                                {
                                    flag = false;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                list.Add(keyValuePair.Key);
                                break;
                            }
                            if (diagnosticMeasurementValue.Value == null)
                            {
                                diagnosticMeasurementValue.Value = new float?(0f);
                            }
                            MailboxDatabaseCalculatedCounters.DiagnosticMeasurementValue diagnosticMeasurementValue2 = diagnosticMeasurementValue;
                            float?value = diagnosticMeasurementValue2.Value;
                            float num   = func(array2);
                            diagnosticMeasurementValue2.Value = ((value != null) ? new float?(value.GetValueOrDefault() + num) : null);
                        }
                    }
                }
            }
            foreach (MailboxDatabase key in list)
            {
                dictionary.Remove(key);
            }
            bool flag2 = dictionary.Any <KeyValuePair <MailboxDatabase, List <MailboxDatabaseCalculatedCounters.DiagnosticMeasurementValue> > >();

            if (flag2)
            {
                counters = dictionary;
            }
            return(flag2);
        }