agregado procesos y bd clases
This commit is contained in:
56
bdAsegasa/Extensiones/logs.cs
Normal file
56
bdAsegasa/Extensiones/logs.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace bdAsegasa.db
|
||||
{
|
||||
public partial class logs
|
||||
{
|
||||
public static int GeneraLog(tscgestionasegasa bd, string Tabla, int id, int? idrelacionado, string Tipo, string LogXML, bool SuperUsuario, string Aplicacion)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bd == null) bd = tscgestionasegasa.NuevoContexto();
|
||||
|
||||
var nl = new logs();
|
||||
nl.Tabla = Tabla;
|
||||
nl.Aplicacion = Aplicacion;
|
||||
nl.LogXML = LogXML;
|
||||
nl.id = id;
|
||||
nl.idRelacionado = idrelacionado;
|
||||
nl.ip = bd.ip;
|
||||
nl.FechaHora = DateTime.Now;
|
||||
nl.Tipo = Tipo;
|
||||
nl.Usuario = SuperUsuario ? $"{Utilidades.Usuario} (SU)" : Utilidades.Usuario;
|
||||
nl.idTimeStamp = (double)DateTime.Now.Ticks;
|
||||
|
||||
bd.logs.Add(nl);
|
||||
bd.SaveChanges();
|
||||
return nl.idLog;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utilidades.AñadeLog(tsUtilidades.Enumeraciones.TipoLog.Fallo, "En GeneraLog", ex.Message, ex);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public string GeneradoPor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idRelacionado.HasValue)
|
||||
{
|
||||
using (var bd = tscgestionasegasa.NuevoContexto())
|
||||
{
|
||||
var lp = bd.logs.FirstOrDefault(x => x.idLog == this.idRelacionado);
|
||||
return lp?.Aplicacion ?? "DESCONOCIDO";
|
||||
}
|
||||
}
|
||||
return this.Aplicacion;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user