cambios variables de ambiente
This commit is contained in:
parent
222d5fdc08
commit
0d67a44d36
20 changed files with 261 additions and 297 deletions
|
@ -9,25 +9,17 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
using Shared.DTO.VariablesEntorno;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public class JobsDgaRepository
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
public JobsDgaRepository(IConfiguration configuration,BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaMacroResultado(List<DgaMacroResultado> dgaMacroResultados)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (SqlConnection connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
// 1. Truncar la tabla antes de insertar
|
||||
|
@ -49,7 +41,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
|
@ -77,7 +69,7 @@ namespace DAL
|
|||
try
|
||||
{
|
||||
// Configurar la conexión a la base de datos
|
||||
using (SqlConnection connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (SqlConnection connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
// Truncar la tabla antes de insertar
|
||||
|
@ -102,7 +94,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
// Ejecuta el stored procedure sin parámetros
|
||||
|
@ -120,7 +112,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
@ -140,7 +132,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Integracion_DGA;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
using Shared.DTO.VariablesEntorno;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -14,21 +14,12 @@ namespace DAL
|
|||
{
|
||||
public class JobsDgaSupFlujRepository
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
|
||||
public JobsDgaSupFlujRepository(IConfiguration configuration, BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaMacroResultadoSupFluj(List<DgaMacroResultadoSupFluj> dgaMacroResultadoSupFluj)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Configurar la conexión a la base de datos
|
||||
using (SqlConnection connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (SqlConnection connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_MACRO_RESULTADO_SUP_FLUJ");
|
||||
|
@ -50,7 +41,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
@ -70,7 +61,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Integracion_DGA;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
using Shared.DTO.VariablesEntorno;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -14,47 +14,39 @@ namespace DAL
|
|||
{
|
||||
public class JobsDgaVilosRepository
|
||||
{
|
||||
private IConfiguration _configuration;
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
|
||||
public JobsDgaVilosRepository(IConfiguration configuration,BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaMacroResultadoVilos(List<DgaMacroResultadoVilos> dgaMacroResultadoVilos)
|
||||
{
|
||||
try
|
||||
public async Task<bool> InsertarDgaMacroResultadoVilos(List<DgaMacroResultadoVilos> dgaMacroResultadoVilos)
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
try
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
// 1. Truncar la tabla antes de insertar
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_MACRO_RESULTADO_VILOS");
|
||||
// 1. Truncar la tabla antes de insertar
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_MACRO_RESULTADO_VILOS");
|
||||
|
||||
// 2. Llamar al stored procedure
|
||||
await connection.ExecuteAsync("SP_CALCULO_DGA_VILOS", commandType: System.Data.CommandType.StoredProcedure);
|
||||
// 2. Llamar al stored procedure
|
||||
await connection.ExecuteAsync("SP_CALCULO_DGA_VILOS", commandType: System.Data.CommandType.StoredProcedure);
|
||||
|
||||
// 3. Insertar todos los datos de la lista usando Dapper
|
||||
string sql = "INSERT INTO DGA_MACRO_RESULTADO_VILOS (TagName, TimeStamp, Value, Quality) VALUES (@TagName, @TimeStamp, @Value, @Quality)";
|
||||
await connection.ExecuteAsync(sql, dgaMacroResultadoVilos);
|
||||
// 3. Insertar todos los datos de la lista usando Dapper
|
||||
string sql = "INSERT INTO DGA_MACRO_RESULTADO_VILOS (TagName, TimeStamp, Value, Quality) VALUES (@TagName, @TimeStamp, @Value, @Quality)";
|
||||
await connection.ExecuteAsync(sql, dgaMacroResultadoVilos);
|
||||
|
||||
return true; // Éxito
|
||||
return true; // Éxito
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaSensorResultadoVilos(List<DgaSensorResultadoVilos> dgaSensorResultadoVilos)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
|
@ -78,7 +70,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
@ -98,7 +90,7 @@ namespace DAL
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
|
|
|
@ -7,26 +7,17 @@ using Dapper;
|
|||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Envios_DGA;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
using Shared.DTO.VariablesEntorno;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public class LogMedicionScadaRepository
|
||||
{
|
||||
private IConfiguration _configuration;
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
|
||||
public LogMedicionScadaRepository(IConfiguration configuration,BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarLogMedicionScadaAsync(LogMedicionScada logMedicionScada)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(_bdConexion.stringConnection))
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
|
|
|
@ -2,25 +2,16 @@
|
|||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Envios_DGA;
|
||||
using Shared.Utils.Variables_Entorno;
|
||||
using Shared.DTO.VariablesEntorno;
|
||||
using System.Data;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public class MedicionScadaRepository
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly BD_Conexion _bdConexion;
|
||||
|
||||
public MedicionScadaRepository(IConfiguration configuration,BD_Conexion bdConexion)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_bdConexion = bdConexion;
|
||||
}
|
||||
|
||||
public async Task<List<MedicionScada>> ObtenerMedicionesAsync()
|
||||
{
|
||||
await using var connection = new SqlConnection(_bdConexion.stringConnection);
|
||||
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