Cambios mensajes

This commit is contained in:
2026-04-29 09:11:56 +02:00
parent cd2e8b8530
commit 444b15679d
13 changed files with 2545 additions and 2292 deletions

View File

@@ -0,0 +1,109 @@
using bdAsegasa;
using bdAsegasa.db;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Serilog;
namespace Servicio_Gestion_Asegasa
{
public class Logs
{
private static object oBloqueoLog;
//private static EventLog el;
public static async Task AñadeLogAsync(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(ProcesosConf.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) {
tsUtilidades.TsNotificacionesClient.RegistrarAsync("Error en Servicio Gestion Asegasa", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
}
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) {
tsUtilidades.TsNotificacionesClient.RegistrarAsync("Advertencia en Servicio Gestion Asegasa", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ADVERTENCIA);
}
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) {
tsUtilidades.TsNotificacionesClient.RegistrarAsync("Inicio Servicio Gestion Asegasa", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.INFO);
}
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) {
tsUtilidades.TsNotificacionesClient.RegistrarAsync("Finalización Servicio Gestion Asegasa", Mensaje, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.INFO);
}
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);
}
}
}
}
}