Compare commits
3 commits
6335ff42e0
...
a69a85dcb7
Author | SHA1 | Date | |
---|---|---|---|
a69a85dcb7 | |||
|
ecafbdfa02 | ||
|
f62bb133c5 |
2 changed files with 24 additions and 18 deletions
|
@ -37,12 +37,11 @@ namespace BLL.Recuperacion_DGA
|
||||||
|
|
||||||
var logsEnviado = new LogMedicionEnvio();
|
var logsEnviado = new LogMedicionEnvio();
|
||||||
|
|
||||||
var pageNumber = 1;
|
|
||||||
var fechaInicio = DateTime.UtcNow;
|
var fechaInicio = DateTime.UtcNow;
|
||||||
var cont = 1;
|
var cont = 1;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var mediciones = await _dGAMedicionRepository.ObtenerMedicionesPorLoteAsync(pageNumber, fechaInicio);
|
var mediciones = await _dGAMedicionRepository.ObtenerMedicionesPorLoteAsync(1, fechaInicio);
|
||||||
var totalMediciones = await _dGAMedicionRepository.ObtenerTotalMediciones(fechaInicio);
|
var totalMediciones = await _dGAMedicionRepository.ObtenerTotalMediciones(fechaInicio);
|
||||||
if (mediciones == null || mediciones.Count == 0)
|
if (mediciones == null || mediciones.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -80,15 +79,10 @@ namespace BLL.Recuperacion_DGA
|
||||||
|
|
||||||
await _logEnvioRepository.InsertarLogRespuesta(logsEnviado);
|
await _logEnvioRepository.InsertarLogRespuesta(logsEnviado);
|
||||||
|
|
||||||
if (logsEnviado.ESTADO_ENVIO == "EXITO")
|
|
||||||
{
|
|
||||||
await _dGAMedicionRepository.GuardarMedicionesEnviadaAsync(medicion.ID);
|
await _dGAMedicionRepository.GuardarMedicionesEnviadaAsync(medicion.ID);
|
||||||
}
|
|
||||||
|
|
||||||
ConsoleLoggerHelper.WriteLineAndLogInfo($"Estado medición enviada {logsEnviado.ESTADO_ENVIO ?? ""}", ConsoleColor.Yellow);
|
ConsoleLoggerHelper.WriteLineAndLogInfo($"Estado medición enviada {logsEnviado.ESTADO_ENVIO ?? ""}", ConsoleColor.Yellow);
|
||||||
|
|
||||||
cont++;
|
cont++;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -97,11 +91,9 @@ namespace BLL.Recuperacion_DGA
|
||||||
}
|
}
|
||||||
|
|
||||||
mediciones.Clear();
|
mediciones.Clear();
|
||||||
pageNumber++;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleLoggerHelper.WriteLineAndLogEventoAsync("FIN","Fin proceso de recuperación DGA","");
|
ConsoleLoggerHelper.WriteLineAndLogEventoAsync("FIN", "Fin proceso de recuperación DGA", "");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,12 +8,26 @@ namespace Shared.Helper
|
||||||
{
|
{
|
||||||
public static void ConfigureLogger(IConfiguration configuration)
|
public static void ConfigureLogger(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var logFilePath = configuration.GetSection("Logging:LogFile:Path").Value ?? "";
|
var logFilePath = configuration.GetSection("Logging:LogFile:Path").Value ?? "logs/log-.txt";
|
||||||
var logFileFullPath = Path.Combine(Directory.GetCurrentDirectory(), logFilePath);
|
|
||||||
|
var exePath = AppContext.BaseDirectory;
|
||||||
|
var logFileFullPath = Path.Combine(exePath, logFilePath);
|
||||||
|
|
||||||
|
var logDirectory = Path.GetDirectoryName(logFileFullPath);
|
||||||
|
if (!string.IsNullOrEmpty(logDirectory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(logDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
.ReadFrom.Configuration(configuration)
|
.ReadFrom.Configuration(configuration)
|
||||||
.WriteTo.File(logFileFullPath, rollingInterval: RollingInterval.Day)
|
.WriteTo.File(
|
||||||
|
path: logFileFullPath,
|
||||||
|
rollingInterval: RollingInterval.Day,
|
||||||
|
shared: true,
|
||||||
|
retainedFileCountLimit: 30,
|
||||||
|
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||||
|
)
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue