This commit is contained in:
bcastrogallardo 2025-07-17 09:22:55 -04:00
parent 657fd50ac9
commit b52be74bfa
9 changed files with 129 additions and 42 deletions

View file

@ -1,6 +1,7 @@
using System.Text.Json;
using DAL;
using DAS;
using Shared.DTO;
using Shared.DTO.Envios_DGA;
using Shared.DTO.VariablesEntorno;
using Shared.Helper;
@ -11,17 +12,25 @@ namespace BLL.Recuperacion_DGA
{
private readonly MedicionDGARepository _dGAMedicionRepository;
private readonly RegistrarMedicion _registrarMedicion;
private readonly LogEnvioRepository _logEnvioRepository;
public EnvioDGA(MedicionDGARepository dGAMedicionRepository, RegistrarMedicion registrarMedicion)
public EnvioDGA(MedicionDGARepository dGAMedicionRepository, RegistrarMedicion registrarMedicion, LogEnvioRepository logEnvioRepository)
{
_dGAMedicionRepository = dGAMedicionRepository;
_registrarMedicion = registrarMedicion;
_logEnvioRepository = logEnvioRepository;
}
public async Task<bool> RegistrarMedicionesAsync()
{
try
{
await _logEnvioRepository.InsertarLogProcesoAsync(new LogProceso
{
FechaEjecucion = DateTime.UtcNow,
NombreProceso = "ENVIO DATOS DGA"
});
ConsoleLoggerHelper.WriteLineAndLogEventoAsync("INICIO", "Inicio proceso de recuperación DGA", "");
ConsoleLoggerHelper.WriteLineAndLogInfo("Obteniendo Mediciones Scada", ConsoleColor.Green);
@ -51,9 +60,10 @@ namespace BLL.Recuperacion_DGA
Totalizador = medicion.TOTALIZADOR_CAUDAL ?? "",
}
};
await _registrarMedicion.EnviarMedicionAsync(medicion, body, fechaEnvio);
listaMediciones.Add(new {Id = medicion.ID,FechaEnvio = fechaEnvio.ToString("yyyy-MM-dd HH:mm:ss"), Enviado = medicion.ENVIADO + 1});
var response = await _registrarMedicion.EnviarMedicionAsync(medicion, body, fechaEnvio);
listaMediciones.Add(new {Id = medicion.ID,FechaEnvio = fechaEnvio.ToString("yyyy-MM-dd HH:mm:ss"), Enviado = 1});
}
catch (Exception ex)
{
@ -76,6 +86,7 @@ namespace BLL.Recuperacion_DGA
ConsoleLoggerHelper.WriteLineAndLogInfo($"Error al procesar las mediciones.", ConsoleColor.Red);
return false;
}
return true;
}
}