Пример #1
0
        public static async Task UpdateWorker(long siteId, IConfigurationService configurationService)
        {
            var site = await configurationService.GetSite(siteId);

            var param = new BackgroundJobInfo(siteId, site.FetchIntervalInMinutes, site.Endpoints);

            RecurringJob.AddOrUpdate(GetStringId(siteId), () => MakeReports(param), Cron.MinuteInterval(site.FetchIntervalInMinutes));
        }
Пример #2
0
        public static void MakeReports(BackgroundJobInfo jobInfo)
        {
            var resolver = DependencyResolverConfig.GetResolver(true);
            var service  = (IReportingService)resolver.GetService(typeof(IReportingService));

            var fetcher = new EndpointFetcher();

            foreach (var endpoint in jobInfo.Endpoints)
            {
                Task.Run(() =>
                {
                    var report = fetcher.MakeHealthReport(endpoint.Url, endpoint.Id);
                    report.IntervalInMinutes = jobInfo.FetchIntervalInMinutes;
                    service.AddReportSyncroniously(report);
                });
            }
        }