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-17 14:00:21 -04:00
|
|
|
|
public async Task<List<DatoDGATemporal>> ObtenerMedicionesPorLoteAsync(int pageNumber, DateTime fecha)
|
2025-06-24 14:46:32 -04:00
|
|
|
|
{
|
2025-07-17 14:00:21 -04:00
|
|
|
|
var parameters = new DynamicParameters();
|
|
|
|
|
parameters.Add("@PageNumber", pageNumber);
|
|
|
|
|
parameters.Add("@FechaInicio", fecha);
|
2025-07-17 12:40:59 -04:00
|
|
|
|
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
|
|
|
|
|
|
|
|
|
var resultado = await connection.QueryAsync<DatoDGATemporal>(
|
|
|
|
|
"SP_OBTENER_LOTE_DGA_DATOS",
|
2025-07-17 14:00:21 -04:00
|
|
|
|
parameters,
|
2025-07-17 12:40:59 -04:00
|
|
|
|
commandType: CommandType.StoredProcedure);
|
|
|
|
|
|
|
|
|
|
return resultado.ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<bool> GuardarMedicionesEnviadasAsync(List<int> medicionesGuardadas)
|
|
|
|
|
{
|
|
|
|
|
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var query = @"UPDATE DGA_DATOS SET ENVIADO = 1 WHERE ID IN @Ids";
|
|
|
|
|
|
|
|
|
|
await connection.ExecuteAsync(query, new { Ids = medicionesGuardadas });
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex) {
|
|
|
|
|
|
|
|
|
|
throw new Exception($"Error {ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2025-06-24 14:46:32 -04:00
|
|
|
|
}
|
|
|
|
|
}
|