12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- using System.Threading.Tasks;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Hosting;
- using Microsoft.Extensions.Logging;
- using FMSApp.Repositories;
- using Quartz;
- using FMSAdmin.Services;
- using FMSAdmin.Data;
- using System.Linq;
- namespace FMSAdmin.QuartzSchedule.Jobs {
- public class SiteWeatherJob : IJob {
- private readonly ILogger<SiteWeatherJob> _logger;
- private readonly SiteWeatherInfoService _siteWeatherInfoService;
- private readonly SiteService _siteService;
- private readonly FMSContext _context;
- public SiteWeatherJob(ILogger<SiteWeatherJob> logger, SiteWeatherInfoService siteWeatherInfoService, SiteService siteService, FMSContext context) {
- _logger = logger;
- _siteWeatherInfoService = siteWeatherInfoService;
- _siteService = siteService;
- _context = context;
- }
- public Task Execute(IJobExecutionContext context) {
- _logger.LogInformation("SiteWeatherJob Execute");
- foreach (var site in _siteService.GetAll().ToList()) {
- if (!string.IsNullOrEmpty(site.ApiSido) && !string.IsNullOrEmpty(site.ApiSigun)) {
- var weatherInfo = _siteWeatherInfoService.GetInfo(site.SiteId, site.ApiSido, site.ApiSigun, true, false);
- }
- }
- return Task.CompletedTask;
- }
- }
- }
|