2025-07-01 14:00:41 -04:00
|
|
|
|
using System.Data;
|
|
|
|
|
using Dapper;
|
2025-06-24 14:46:32 -04:00
|
|
|
|
using Microsoft.Data.SqlClient;
|
2025-06-25 13:01:32 -04:00
|
|
|
|
using Shared.DTO.Envios_DGA;
|
2025-07-01 09:59:59 -04:00
|
|
|
|
using Shared.DTO.VariablesEntorno;
|
2025-06-24 14:46:32 -04:00
|
|
|
|
|
|
|
|
|
namespace DAL
|
|
|
|
|
{
|
2025-07-16 20:39:24 -04:00
|
|
|
|
public class MedicionDGARepository
|
2025-06-24 14:46:32 -04:00
|
|
|
|
{
|
2025-07-16 20:39:24 -04:00
|
|
|
|
public async Task<List<DatoDGA>> ObtenerMedicionesAsync()
|
2025-06-24 14:46:32 -04:00
|
|
|
|
{
|
2025-07-01 09:59:59 -04:00
|
|
|
|
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
2025-06-24 14:46:32 -04:00
|
|
|
|
|
2025-07-16 20:39:24 -04:00
|
|
|
|
var result = await connection.QueryAsync<DatoDGA>(
|
|
|
|
|
"SP_OBTENER_DGA_DATOS",
|
2025-06-24 14:46:32 -04:00
|
|
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
|
|
|
|
return result.ToList();
|
|
|
|
|
}
|
2025-07-03 13:06:58 -04:00
|
|
|
|
|
|
|
|
|
public static async Task<bool> ActualizarMedicionesAsync(string medicionesJson)
|
|
|
|
|
{
|
2025-07-17 09:22:55 -04:00
|
|
|
|
//TODO: ACTUALIZAR REGISTROS
|
2025-07-03 13:06:58 -04:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
|
|
|
|
await connection.ExecuteAsync("SP_ACTUALIZAR_MEDICION_SMARTSCADA_OPERACION", new { JsonMediciones = medicionesJson }, commandType: CommandType.StoredProcedure);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"Error: {ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-24 14:46:32 -04:00
|
|
|
|
}
|
|
|
|
|
}
|