diff --git a/BLL/EnvioDGA.cs b/BLL/EnvioDGA.cs index 8f8ec69..608df5d 100644 --- a/BLL/EnvioDGA.cs +++ b/BLL/EnvioDGA.cs @@ -7,13 +7,24 @@ namespace BLL { public class EnvioDGA { + private readonly IConfiguration _configuration; private readonly MedicionScadaRepository _dGAMedicionScadaRepository; private readonly RegistrarMedicion _registrarMedicion; + private static string? password; + private static string? rutEmpresa; + private static string? rutUsuario; - public EnvioDGA(MedicionScadaRepository dGAMedicionScadaRepository, RegistrarMedicion registrarMedicion) + public EnvioDGA(IConfiguration configuration, MedicionScadaRepository dGAMedicionScadaRepository, RegistrarMedicion registrarMedicion) { + _configuration = configuration ?? new ConfigurationBuilder() + .SetBasePath(AppContext.BaseDirectory) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .Build(); _dGAMedicionScadaRepository = dGAMedicionScadaRepository; _registrarMedicion = registrarMedicion; + rutUsuario = _configuration["Credenciales:rutEmpresa"] ?? ""; + rutEmpresa = _configuration["Credenciales:rutUsuario"] ?? "" ?? ""; + password = _configuration["Credenciales:password"] ?? ""; } public async Task> ObtenerMedicionesAsync() @@ -28,9 +39,9 @@ namespace BLL { Autenticacion = new Autenticacion { - Password = string.Empty, - RutEmpresa = string.Empty, - RutUsuario = string.Empty + Password = password, + RutEmpresa = rutEmpresa, + RutUsuario = rutUsuario }, MedicionSubterranea = new Medicion { diff --git a/DAS/RegistrarMedicion.cs b/DAS/RegistrarMedicion.cs index 5ed4372..b669259 100644 --- a/DAS/RegistrarMedicion.cs +++ b/DAS/RegistrarMedicion.cs @@ -9,26 +9,15 @@ namespace DAS { private readonly HttpClient _httpClient; private readonly IConfiguration _configuration; - private static string? password; - private static string? rutEmpresa; - private static string? rutUsuario; public RegistrarMedicion(HttpClient httpClient, IConfiguration configuration) { _httpClient = httpClient; _configuration = configuration; - rutUsuario = _configuration["Credenciales:rutEmpresa"] ?? ""; - rutEmpresa = _configuration["Credenciales:rutUsuario"] ?? "" ?? ""; - password = _configuration["Credenciales:password"] ?? ""; } public async Task EnviarMedicionAsync(string codigoObra, MedicionSubterraneaRequest request) { - - request.Autenticacion.Password = password; - request.Autenticacion.RutEmpresa = rutEmpresa; - request.Autenticacion.RutUsuario = rutUsuario; - var baseUrl = _configuration["ApiSubterranea:BaseUrl"]; var endpoint = _configuration["ApiSubterranea:Endpoint"]; var url = $"{baseUrl}{endpoint}"; diff --git a/Integracion_DGA.sln b/Integracion_DGA.sln index 4eeba9a..5d3ffbc 100644 --- a/Integracion_DGA.sln +++ b/Integracion_DGA.sln @@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAS", "DAS\DAS.csproj", "{E EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "SHARED\Shared.csproj", "{6F270A26-F9CB-4F15-A2F7-EA72DB31F2CA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Recuperacion_DGA", "Recuperacion_DGA\Recuperacion_DGA.csproj", "{768016E4-ED7F-4F3D-A174-84C8AB26D9F4}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,10 +39,6 @@ Global {6F270A26-F9CB-4F15-A2F7-EA72DB31F2CA}.Debug|Any CPU.Build.0 = Debug|Any CPU {6F270A26-F9CB-4F15-A2F7-EA72DB31F2CA}.Release|Any CPU.ActiveCfg = Release|Any CPU {6F270A26-F9CB-4F15-A2F7-EA72DB31F2CA}.Release|Any CPU.Build.0 = Release|Any CPU - {768016E4-ED7F-4F3D-A174-84C8AB26D9F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {768016E4-ED7F-4F3D-A174-84C8AB26D9F4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {768016E4-ED7F-4F3D-A174-84C8AB26D9F4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {768016E4-ED7F-4F3D-A174-84C8AB26D9F4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Recuperacion_DGA/Program.cs b/Recuperacion_DGA/Program.cs deleted file mode 100644 index 3751555..0000000 --- a/Recuperacion_DGA/Program.cs +++ /dev/null @@ -1,2 +0,0 @@ -// See https://aka.ms/new-console-template for more information -Console.WriteLine("Hello, World!"); diff --git a/Recuperacion_DGA/Recuperacion_DGA.csproj b/Recuperacion_DGA/Recuperacion_DGA.csproj deleted file mode 100644 index 2150e37..0000000 --- a/Recuperacion_DGA/Recuperacion_DGA.csproj +++ /dev/null @@ -1,10 +0,0 @@ - - - - Exe - net8.0 - enable - enable - - -