Primera versión estable compatible con linux de WSAsegasa
This commit is contained in:
102
WSAsegasa/Logs.cs
Normal file
102
WSAsegasa/Logs.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
//mmm
|
||||
namespace WSAsegasa
|
||||
{
|
||||
internal class Logs
|
||||
{
|
||||
private static object oBloqueoLog;
|
||||
//private static EventLog el;
|
||||
public static void AñadeLog(tsUtilidades.Enumeraciones.TipoLog Tipo, string Mensaje, Exception e = null)
|
||||
{
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
// Descripción Sub: Gestión de logs de la aplicación
|
||||
// Fecha. Creacion: ???
|
||||
// Creada por: manmog
|
||||
// Ultima Modificacion: 24/11/2010
|
||||
//
|
||||
// Modificaciones:
|
||||
// ===============
|
||||
if (oBloqueoLog == null) oBloqueoLog = new object();
|
||||
lock (oBloqueoLog)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e != null)
|
||||
{
|
||||
|
||||
string sStackTrace = "Tipo excepción: " + e.ToString() + Constants.vbCrLf;
|
||||
Exception exError = e;
|
||||
do
|
||||
{
|
||||
sStackTrace += exError.StackTrace + Constants.vbCrLf;
|
||||
exError = exError.InnerException;
|
||||
}
|
||||
while (!Information.IsNothing(exError));
|
||||
if (sStackTrace != "")
|
||||
Mensaje += Constants.vbCrLf + "|StackTrace: " + sStackTrace;
|
||||
}
|
||||
|
||||
bdAsegasa.db.cuentascorreo? cta = null;
|
||||
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto(Procesos.Conf.NombreConexionBD, true, false, true, "WSAsegasa");
|
||||
cta = bd.cuentascorreo.First(x => x.Codigo == "DEFECTO");
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
switch (Tipo)
|
||||
{
|
||||
case tsUtilidades.Enumeraciones.TipoLog.Fallo:
|
||||
Mensaje = "Error WSAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
||||
Log.Fatal(Mensaje);
|
||||
if (cta != null) tsCorreos.Funciones.EnviaCorreo(cta.ServidorSMTP, cta.Remitente, "sevilla@tecnosis.net", "Error en WSAsegasa", Mensaje, null, null, "", "", cta.CuentaCorreo, cta.Password, cta.Puerto.Value, true);
|
||||
break;
|
||||
case tsUtilidades.Enumeraciones.TipoLog.Advertencia:
|
||||
Mensaje = "Advertencia WSAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". " + Mensaje;
|
||||
Log.Warning(Mensaje);
|
||||
if (cta != null) tsCorreos.Funciones.EnviaCorreo(cta.ServidorSMTP, cta.Remitente, "sevilla@tecnosis.net", "Advertencia en WSAsegasa", Mensaje, null, null, "", "", cta.CuentaCorreo, cta.Password, cta.Puerto.Value, true);
|
||||
break;
|
||||
case tsUtilidades.Enumeraciones.TipoLog.InicioServicio:
|
||||
Mensaje = "Inicio WSAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
||||
Log.Information(Mensaje);
|
||||
if (cta != null) tsCorreos.Funciones.EnviaCorreo(cta.ServidorSMTP, cta.Remitente, "sevilla@tecnosis.net", "Inicio WSAsegasa", Mensaje, null, null, "", "", cta.CuentaCorreo, cta.Password, cta.Puerto.Value, true);
|
||||
break;
|
||||
case tsUtilidades.Enumeraciones.TipoLog.FinServicio:
|
||||
Mensaje = "Finalización WSAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
||||
Log.Information(Mensaje);
|
||||
if (cta != null) tsCorreos.Funciones.EnviaCorreo(cta.ServidorSMTP, cta.Remitente, "sevilla@tecnosis.net", "Finalización WSAsegasa", Mensaje, null, null, "", "", cta.CuentaCorreo, cta.Password, cta.Puerto.Value, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
Mensaje = Tipo.ToString() + " WSAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". " + Mensaje;
|
||||
Log.Information(Mensaje);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (e != null)
|
||||
Mensaje += " --- " + e.StackTrace;
|
||||
|
||||
Log.Fatal(Mensaje + " ---" + ex.Message + " --- " + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user