54 lines
No EOL
2 KiB
C#
54 lines
No EOL
2 KiB
C#
using BLL.Integracion_DGA;
|
|
using BLL.Recuperacion_DGA;
|
|
using DAL;
|
|
using DAS;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Shared.Helper;
|
|
using Shared.Utils;
|
|
|
|
namespace Recuperacion_DGA
|
|
{
|
|
class Program
|
|
{
|
|
static async Task Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
Console.WriteLine("Obteniendo variables de entorno...");
|
|
ObtenerVariablesEntorno.AmbientarApiUrlNexus("NEXUS_API_URL");
|
|
ObtenerVariablesEntorno.AmbientarUrlApiSubterranea("SUBTERRANEAS_API_URL");
|
|
ObtenerVariablesEntorno.AmbientarConexionBd("CONEXION_BD_ENVIO_DGA");
|
|
ObtenerVariablesEntorno.AmbientarCredencialesDGA("DGA_CREDENCIALES");
|
|
ObtenerVariablesEntorno.ValidarVariablesEntorno();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
Console.WriteLine($"[Error] {ex.Message}");
|
|
Console.ResetColor();
|
|
FileLoggerHelper.LogInformation($"{ex.Message}");
|
|
return;
|
|
}
|
|
|
|
using IHost host = Host.CreateDefaultBuilder(args)
|
|
.ConfigureServices((context, services) =>
|
|
{
|
|
IConfiguration configuration = context.Configuration;
|
|
services.AddSingleton<IConfiguration>(configuration);
|
|
|
|
services.AddScoped<MedicionScadaRepository>();
|
|
services.AddScoped<MedicionScadaVilosRepository>();
|
|
services.AddScoped<EnvioDGA>();
|
|
services.AddHttpClient<RegistrarMedicion>();
|
|
services.AddScoped<LogMedicionScadaRepository>();
|
|
})
|
|
.Build();
|
|
|
|
|
|
var envioDGA = host.Services.GetRequiredService<EnvioDGA>();
|
|
await envioDGA.RegistrarMedicionesAsync();
|
|
}
|
|
}
|
|
} |