/// <summary>
        /// Cleans the egm data from datastore.
        /// </summary>
        /// <param name="arg1">The arg1.</param>
        /// <param name="arg2">The arg2.</param>
        private void CleanEgmDataFromDatastore(Timer arg1, object arg2)
        {
            var now = DateTime.UtcNow;

            EgmEventDao.CleanOlderThan(now.Subtract(TimeSpan.FromHours(EventDataExpiryHours)));
            EgmMeterReadingDao.CleanOlderThan(now.Subtract(TimeSpan.FromHours(MeterDataExpiryHours)));
            EgmMetricDao.CleanOlderThan(now.Subtract(TimeSpan.FromHours(MetricDataExpiryHours)));
            EgmWindowsEventDao.CleanOlderThan(now.Subtract(TimeSpan.FromHours(WindowsEventDataExpiryHours)));
            EgmVersionDao.CleanOlderThan(now.Subtract(TimeSpan.FromHours(VersionDataExpiryHours)));
        }
        /// <summary>
        /// Starts this instance.
        /// </summary>
        public void Start()
        {
            if (IsDisposed)
            {
                Logger.Warn("Cannot Start DataCleaner - it has been Disposed.");
                return;
            }

            if (IsStarted)
            {
                Logger.Info("Cannot Start DataCleaner - it has already been started.");
                return;
            }

            Logger.Debug("Starting DataCleaner");

            lock (_locker)
            {
                IsStarted = true;

                // this is here to initialize database (and apply any pending migrations) at startup
                EgmEventDao.GetById(long.MinValue);

                // set up the daily timers to fire at 10:00 AM and 10:15 AM (note that it will be UTC
                // since servers are all set to UTC as time zone), respectively
                var now             = DateTime.Now;
                var tenOClockAm     = DateTime.Today.AddHours(10.0);
                var tenFifteenAm    = tenOClockAm.AddMinutes(15.0);
                var tenTwentyAm     = tenFifteenAm.AddMinutes(5.0);
                var tenTwentyFiveAm = tenTwentyAm.AddMinutes(5.0);

                // if already passed trigger times for today, we wait until tomorrow for first trigger
                if (now > tenOClockAm)
                {
                    tenOClockAm = tenOClockAm.AddDays(1.0);
                }

                if (now > tenFifteenAm)
                {
                    tenFifteenAm = tenFifteenAm.AddDays(1.0);
                }

                if (now > tenTwentyAm)
                {
                    tenTwentyAm = tenTwentyAm.AddDays(1.0);
                }

                if (now > tenTwentyFiveAm)
                {
                    tenTwentyFiveAm = tenTwentyFiveAm.AddDays(1.0);
                }

                var secondsUntilTen           = (tenOClockAm - now).TotalSeconds;
                var secondsUntilTenFifteen    = (tenFifteenAm - now).TotalSeconds;
                var secondsUntilTenTwenty     = (tenTwentyAm - now).TotalSeconds;
                var secondsUntilTenTwentyFive = (tenTwentyFiveAm - now).TotalSeconds;

                EgmDataCleanTimer             = new CHGTimer();
                EgmDataCleanTimer.TimerEvent += CleanEgmDataFromDatastore;
                EgmDataCleanTimer.Start(TimeSpan.FromSeconds(secondsUntilTen),
                                        TimeSpan.FromHours(EgmDataCleanIntervalHours));

                DataBackupCleanTimer             = new CHGTimer();
                DataBackupCleanTimer.TimerEvent += CleanBackupData;
                DataBackupCleanTimer.Start(TimeSpan.FromSeconds(secondsUntilTenFifteen),
                                           TimeSpan.FromHours(DataBackupCleanIntervalHours));

                DiagnosticDataCleanTimer             = new CHGTimer();
                DiagnosticDataCleanTimer.TimerEvent += CleanDiagnosticData;
                DiagnosticDataCleanTimer.Start(TimeSpan.FromSeconds(secondsUntilTenTwenty),
                                               TimeSpan.FromHours(DiagnosticDataCleanIntervalHours));

                LocalExportDataCleanTimer             = new CHGTimer();
                LocalExportDataCleanTimer.TimerEvent += CleanLocalExportData;
                LocalExportDataCleanTimer.Start(TimeSpan.FromSeconds(secondsUntilTenTwentyFive),
                                                TimeSpan.FromHours(LocalExportDataCleanIntervalHours));
            }
        }