feat:se eliminan modelos innecesarios e implementan los logs de medicion
This commit is contained in:
parent
903414e773
commit
f519f3329b
78 changed files with 112 additions and 1683 deletions
50
DAL/LogMedicionScadaRepository.cs
Normal file
50
DAL/LogMedicionScadaRepository.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Shared.DTO.Envios_DGA;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public class LogMedicionScadaRepository
|
||||
{
|
||||
private IConfiguration _configuration;
|
||||
private static string connectionString = string.Empty;
|
||||
public LogMedicionScadaRepository(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
connectionString = _configuration.GetConnectionString("DefaultConnection") ?? "";
|
||||
}
|
||||
|
||||
public async Task<bool> InsertarLogMedicionScadaAsync(LogMedicionScada logMedicionScada)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
{
|
||||
await connection.OpenAsync();
|
||||
|
||||
// Truncar la tabla antes de insertar
|
||||
await connection.ExecuteAsync("TRUNCATE TABLE DGA_LOGS_OPERACION");
|
||||
// Insertar todos los datos de la lista usando Dapper
|
||||
var sql = @"INSERT INTO dbo.DGA_LOGS_OPERACION
|
||||
(estado_envio, json_enviado, json_recibido, comprobante, fecha_envio, id_medicion_smartscada_operacion)
|
||||
VALUES
|
||||
(@EstadoEnvio, @JsonEnviado, @JsonRecibido, @Comprobante, @FechaEnvio, @IdMedicionSmartscadaOperacion)";
|
||||
await connection.ExecuteAsync(sql, logMedicionScada);
|
||||
|
||||
return true; // Éxito
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue