コード例 #1
0
        public void ProcessHistoryByFrequency(
            MonitorValue monitorValue,
            DateTime dateTime,
            FrequencyTypes frequency)
        {
            DateTime dateStart;
            var      monitorDb = new MonitorDb();

            monitorDb.ConvertFrequencyToSubtractHrs(dateTime, frequency, out dateStart);
            bool isEntryPresentinDb = monitorDb.isEntryPresent(monitorValue, dateStart, frequency);

            if (!isEntryPresentinDb)
            {
                int frequencyToAvgEntries;
                switch (frequency)
                {
                case FrequencyTypes.Hours:
                    frequencyToAvgEntries = 0;
                    monitorValue.Value    = monitorDb.GetAverageValue(
                        monitorValue,
                        frequencyToAvgEntries);
                    break;

                case FrequencyTypes.Days
                    :
                    frequencyToAvgEntries = 1;
                    monitorValue.Value    = monitorDb.GetAverageValue(
                        monitorValue,
                        frequencyToAvgEntries);
                    break;

                default:
                    throw new Exception("frequency is not supported");
                }
                monitorDb.InsertHistory(monitorValue, dateStart, frequency);
            }
        }