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.WriteLineAndLogInfo("Obteniendo Mediciones Scada", ConsoleColor.Green);
|
||||
|
||||
var logsEnviados = new LogMedicionEnvio();
|
||||
var logsEnviado = new LogMedicionEnvio();
|
||||
|
||||
var pageNumber = 1;
|
||||
var fechaInicio = DateTime.UtcNow;
|
||||
|
@ -54,13 +54,14 @@ namespace BLL.Recuperacion_DGA
|
|||
try
|
||||
{
|
||||
var fechaEnvio = DateTime.UtcNow;
|
||||
|
||||
var body = new MedicionSubterraneaRequest
|
||||
{
|
||||
Autenticacion = new Autenticacion
|
||||
{
|
||||
Password = medicion.Password,
|
||||
Password = medicion.Password ?? "",
|
||||
RutEmpresa = medicion.Empresa_Informante == "EV" ? CredencialDGA.RutEsval : CredencialDGA.RutAv,
|
||||
RutUsuario = medicion.RUT
|
||||
RutUsuario = medicion.RUT ?? ""
|
||||
},
|
||||
MedicionSubterranea = new Medicion
|
||||
{
|
||||
|
@ -75,8 +76,17 @@ 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);
|
||||
logsEnviado = response;
|
||||
|
||||
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++;
|
||||
|
||||
}
|
||||
|
@ -85,15 +95,6 @@ namespace BLL.Recuperacion_DGA
|
|||
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();
|
||||
pageNumber++;
|
||||
|
|
|
@ -23,22 +23,19 @@ namespace DAL
|
|||
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);
|
||||
try
|
||||
{
|
||||
var query = @"UPDATE DGA_DATOS SET ENVIADO = 1 WHERE ID IN @Ids";
|
||||
|
||||
await connection.ExecuteAsync(query, new { Ids = medicionesGuardadas });
|
||||
var query = @"UPDATE DGA_DATOS SET ENVIADO = 1 WHERE ID = @Id";
|
||||
await connection.ExecuteAsync(query, new { Id = idMedicion });
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw new Exception($"Error {ex.Message}");
|
||||
throw new Exception($"Error al actualizar medición ID {idMedicion}: {ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<int> ObtenerTotalMediciones(DateTime fechaInicio)
|
||||
|
|
|
@ -25,7 +25,10 @@ namespace DAS
|
|||
var log = new LogMedicionEnvio();
|
||||
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
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue