Fix: TimeZone Fetcher.
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Mercados.Infrastructure.DataFetchers
|
||||
private readonly ICotizacionGanadoRepository _cotizacionRepository;
|
||||
private readonly IFuenteDatoRepository _fuenteDatoRepository;
|
||||
private readonly ILogger<MercadoAgroFetcher> _logger;
|
||||
private readonly TimeZoneInfo _argentinaTimeZone;
|
||||
|
||||
public MercadoAgroFetcher(
|
||||
IHttpClientFactory httpClientFactory,
|
||||
@@ -25,6 +26,14 @@ namespace Mercados.Infrastructure.DataFetchers
|
||||
_cotizacionRepository = cotizacionRepository;
|
||||
_fuenteDatoRepository = fuenteDatoRepository;
|
||||
_logger = logger;
|
||||
try
|
||||
{
|
||||
_argentinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("America/Argentina/Buenos_Aires");
|
||||
}
|
||||
catch (TimeZoneNotFoundException)
|
||||
{
|
||||
_argentinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Argentina Standard Time");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<(bool Success, string Message)> FetchDataAsync()
|
||||
@@ -41,7 +50,8 @@ namespace Mercados.Infrastructure.DataFetchers
|
||||
return (true, "Conexión exitosa, pero no se encontraron nuevos datos de ganado.");
|
||||
}
|
||||
|
||||
var hoy = DateOnly.FromDateTime(DateTime.UtcNow);
|
||||
var ahoraEnArgentina = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, _argentinaTimeZone);
|
||||
var hoy = DateOnly.FromDateTime(ahoraEnArgentina);
|
||||
var cotizacionesViejas = await _cotizacionRepository.ObtenerTandaPorFechaAsync(hoy);
|
||||
|
||||
// Si el número de registros es diferente, sabemos que hay cambios.
|
||||
|
||||
Reference in New Issue
Block a user