103 lines
4.8 KiB
C#
103 lines
4.8 KiB
C#
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 WSAsegasaVerifactu
|
|
{
|
|
internal class Logs
|
|
{
|
|
private static object oBloqueoLog;
|
|
//private static EventLog el;
|
|
public static async 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, "WSAsegasaVerifactu");
|
|
// cta = bd.cuentascorreo.First(x => x.Codigo == "DEFECTO");
|
|
//}
|
|
//catch
|
|
//{
|
|
//}
|
|
|
|
switch (Tipo)
|
|
{
|
|
case tsUtilidades.Enumeraciones.TipoLog.Fallo:
|
|
Mensaje = "Error WSAsegasaVerifactu. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
|
Log.Fatal(Mensaje);
|
|
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Error en WSAsegasaVerifactu", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
|
break;
|
|
case tsUtilidades.Enumeraciones.TipoLog.Advertencia:
|
|
Mensaje = "Advertencia WSAsegasaVerifactu. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". " + Mensaje;
|
|
Log.Warning(Mensaje);
|
|
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Adverntencia en WSAsegasaVerifactu", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ADVERTENCIA);
|
|
break;
|
|
case tsUtilidades.Enumeraciones.TipoLog.InicioServicio:
|
|
Mensaje = "Inicio WSAsegasaVerifactu. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
|
Log.Information(Mensaje);
|
|
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Inicio Servicio WSAsegasaVerifactu", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.INFO);
|
|
break;
|
|
case tsUtilidades.Enumeraciones.TipoLog.FinServicio:
|
|
Mensaje = "Finalización WSAsegasaVerifactu. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje;
|
|
Log.Information(Mensaje);
|
|
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("Fin Servicio WSAsegasaVerifactu", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.INFO);
|
|
break;
|
|
|
|
default:
|
|
Mensaje = Tipo.ToString() + " WSAsegasaVerifactu. " + " 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|