feat: Se implementan logs para auditoria
This commit is contained in:
parent
4b6204d9e7
commit
d455289087
3 changed files with 150 additions and 90 deletions
|
@ -1,5 +1,8 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Dapper;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Serilog;
|
||||
using Shared.DTO.VariablesEntorno;
|
||||
|
||||
namespace Shared.Helper
|
||||
{
|
||||
|
@ -25,5 +28,33 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue