feat(Worker): Implementa servicio de notificación para alertas de fallos críticos - Se remueve .env y se utilizan appsettings.Development.json y User Secrets
This commit is contained in:
		| @@ -10,7 +10,6 @@ namespace Mercados.Infrastructure.DataFetchers | ||||
|     { | ||||
|         public string SourceName => "MercadoAgroganadero"; | ||||
|         private const string DataUrl = "https://www.mercadoagroganadero.com.ar/dll/hacienda6.dll/haciinfo000225"; | ||||
|  | ||||
|         private readonly IHttpClientFactory _httpClientFactory; | ||||
|         private readonly ICotizacionGanadoRepository _cotizacionRepository; | ||||
|         private readonly IFuenteDatoRepository _fuenteDatoRepository; | ||||
| @@ -37,13 +36,18 @@ namespace Mercados.Infrastructure.DataFetchers | ||||
|                 var htmlContent = await GetHtmlContentAsync(); | ||||
|                 if (string.IsNullOrEmpty(htmlContent)) | ||||
|                 { | ||||
|                     // Esto sigue siendo un fallo, no se pudo obtener la página | ||||
|                     return (false, "No se pudo obtener el contenido HTML."); | ||||
|                 } | ||||
|  | ||||
|                 var cotizaciones = ParseHtmlToEntities(htmlContent); | ||||
|  | ||||
|                 if (!cotizaciones.Any()) | ||||
|                 { | ||||
|                     return (false, "No se encontraron cotizaciones válidas en el HTML."); | ||||
|                     // La conexión fue exitosa, pero no se encontraron datos válidos. | ||||
|                     // Esto NO es un error crítico, es un estado informativo. | ||||
|                     _logger.LogInformation("La conexión con {SourceName} fue exitosa, pero no se encontraron datos de cotizaciones para procesar.", SourceName); | ||||
|                     return (true, "Conexión exitosa, pero no se encontraron nuevos datos."); | ||||
|                 } | ||||
|  | ||||
|                 await _cotizacionRepository.GuardarMuchosAsync(cotizaciones); | ||||
| @@ -54,6 +58,7 @@ namespace Mercados.Infrastructure.DataFetchers | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 // Un catch aquí sí es un error real (ej. 404, timeout, etc.) | ||||
|                 _logger.LogError(ex, "Ocurrió un error durante el fetch para {SourceName}.", SourceName); | ||||
|                 return (false, $"Error: {ex.Message}"); | ||||
|             } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user