fix error fecha
This commit is contained in:
parent
30ebaed959
commit
6335ff42e0
3 changed files with 23 additions and 22 deletions
|
@ -35,7 +35,7 @@ namespace BLL.Recuperacion_DGA
|
||||||
ConsoleLoggerHelper.WriteLineAndLogEventoAsync("INICIO", "Inicio proceso de recuperación DGA", "");
|
ConsoleLoggerHelper.WriteLineAndLogEventoAsync("INICIO", "Inicio proceso de recuperación DGA", "");
|
||||||
ConsoleLoggerHelper.WriteLineAndLogInfo("Obteniendo Mediciones Scada", ConsoleColor.Green);
|
ConsoleLoggerHelper.WriteLineAndLogInfo("Obteniendo Mediciones Scada", ConsoleColor.Green);
|
||||||
|
|
||||||
var logsEnviados = new LogMedicionEnvio();
|
var logsEnviado = new LogMedicionEnvio();
|
||||||
|
|
||||||
var pageNumber = 1;
|
var pageNumber = 1;
|
||||||
var fechaInicio = DateTime.UtcNow;
|
var fechaInicio = DateTime.UtcNow;
|
||||||
|
@ -54,13 +54,14 @@ namespace BLL.Recuperacion_DGA
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fechaEnvio = DateTime.UtcNow;
|
var fechaEnvio = DateTime.UtcNow;
|
||||||
|
|
||||||
var body = new MedicionSubterraneaRequest
|
var body = new MedicionSubterraneaRequest
|
||||||
{
|
{
|
||||||
Autenticacion = new Autenticacion
|
Autenticacion = new Autenticacion
|
||||||
{
|
{
|
||||||
Password = medicion.Password,
|
Password = medicion.Password ?? "",
|
||||||
RutEmpresa = medicion.Empresa_Informante == "EV" ? CredencialDGA.RutEsval : CredencialDGA.RutAv,
|
RutEmpresa = medicion.Empresa_Informante == "EV" ? CredencialDGA.RutEsval : CredencialDGA.RutAv,
|
||||||
RutUsuario = medicion.RUT
|
RutUsuario = medicion.RUT ?? ""
|
||||||
},
|
},
|
||||||
MedicionSubterranea = new Medicion
|
MedicionSubterranea = new Medicion
|
||||||
{
|
{
|
||||||
|
@ -75,8 +76,17 @@ namespace BLL.Recuperacion_DGA
|
||||||
ConsoleLoggerHelper.WriteLineAndLogInfo($"Enviando medición DGA {cont} - {totalMediciones}", ConsoleColor.Yellow);
|
ConsoleLoggerHelper.WriteLineAndLogInfo($"Enviando medición DGA {cont} - {totalMediciones}", ConsoleColor.Yellow);
|
||||||
var response = await _registrarMedicion.EnviarMedicionAsync(medicion, body, fechaEnvio);
|
var response = await _registrarMedicion.EnviarMedicionAsync(medicion, body, fechaEnvio);
|
||||||
|
|
||||||
logsEnviados = response;
|
logsEnviado = response;
|
||||||
await _logEnvioRepository.InsertarLogRespuesta(logsEnviados);
|
|
||||||
|
await _logEnvioRepository.InsertarLogRespuesta(logsEnviado);
|
||||||
|
|
||||||
|
if (logsEnviado.ESTADO_ENVIO == "EXITO")
|
||||||
|
{
|
||||||
|
await _dGAMedicionRepository.GuardarMedicionesEnviadaAsync(medicion.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsoleLoggerHelper.WriteLineAndLogInfo($"Estado medición enviada {logsEnviado.ESTADO_ENVIO ?? ""}", ConsoleColor.Yellow);
|
||||||
|
|
||||||
cont++;
|
cont++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,15 +95,6 @@ namespace BLL.Recuperacion_DGA
|
||||||
ConsoleLoggerHelper.WriteLineAndLogInfo($"[Error]: medicion[{medicion.ID}], mensaje: {ex.Message}");
|
ConsoleLoggerHelper.WriteLineAndLogInfo($"[Error]: medicion[{medicion.ID}], mensaje: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
|
||||||
{
|
|
||||||
var idMediciones = mediciones.Select(x => x.ID).ToList();
|
|
||||||
await _dGAMedicionRepository.GuardarMedicionesEnviadasAsync(idMediciones);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
ConsoleLoggerHelper.WriteLineAndLogInfo($"[Error] {e.Message}");
|
|
||||||
}
|
|
||||||
|
|
||||||
mediciones.Clear();
|
mediciones.Clear();
|
||||||
pageNumber++;
|
pageNumber++;
|
||||||
|
|
|
@ -23,22 +23,19 @@ namespace DAL
|
||||||
return resultado.ToList();
|
return resultado.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> GuardarMedicionesEnviadasAsync(List<int> medicionesGuardadas)
|
public async Task<bool> GuardarMedicionesEnviadaAsync(int idMedicion)
|
||||||
{
|
{
|
||||||
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var query = @"UPDATE DGA_DATOS SET ENVIADO = 1 WHERE ID IN @Ids";
|
var query = @"UPDATE DGA_DATOS SET ENVIADO = 1 WHERE ID = @Id";
|
||||||
|
await connection.ExecuteAsync(query, new { Id = idMedicion });
|
||||||
await connection.ExecuteAsync(query, new { Ids = medicionesGuardadas });
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
throw new Exception($"Error al actualizar medición ID {idMedicion}: {ex.Message}");
|
||||||
throw new Exception($"Error {ex.Message}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> ObtenerTotalMediciones(DateTime fechaInicio)
|
public async Task<int> ObtenerTotalMediciones(DateTime fechaInicio)
|
||||||
|
|
|
@ -25,7 +25,10 @@ namespace DAS
|
||||||
var log = new LogMedicionEnvio();
|
var log = new LogMedicionEnvio();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var timeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd'T'HH:mm:ss-0000", CultureInfo.InvariantCulture);
|
var chileTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific SA Standard Time");
|
||||||
|
var chileTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, chileTimeZone);
|
||||||
|
var timeStamp = chileTime.ToString("yyyy-MM-dd'T'HH:mm:sszzz", CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
var json = JsonSerializer.Serialize(request, new JsonSerializerOptions
|
var json = JsonSerializer.Serialize(request, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue