integración nueva tabla
This commit is contained in:
parent
5db07294f9
commit
657fd50ac9
22 changed files with 203 additions and 447 deletions
|
@ -1,54 +0,0 @@
|
|||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace DAL
|
||||
{
|
||||
public static class Encriptador
|
||||
{
|
||||
private static readonly byte[] key = Encoding.ASCII.GetBytes("1234567891234567");
|
||||
private static readonly byte[] iv = Encoding.ASCII.GetBytes("Devjoker7.37hAES");
|
||||
|
||||
public static string Encripta(string Cadena)
|
||||
{
|
||||
|
||||
using Aes aesAlg = Aes.Create();
|
||||
aesAlg.Key = key;
|
||||
aesAlg.IV = iv;
|
||||
|
||||
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
|
||||
|
||||
using (MemoryStream msEncrypt = new MemoryStream())
|
||||
{
|
||||
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
|
||||
{
|
||||
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
|
||||
{
|
||||
swEncrypt.Write(Cadena);
|
||||
}
|
||||
}
|
||||
|
||||
return Convert.ToBase64String(msEncrypt.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public static string Desencripta(string Cadena)
|
||||
{
|
||||
using Aes aesAlg = Aes.Create();
|
||||
aesAlg.Key = key;
|
||||
aesAlg.IV = iv;
|
||||
|
||||
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
|
||||
|
||||
using (MemoryStream msDecrypt = new MemoryStream(Convert.FromBase64String(Cadena)))
|
||||
{
|
||||
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
|
||||
{
|
||||
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
|
||||
{
|
||||
return srDecrypt.ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,9 +5,9 @@ using Shared.DTO.VariablesEntorno;
|
|||
|
||||
namespace DAL
|
||||
{
|
||||
public class LogMedicionScadaRepository
|
||||
public class LogEnvioRepository
|
||||
{
|
||||
public async Task<bool> InsertarLogMedicionScadaAsync(LogMedicionScada logMedicionScada)
|
||||
public async Task<bool> InsertarLogEnvioAsync(LogMedicionEnvio logMedicionScada)
|
||||
{
|
||||
try
|
||||
{
|
|
@ -6,14 +6,14 @@ using Shared.DTO.VariablesEntorno;
|
|||
|
||||
namespace DAL
|
||||
{
|
||||
public class MedicionScadaRepository
|
||||
public class MedicionDGARepository
|
||||
{
|
||||
public async Task<List<MedicionScada>> ObtenerMedicionesAsync()
|
||||
public async Task<List<DatoDGA>> ObtenerMedicionesAsync()
|
||||
{
|
||||
await using var connection = new SqlConnection(BdConexion.StringConnection);
|
||||
|
||||
var result = await connection.QueryAsync<MedicionScada>(
|
||||
"SP_OBTENER_MEDICION_SMARTSCADA_OPERACION",
|
||||
var result = await connection.QueryAsync<DatoDGA>(
|
||||
"SP_OBTENER_DGA_DATOS",
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return result.ToList();
|
Loading…
Add table
Add a link
Reference in a new issue