feat: se centralizan las variables de entorno y utilidades, ademas de agregar entidades para poder hacer más legible el codigo
This commit is contained in:
parent
bffcdabc0a
commit
222d5fdc08
14 changed files with 203 additions and 59 deletions
|
@ -9,25 +9,25 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public class JobsDgaRepository
|
||||
{
|
||||
private static string connectionString = string.Empty;
|
||||
private readonly IConfiguration _configuration;
|
||||
public JobsDgaRepository(IConfiguration configuration)
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
public JobsDgaRepository(IConfiguration configuration,BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
connectionString = _configuration.GetConnectionString("DefaultConnection") ?? "";
|
||||
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaMacroResultado(List<DgaMacroResultado> dgaMacroResultados)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection connection = new SqlConnection(connectionString))
|
||||
using (SqlConnection connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
// 1. Truncar la tabla antes de insertar
|
||||
|
@ -49,7 +49,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace DAL
|
|||
try
|
||||
{
|
||||
// Configurar la conexión a la base de datos
|
||||
using (SqlConnection connection = new SqlConnection(connectionString))
|
||||
using (SqlConnection connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
// Truncar la tabla antes de insertar
|
||||
|
@ -102,7 +102,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
// Ejecuta el stored procedure sin parámetros
|
||||
|
@ -120,7 +120,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
@ -140,7 +140,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Integracion_DGA;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -13,13 +14,13 @@ namespace DAL
|
|||
{
|
||||
public class JobsDgaSupFlujRepository
|
||||
{
|
||||
private static string connectionString = string.Empty;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
|
||||
public JobsDgaSupFlujRepository(IConfiguration configuration)
|
||||
public JobsDgaSupFlujRepository(IConfiguration configuration, BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
connectionString = _configuration.GetConnectionString("DefaultConnection") ?? "";
|
||||
_configuration = configuration;
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaMacroResultadoSupFluj(List<DgaMacroResultadoSupFluj> dgaMacroResultadoSupFluj)
|
||||
|
@ -27,7 +28,7 @@ namespace DAL
|
|||
try
|
||||
{
|
||||
// Configurar la conexión a la base de datos
|
||||
using (SqlConnection connection = new SqlConnection(connectionString))
|
||||
using (SqlConnection connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_MACRO_RESULTADO_SUP_FLUJ");
|
||||
|
@ -49,7 +50,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
@ -69,7 +70,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Integracion_DGA;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -14,19 +15,19 @@ namespace DAL
|
|||
public class JobsDgaVilosRepository
|
||||
{
|
||||
private IConfiguration _configuration;
|
||||
private static string connectionString = string.Empty;
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
|
||||
public JobsDgaVilosRepository(IConfiguration configuration)
|
||||
public JobsDgaVilosRepository(IConfiguration configuration,BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
connectionString = _configuration.GetConnectionString("DefaultConnection") ?? "";
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaMacroResultadoVilos(List<DgaMacroResultadoVilos> dgaMacroResultadoVilos)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
|
@ -53,7 +54,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
|
@ -77,7 +78,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
@ -97,7 +98,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
|
|
@ -7,24 +7,26 @@ using Dapper;
|
|||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Envios_DGA;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public class LogMedicionScadaRepository
|
||||
{
|
||||
private IConfiguration _configuration;
|
||||
private static string connectionString = string.Empty;
|
||||
public LogMedicionScadaRepository(IConfiguration configuration)
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
|
||||
public LogMedicionScadaRepository(IConfiguration configuration,BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
connectionString = _configuration.GetConnectionString("DefaultConnection") ?? "";
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarLogMedicionScadaAsync(LogMedicionScada logMedicionScada)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Envios_DGA;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
using System.Data;
|
||||
|
||||
namespace DAL
|
||||
|
@ -9,16 +10,17 @@ namespace DAL
|
|||
public class MedicionScadaRepository
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
|
||||
public MedicionScadaRepository(IConfiguration configuration)
|
||||
public MedicionScadaRepository(IConfiguration configuration,BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<List<MedicionScada>> ObtenerMedicionesAsync()
|
||||
{
|
||||
var connectionString = _configuration.GetConnectionString("DefaultConnection");
|
||||
await using var connection = new SqlConnection(connectionString);
|
||||
await using var connection = new SqlConnection(_bdConexion.stringConnection);
|
||||
|
||||
var result = await connection.QueryAsync<MedicionScada>(
|
||||
"SP_OBTENER_MEDICION_SMARTSCADA_OPERACION",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue