DGA solucion
This commit is contained in:
parent
6edec57054
commit
5db07294f9
2 changed files with 8 additions and 161 deletions
|
@ -92,7 +92,6 @@ namespace BLL.Integracion_DGA
|
|||
).ToList();
|
||||
|
||||
await _jobs.InsertarDgaCaudal(caudalData);
|
||||
await _jobs.InsertarMedicionOperacionCaudal();
|
||||
}
|
||||
else if (item.name == "API - DGA - NIVELES")
|
||||
{
|
||||
|
@ -110,7 +109,6 @@ namespace BLL.Integracion_DGA
|
|||
).ToList();
|
||||
|
||||
await _jobs.InsertarDgaNivel(nivelData);
|
||||
await _jobs.InsertarMedicionOperacionNivel();
|
||||
}
|
||||
else if (item.name == "API - DGA")
|
||||
{
|
||||
|
@ -128,7 +126,12 @@ namespace BLL.Integracion_DGA
|
|||
).ToList();
|
||||
}
|
||||
}
|
||||
WriteLineAndLog($"FIN Proceso DGA");
|
||||
|
||||
WriteLineAndLog($"INICIO REGISTRO DE MEDICIONES DGA");
|
||||
await _jobs.SpRegistrarMedicionesDga();
|
||||
WriteLineAndLog($"FIN REGISTRO DE MEDICIONES DGA");
|
||||
|
||||
WriteLineAndLog($"FIN PROCESO DGA");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -9,83 +9,7 @@ namespace DAL
|
|||
{
|
||||
public class JobsDgaRepository
|
||||
{
|
||||
public async Task<bool> InsertarDgaMacroResultado(List<DgaMacroResultado> dgaMacroResultados)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
// 1. Truncar la tabla antes de insertar
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_MACRO_RESULTADO");
|
||||
// 2. Insertar la lista de registros
|
||||
string sql = "INSERT INTO DGA_MACRO_RESULTADO (TagName, TimeStamp, Value, Quality) VALUES (@TagName, @TimeStamp, @Value, @Quality)";
|
||||
// Esto inserta todos los elementos de la lista en la tabla
|
||||
await connection.ExecuteAsync(sql, dgaMacroResultados);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaSensorResultado(List<DgaSensorResultado> dgaSensorResultado)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
// 1. Truncar la tabla DGA_SENSOR_RESULTADO
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_SENSOR_RESULTADO");
|
||||
|
||||
// 2. Llamar al stored procedure SP_CALCULO_DGA
|
||||
await connection.ExecuteAsync("SP_CALCULO_DGA", commandType: System.Data.CommandType.StoredProcedure);
|
||||
|
||||
// 3. Insertar todos los registros de la lista con Dapper
|
||||
string sql = "INSERT INTO DGA_SENSOR_RESULTADO (TagName, TimeStamp, Value, Quality) VALUES (@TagName, @TimeStamp, @Value, @Quality)";
|
||||
await connection.ExecuteAsync(sql, dgaSensorResultado);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarDgaMacroResultadoSupFlujSuma(List<DgaMacroResultadoSupFlujSuma> dgaMacroResultadoSupFlujSuma)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Configurar la conexión a la base de datos
|
||||
using (SqlConnection connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
// Truncar la tabla antes de insertar
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_MACRO_RESULTADO_SUP_FLUJ_SUMA");
|
||||
|
||||
// Crear un adaptador de datos
|
||||
SqlDataAdapter adapter = new SqlDataAdapter();
|
||||
|
||||
// Configurar el comando de inserción
|
||||
string sql = "INSERT INTO DGA_MACRO_RESULTADO_SUP_FLUJ_SUMA (TagName, TimeStamp, Value, Quality) VALUES (@TagName, @TimeStamp, @Value, @Quality)";
|
||||
await connection.ExecuteAsync(sql, dgaMacroResultadoSupFlujSuma);
|
||||
|
||||
return true; // Éxito
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SpCalculoDga()
|
||||
public async Task<bool> SpRegistrarMedicionesDga()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -93,47 +17,7 @@ namespace DAL
|
|||
{
|
||||
await connection.OpenAsync();
|
||||
// Ejecuta el stored procedure sin parámetros
|
||||
await connection.ExecuteAsync("SP_CALCULO_DGA", commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
return true; // Éxito
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SpCalculoDgaSupFlujSumaSnreversibilidad()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
"SP_CALCULO_DGA_SUP_FLUJ_SUMA_SNREVERSIBILIDAD",
|
||||
commandType: CommandType.StoredProcedure
|
||||
);
|
||||
}
|
||||
return true; // Éxito
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SpTraspasoDatosAchird()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
"SP_TRASPASO_DATOS_ACHIRD",
|
||||
commandType: CommandType.StoredProcedure
|
||||
);
|
||||
await connection.ExecuteAsync("SP_REGISTRAR_DATOS_DGA", commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
return true; // Éxito
|
||||
}
|
||||
|
@ -186,45 +70,5 @@ namespace DAL
|
|||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarMedicionOperacionNivel()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
"SP_CALCULO_NIVEL_MEDICION_SMARTSCADA_OPERACION",
|
||||
commandType: CommandType.StoredProcedure
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarMedicionOperacionCaudal()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (SqlConnection connection = new SqlConnection(BdConexion.StringConnection))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
await connection.ExecuteAsync(
|
||||
"SP_CALCULO_CAUDAL_MEDICION_SMARTSCADA_OPERACION",
|
||||
commandType: CommandType.StoredProcedure
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue