示例#1
0
        /// <summary>
        /// Starts this instance.
        /// </summary>
        /// <exception cref="System.NotImplementedException"></exception>
        public void Start()
        {
            if (IsDisposed)
            {
                Logger.Warn("Cannot Start DataReporter - it has been Disposed.");
                return;
            }

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

            Logger.Debug($"Starting DataReporter - DataExporter is a {DataExporter.GetType()}");

            lock (_locker)
            {
                IsStarted = true;

                // Set up timers for triggering push of data to HMS Cloud service.
                CasinoDataReportTimer             = new CHGTimer();
                CasinoDataReportTimer.TimerEvent += GetEgmDataForReport;
                CasinoDataReportTimer.Start(TimeSpan.FromMinutes(Settings.Default.CloudReportStartupDelay),
                                            TimeSpan.FromMinutes(Settings.Default.CloudReportInterval));

                // Note that if DoReportToCloud configuration parameter is set to False,
                // we set the DataBackup timers such that they never trigger
                DataBackupTimer             = new CHGTimer();
                DataBackupTimer.TimerEvent += GetWeeklyDataBackupFiles;
                DataBackupTimer.Start(Settings.Default.DoReportToCloud
                        ? TimeSpan.FromMinutes(Settings.Default.DataBackupStartupDelay)
                        : CHGTimer.DisableTimer,
                                      Settings.Default.DoReportToCloud
                        ? TimeSpan.FromMinutes(Settings.Default.DataBackupInterval)
                        : CHGTimer.DisableTimer);

                // Note that if DoReportToCloud configuration parameter is set to False,
                // we set the DiagnosticFile timers such that they never trigger
                DiagnosticsTimer             = new CHGTimer();
                DiagnosticsTimer.TimerEvent += GetDiagnosticsFiles;
                DiagnosticsTimer.Start(Settings.Default.DoReportToCloud
                        ? TimeSpan.FromMinutes(Settings.Default.DiagnosticsStartupDelay)
                        : CHGTimer.DisableTimer,
                                       Settings.Default.DoReportToCloud
                        ? TimeSpan.FromMinutes(Settings.Default.DiagnosticsInterval)
                        : CHGTimer.DisableTimer);
            }
        }
示例#2
0
        /// <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));
            }
        }