SiteWeatherJob.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Threading.Tasks;
  3. using Microsoft.Extensions.DependencyInjection;
  4. using Microsoft.AspNetCore.Hosting;
  5. using Microsoft.Extensions.Hosting;
  6. using Microsoft.Extensions.Logging;
  7. using FMSApp.Repositories;
  8. using Quartz;
  9. using FMSAdmin.Services;
  10. using FMSAdmin.Data;
  11. using System.Linq;
  12. namespace FMSAdmin.QuartzSchedule.Jobs {
  13. public class SiteWeatherJob : IJob {
  14. private readonly ILogger<SiteWeatherJob> _logger;
  15. private readonly SiteWeatherInfoService _siteWeatherInfoService;
  16. private readonly SiteService _siteService;
  17. private readonly FMSContext _context;
  18. public SiteWeatherJob(ILogger<SiteWeatherJob> logger, SiteWeatherInfoService siteWeatherInfoService, SiteService siteService, FMSContext context) {
  19. _logger = logger;
  20. _siteWeatherInfoService = siteWeatherInfoService;
  21. _siteService = siteService;
  22. _context = context;
  23. }
  24. public Task Execute(IJobExecutionContext context) {
  25. _logger.LogInformation("SiteWeatherJob Execute");
  26. foreach (var site in _siteService.GetAll().ToList()) {
  27. if (!string.IsNullOrEmpty(site.ApiSido) && !string.IsNullOrEmpty(site.ApiSigun)) {
  28. var weatherInfo = _siteWeatherInfoService.GetInfo(site.SiteId, site.ApiSido, site.ApiSigun, true, false);
  29. }
  30. }
  31. return Task.CompletedTask;
  32. }
  33. }
  34. }