Compare commits
No commits in common. "30ebaed959855794fadd4388b8880e4accb3a7e8" and "e83a41cd54269bb74b1ad81a27a192a596261179" have entirely different histories.
30ebaed959
...
e83a41cd54
4 changed files with 11 additions and 34 deletions
|
@ -35,15 +35,15 @@ namespace BLL.Recuperacion_DGA
|
|||
ConsoleLoggerHelper.WriteLineAndLogEventoAsync("INICIO", "Inicio proceso de recuperación DGA", "");
|
||||
ConsoleLoggerHelper.WriteLineAndLogInfo("Obteniendo Mediciones Scada", ConsoleColor.Green);
|
||||
|
||||
var logsEnviados = new LogMedicionEnvio();
|
||||
var logsEnviados = new List<LogMedicionEnvio>();
|
||||
|
||||
var pageNumber = 1;
|
||||
var fechaInicio = DateTime.UtcNow;
|
||||
var cont = 1;
|
||||
|
||||
while (true)
|
||||
{
|
||||
var mediciones = await _dGAMedicionRepository.ObtenerMedicionesPorLoteAsync(pageNumber, fechaInicio);
|
||||
var totalMediciones = await _dGAMedicionRepository.ObtenerTotalMediciones(fechaInicio);
|
||||
|
||||
if (mediciones == null || mediciones.Count == 0)
|
||||
{
|
||||
break;
|
||||
|
@ -54,6 +54,7 @@ namespace BLL.Recuperacion_DGA
|
|||
try
|
||||
{
|
||||
var fechaEnvio = DateTime.UtcNow;
|
||||
|
||||
var body = new MedicionSubterraneaRequest
|
||||
{
|
||||
Autenticacion = new Autenticacion
|
||||
|
@ -72,12 +73,9 @@ namespace BLL.Recuperacion_DGA
|
|||
}
|
||||
};
|
||||
|
||||
ConsoleLoggerHelper.WriteLineAndLogInfo($"Enviando medición DGA {cont} - {totalMediciones}", ConsoleColor.Yellow);
|
||||
var response = await _registrarMedicion.EnviarMedicionAsync(medicion, body, fechaEnvio);
|
||||
|
||||
logsEnviados = response;
|
||||
await _logEnvioRepository.InsertarLogRespuesta(logsEnviados);
|
||||
cont++;
|
||||
logsEnviados.Add(response);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -89,15 +87,16 @@ namespace BLL.Recuperacion_DGA
|
|||
{
|
||||
var idMediciones = mediciones.Select(x => x.ID).ToList();
|
||||
await _dGAMedicionRepository.GuardarMedicionesEnviadasAsync(idMediciones);
|
||||
await _logEnvioRepository.InsertarLogRespuesta(logsEnviados);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ConsoleLoggerHelper.WriteLineAndLogInfo($"[Error] {e.Message}");
|
||||
}
|
||||
|
||||
logsEnviados.Clear();
|
||||
mediciones.Clear();
|
||||
pageNumber++;
|
||||
|
||||
}
|
||||
|
||||
ConsoleLoggerHelper.WriteLineAndLogEventoAsync("FIN","Fin proceso de recuperación DGA","");
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace DAL
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarLogRespuesta(LogMedicionEnvio logsEnviados)
|
||||
public async Task<bool> InsertarLogRespuesta(List<LogMedicionEnvio> logsEnviados)
|
||||
{
|
||||
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
||||
try
|
||||
|
|
|
@ -40,25 +40,5 @@ namespace DAL
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<int> ObtenerTotalMediciones(DateTime fechaInicio)
|
||||
{
|
||||
try
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("@FechaInicio", fechaInicio);
|
||||
using var connection = new SqlConnection(BdConexion.StringConnection);
|
||||
var resultado = await connection.QuerySingleAsync<int>(
|
||||
"SP_OBTENER_TOTAL_MEDICIONES",
|
||||
parameters,
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return resultado;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw new Exception($"ERROR {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,12 +57,10 @@ namespace DAS
|
|||
log.COMPROBANTE = null;
|
||||
log.ESTADO_ENVIO = "ERROR";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
log.COMPROBANTE = apiResponse!.Data!.NumeroComprobante ?? null;
|
||||
log.ESTADO_ENVIO = "EXITO";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
log.COMPROBANTE = null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue