Esempio n. 1
0
        /// <summary>
        /// Update Monitoring Last Status and Last Check Date
        /// </summary>
        /// <param name="monitor"></param>
        /// <param name="isSuccess"></param>
        private void UpdateMonitoringLastStatusAndLastCheckDate(Monitor monitor, bool isSuccess)
        {
            try {
                var result = MonitoringService.GetById(monitor.Id);

                result.LastCheckDate = DateTime.Now;
                result.LastStatus    = isSuccess ? MonitorStatus.Success : MonitorStatus.Fail;
                MonitoringService.Edit(result);
                MonitoringService.Save();
            }
            catch (Exception ex) {
                Logger.LogError($"Error occured at HangfireService.UpdateMonitoringLastStatusAndLastCheckDate(Monitor monitor, bool isSuccess), {ex}");
                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create Monitoring Jobs
        /// </summary>
        public void CreateRecurringJobsForMonitorings()
        {
            try {
                var monitorings = MonitoringService.GetAllMonitoringsWithUserInfo();

                foreach (var monitoring in monitorings)
                {
                    string jobId = $"Monitoring - {monitoring.Id}";

                    RecurringJob.AddOrUpdate(
                        jobId,
                        () => RequestUrlAndSaveDb(monitoring),
                        Cron.MinuteInterval(monitoring.Interval)
                        );
                }
            }
            catch (Exception ex) {
                Logger.LogError($"Error occured at HangfireService.CreateRecurringJobsForMonitorings(), {ex}");
                throw;
            }
        }