Files
Asegasa.NET/guia/Extensiones/logs.vb
2026-04-28 11:52:16 +02:00

52 lines
1.8 KiB
VB.net

Imports tsl5.Extensiones
Partial Public Class logs
Public Shared Function GeneraLog(bd As gestionasegasaEntities, Tabla As String, id As Integer, idrelacionado As Integer?, Tipo As String, LogXML As String, SuperUsuario As Boolean, Aplicacion As String) As Integer
Try
If bd Is Nothing Then
bd = bdGestionAsegasa.gestionasegasaEntities.NuevoContexto
End If
Dim nl As New logs
With nl
.Tabla = Tabla
.Aplicacion = Aplicacion
.LogXML = LogXML
.id = id
.idRelacionado = idrelacionado
.ip = bd.ip
.FechaHora = tsl5.bbdd.AhoraMysql(bd)
.Tipo = Tipo
If SuperUsuario Then
.Usuario = Utilidades.Usuario & " (SU)"
Else
.Usuario = Utilidades.Usuario
End If
.idTimeStamp = CDbl(Now.Ticks)
End With
bd.logs.AddObject(nl)
bd.GuardarCambios()
Return nl.idLog
Catch ex As Exception
Call Utilidades.AñadeLog(tsl5.Enumeraciones.TipoLog.Fallo, "En GeneraLog", ex.Message, ex)
Return -1
End Try
End Function
Public ReadOnly Property GeneradoPor As String
Get
If Me.idRelacionado.HasValue Then
Dim bd As gestionasegasaEntities = Me.ObtieneContexto
Dim lp = bd.logs.FirstOrDefault(Function(x) x.idLog = Me.idRelacionado)
If lp IsNot Nothing Then
Return lp.Aplicacion
Else
Return "DESCONOCIDO"
End If
Else
Return Me.Aplicacion
End If
End Get
End Property
End Class