integración nueva tabla

This commit is contained in:
bcastrogallardo 2025-07-16 20:39:24 -04:00
parent 5db07294f9
commit 657fd50ac9
22 changed files with 203 additions and 447 deletions

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared.DTO.Envios_DGA
{
public class ApiResponse<T>
{
public string? Status { get; set; }
public string? Message { get; set; }
public T? Data { get; set; }
}
}

View file

@ -0,0 +1,27 @@
namespace Shared.DTO.Envios_DGA
{
public class DatoDGA
{
public int ID { get; set; }
public string? CODIGO_DGA { get; set; }
public string? MACRO { get; set; }
public string? SENSOR { get; set; }
public string? CAUDAL { get; set; }
public string? TOTALIZADOR_CAUDAL { get; set; }
public DateTime? FECHA_MEDICION_CAUDAL { get; set; }
public string? NIVEL_FREATICO_DEL_POZO { get; set; }
public DateTime? FECHA_MEDICION_NIVEL { get; set; }
public string? TIPO_EMPRESA { get; set; }
public int ENVIADO { get; set; } = 0;
}
}

View file

@ -0,0 +1,12 @@
namespace Shared.DTO.Envios_DGA
{
public class LogMedicionEnvio
{
public string EstadoEnvio { get; set; }
public string? JsonEnviado { get; set; }
public string? JsonRecibido { get; set; }
public string? Comprobante { get; set; }
public DateTime FechaEnvio { get; set; }
public long IdDgaDato { get; set; }
}
}

View file

@ -1,12 +0,0 @@
namespace Shared.DTO.Envios_DGA
{
public class LogMedicionScada
{
public string EstadoEnvio { get; set; }
public string JsonEnviado { get; set; }
public string JsonRecibido { get; set; }
public string Comprobante { get; set; }
public DateTime FechaEnvio { get; set; }
public long IdMedicionSmartscadaOperacion { get; set; }
}
}

View file

@ -1,28 +0,0 @@
namespace Shared.DTO.Envios_DGA
{
public class MedicionScada
{
public long Id { get; set; }
public string? Code { get; set; }
public DateTime? DateOrigen { get; set; }
public DateTime? DateMedicionSup { get; set; }
public decimal? Caudal { get; set; }
public decimal? Altura { get; set; }
public DateTime? DateMedicionSub { get; set; }
public decimal? Totalizador { get; set; }
public decimal? Caudalsub { get; set; }
public decimal? Nivel { get; set; }
public DateTime? FechaEnvio { get; set; }
public int Enviado { get; set; }
public string? tipo_empresa { get; set; }
public string? nivelFreaticoDelPozo { get; set; }
}
}

View file

@ -2,24 +2,24 @@
{
public class MedicionSubterraneaRequest
{
public Autenticacion Autenticacion { get; set; }
public Medicion MedicionSubterranea { get; set; }
public Autenticacion Autenticacion { get; set; } = new();
public Medicion MedicionSubterranea { get; set; } = new();
}
public class Autenticacion
{
public string Password { get; set; }
public string RutEmpresa { get; set; }
public string RutUsuario { get; set; }
public string Password { get; set; } = string.Empty;
public string RutEmpresa { get; set; } = string.Empty;
public string RutUsuario { get; set; } = string.Empty;
}
public class Medicion
{
public string Caudal { get; set; }
public string FechaMedicion { get; set; }
public string HoraMedicion { get; set; }
public string NivelFreaticoDelPozo { get; set; }
public string Totalizador { get; set; }
public string? Caudal { get; set; }
public string? FechaMedicion { get; set; }
public string? HoraMedicion { get; set; }
public string? NivelFreaticoDelPozo { get; set; }
public string? Totalizador { get; set; }
public string? TipoEmpresa { get; set; }
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shared.DTO.Envios_DGA
{
public class MedicionSubterraneaResponse
{
public string? NumeroComprobante { get; set; }
}
}

View file

@ -1,12 +0,0 @@
namespace Shared.DTO.Integracion_DGA;
public partial class DgaMacroResultado
{
public string TagName { get; set; } = null!;
public DateTime TimeStamp { get; set; }
public double? Value { get; set; }
public string? Quality { get; set; }
}

View file

@ -1,12 +0,0 @@
namespace Shared.DTO.Integracion_DGA;
public partial class DgaMacroResultadoSupFluj
{
public string TagName { get; set; } = null!;
public DateTime TimeStamp { get; set; }
public double? Value { get; set; }
public string? Quality { get; set; }
}

View file

@ -1,12 +0,0 @@
namespace Shared.DTO.Integracion_DGA;
public partial class DgaMacroResultadoSupFlujSuma
{
public string TagName { get; set; } = null!;
public DateTime TimeStamp { get; set; }
public double? Value { get; set; }
public string? Quality { get; set; }
}

View file

@ -1,12 +0,0 @@
namespace Shared.DTO.Integracion_DGA;
public partial class DgaSensorResultado
{
public string TagName { get; set; } = null!;
public DateTime TimeStamp { get; set; }
public double? Value { get; set; }
public string? Quality { get; set; }
}

View file

@ -0,0 +1,39 @@
using System;
namespace Shared.Helper
{
public static class ConsoleLoggerHelper
{
public static void WriteLineAndLogInfo(string msj, ConsoleColor? color = null)
{
if (color.HasValue && Enum.IsDefined(typeof(ConsoleColor), color.Value))
{
Console.ForegroundColor = color.Value;
Console.WriteLine(msj);
Console.ResetColor();
}
else
{
Console.WriteLine(msj);
}
FileLoggerHelper.LogInformation(msj);
}
public static void WriteLineAndLogEventoAsync(string evento, string proceso, string operacion = "", ConsoleColor? color = null)
{
if (color.HasValue && Enum.IsDefined(typeof(ConsoleColor), color.Value))
{
Console.ForegroundColor = color.Value;
Console.WriteLine(proceso);
Console.ResetColor();
}
else
{
Console.WriteLine(proceso);
}
FileLoggerHelper.LogInformation(proceso);
}
}
}

View file

@ -10,7 +10,7 @@ namespace Shared.Helper
{
public static void ConfigureLogger(IConfiguration configuration)
{
var logFilePath = configuration.GetSection("Logging:LogFile:Path").Value;
var logFilePath = configuration.GetSection("Logging:LogFile:Path").Value ?? "";
var logFileFullPath = Path.Combine(Directory.GetCurrentDirectory(), logFilePath);
Log.Logger = new LoggerConfiguration()
@ -28,31 +28,5 @@ namespace Shared.Helper
{
Log.Error(ex, message);
}
public static async Task<bool> InsertarLogsAsync(string evento, string proceso, string operacion)
{
try
{
using var connection = new SqlConnection(BdConexion.StringConnection);
await connection.OpenAsync();
string sql = @"INSERT INTO DGA_LOGS_REGISTROS_ENVIOS (evento, proceso, operacion)
VALUES (@evento, @proceso, @operacion)";
await connection.ExecuteAsync(sql, new
{
evento,
proceso,
operacion
});
return true;
}
catch (Exception e)
{
LogError("Error al insertar logs", e);
return false;
}
}
}
}