Integracion_DGA/Integracion_DGA/Program.cs
2025-07-01 09:59:59 -04:00

49 lines
2 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
using DAL;
using DAS;
using BLL.Recuperacion_DGA;
using BLL.Integracion_DGA;
using Shared.Utils;
namespace Integracion_DGA
{
class Program
{
static async Task Main(string[] args)
{
ObtenerVariablesEntorno.AmbientarApiUrlNexus("NEXUS_API_URL");
ObtenerVariablesEntorno.AmbientarUrlApiSubterranea("SUBTERRANEAS_API_URL");
ObtenerVariablesEntorno.AmbientarConexionBd("CONEXION_BD_ENVIO_DGA");
ObtenerVariablesEntorno.AmbientarCredencialesDGA("DGA_CREDENCIALES");
using IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
IConfiguration configuration = context.Configuration;
services.AddSingleton<IConfiguration>(configuration);
services.AddScoped<MedicionScadaRepository>();
services.AddScoped<EnvioDGA>();
services.AddHttpClient<RegistrarMedicion>();
//Estos dos servicios son los que migre del otro proyecto
services.AddScoped<JobsDgaRepository>();
services.AddScoped<JobsDgaVilosRepository>();
services.AddScoped<JobsDgaSupFlujRepository>();
services.AddScoped<LogMedicionScadaRepository>();
services.AddScoped<ApiService>();
services.AddScoped<BusinessLogic>();
})
.Build();
//TODO: Controlar si las variables de ambiente existen
var envioDGA = host.Services.GetRequiredService<EnvioDGA>();
var bussinessLogic = host.Services.GetRequiredService<BusinessLogic>();
var apiService = host.Services.GetRequiredService<ApiService>();
await bussinessLogic.Run();
}
}
}