74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using System.Data;
|
|
using Dapper;
|
|
using Microsoft.Data.SqlClient;
|
|
using Shared.DTO.Integracion_DGA;
|
|
using Shared.DTO.VariablesEntorno;
|
|
|
|
namespace DAL
|
|
{
|
|
public class JobsDgaSupFlujRepository
|
|
{
|
|
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))
|
|
{
|
|
await connection.OpenAsync();
|
|
await connection.ExecuteAsync("TRUNCATE TABLE DGA_MACRO_RESULTADO_SUP_FLUJ");
|
|
|
|
await SpCalculoDgaSupFluj();
|
|
|
|
string sql = "INSERT INTO DGA_MACRO_RESULTADO_SUP_FLUJ (TagName, TimeStamp, Value, Quality) VALUES (@TagName, @TimeStamp, @Value, @Quality)";
|
|
await connection.ExecuteAsync(sql, dgaMacroResultadoSupFluj);
|
|
return true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception($"Error: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
public async Task<bool> SpCalculoDgaSupFluj()
|
|
{
|
|
try
|
|
{
|
|
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
|
{
|
|
await connection.OpenAsync();
|
|
await connection.ExecuteAsync(
|
|
"SP_CALCULO_DGA_SUP_FLUJ",
|
|
commandType: CommandType.StoredProcedure
|
|
);
|
|
}
|
|
return true; // Éxito
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception($"Error: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
public async Task<bool> SpTraspasoDatosAchirdSupFluj()
|
|
{
|
|
try
|
|
{
|
|
using (var connection = new SqlConnection(BdConexion.StringConnection))
|
|
{
|
|
await connection.OpenAsync();
|
|
await connection.ExecuteAsync(
|
|
"SP_TRASPASO_DATOS_ACHIRD_SUP_FLUJ",
|
|
commandType: CommandType.StoredProcedure
|
|
);
|
|
}
|
|
return true; // Éxito
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception($"Error: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|