From 699f0efcd19fc55f77e4b2d2a8a2c962c09b2b0b Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 12 May 2026 13:32:44 +0200 Subject: [PATCH] =?UTF-8?q?=20=20=20-=202026-05-12=201.2.0.0=20Correccion?= =?UTF-8?q?=20tsUtilidades=20=20=20=20-=202026-05-12=201.1.0.0=20Se=20a?= =?UTF-8?q?=C3=B1ade=20rutina=20diaria=20FinalizaPolizasPagoUnicoVencidas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Clases/PolizaPagoUnicoExcel.cs | 7 +- Servicio Gestion Asegasa/Logs.cs | 92 +++++++++---------- .../Procesos/ProcesosPolizas.cs | 65 ++++++------- Servicio Gestion Asegasa/Program.cs | 3 + .../Servicio Gestion Asegasa.csproj | 7 +- Servicio Gestion Asegasa/Worker.cs | 16 +--- bdAsegasa/db/vf_recibosextendidos.cs | 7 ++ bdAsegasa/dbcontext/gestionasegasaContext.cs | 5 +- 8 files changed, 106 insertions(+), 96 deletions(-) diff --git a/Servicio Gestion Asegasa/Clases/PolizaPagoUnicoExcel.cs b/Servicio Gestion Asegasa/Clases/PolizaPagoUnicoExcel.cs index c13e7a5..e094688 100644 --- a/Servicio Gestion Asegasa/Clases/PolizaPagoUnicoExcel.cs +++ b/Servicio Gestion Asegasa/Clases/PolizaPagoUnicoExcel.cs @@ -8,18 +8,19 @@ namespace Servicio_Gestion_Asegasa.Clases { public class PolizaPagoUnicoExcel { + public int idPoliza { get; set; } public string NumeroPoliza { get; set; } - public string RazonSocial { get; set; } + public string Tomador { get; set; } public DateOnly FechaEfecto { get; set; } public DateOnly FechaVencimiento { get; set; } - public string Descripcion { get; set; } + public string Ramo { get; set; } public string NombreAgente { get; set; } - public string CiaNumeroPolizaSuplemento { get; set; } + public string Compañia { get; set; } } } diff --git a/Servicio Gestion Asegasa/Logs.cs b/Servicio Gestion Asegasa/Logs.cs index 85ad44b..92dc47d 100644 --- a/Servicio Gestion Asegasa/Logs.cs +++ b/Servicio Gestion Asegasa/Logs.cs @@ -25,61 +25,61 @@ namespace Servicio_Gestion_Asegasa // // Modificaciones: // =============== - if (oBloqueoLog == null) oBloqueoLog = new object(); - lock (oBloqueoLog) + //if (oBloqueoLog == null) oBloqueoLog = new object(); + //lock (oBloqueoLog) + //{ + try { - try + if (e != null) { - 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; - } - switch (Tipo) + string sStackTrace = "Tipo excepción: " + e.ToString() + Constants.vbCrLf; + Exception exError = e; + do { - case tsUtilidades.Enumeraciones.TipoLog.Fallo: - Mensaje = "Error WSAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje; - Log.Fatal(Mensaje); - 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); - 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); - 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); - 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; + sStackTrace += exError.StackTrace + Constants.vbCrLf; + exError = exError.InnerException; } + while (!Information.IsNothing(exError)); + if (sStackTrace != "") + Mensaje += Constants.vbCrLf + "|StackTrace: " + sStackTrace; } - catch (Exception ex) + switch (Tipo) { - if (e != null) - Mensaje += " --- " + e.StackTrace; - - Log.Fatal(Mensaje + " ---" + ex.Message + " --- " + ex.StackTrace); + case tsUtilidades.Enumeraciones.TipoLog.Fallo: + Mensaje = "Error WSAsegasa. " + " Enviado desde " + Environment.MachineName + ". Version:" + Assembly.GetEntryAssembly()?.GetName().Version + ". Mensaje: " + Mensaje; + Log.Fatal(Mensaje); + await 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); + await 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); + await 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); + await 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); + } + // } } } } diff --git a/Servicio Gestion Asegasa/Procesos/ProcesosPolizas.cs b/Servicio Gestion Asegasa/Procesos/ProcesosPolizas.cs index 04a4b15..ddeb8d2 100644 --- a/Servicio Gestion Asegasa/Procesos/ProcesosPolizas.cs +++ b/Servicio Gestion Asegasa/Procesos/ProcesosPolizas.cs @@ -1,6 +1,9 @@ using bdAsegasa; using bdAsegasa.db; using bdAsegasa.dbcontext; +using DevExpress.DataProcessing.InMemoryDataProcessor; +using DevExpress.XtraCharts.Native; +using DocumentFormat.OpenXml.Bibliography; using Microsoft.EntityFrameworkCore; using Servicio_Gestion_Asegasa.Clases; using System; @@ -16,58 +19,58 @@ namespace Servicio_Gestion_Asegasa.Procesos public class ProcesosPolizas { - public static async Task ComprobarPolizasPagoUnico() + public static async Task FinalizaPolizasPagoUnicoVencidas() { var bd = tscgestionasegasa.NuevoContexto(); try { DateOnly hoy = DateOnly.FromDateTime(DateTime.Now); + int idTcpu = bd.enumeraciones.First(x => x.Codigo == "DUR.U").idEnumeracion; + int idcaba = bd.enumeraciones.First(x => x.Codigo == "CABA.VENCI").idEnumeracion; + + var lr = bd.vf_recibosextendidos.Where(x => x.idDuracion == idTcpu && x.FechaVencimiento < hoy && x.FechaBajaPoliza==null && x.NumeroPoliza!=null).Select(x => new PolizaPagoUnicoExcel{ + idPoliza = x.idPoliza, - var lr = bd.recibos.Include(x => x.idPolizaNavigation).ThenInclude(x => x.entidadespolizas).ThenInclude(x => x.idEntidadNavigation).Include(x => x.idPolizaNavigation) - .ThenInclude(x => x.idCompaniaNavigation).Include(x => x.idAgenteNavigation).Where(x => x.idPolizaNavigation.idTipoCobro == 272 && x.FechaVencimiento < hoy).Select(x => new PolizaPagoUnicoExcel{ - NumeroPoliza = x.idPolizaNavigation.NumeroPoliza ?? "", + NumeroPoliza = x.NumeroPoliza , - RazonSocial = x.idPolizaNavigation.Tomador.RazonSocial ?? "", + Tomador = x.Tomador, FechaEfecto = x.FechaEfecto, FechaVencimiento = x.FechaVencimiento, - Descripcion = x.idPolizaNavigation.idRamoNavigation.Descripcion ?? "", + Ramo = x.Ramo, - NombreAgente = x.idPolizaNavigation.idAgenteNavigation.Nombre ?? "", + NombreAgente = x.Agente ?? "", - CiaNumeroPolizaSuplemento = x.idPolizaNavigation.CiaNumeroPolizaSuplemento + Compañia = x.Compania }).ToList(); + if (lr.Count > 0) + { + string Destinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo; + byte[] excelPolizas = tsUtilidades.Excel.IEnumerableAExcel(lr); + string sql = @"UPDATE polizassg p INNER JOIN recibos r ON r.idPoliza = p.idPoliza SET p.FechaBaja = p.FechaVencimiento, p.idCausaBaja = " + idcaba.ToString() + " WHERE p.idDuracion = " + idTcpu.ToString() + " AND r.FechaVencimiento < '" + hoy.ToString("yyyyMMdd") +@"' AND p.FechaBaja IS NULL;"; + var na = await bd.Database.ExecuteSqlRawAsync(sql); + //await bd.polizassg.Where(x => lPol.Contains(x.idPoliza)).ExecuteUpdateAsync(setters => setters + // .SetProperty(x => x.FechaBaja, x.FechaVencimiento) + // .SetProperty(x => x.idCausaBaja, idcaba)); - byte[] excelPolizas = tsUtilidades.Excel.IEnumerableAExcel(lr); - - - //await bd.polizassg.Where(x => x.idTipoCobro == 272 && x.recibos.Any(r => r.FechaVencimiento < hoy)).ExecuteUpdateAsync(setters => setters - // .SetProperty(x => x.FechaBaja, hoy) - // .SetProperty(x => x.idCausaBaja, 784)); - - string sDireccionesEnvio = "sevilla@tecnosis.net"; - string sServidorSMTP = "mail.tecnosis.net"; - string sRemitente = "logs@tecnosis.es"; - string Asunto = "Ficheros vencidos"; - string Cuerpo = "Excel de ficheros cobro único vencidos."; - - List listadoFicheros = new List(); - listadoFicheros.Add(new tsUtilidades.Correo.FicheroAdjunto - { - NombreFichero = "FicherosVencidos.xlsx", - Fichero = excelPolizas - }); - - tsUtilidades.Correo.Funciones.EnviaCorreoVariosAdjuntos(sServidorSMTP, sRemitente, sDireccionesEnvio, Asunto, Cuerpo, listadoFicheros); + var cta = bd.cuentascorreo.First(x => x.Codigo == "TECNOSIS"); + correos.GeneraRegistroCorreoConAdjunto(bd, + "Listado de pólizas de Duración Pago Único Vencidas.", + "Se ha procedido dar de baja por vencimiento a las pólizas del fichero adjunto de tipo de duración a único.", + cta, + excelPolizas, "PolizasPagoUnicoVencidas-" + hoy.ToString("yyyy-MM-dd") + ".xlsx", + "Pólizas pago único vencidas", + Destinatarios); + } } - catch (Exception ex) { - + catch (Exception ex) { + await Logs.AñadeLogAsync(tsUtilidades.Enumeraciones.TipoLog.Fallo, ex.Message, ex); } } diff --git a/Servicio Gestion Asegasa/Program.cs b/Servicio Gestion Asegasa/Program.cs index f0f5d7a..2957dfc 100644 --- a/Servicio Gestion Asegasa/Program.cs +++ b/Servicio Gestion Asegasa/Program.cs @@ -3,6 +3,9 @@ using Microsoft.Extensions.Hosting; var builder = Host.CreateApplicationBuilder(args); +builder.Configuration + .SetBasePath(AppContext.BaseDirectory) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); builder.Services.AddHostedService(); builder.Services.Configure( diff --git a/Servicio Gestion Asegasa/Servicio Gestion Asegasa.csproj b/Servicio Gestion Asegasa/Servicio Gestion Asegasa.csproj index d3311e2..9008ed3 100644 --- a/Servicio Gestion Asegasa/Servicio Gestion Asegasa.csproj +++ b/Servicio Gestion Asegasa/Servicio Gestion Asegasa.csproj @@ -2,8 +2,10 @@ net8.0 - 1.0.0.0 + 1.2.0.0 + - 2026-05-12 1.2.0.0 Correccion tsUtilidades + - 2026-05-12 1.1.0.0 Se añade rutina diaria FinalizaPolizasPagoUnicoVencidas - 2026-04-24 1.0.0.0 Primera versión estable enable @@ -18,7 +20,8 @@ - + + diff --git a/Servicio Gestion Asegasa/Worker.cs b/Servicio Gestion Asegasa/Worker.cs index 8a431b9..02af908 100644 --- a/Servicio Gestion Asegasa/Worker.cs +++ b/Servicio Gestion Asegasa/Worker.cs @@ -25,11 +25,11 @@ namespace Servicio_Gestion_Asegasa protected override async Task ExecuteAsync(CancellationToken stoppingToken) { - string Mensaje = "Servicio Gestion Asegasa. Versión: " + tsUtilidades.Utilidades.ExtraeValorCadena(Assembly.GetExecutingAssembly().FullName, "Version"); try { + //await ProcesosPolizas.ComprobarPolizasPagoUnico(); if (ProcesosConf.Conf.HoraProcesosDiarios != null) { @@ -76,10 +76,6 @@ namespace Servicio_Gestion_Asegasa .WithIdentity("TareasProgramadas", "Grupo1") .Build(); // Crear un trigger que se ejecute diariamente a una hora específica - - await ComprobarPolizasPagoUnico(); - - int Hora = int.Parse(ProcesosConf.Conf.HoraProcesosDiarios.Split(":")[0]); int Minutos = int.Parse(ProcesosConf.Conf.HoraProcesosDiarios.Split(":")[1]); Quartz.ITrigger trigger = Quartz.TriggerBuilder.Create() @@ -99,15 +95,9 @@ namespace Servicio_Gestion_Asegasa public class TareasProgramadas : IJob { - public Task Execute(IJobExecutionContext context) + public async Task Execute(IJobExecutionContext context) { - //var ch = bdTecnosis.db.chequeos; - // var bd = bdTecnosis.tscTecnosis.NuevoContexto(); - //var c = bd.chequeos.FirstOrDefault(x => x.idChequeo == ch.idChequeo); - //Comprobaciones.ChequeaColaCorreo(bd,c); - //Comprobaciones.CompruebaReplica(); - //Aqui van los procesos y comprobaciones - return Task.CompletedTask; + await ProcesosPolizas.FinalizaPolizasPagoUnicoVencidas(); } } } diff --git a/bdAsegasa/db/vf_recibosextendidos.cs b/bdAsegasa/db/vf_recibosextendidos.cs index 68c7899..f5faba7 100644 --- a/bdAsegasa/db/vf_recibosextendidos.cs +++ b/bdAsegasa/db/vf_recibosextendidos.cs @@ -191,4 +191,11 @@ public partial class vf_recibosextendidos public string? CodigoCausaDevolucion { get; set; } public DateOnly? FechaRemesa { get; set; } + + /// + /// tabla enumeraciones + /// + public int? idTipoCobro { get; set; } + + public DateOnly? FechaBajaPoliza { get; set; } } diff --git a/bdAsegasa/dbcontext/gestionasegasaContext.cs b/bdAsegasa/dbcontext/gestionasegasaContext.cs index f8ff186..258942a 100644 --- a/bdAsegasa/dbcontext/gestionasegasaContext.cs +++ b/bdAsegasa/dbcontext/gestionasegasaContext.cs @@ -3796,7 +3796,7 @@ public partial class gestionasegasaContext : DbContext entity.Property(e => e.idPlantilla).HasColumnType("int(11)"); entity.Property(e => e.Codigo) - .HasMaxLength(30) + .HasMaxLength(60) .UseCollation("latin1_swedish_ci") .HasCharSet("latin1"); entity.Property(e => e.Descripcion) @@ -6275,6 +6275,9 @@ public partial class gestionasegasaContext : DbContext entity.Property(e => e.idSituacion).HasColumnType("int(11)"); entity.Property(e => e.idSubagente).HasColumnType("int(11)"); entity.Property(e => e.idTipo).HasColumnType("int(11)"); + entity.Property(e => e.idTipoCobro) + .HasComment("tabla enumeraciones") + .HasColumnType("int(11)"); entity.Property(e => e.idTipoPago) .HasComment("tabla enumeraciones") .HasColumnType("int(11)");