Cambios mensajes
This commit is contained in:
15
Servicio Gestion Asegasa/Configuracion.cs
Normal file
15
Servicio Gestion Asegasa/Configuracion.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Servicio_Gestion_Asegasa
|
||||||
|
{
|
||||||
|
public class Configuracion
|
||||||
|
{
|
||||||
|
public int SegundosMinimosEntreProcesos { get; set; }
|
||||||
|
public string? HoraProcesosDiarios { get; set; }
|
||||||
|
public string? NombreConexionBD { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
109
Servicio Gestion Asegasa/Logs.cs
Normal file
109
Servicio Gestion Asegasa/Logs.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,136 +1,136 @@
|
|||||||
using System;
|
//using System;
|
||||||
using System.IO;
|
//using System.IO;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.IO.Compression;
|
//using System.IO.Compression;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using Renci.SshNet;
|
//using Renci.SshNet;
|
||||||
using Renci.SshNet.Common;
|
//using Renci.SshNet.Common;
|
||||||
using tsUtilidades;
|
//using tsUtilidades;
|
||||||
using tsUtilidades.Extensiones;
|
//using tsUtilidades.Extensiones;
|
||||||
using bdAsegasa.db;
|
//using bdAsegasa.db;
|
||||||
using tsUtilidades.Enumeraciones;
|
//using tsUtilidades.Enumeraciones;
|
||||||
|
|
||||||
namespace Servicio_Gestion_Asegasa.Procesos
|
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||||
{
|
//{
|
||||||
public class ProcesosCaser
|
// public class ProcesosCaser
|
||||||
{
|
// {
|
||||||
|
|
||||||
public static async Task GuardarEnBDFicherosDisponiblesSFTPAsync()
|
// public static async Task GuardarEnBDFicherosDisponiblesSFTPAsync()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using (var bd = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
// using (var bd = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
||||||
using (var bdtmp = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
// using (var bdtmp = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
||||||
{
|
// {
|
||||||
var idCaser = bd.companias.First(x => x.Codigo == "0017").idCompania;
|
// var idCaser = bd.companias.First(x => x.Codigo == "0017").idCompania;
|
||||||
|
|
||||||
var keybAuth = new KeyboardInteractiveAuthenticationMethod("ca071106");
|
// var keybAuth = new KeyboardInteractiveAuthenticationMethod("ca071106");
|
||||||
keybAuth.AuthenticationPrompt += HandleKeyEvent;
|
// keybAuth.AuthenticationPrompt += HandleKeyEvent;
|
||||||
var conInfo = new ConnectionInfo("ftp.caser.es", 22, "ca071106", keybAuth);
|
// var conInfo = new ConnectionInfo("ftp.caser.es", 22, "ca071106", keybAuth);
|
||||||
|
|
||||||
using (var sftp = new SftpClient(conInfo))
|
// using (var sftp = new SftpClient(conInfo))
|
||||||
{
|
// {
|
||||||
sftp.Connect();
|
// sftp.Connect();
|
||||||
var lf = sftp.ListDirectory("ca071106").Where(x => x.IsDirectory == false);
|
// var lf = sftp.ListDirectory("ca071106").Where(x => x.IsDirectory == false);
|
||||||
|
|
||||||
foreach (var F in lf)
|
// foreach (var F in lf)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (F.Name.StartsWith("EIAC_REC_") || F.Name.StartsWith("EIAC_POL_") || F.Name.StartsWith("EIAC_SIN_"))
|
// if (F.Name.StartsWith("EIAC_REC_") || F.Name.StartsWith("EIAC_POL_") || F.Name.StartsWith("EIAC_SIN_"))
|
||||||
{
|
// {
|
||||||
string nomfic;
|
// string nomfic;
|
||||||
bool Eszip;
|
// bool Eszip;
|
||||||
if (F.Name.EndsWith(".txt"))
|
// if (F.Name.EndsWith(".txt"))
|
||||||
{
|
// {
|
||||||
nomfic = F.Name.Substring(0, F.Name.Length - 4);
|
// nomfic = F.Name.Substring(0, F.Name.Length - 4);
|
||||||
Eszip = false;
|
// Eszip = false;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
nomfic = Path.ChangeExtension(F.Name, "xml");
|
// nomfic = Path.ChangeExtension(F.Name, "xml");
|
||||||
Eszip = true;
|
// Eszip = true;
|
||||||
}
|
// }
|
||||||
using (var ms = new MemoryStream())
|
// using (var ms = new MemoryStream())
|
||||||
{
|
// {
|
||||||
sftp.DownloadFile(F.FullName, ms);
|
// sftp.DownloadFile(F.FullName, ms);
|
||||||
ms.Position = 0;
|
// ms.Position = 0;
|
||||||
|
|
||||||
byte[] b;
|
// byte[] b;
|
||||||
if (Eszip)
|
// if (Eszip)
|
||||||
{
|
// {
|
||||||
using (var zip = new ZipArchive(ms, ZipArchiveMode.Read))
|
// using (var zip = new ZipArchive(ms, ZipArchiveMode.Read))
|
||||||
{
|
// {
|
||||||
var firstEntry = zip.Entries.First();
|
// var firstEntry = zip.Entries.First();
|
||||||
using (var msxml = new MemoryStream())
|
// using (var msxml = new MemoryStream())
|
||||||
{
|
// {
|
||||||
using (var entryStream = firstEntry.Open())
|
// using (var entryStream = firstEntry.Open())
|
||||||
{
|
// {
|
||||||
entryStream.CopyTo(msxml);
|
// entryStream.CopyTo(msxml);
|
||||||
}
|
// }
|
||||||
msxml.Position = 0;
|
// msxml.Position = 0;
|
||||||
b = msxml.ToArray();
|
// b = msxml.ToArray();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
b = ms.ToArray();
|
// b = ms.ToArray();
|
||||||
}
|
// }
|
||||||
|
|
||||||
var sha1 = tsUtilidades.crypt.SHA1(b);
|
// var sha1 = tsUtilidades.crypt.SHA1(b);
|
||||||
if (bdtmp.ficheroscompanias.Any(x => x.SHA1 == sha1 && x.idCompania == idCaser) == false)
|
// if (bdtmp.ficheroscompanias.Any(x => x.SHA1 == sha1 && x.idCompania == idCaser) == false)
|
||||||
{
|
// {
|
||||||
var nf = new bdAsegasa.db.ficheroscompanias();
|
// var nf = new bdAsegasa.db.ficheroscompanias();
|
||||||
nf.FechaCreacion = DateTime.Now;
|
// nf.FechaCreacion = DateTime.Now;
|
||||||
nf.idCompania = idCaser;
|
// nf.idCompania = idCaser;
|
||||||
nf.Fichero = b;
|
// nf.Fichero = b;
|
||||||
nf.NombreFichero = nomfic;
|
// nf.NombreFichero = nomfic;
|
||||||
nf.SHA1 = sha1;
|
// nf.SHA1 = sha1;
|
||||||
|
|
||||||
switch (F.Name.Split('_')[1])
|
// switch (F.Name.Split('_')[1])
|
||||||
{
|
// {
|
||||||
case "REC":
|
// case "REC":
|
||||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.RECIBOS_EIAC;
|
// nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.RECIBOS_EIAC;
|
||||||
break;
|
// break;
|
||||||
case "POL":
|
// case "POL":
|
||||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.POLIZAS_EIAC;
|
// nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.POLIZAS_EIAC;
|
||||||
break;
|
// break;
|
||||||
case "SIN":
|
// case "SIN":
|
||||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
// nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
bd.ficheroscompanias.Add(nf);
|
// bd.ficheroscompanias.Add(nf);
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
sftp.RenameFile(F.FullName, F.FullName.Replace(F.Name, "PROCESADOS/" + F.Name));
|
// sftp.RenameFile(F.FullName, F.FullName.Replace(F.Name, "PROCESADOS/" + F.Name));
|
||||||
}
|
// }
|
||||||
catch (Exception EX)
|
// catch (Exception EX)
|
||||||
{
|
// {
|
||||||
throw new Exception(EX.Message + " Fichero: " + F.FullName, EX);
|
// throw new Exception(EX.Message + " Fichero: " + F.FullName, EX);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
sftp.Disconnect();
|
// sftp.Disconnect();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception EX)
|
// catch (Exception EX)
|
||||||
{
|
// {
|
||||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GuardarEnBDFicherosDisponibles CASER", EX.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GuardarEnBDFicherosDisponibles CASER", EX.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static void HandleKeyEvent(object? sender, AuthenticationPromptEventArgs e)
|
// private static void HandleKeyEvent(object? sender, AuthenticationPromptEventArgs e)
|
||||||
{
|
// {
|
||||||
foreach (var prompt in e.Prompts)
|
// foreach (var prompt in e.Prompts)
|
||||||
{
|
// {
|
||||||
if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
|
// if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
|
||||||
{
|
// {
|
||||||
prompt.Response = "As69gs73";
|
// prompt.Response = "As69gs73";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,139 +1,139 @@
|
|||||||
using bdAsegasa;
|
//using bdAsegasa;
|
||||||
using bdAsegasa.db;
|
//using bdAsegasa.db;
|
||||||
using bdAsegasa.dbcontext;
|
//using bdAsegasa.dbcontext;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
|
|
||||||
namespace Servicio_Gestion_Asegasa.Procesos
|
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||||
{
|
//{
|
||||||
public class ProcesosContabilidad
|
// public class ProcesosContabilidad
|
||||||
{
|
// {
|
||||||
public static void CompruebaContabilidad()
|
// public static void CompruebaContabilidad()
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||||
string sDestinatarios = "sevilla@tecnosis.net";
|
// string sDestinatarios = "sevilla@tecnosis.net";
|
||||||
|
|
||||||
var asis = bd.asientos.Where(x =>
|
// var asis = bd.asientos.Where(x =>
|
||||||
x.Fecha < x.idEjercicioNavigation.FechaInicio ||
|
// x.Fecha < x.idEjercicioNavigation.FechaInicio ||
|
||||||
x.Fecha > x.idEjercicioNavigation.FechaFin ||
|
// x.Fecha > x.idEjercicioNavigation.FechaFin ||
|
||||||
x.apuntes.Any(y => y.idCuentaNavigation.idEjercicio != x.idEjercicio)
|
// x.apuntes.Any(y => y.idCuentaNavigation.idEjercicio != x.idEjercicio)
|
||||||
).ToList();
|
// ).ToList();
|
||||||
|
|
||||||
if (asis.Count > 0)
|
// if (asis.Count > 0)
|
||||||
{
|
// {
|
||||||
var lFechaErronea = new List<asientos>();
|
// var lFechaErronea = new List<asientos>();
|
||||||
foreach (var asi in asis)
|
// foreach (var asi in asis)
|
||||||
{
|
// {
|
||||||
var ej = bd.ejercicioscontables.FirstOrDefault(x =>
|
// var ej = bd.ejercicioscontables.FirstOrDefault(x =>
|
||||||
x.FechaCierre == null &&
|
// x.FechaCierre == null &&
|
||||||
(x.FechaInicio <= asi.Fecha && x.FechaFin >= asi.Fecha)
|
// (x.FechaInicio <= asi.Fecha && x.FechaFin >= asi.Fecha)
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (ej != null)
|
// if (ej != null)
|
||||||
{
|
// {
|
||||||
lFechaErronea.Add(asi);
|
// lFechaErronea.Add(asi);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
if (asi.idEjercicio != ej.idEjercicio)
|
// if (asi.idEjercicio != ej.idEjercicio)
|
||||||
{
|
// {
|
||||||
asi.idEjercicio = ej.idEjercicio;
|
// asi.idEjercicio = ej.idEjercicio;
|
||||||
}
|
// }
|
||||||
foreach (var ap in asi.apuntes)
|
// foreach (var ap in asi.apuntes)
|
||||||
{
|
// {
|
||||||
ap.idCuenta = bd.cuentas.First(x => x.NumeroCuenta == ap.idCuentaNavigation.NumeroCuenta && x.idEjercicio == asi.idEjercicio).idCuenta;
|
// ap.idCuenta = bd.cuentas.First(x => x.NumeroCuenta == ap.idCuentaNavigation.NumeroCuenta && x.idEjercicio == asi.idEjercicio).idCuenta;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
|
|
||||||
if (lFechaErronea.Count > 0)
|
// if (lFechaErronea.Count > 0)
|
||||||
{
|
// {
|
||||||
var lae = lFechaErronea.Select(x => new
|
// var lae = lFechaErronea.Select(x => new
|
||||||
{
|
// {
|
||||||
NumeroAsiento = x.idAsiento,
|
// NumeroAsiento = x.idAsiento,
|
||||||
Fecha = x.Fecha,
|
// Fecha = x.Fecha,
|
||||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
// Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||||
}).ToList();
|
// }).ToList();
|
||||||
|
|
||||||
byte[] fe = tsUtilidades.Excel.IEnumerableAExcel(lae);
|
// byte[] fe = tsUtilidades.Excel.IEnumerableAExcel(lae);
|
||||||
|
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||||
"Existen apuntes con cuentas de un ejercicio diferente al del asiento (No se corrige el asiento)",
|
// "Existen apuntes con cuentas de un ejercicio diferente al del asiento (No se corrige el asiento)",
|
||||||
"Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
// "Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
||||||
cta, fe, "AsientosFechaErronea-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
// cta, fe, "AsientosFechaErronea-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||||
"Asientos Con Fecha Erronea " + DateTime.Now.ToString("yyyy-MM-dd"),
|
// "Asientos Con Fecha Erronea " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
sDestinatarios);
|
// sDestinatarios);
|
||||||
|
|
||||||
var idsErrores = lae.Select(y => y.NumeroAsiento).ToList();
|
// var idsErrores = lae.Select(y => y.NumeroAsiento).ToList();
|
||||||
asis = asis.Where(x => !idsErrores.Contains(x.idAsiento)).ToList();
|
// asis = asis.Where(x => !idsErrores.Contains(x.idAsiento)).ToList();
|
||||||
}
|
// }
|
||||||
|
|
||||||
var la = asis.Select(x => new
|
// var la = asis.Select(x => new
|
||||||
{
|
// {
|
||||||
NumeroAsiento = x.idAsiento,
|
// NumeroAsiento = x.idAsiento,
|
||||||
Fecha = x.Fecha,
|
// Fecha = x.Fecha,
|
||||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
// Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||||
}).ToList();
|
// }).ToList();
|
||||||
|
|
||||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
// byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||||
|
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||||
"Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
// "Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
||||||
"Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
// "Existen apuntes con cuentas de un ejercicio diferente al del asiento (Se corrige el asiento)",
|
||||||
cta, f, "ApuntesIncoherentes-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
// cta, f, "ApuntesIncoherentes-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||||
"Apuntes Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
// "Apuntes Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
sDestinatarios);
|
// sDestinatarios);
|
||||||
}
|
// }
|
||||||
|
|
||||||
asis = bd.asientos.Where(x => x.Fecha < x.idEjercicioNavigation.FechaInicio || x.Fecha > x.idEjercicioNavigation.FechaFin).ToList();
|
// asis = bd.asientos.Where(x => x.Fecha < x.idEjercicioNavigation.FechaInicio || x.Fecha > x.idEjercicioNavigation.FechaFin).ToList();
|
||||||
|
|
||||||
if (asis.Count > 0)
|
// if (asis.Count > 0)
|
||||||
{
|
// {
|
||||||
var la = asis.Select(x => new
|
// var la = asis.Select(x => new
|
||||||
{
|
// {
|
||||||
NumeroAsiento = x.idAsiento,
|
// NumeroAsiento = x.idAsiento,
|
||||||
Fecha = x.Fecha,
|
// Fecha = x.Fecha,
|
||||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
// Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||||
}).ToList();
|
// }).ToList();
|
||||||
|
|
||||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
// byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||||
|
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||||
"Existen asientos con fecha incoherente al del ejercicio",
|
// "Existen asientos con fecha incoherente al del ejercicio",
|
||||||
"Existen asientos con fecha incoherente al del ejercicio",
|
// "Existen asientos con fecha incoherente al del ejercicio",
|
||||||
cta, f, "AsientosIncoherentes-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
// cta, f, "AsientosIncoherentes-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||||
"Asientos Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
// "Asientos Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
sDestinatarios);
|
// sDestinatarios);
|
||||||
}
|
// }
|
||||||
|
|
||||||
asis = bd.asientos.Where(x => Math.Round((double)x.apuntes.Sum(y => y.Debe ), 2) != Math.Round((double)x.apuntes.Sum(y => y.Haber), 2)).ToList();
|
// asis = bd.asientos.Where(x => Math.Round((double)x.apuntes.Sum(y => y.Debe ), 2) != Math.Round((double)x.apuntes.Sum(y => y.Haber), 2)).ToList();
|
||||||
|
|
||||||
if (asis.Count > 0)
|
// if (asis.Count > 0)
|
||||||
{
|
// {
|
||||||
var la = asis.Select(x => new
|
// var la = asis.Select(x => new
|
||||||
{
|
// {
|
||||||
NumeroAsiento = x.idAsiento,
|
// NumeroAsiento = x.idAsiento,
|
||||||
Fecha = x.Fecha,
|
// Fecha = x.Fecha,
|
||||||
Ejercicio = x.idEjercicioNavigation.Descripcion,
|
// Ejercicio = x.idEjercicioNavigation.Descripcion,
|
||||||
Debe = Math.Round((double)x.apuntes.Sum(y => y.Debe ), 2, MidpointRounding.AwayFromZero),
|
// Debe = Math.Round((double)x.apuntes.Sum(y => y.Debe ), 2, MidpointRounding.AwayFromZero),
|
||||||
Haber = Math.Round((double)x.apuntes.Sum(y => y.Haber ), 2, MidpointRounding.AwayFromZero)
|
// Haber = Math.Round((double)x.apuntes.Sum(y => y.Haber ), 2, MidpointRounding.AwayFromZero)
|
||||||
}).ToList();
|
// }).ToList();
|
||||||
|
|
||||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
// byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||||
|
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||||
"Existen asientos descuadrados",
|
// "Existen asientos descuadrados",
|
||||||
"Existen asientos descuadrados",
|
// "Existen asientos descuadrados",
|
||||||
cta, f, "AsientosDescuadrados-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
// cta, f, "AsientosDescuadrados-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||||
"Asientos Descuadrados " + DateTime.Now.ToString("yyyy-MM-dd"),
|
// "Asientos Descuadrados " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||||
sDestinatarios);
|
// sDestinatarios);
|
||||||
}
|
// }
|
||||||
|
|
||||||
asis = bd.asientos.Where(x => x.Fecha < x.idEjercicioNavigation.FechaInicio || x.Fecha > x.idEjercicioNavigation.FechaFin).ToList();
|
// asis = bd.asientos.Where(x => x.Fecha < x.idEjercicioNavigation.FechaInicio || x.Fecha > x.idEjercicioNavigation.FechaFin).ToList();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,107 +1,107 @@
|
|||||||
using bdAsegasa;
|
//using bdAsegasa;
|
||||||
using bdAsegasa.db;
|
//using bdAsegasa.db;
|
||||||
using bdAsegasa.dbcontext;
|
//using bdAsegasa.dbcontext;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.IO;
|
//using System.IO;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using tsUtilidades;
|
//using tsUtilidades;
|
||||||
using tsUtilidades.Extensiones;
|
//using tsUtilidades.Extensiones;
|
||||||
|
|
||||||
namespace Servicio_Gestion_Asegasa.Procesos
|
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||||
{
|
//{
|
||||||
public class ProcesosGestionesVarias
|
// public class ProcesosGestionesVarias
|
||||||
{
|
// {
|
||||||
public static async Task GeneraCorreoRestablecimientoContraseñaAsync()
|
// public static async Task GeneraCorreoRestablecimientoContraseñaAsync()
|
||||||
{
|
// {
|
||||||
string sProceso = "GeneraCorreoRestablecimientoContraseña";
|
// string sProceso = "GeneraCorreoRestablecimientoContraseña";
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var bd = tscgestionasegasa.NuevoContexto(); ;
|
// var bd = tscgestionasegasa.NuevoContexto(); ;
|
||||||
var idTgag = bd.enumeraciones.First(x => x.Codigo == "TGV.CCAG").idEnumeracion;
|
// var idTgag = bd.enumeraciones.First(x => x.Codigo == "TGV.CCAG").idEnumeracion;
|
||||||
var idTgsag = bd.enumeraciones.First(x => x.Codigo == "TGV.CCSAG").idEnumeracion;
|
// var idTgsag = bd.enumeraciones.First(x => x.Codigo == "TGV.CCSAG").idEnumeracion;
|
||||||
var gess = bd.gestionesvarias.Where(x => x.idCorreo.HasValue == false && (x.idTipo == idTgag || x.idTipo == idTgsag) && x.FechaProcesado.HasValue == false).ToList();
|
// var gess = bd.gestionesvarias.Where(x => x.idCorreo.HasValue == false && (x.idTipo == idTgag || x.idTipo == idTgsag) && x.FechaProcesado.HasValue == false).ToList();
|
||||||
var urlaseg = bd.enumeraciones.First(x => x.Codigo == "CONF.URLWC").ValorAlfabeticoLargo;
|
// var urlaseg = bd.enumeraciones.First(x => x.Codigo == "CONF.URLWC").ValorAlfabeticoLargo;
|
||||||
|
|
||||||
foreach (var g in gess)
|
// foreach (var g in gess)
|
||||||
{
|
// {
|
||||||
string sDestinatario;
|
// string sDestinatario;
|
||||||
string sAsunto;
|
// string sAsunto;
|
||||||
|
|
||||||
if (g.idTipo == idTgag)
|
// if (g.idTipo == idTgag)
|
||||||
{
|
// {
|
||||||
var ag = bd.agentes.First(x => x.idAgente != 0);
|
// var ag = bd.agentes.First(x => x.idAgente != 0);
|
||||||
sDestinatario = ag.Email;
|
// sDestinatario = ag.Email;
|
||||||
sAsunto = "Solicitud de cambio de contraseña al Agente " + ag.Nombre + " (Nº " + ag.Codigo + ")";
|
// sAsunto = "Solicitud de cambio de contraseña al Agente " + ag.Nombre + " (Nº " + ag.Codigo + ")";
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
var sag = bd.subagentes.First(x => x.idAgente != 0);
|
// var sag = bd.subagentes.First(x => x.idAgente != 0);
|
||||||
sDestinatario = sag.Email;
|
// sDestinatario = sag.Email;
|
||||||
sAsunto = "Solicitud de cambio de contraseña al SubAgente " + sag.Nombre + " (Nº " + sag.idAgenteNavigation.Codigo + "-" + sag.Codigo + ")";
|
// sAsunto = "Solicitud de cambio de contraseña al SubAgente " + sag.Nombre + " (Nº " + sag.idAgenteNavigation.Codigo + "-" + sag.Codigo + ")";
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (Directory.Exists(@"c:\tecnosis.tfs"))
|
// if (Directory.Exists(@"c:\tecnosis.tfs"))
|
||||||
{
|
// {
|
||||||
sDestinatario = "sevilla@tecnosis.net";
|
// sDestinatario = "sevilla@tecnosis.net";
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (sDestinatario.EsEmailValido())
|
// if (sDestinatario.EsEmailValido())
|
||||||
{
|
// {
|
||||||
g.Parametros = tsUtilidades.crypt.SHA1("M3Soft." + DateTime.Now.ToBinary().ToString() + g.idGestion.ToString());
|
// g.Parametros = tsUtilidades.crypt.SHA1("M3Soft." + DateTime.Now.ToBinary().ToString() + g.idGestion.ToString());
|
||||||
string sUrlEnlace = urlaseg + "/nuevaContrasena.aspx?id=" + g.idGestion.ToString() + "&cl=" + g.Parametros;
|
// string sUrlEnlace = urlaseg + "/nuevaContrasena.aspx?id=" + g.idGestion.ToString() + "&cl=" + g.Parametros;
|
||||||
|
|
||||||
string sCuerpo = "Estimado compañero/a: Adjunto te remitimos el enlace para restablecer la contraseña de acceso a la Web de Asegasa. Si usted no ha realizado dicha solicitud, póngase en contacto con nosotros. Un saludo.";
|
// string sCuerpo = "Estimado compañero/a: Adjunto te remitimos el enlace para restablecer la contraseña de acceso a la Web de Asegasa. Si usted no ha realizado dicha solicitud, póngase en contacto con nosotros. Un saludo.";
|
||||||
sCuerpo += "<br /><br />Url Restablecimiento de contraseña: <a href=" + (char)34 + sUrlEnlace + (char)34 + ">Pulse aquí</a>";
|
// sCuerpo += "<br /><br />Url Restablecimiento de contraseña: <a href=" + (char)34 + sUrlEnlace + (char)34 + ">Pulse aquí</a>";
|
||||||
|
|
||||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||||
|
|
||||||
g.idCorreo = bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, cta, sDestinatario);
|
// g.idCorreo = bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, cta, sDestinatario);
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
g.FechaProcesado = DateTime.Now;
|
// g.FechaProcesado = DateTime.Now;
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreoRestablecimientoContraseña.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " El Agente o subagente " + g.Descripción + " no tiene un correo válido.", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreoRestablecimientoContraseña.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " El Agente o subagente " + g.Descripción + " no tiene un correo válido.", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreoRestablecimientoContraseña.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreoRestablecimientoContraseña.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task EnviaAlertaCredencialesProximasACaducarAsync()
|
// public static async Task EnviaAlertaCredencialesProximasACaducarAsync()
|
||||||
{
|
// {
|
||||||
string sProceso = "EnviaAlertaCredencialesProximasACaducar";
|
// string sProceso = "EnviaAlertaCredencialesProximasACaducar";
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var bd = tscgestionasegasa.NuevoContexto();
|
// var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var ctaspc = bd.cuentascorreo.Where(x => x.FechaAvisoCaducidadCredenciales != null && x.FechaAvisoCaducidadCredenciales < DateTime.Now).ToList();
|
// var ctaspc = bd.cuentascorreo.Where(x => x.FechaAvisoCaducidadCredenciales != null && x.FechaAvisoCaducidadCredenciales < DateTime.Now).ToList();
|
||||||
var dest = bd.enumeraciones.Where(x => x.Codigo == "CONF.EMAILCRCTA").First().ValorAlfabeticoLargo;
|
// var dest = bd.enumeraciones.Where(x => x.Codigo == "CONF.EMAILCRCTA").First().ValorAlfabeticoLargo;
|
||||||
|
|
||||||
foreach (var c in ctaspc)
|
// foreach (var c in ctaspc)
|
||||||
{
|
// {
|
||||||
string sAsunto;
|
// string sAsunto;
|
||||||
sAsunto = "Crecenciales de la cuenta de correo " + c.Remitente + " próxima a caducar.";
|
// sAsunto = "Crecenciales de la cuenta de correo " + c.Remitente + " próxima a caducar.";
|
||||||
|
|
||||||
if (Directory.Exists(@"c:\tecnosis.tfs"))
|
// if (Directory.Exists(@"c:\tecnosis.tfs"))
|
||||||
{
|
// {
|
||||||
dest = "sevilla@tecnosis.net";
|
// dest = "sevilla@tecnosis.net";
|
||||||
}
|
// }
|
||||||
|
|
||||||
string sCuerpo = "Atención: Se deben renovar las credenciales de la cuenta " + c.Remitente + " y comunicárselo a Tecnosis para su actualización.";
|
// string sCuerpo = "Atención: Se deben renovar las credenciales de la cuenta " + c.Remitente + " y comunicárselo a Tecnosis para su actualización.";
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, c, dest);
|
// bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, c, dest);
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En EnviaAlertaCredencialesProximasACaducar.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En EnviaAlertaCredencialesProximasACaducar.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,457 +1,457 @@
|
|||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.IO;
|
//using System.IO;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
//using Microsoft.EntityFrameworkCore;
|
||||||
using tsUtilidades;
|
//using tsUtilidades;
|
||||||
using tsUtilidades.Extensiones;
|
//using tsUtilidades.Extensiones;
|
||||||
using tsUtilidades.Enumeraciones;
|
//using tsUtilidades.Enumeraciones;
|
||||||
using bdAsegasa.db;
|
//using bdAsegasa.db;
|
||||||
using bdAsegasa.dbcontext;
|
//using bdAsegasa.dbcontext;
|
||||||
using bdAsegasa.Presupuestos;
|
//using bdAsegasa.Presupuestos;
|
||||||
using bdAsegasa.Informes;
|
//using bdAsegasa.Informes;
|
||||||
using bdAsegasa;
|
//using bdAsegasa;
|
||||||
|
|
||||||
namespace Servicio_Gestion_Asegasa.Procesos
|
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||||
{
|
//{
|
||||||
public class ProcesosRecibos
|
// public class ProcesosRecibos
|
||||||
{
|
// {
|
||||||
public static async Task EstableceFechaPagoRecibosAsync()
|
// public static async Task EstableceFechaPagoRecibosAsync()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd =tscgestionasegasa.NuevoContexto();
|
// using var bd =tscgestionasegasa.NuevoContexto();
|
||||||
var idtippag = bd.enumeraciones.First(x => x.Codigo == "TIPP.AG").idEnumeracion;
|
// var idtippag = bd.enumeraciones.First(x => x.Codigo == "TIPP.AG").idEnumeracion;
|
||||||
var idtipppe = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
// var idtipppe = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||||
var idSitPag = bd.enumeraciones.First(x => x.Codigo == "SITR.PA").idEnumeracion;
|
// var idSitPag = bd.enumeraciones.First(x => x.Codigo == "SITR.PA").idEnumeracion;
|
||||||
var idE = bd.enumeraciones.First(x => x.Codigo == "TRC.E").idEnumeracion;
|
// var idE = bd.enumeraciones.First(x => x.Codigo == "TRC.E").idEnumeracion;
|
||||||
var idES = bd.enumeraciones.First(x => x.Codigo == "TRC.ES").idEnumeracion;
|
// var idES = bd.enumeraciones.First(x => x.Codigo == "TRC.ES").idEnumeracion;
|
||||||
var idEX = bd.enumeraciones.First(x => x.Codigo == "TRC.EX").idEnumeracion;
|
// var idEX = bd.enumeraciones.First(x => x.Codigo == "TRC.EX").idEnumeracion;
|
||||||
|
|
||||||
var hoy = DateOnly.FromDateTime( DateTime.Today);
|
// var hoy = DateOnly.FromDateTime( DateTime.Today);
|
||||||
|
|
||||||
var recs = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.FechaDevolucionBanco == null).ToList() .Where(r => r.idTipoPago != idtippag && (
|
// var recs = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.FechaDevolucionBanco == null).ToList() .Where(r => r.idTipoPago != idtippag && (
|
||||||
(r.idTipoPago == idtipppe && (hoy.DayNumber - r.FechaEfecto.DayNumber) >= 10) ||(r.idRemesa.HasValue && (hoy.DayNumber - r.FechaEfecto.DayNumber) >=
|
// (r.idTipoPago == idtipppe && (hoy.DayNumber - r.FechaEfecto.DayNumber) >= 10) ||(r.idRemesa.HasValue && (hoy.DayNumber - r.FechaEfecto.DayNumber) >=
|
||||||
(r.idTipo == idE || r.idTipo == idES || r.idTipo == idEX ? 15 : r.NumeroDiasRemesaPago)))).ToList();
|
// (r.idTipo == idE || r.idTipo == idES || r.idTipo == idEX ? 15 : r.NumeroDiasRemesaPago)))).ToList();
|
||||||
|
|
||||||
var lrp = new List<bdAsegasa.db.recibos>();
|
// var lrp = new List<bdAsegasa.db.recibos>();
|
||||||
if (recs.Count > 0)
|
// if (recs.Count > 0)
|
||||||
{
|
// {
|
||||||
var Cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
// var Cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||||
Cont.ValorNumerico1 += 1;
|
// Cont.ValorNumerico1 += 1;
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
|
|
||||||
foreach (var r in recs)
|
// foreach (var r in recs)
|
||||||
{
|
// {
|
||||||
r.FechaPago = hoy;
|
// r.FechaPago = hoy;
|
||||||
r.idSituacion = idSitPag;
|
// r.idSituacion = idSitPag;
|
||||||
lrp.Add(r);
|
// lrp.Add(r);
|
||||||
}
|
// }
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
await bd.Database.ExecuteSqlRawAsync($"UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={Cont.ValorNumerico1};");
|
// await bd.Database.ExecuteSqlRawAsync($"UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={Cont.ValorNumerico1};");
|
||||||
}
|
// }
|
||||||
|
|
||||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
// var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||||
|
|
||||||
if (lrp.Count == 0)
|
// if (lrp.Count == 0)
|
||||||
{
|
// {
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "No se han marcado ningún recibo como pagado", "Le informamos que no se han marcado ningún recibo como pagado", cta, sDestinatarios);
|
// bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "No se han marcado ningún recibo como pagado", "Le informamos que no se han marcado ningún recibo como pagado", cta, sDestinatarios);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
var lr = lrp.Select(x => new
|
// var lr = lrp.Select(x => new
|
||||||
{
|
// {
|
||||||
x.CodigoRecibo,
|
// x.CodigoRecibo,
|
||||||
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
// NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
||||||
NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
// NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
||||||
Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
// Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
||||||
BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
// BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
||||||
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
// Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
||||||
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre
|
// Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre
|
||||||
}).ToList();
|
// }).ToList();
|
||||||
|
|
||||||
var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
// var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Se han marcado {recs.Count} Recibos como Pagados", "Adjunto le remitimos listado de recibos marcados como pagados", cta, f, $"Pagos-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de con fecha de pago {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Se han marcado {recs.Count} Recibos como Pagados", "Adjunto le remitimos listado de recibos marcados como pagados", cta, f, $"Pagos-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de con fecha de pago {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibos.", $"Rutina: EstableceFechaPagoRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibos.", $"Rutina: EstableceFechaPagoRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task EstableceFechaPagoRecibosAGAsync()
|
// public static async Task EstableceFechaPagoRecibosAGAsync()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// Assuming this method exists in the C# domain model for recibos
|
// // Assuming this method exists in the C# domain model for recibos
|
||||||
bdAsegasa.db.recibos.ContabilizaRecibosPagoAG();
|
// bdAsegasa.db.recibos.ContabilizaRecibosPagoAG();
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibosAG.", $"Rutina: EstableceFechaPagoRecibosAG. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibosAG.", $"Rutina: EstableceFechaPagoRecibosAG. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task EstableceFechaBajaRecibosAsync(int DiasLimiteCartaImperativo = -10)
|
// public static async Task EstableceFechaBajaRecibosAsync(int DiasLimiteCartaImperativo = -10)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var TipoCarta = (int)TipoGestionEnum.AVISO_IMPERATIVO_LEGAL;
|
// var TipoCarta = (int)TipoGestionEnum.AVISO_IMPERATIVO_LEGAL;
|
||||||
var idtipS = bd.enumeraciones.Where(x => x.Codigo == "TIPP.CO" || x.Codigo == "TIPP.CTR" || x.Codigo == "TIPP.CTA" || x.Codigo == "TIPP.CIN" || x.Codigo == "TIPP.PE").Select(x => x.idEnumeracion).ToList();
|
// var idtipS = bd.enumeraciones.Where(x => x.Codigo == "TIPP.CO" || x.Codigo == "TIPP.CTR" || x.Codigo == "TIPP.CTA" || x.Codigo == "TIPP.CIN" || x.Codigo == "TIPP.PE").Select(x => x.idEnumeracion).ToList();
|
||||||
var idFP = bd.enumeraciones.First(x => x.Codigo == "CABA.FP").idEnumeracion;
|
// var idFP = bd.enumeraciones.First(x => x.Codigo == "CABA.FP").idEnumeracion;
|
||||||
var confEmail = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
// var confEmail = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||||
var sDestinatarios = $"{confEmail};lolaherrera@asegasa.es";
|
// var sDestinatarios = $"{confEmail};lolaherrera@asegasa.es";
|
||||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||||
|
|
||||||
var FechaLimite = DateTime.Now.Date.AddDays(-DiasLimiteCartaImperativo);
|
// var FechaLimite = DateTime.Now.Date.AddDays(-DiasLimiteCartaImperativo);
|
||||||
|
|
||||||
var recs = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.gestionesrecibos.Any(y => y.Tipo == TipoCarta && y.Fecha <= FechaLimite)).ToList()
|
// var recs = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.gestionesrecibos.Any(y => y.Tipo == TipoCarta && y.Fecha <= FechaLimite)).ToList()
|
||||||
.Where(x => x.LimiteEfectoSobrePasadoFechaBaja && idtipS.Contains(x.idTipoPago.Value)).ToList();
|
// .Where(x => x.LimiteEfectoSobrePasadoFechaBaja && idtipS.Contains(x.idTipoPago.Value)).ToList();
|
||||||
|
|
||||||
enumeraciones? cont = null;
|
// enumeraciones? cont = null;
|
||||||
int Numrec = 0;
|
// int Numrec = 0;
|
||||||
var hoy = DateOnly.FromDateTime(DateTime.Today);
|
// var hoy = DateOnly.FromDateTime(DateTime.Today);
|
||||||
|
|
||||||
if (recs.Count > 0)
|
// if (recs.Count > 0)
|
||||||
{
|
// {
|
||||||
cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
// cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||||
cont.ValorNumerico1 += 1;
|
// cont.ValorNumerico1 += 1;
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
|
|
||||||
foreach (var r in recs)
|
// foreach (var r in recs)
|
||||||
{
|
// {
|
||||||
Numrec += 1;
|
// Numrec += 1;
|
||||||
r.FechaBaja = hoy;
|
// r.FechaBaja = hoy;
|
||||||
r.idCausaBaja = idFP;
|
// r.idCausaBaja = idFP;
|
||||||
}
|
// }
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
|
|
||||||
var FechaLimiteDev = DateOnly.FromDateTime( DateTime.Now.Date.AddDays(-25));
|
// var FechaLimiteDev = DateOnly.FromDateTime( DateTime.Now.Date.AddDays(-25));
|
||||||
var recsdb = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.FechaDevolucionBanco != null).ToList()
|
// var recsdb = bd.recibos.Where(x => x.FechaPago == null && x.FechaBaja == null && x.FechaDevolucionBanco != null).ToList()
|
||||||
.Where(x => x.FechaDevolucionBanco.Value <= FechaLimiteDev && !idtipS.Contains(x.idTipoPago.Value)).ToList();
|
// .Where(x => x.FechaDevolucionBanco.Value <= FechaLimiteDev && !idtipS.Contains(x.idTipoPago.Value)).ToList();
|
||||||
|
|
||||||
|
|
||||||
if (recsdb.Count > 0)
|
// if (recsdb.Count > 0)
|
||||||
{
|
// {
|
||||||
if (cont == null)
|
// if (cont == null)
|
||||||
{
|
// {
|
||||||
cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
// cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||||
cont.ValorNumerico1 += 1;
|
// cont.ValorNumerico1 += 1;
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
foreach (var r in recsdb)
|
// foreach (var r in recsdb)
|
||||||
{
|
// {
|
||||||
Numrec += 1;
|
// Numrec += 1;
|
||||||
r.FechaBaja = hoy;
|
// r.FechaBaja = hoy;
|
||||||
r.idCausaBaja = idFP;
|
// r.idCausaBaja = idFP;
|
||||||
}
|
// }
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (cont != null)
|
// if (cont != null)
|
||||||
{
|
// {
|
||||||
await bd.Database.ExecuteSqlRawAsync($"UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={cont.ValorNumerico1};");
|
// await bd.Database.ExecuteSqlRawAsync($"UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={cont.ValorNumerico1};");
|
||||||
var lr = recs.Union(recsdb).Select(x => new
|
// var lr = recs.Union(recsdb).Select(x => new
|
||||||
{
|
// {
|
||||||
x.CodigoRecibo,
|
// x.CodigoRecibo,
|
||||||
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
// NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
||||||
NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
// NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
||||||
Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
// Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
||||||
BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
// BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
||||||
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
// Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
||||||
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
|
// Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
|
||||||
FormaPago = x.idTipoPagoNavigation?.Descripcion,
|
// FormaPago = x.idTipoPagoNavigation?.Descripcion,
|
||||||
Agente = x.idPolizaNavigation.idAgenteNavigation?.CodigoYNombre
|
// Agente = x.idPolizaNavigation.idAgenteNavigation?.CodigoYNombre
|
||||||
}).ToList();
|
// }).ToList();
|
||||||
|
|
||||||
var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
// var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Se han marcado {Numrec} Recibos de BAJA por Falta de PAGO", "Adjunto le remitimos listado de recibos puestos de baja por Falta de Pago", cta, f, $"Bajas-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de Baja Fecha {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Se han marcado {Numrec} Recibos de BAJA por Falta de PAGO", "Adjunto le remitimos listado de recibos puestos de baja por Falta de Pago", cta, f, $"Bajas-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de Baja Fecha {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "No se han marcado ningún recibo de Baja por Falta de Pago", "Le informamos que no se han marcado ningún recibo de Baja por Falta de Pago", cta, sDestinatarios);
|
// bdAsegasa.db.correos.GeneraRegistroCorreo(bd, "No se han marcado ningún recibo de Baja por Falta de Pago", "Le informamos que no se han marcado ningún recibo de Baja por Falta de Pago", cta, sDestinatarios);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaBajaRecibos.", $"Rutina: EstableceFechaBajaRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En EstableceFechaBajaRecibos.", $"Rutina: EstableceFechaBajaRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task GeneraApuntesContadoAsync()
|
// public static async Task GeneraApuntesContadoAsync()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var idTippContado = bd.enumeraciones.Where(x => x.Codigo == "TIPP.PE" || (x.idGrupoEnumeracionNavigation.Grupo == "TIPP" && x.ValorNumerico1 == 1)).Select(x => x.idEnumeracion).ToList();
|
// var idTippContado = bd.enumeraciones.Where(x => x.Codigo == "TIPP.PE" || (x.idGrupoEnumeracionNavigation.Grupo == "TIPP" && x.ValorNumerico1 == 1)).Select(x => x.idEnumeracion).ToList();
|
||||||
var idTippPE = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
// var idTippPE = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||||
var idCbPGO = bd.enumeraciones.First(x => x.Codigo == "CABA.PGO").idEnumeracion;
|
// var idCbPGO = bd.enumeraciones.First(x => x.Codigo == "CABA.PGO").idEnumeracion;
|
||||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
// var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||||
|
|
||||||
var recs = bd.vf_recibosextendidos.Where(x => x.idRemesa == null && x.FechaPago != null && idTippContado.Contains(x.idTipoPago.Value) && (x.idCausaBaja == null || x.idCausaBaja.Value != idCbPGO)).ToList();
|
// var recs = bd.vf_recibosextendidos.Where(x => x.idRemesa == null && x.FechaPago != null && idTippContado.Contains(x.idTipoPago.Value) && (x.idCausaBaja == null || x.idCausaBaja.Value != idCbPGO)).ToList();
|
||||||
|
|
||||||
if (recs.Count > 0)
|
// if (recs.Count > 0)
|
||||||
{
|
// {
|
||||||
var recsnv = recs.Where(x => x.idTipoPago == idTippPE && x.CuentaContableTomadorErronea).ToList();
|
// var recsnv = recs.Where(x => x.idTipoPago == idTippPE && x.CuentaContableTomadorErronea).ToList();
|
||||||
if (recsnv.Any())
|
// if (recsnv.Any())
|
||||||
{
|
// {
|
||||||
var lre = recsnv.Select(x => new
|
// var lre = recsnv.Select(x => new
|
||||||
{
|
// {
|
||||||
x.CodigoRecibo,
|
// x.CodigoRecibo,
|
||||||
x.NumeroPoliza,
|
// x.NumeroPoliza,
|
||||||
x.NumeroSuplemento,
|
// x.NumeroSuplemento,
|
||||||
x.Tomador,
|
// x.Tomador,
|
||||||
BinesAsegurados = x.BienesAsegurados,
|
// BinesAsegurados = x.BienesAsegurados,
|
||||||
x.Ramo,
|
// x.Ramo,
|
||||||
x.Compania
|
// x.Compania
|
||||||
}).ToList();
|
// }).ToList();
|
||||||
|
|
||||||
var fe = tsUtilidades.Excel.IEnumerableAExcel(lre);
|
// var fe = tsUtilidades.Excel.IEnumerableAExcel(lre);
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, "Recibos de cobro personal con cuenta contable errónea", "Adjunto le remitimos listado de recibos de cobro personal con cuenta contable errónea.", cta, fe, $"RecibosContadoErroneo-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de cobro personal erróneos {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, "Recibos de cobro personal con cuenta contable errónea", "Adjunto le remitimos listado de recibos de cobro personal con cuenta contable errónea.", cta, fe, $"RecibosContadoErroneo-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de cobro personal erróneos {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
||||||
}
|
// }
|
||||||
|
|
||||||
recs = recs.Where(x => !x.CuentaContableTomadorErronea).ToList();
|
// recs = recs.Where(x => !x.CuentaContableTomadorErronea).ToList();
|
||||||
if (recs.Count > 0)
|
// if (recs.Count > 0)
|
||||||
{
|
// {
|
||||||
bdAsegasa.db.asientos.GeneraAsientoRecibosContado(bd, recs, DelegadoErrorNoControlado);
|
// bdAsegasa.db.asientos.GeneraAsientoRecibosContado(bd, recs, DelegadoErrorNoControlado);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En GeneraApuntesContado.", $"Rutina: GeneraApuntesContado. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En GeneraApuntesContado.", $"Rutina: GeneraApuntesContado. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static void DelegadoErrorNoControlado(string Aplicacion, Exception ex)
|
// private static void DelegadoErrorNoControlado(string Aplicacion, Exception ex)
|
||||||
{
|
// {
|
||||||
_ = TsNotificacionesClient.RegistrarAsync($"En {Aplicacion}", $"Rutina: {Aplicacion} {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// _ = TsNotificacionesClient.RegistrarAsync($"En {Aplicacion}", $"Rutina: {Aplicacion} {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task CompruebaRecibosNoRemesadosAsync()
|
// public static async Task CompruebaRecibosNoRemesadosAsync()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var FechaLimite = DateOnly.FromDateTime(DateTime.Today.AddDays(-10));
|
// var FechaLimite = DateOnly.FromDateTime(DateTime.Today.AddDays(-10));
|
||||||
var hoy = DateOnly.FromDateTime(DateTime.Today);
|
// var hoy = DateOnly.FromDateTime(DateTime.Today);
|
||||||
|
|
||||||
var idBanco = bd.enumeraciones.First(x => x.Codigo == "TIPP.BA").idEnumeracion;
|
// var idBanco = bd.enumeraciones.First(x => x.Codigo == "TIPP.BA").idEnumeracion;
|
||||||
|
|
||||||
var recs = bd.recibos.Where(x => x.FechaBaja == null && x.idRemesa == null && x.idTipoPago == idBanco && x.FechaEfecto < FechaLimite && x.FechaVencimiento > hoy && x.PrimaNeta > 0).ToList();
|
// var recs = bd.recibos.Where(x => x.FechaBaja == null && x.idRemesa == null && x.idTipoPago == idBanco && x.FechaEfecto < FechaLimite && x.FechaVencimiento > hoy && x.PrimaNeta > 0).ToList();
|
||||||
|
|
||||||
if (recs.Count > 0)
|
// if (recs.Count > 0)
|
||||||
{
|
// {
|
||||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
// var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||||
|
|
||||||
var lr = recs.Select(x => x.AListadoGestionCobro()).ToList();
|
// var lr = recs.Select(x => x.AListadoGestionCobro()).ToList();
|
||||||
var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
// var f = tsUtilidades.Excel.IEnumerableAExcel(lr);
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Existen recibos no remesados con fecha anterior a {FechaLimite:d}", $"Le informamos que existen recibos no remesados con fecha anterior a {FechaLimite:d}", cta, f, $"RecibosNoReMesados-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de con fecha de pago {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Existen recibos no remesados con fecha anterior a {FechaLimite:d}", $"Le informamos que existen recibos no remesados con fecha anterior a {FechaLimite:d}", cta, f, $"RecibosNoReMesados-{DateTime.Now:yyyy-MM-dd}.xlsx", $"Listado Recibos de con fecha de pago {DateTime.Now:yyyy-MM-dd}", sDestinatarios);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En CompruebaRecibosNoRemesados.", $"Rutina: CompruebaRecibosNoRemesados. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En CompruebaRecibosNoRemesados.", $"Rutina: CompruebaRecibosNoRemesados. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task CompruebaCarteraPerdidaAsync()
|
// public static async Task CompruebaCarteraPerdidaAsync()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var ultl = bd.enumeraciones.First(x => x.Codigo == "CONF.ULTLCP");
|
// var ultl = bd.enumeraciones.First(x => x.Codigo == "CONF.ULTLCP");
|
||||||
var FechaInicio = ultl.Fecha1.Value.AddDays(1);
|
// var FechaInicio = ultl.Fecha1.Value.AddDays(1);
|
||||||
var FechaFin = DateTime.Today;
|
// var FechaFin = DateTime.Today;
|
||||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCARPER").ValorAlfabeticoLargo;
|
// var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCARPER").ValorAlfabeticoLargo;
|
||||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||||
|
|
||||||
var b = bdAsegasa.Informes.CarteraPerdida.GeneraExcelCarteraPerdida(FechaInicio);
|
// var b = bdAsegasa.Informes.CarteraPerdida.GeneraExcelCarteraPerdida(FechaInicio);
|
||||||
|
|
||||||
if (b == null)
|
// if (b == null)
|
||||||
{
|
// {
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, $"Listado de Cartera Perdida {FechaInicio:dd/MM/yyyy}", $"No existen recibos de Cartera Perdida desde el {FechaInicio:dd/MM/yyyy}", cta, sDestinatarios);
|
// bdAsegasa.db.correos.GeneraRegistroCorreo(bd, $"Listado de Cartera Perdida {FechaInicio:dd/MM/yyyy}", $"No existen recibos de Cartera Perdida desde el {FechaInicio:dd/MM/yyyy}", cta, sDestinatarios);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Listado de Cartera Perdida {FechaInicio:dd/MM/yyyy}", $"Adjunto le remitimos Listado de Cartera Perdida de las fechas comprendidas entre {FechaInicio:dd/MM/yyyy} y el {FechaFin:dd/MM/yyyy}", cta, b, $"CarteraPerdida_{FechaInicio:yyyy-MM-dd}_{FechaFin:yyyy-MM-dd}.xlsx", $"Cartera Perdida desde el {FechaInicio:yyyy-MM-dd}", sDestinatarios);
|
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Listado de Cartera Perdida {FechaInicio:dd/MM/yyyy}", $"Adjunto le remitimos Listado de Cartera Perdida de las fechas comprendidas entre {FechaInicio:dd/MM/yyyy} y el {FechaFin:dd/MM/yyyy}", cta, b, $"CarteraPerdida_{FechaInicio:yyyy-MM-dd}_{FechaFin:yyyy-MM-dd}.xlsx", $"Cartera Perdida desde el {FechaInicio:yyyy-MM-dd}", sDestinatarios);
|
||||||
}
|
// }
|
||||||
|
|
||||||
ultl.Fecha1 = DateTime.Today;
|
// ultl.Fecha1 = DateTime.Today;
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En CompruebaCarteraPerdida.", $"Rutina: CompruebaCarteraPerdida. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En CompruebaCarteraPerdida.", $"Rutina: CompruebaCarteraPerdida. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task GeneraComunicacionesRecibosAsync()
|
// public static async Task GeneraComunicacionesRecibosAsync()
|
||||||
{
|
// {
|
||||||
// Case 1: Remittance warning
|
// // Case 1: Remittance warning
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaRemesa();
|
// var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaRemesa();
|
||||||
bdAsegasa.db.recibos.GeneraAvisoRemesa(lr, bd);
|
// bdAsegasa.db.recibos.GeneraAvisoRemesa(lr, bd);
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Remesa). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Remesa). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Case 2: Legal notice
|
// // Case 2: Legal notice
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosAvisoImperativoLegal(bd);
|
// var lr = bdAsegasa.db.recibos.ObtieneRecibosAvisoImperativoLegal(bd);
|
||||||
var sAsunto = "Falta de pago de su recibo %RECIBO% correspondiente a su poliza %POLIZAYRAMO%";
|
// var sAsunto = "Falta de pago de su recibo %RECIBO% correspondiente a su poliza %POLIZAYRAMO%";
|
||||||
var sCuerpo = "En el presente correo le adjuntamos enlace al documento con el detalle del recibo %RECIBO% pendiente de pago correspondiente a su poliza %POLIZA%";
|
// var sCuerpo = "En el presente correo le adjuntamos enlace al documento con el detalle del recibo %RECIBO% pendiente de pago correspondiente a su poliza %POLIZA%";
|
||||||
bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_IMPERATIVO_LEGAL, sAsunto, sCuerpo, bd);
|
// bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_IMPERATIVO_LEGAL, sAsunto, sCuerpo, bd);
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Legal). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Legal). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Case 3: Cancellation notice
|
// // Case 3: Cancellation notice
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaBaja(bd);
|
// var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaBaja(bd);
|
||||||
var sAsunto = "Aviso de baja de su poliza %POLIZAYRAMO%";
|
// var sAsunto = "Aviso de baja de su poliza %POLIZAYRAMO%";
|
||||||
var sCuerpo = "Con el presente correo le adjuntamos enlace al documento con el detalle de la baja de su póliza %POLIZAYRAMO%";
|
// var sCuerpo = "Con el presente correo le adjuntamos enlace al documento con el detalle de la baja de su póliza %POLIZAYRAMO%";
|
||||||
bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_BAJA_POLIZA, sAsunto, sCuerpo, bd);
|
// bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_BAJA_POLIZA, sAsunto, sCuerpo, bd);
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Baja). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Baja). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Case 4: Bank return notice
|
// // Case 4: Bank return notice
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosComunicacionDevueltoBanco(bd);
|
// var lr = bdAsegasa.db.recibos.ObtieneRecibosComunicacionDevueltoBanco(bd);
|
||||||
var sAsunto = "Aviso de devolución del recibo %RECIBO% correspondiente a su poliza %POLIZAYRAMO%";
|
// var sAsunto = "Aviso de devolución del recibo %RECIBO% correspondiente a su poliza %POLIZAYRAMO%";
|
||||||
var sCuerpo = "En el presente correo le adjuntamos enlace al documento con el detalle de la de devolución del recibo %RECIBO% correspondiente a su poliza %POLIZA%";
|
// var sCuerpo = "En el presente correo le adjuntamos enlace al documento con el detalle de la de devolución del recibo %RECIBO% correspondiente a su poliza %POLIZA%";
|
||||||
bdAsegasa.db.recibos.GeneraAviso(lr,bdAsegasa.db.recibos.TipoGeneracionEnum.COMUNICACION_DEVUELTO_BANCO, sAsunto, sCuerpo, bd);
|
// bdAsegasa.db.recibos.GeneraAviso(lr,bdAsegasa.db.recibos.TipoGeneracionEnum.COMUNICACION_DEVUELTO_BANCO, sAsunto, sCuerpo, bd);
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Devuelto). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Devuelto). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task GeneraRecibosPolizasColectivasAsync()
|
// public static async Task GeneraRecibosPolizasColectivasAsync()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var enums = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "CP").ToList();
|
// var enums = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "CP").ToList();
|
||||||
foreach (var pc in enums)
|
// foreach (var pc in enums)
|
||||||
{
|
// {
|
||||||
var idCia = bd.companias.First(x => x.Codigo == pc.ValorAlfabetico2).idCompania;
|
// var idCia = bd.companias.First(x => x.Codigo == pc.ValorAlfabetico2).idCompania;
|
||||||
var PrimaNeta = pc.ValorNumerico1 ?? 0;
|
// var PrimaNeta = pc.ValorNumerico1 ?? 0;
|
||||||
var PorcentajeImpuestos = pc.ValorNumerico2 ?? 0;
|
// var PorcentajeImpuestos = pc.ValorNumerico2 ?? 0;
|
||||||
var Impuestos = Math.Round(PrimaNeta * PorcentajeImpuestos / 100, 2);
|
// var Impuestos = Math.Round(PrimaNeta * PorcentajeImpuestos / 100, 2);
|
||||||
var Flim = DateTime.Today.AddDays(40);
|
// var Flim = DateTime.Today.AddDays(40);
|
||||||
|
|
||||||
var pols = bd.polizassg.Where(x => x.FechaAceptacionPresupuesto != null && x.NumeroPoliza.StartsWith(pc.ValorAlfabetico1 + "-") && x.idCompania == idCia && x.FechaBaja == null && !x.recibos.Any(y => y.FechaVencimiento >= DateOnly.FromDateTime( Flim))).ToList();
|
// var pols = bd.polizassg.Where(x => x.FechaAceptacionPresupuesto != null && x.NumeroPoliza.StartsWith(pc.ValorAlfabetico1 + "-") && x.idCompania == idCia && x.FechaBaja == null && !x.recibos.Any(y => y.FechaVencimiento >= DateOnly.FromDateTime( Flim))).ToList();
|
||||||
|
|
||||||
foreach (var p in pols)
|
// foreach (var p in pols)
|
||||||
{
|
// {
|
||||||
p.GeneraReciboPolizaColectivo(bd, PrimaNeta, Impuestos, 0);
|
// p.GeneraReciboPolizaColectivo(bd, PrimaNeta, Impuestos, 0);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En GeneraRecibosPolizasColectivas.", $"Rutina: GeneraRecibosPolizasColectivas. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En GeneraRecibosPolizasColectivas.", $"Rutina: GeneraRecibosPolizasColectivas. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static async Task GeneraEmailPolizasColectivas0057Async()
|
// public static async Task GeneraEmailPolizasColectivas0057Async()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var idCia = bd.companias.First(x => x.Codigo == "0057").idCompania;
|
// var idCia = bd.companias.First(x => x.Codigo == "0057").idCompania;
|
||||||
var idRamo = bd.ramos.First(x => x.Codigo == "2-8-1").idRamo;
|
// var idRamo = bd.ramos.First(x => x.Codigo == "2-8-1").idRamo;
|
||||||
|
|
||||||
var recs = bd.recibos.Where(x => x.FechaBaja == null && x.idPolizaNavigation.idCompania == idCia && x.idPolizaNavigation.idRamo == idRamo && !x.gestionesrecibos.Any(y => y.Tipo == (int)TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA)).ToList();
|
// var recs = bd.recibos.Where(x => x.FechaBaja == null && x.idPolizaNavigation.idCompania == idCia && x.idPolizaNavigation.idRamo == idRamo && !x.gestionesrecibos.Any(y => y.Tipo == (int)TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA)).ToList();
|
||||||
|
|
||||||
if (recs.Count > 0)
|
// if (recs.Count > 0)
|
||||||
{
|
// {
|
||||||
var Polcol = bd.enumeraciones.First(x => x.Codigo == "CP.TRACTORESEUROP");
|
// var Polcol = bd.enumeraciones.First(x => x.Codigo == "CP.TRACTORESEUROP");
|
||||||
var laltas = new List<DatoReciboColectivo0057>();
|
// var laltas = new List<DatoReciboColectivo0057>();
|
||||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||||
|
|
||||||
foreach (var r in recs)
|
// foreach (var r in recs)
|
||||||
{
|
// {
|
||||||
var dp = (TractoresEuropAssistance)tsUtilidades.Utilidades.Deserializa(r.idPolizaNavigation.idFicheroPresupuestoNavigation.Fichero, typeof(TractoresEuropAssistance));
|
// var dp = (TractoresEuropAssistance)tsUtilidades.Utilidades.Deserializa(r.idPolizaNavigation.idFicheroPresupuestoNavigation.Fichero, typeof(TractoresEuropAssistance));
|
||||||
var nd = new DatoReciboColectivo0057
|
// var nd = new DatoReciboColectivo0057
|
||||||
{
|
// {
|
||||||
Contrato = Polcol.ValorAlfabetico1,
|
// Contrato = Polcol.ValorAlfabetico1,
|
||||||
Codigo_Producto = Polcol.ValorAlfabetico3,
|
// Codigo_Producto = Polcol.ValorAlfabetico3,
|
||||||
País = "ESPAÑA",
|
// País = "ESPAÑA",
|
||||||
Fecha_Inicio = new DateTime(r.FechaEfecto.Year, r.FechaEfecto.Month, r.FechaEfecto.Day) ,
|
// Fecha_Inicio = new DateTime(r.FechaEfecto.Year, r.FechaEfecto.Month, r.FechaEfecto.Day) ,
|
||||||
Fecha_Fin = new DateTime(r.FechaVencimiento.Year, r.FechaVencimiento.Month, r.FechaVencimiento.Day),
|
// Fecha_Fin = new DateTime(r.FechaVencimiento.Year, r.FechaVencimiento.Month, r.FechaVencimiento.Day),
|
||||||
Matrícula = dp.Matricula,
|
// Matrícula = dp.Matricula,
|
||||||
Marca = dp.Marca,
|
// Marca = dp.Marca,
|
||||||
Modelo = dp.Modelo,
|
// Modelo = dp.Modelo,
|
||||||
Fecha_Matriculacion = dp.FechaMatriculacion,
|
// Fecha_Matriculacion = dp.FechaMatriculacion,
|
||||||
Referencia_Externa = $"{r.idPolizaNavigation.Tomador.CIF} {r.idPolizaNavigation.Tomador.RazonSocial}"
|
// Referencia_Externa = $"{r.idPolizaNavigation.Tomador.CIF} {r.idPolizaNavigation.Tomador.RazonSocial}"
|
||||||
};
|
// };
|
||||||
laltas.Add(nd);
|
// laltas.Add(nd);
|
||||||
}
|
// }
|
||||||
|
|
||||||
var b = tsUtilidades.Excel.IEnumerableAExcel(laltas);
|
// var b = tsUtilidades.Excel.IEnumerableAExcel(laltas);
|
||||||
var idCorreo = bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Listado recibos de Asistencia en Viaje Tractores Día: {DateTime.Today:dd/MM/yyyy}", $"Adjunto le remitimos listado recibos de Asistencia en Viaje Tractores Día: {DateTime.Today:dd/MM/yyyy}", cta, b, $"Asistencia_Viaje_Tractores_{DateTime.Today:yyyy-MM-dd}.xlsx", $"Asistencia Viaje Tractores {DateTime.Today:yyyy-MM-dd}", Polcol.ValorAlfabetico4, "", Polcol.ValorAlfabeticoLargo, idAplicacion: idCia, CodigoAplicacion: "COMPAÑIAS");
|
// var idCorreo = bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd, $"Listado recibos de Asistencia en Viaje Tractores Día: {DateTime.Today:dd/MM/yyyy}", $"Adjunto le remitimos listado recibos de Asistencia en Viaje Tractores Día: {DateTime.Today:dd/MM/yyyy}", cta, b, $"Asistencia_Viaje_Tractores_{DateTime.Today:yyyy-MM-dd}.xlsx", $"Asistencia Viaje Tractores {DateTime.Today:yyyy-MM-dd}", Polcol.ValorAlfabetico4, "", Polcol.ValorAlfabeticoLargo, idAplicacion: idCia, CodigoAplicacion: "COMPAÑIAS");
|
||||||
|
|
||||||
foreach (var r in recs)
|
// foreach (var r in recs)
|
||||||
{
|
// {
|
||||||
var tg = new gestionesrecibos
|
// var tg = new gestionesrecibos
|
||||||
{
|
// {
|
||||||
idRecibo = r.idRecibo,
|
// idRecibo = r.idRecibo,
|
||||||
FormaComunicacion = (int)FormaComunicacionEnum.NINGUNA,
|
// FormaComunicacion = (int)FormaComunicacionEnum.NINGUNA,
|
||||||
Tipo = (int)TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA,
|
// Tipo = (int)TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA,
|
||||||
GestionesRealizadas = TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA.ToString().Replace("_", " "),
|
// GestionesRealizadas = TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA.ToString().Replace("_", " "),
|
||||||
Fecha = DateTime.Now,
|
// Fecha = DateTime.Now,
|
||||||
idCorreo = idCorreo,
|
// idCorreo = idCorreo,
|
||||||
Observaciones = ""
|
// Observaciones = ""
|
||||||
};
|
// };
|
||||||
bd.gestionesrecibos.Add(tg);
|
// bd.gestionesrecibos.Add(tg);
|
||||||
}
|
// }
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
await TsNotificacionesClient.RegistrarAsync("En GeneraEmailPolizasColectivas0057.", $"Rutina: GeneraEmailPolizasColectivas0057. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// await TsNotificacionesClient.RegistrarAsync("En GeneraEmailPolizasColectivas0057.", $"Rutina: GeneraEmailPolizasColectivas0057. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public class DatoReciboColectivo0057
|
// public class DatoReciboColectivo0057
|
||||||
{
|
// {
|
||||||
public string Contrato { get; set; }
|
// public string Contrato { get; set; }
|
||||||
public string Codigo_Producto { get; set; }
|
// public string Codigo_Producto { get; set; }
|
||||||
public DateTime Fecha_Inicio { get; set; }
|
// public DateTime Fecha_Inicio { get; set; }
|
||||||
public DateTime Fecha_Fin { get; set; }
|
// public DateTime Fecha_Fin { get; set; }
|
||||||
public string País { get; set; }
|
// public string País { get; set; }
|
||||||
public string Matrícula { get; set; }
|
// public string Matrícula { get; set; }
|
||||||
public string Marca { get; set; }
|
// public string Marca { get; set; }
|
||||||
public string Modelo { get; set; }
|
// public string Modelo { get; set; }
|
||||||
public DateTime Fecha_Matriculacion { get; set; }
|
// public DateTime Fecha_Matriculacion { get; set; }
|
||||||
public string Referencia_Externa { get; set; }
|
// public string Referencia_Externa { get; set; }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,388 +1,388 @@
|
|||||||
using System;
|
//using System;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using Microsoft.EntityFrameworkCore;
|
//using Microsoft.EntityFrameworkCore;
|
||||||
using bdAsegasa;
|
//using bdAsegasa;
|
||||||
using bdAsegasa.db;
|
//using bdAsegasa.db;
|
||||||
|
|
||||||
namespace Servicio_Gestion_Asegasa.Procesos
|
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||||
{
|
//{
|
||||||
public class ProcesosSiniestros
|
// public class ProcesosSiniestros
|
||||||
{
|
// {
|
||||||
public static void IncorporaSiniestrosEIACV6()
|
// public static void IncorporaSiniestrosEIACV6()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = gestionasegasaEntities.NuevoContexto();
|
// using var bd = gestionasegasaEntities.NuevoContexto();
|
||||||
var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
// var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||||
int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
// int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||||
|
|
||||||
var ficspen = bd.ficheroscompanias
|
// var ficspen = bd.ficheroscompanias
|
||||||
.Where(x => x.FechaProcesado == null &&
|
// .Where(x => x.FechaProcesado == null &&
|
||||||
x.FechaError == null &&
|
// x.FechaError == null &&
|
||||||
x.Tipo == tipo &&
|
// x.Tipo == tipo &&
|
||||||
x.Version == "6.0")
|
// x.Version == "6.0")
|
||||||
.OrderBy(x => x.idFichero)
|
// .OrderBy(x => x.idFichero)
|
||||||
.ToList();
|
// .ToList();
|
||||||
|
|
||||||
foreach (var f in ficspen)
|
// foreach (var f in ficspen)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// Asumimos ProcesosEIAC_V6 existe y Utilizamos una librería genérica de serialización
|
// // Asumimos ProcesosEIAC_V6 existe y Utilizamos una librería genérica de serialización
|
||||||
dynamic DatosEIAC = tsUtilidades.Utilidades.Deserializa(f.Fichero, Type.GetType("ProcesosEIAC_V6.ProcesosEIAC") ?? typeof(object));
|
// dynamic DatosEIAC = tsUtilidades.Utilidades.Deserializa(f.Fichero, Type.GetType("ProcesosEIAC_V6.ProcesosEIAC") ?? typeof(object));
|
||||||
|
|
||||||
if (DatosEIAC?.Objetos?.Items != null)
|
// if (DatosEIAC?.Objetos?.Items != null)
|
||||||
{
|
// {
|
||||||
IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
// IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
||||||
var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
// var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
||||||
|
|
||||||
foreach (var s in lSins)
|
// foreach (var s in lSins)
|
||||||
{
|
// {
|
||||||
List<siniestros> sins = null;
|
// List<siniestros> sins = null;
|
||||||
string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
// string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
||||||
|
|
||||||
var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
// var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
||||||
if (seiac == null)
|
// if (seiac == null)
|
||||||
{
|
// {
|
||||||
seiac = new siniestros_eiac
|
// seiac = new siniestros_eiac
|
||||||
{
|
// {
|
||||||
idSiniestroEntidad = idSiniestroEntidad,
|
// idSiniestroEntidad = idSiniestroEntidad,
|
||||||
idFicheroCompania = f.idFichero,
|
// idFicheroCompania = f.idFichero,
|
||||||
idCompania = f.idCompania
|
// idCompania = f.idCompania
|
||||||
};
|
// };
|
||||||
bd.siniestros_eiac.Add(seiac);
|
// bd.siniestros_eiac.Add(seiac);
|
||||||
}
|
// }
|
||||||
|
|
||||||
seiac.NumeroPoliza = s.DatosPoliza.IdPoliza;
|
// seiac.NumeroPoliza = s.DatosPoliza.IdPoliza;
|
||||||
var pol = bd.polizassg
|
// var pol = bd.polizassg
|
||||||
.Where(x => x.NumeroPoliza == seiac.NumeroPoliza && x.idCompania == seiac.idCompania)
|
// .Where(x => x.NumeroPoliza == seiac.NumeroPoliza && x.idCompania == seiac.idCompania)
|
||||||
.OrderByDescending(x => x.NumeroSuplemento)
|
// .OrderByDescending(x => x.NumeroSuplemento)
|
||||||
.FirstOrDefault();
|
// .FirstOrDefault();
|
||||||
|
|
||||||
if (pol != null)
|
// if (pol != null)
|
||||||
seiac.idPoliza = pol.idPoliza;
|
// seiac.idPoliza = pol.idPoliza;
|
||||||
|
|
||||||
seiac.NumeroSuplemento = s.DatosPoliza.NumeroSuplemento;
|
// seiac.NumeroSuplemento = s.DatosPoliza.NumeroSuplemento;
|
||||||
seiac.FechaDeclaracion = s.DatosSiniestro.FechaDeclaracion;
|
// seiac.FechaDeclaracion = s.DatosSiniestro.FechaDeclaracion;
|
||||||
seiac.FechaOcurrencia = s.DatosSiniestro.FechaOcurrencia;
|
// seiac.FechaOcurrencia = s.DatosSiniestro.FechaOcurrencia;
|
||||||
seiac.PosicionSiniestro = (int)bdAsegasa.db.siniestros_eiac.ObtienePosicionSiniestroV6((string)s.DatosSiniestro.PosicionSiniestro);
|
// seiac.PosicionSiniestro = (int)bdAsegasa.db.siniestros_eiac.ObtienePosicionSiniestroV6((string)s.DatosSiniestro.PosicionSiniestro);
|
||||||
seiac.DescripcionSiniestro = tsUtilidades.Extensiones.StringExtensions.Acortar((string)s.DatosSiniestro.DescripcionSiniestro, 2048);
|
// seiac.DescripcionSiniestro = tsUtilidades.Extensiones.StringExtensions.Acortar((string)s.DatosSiniestro.DescripcionSiniestro, 2048);
|
||||||
seiac.TipologiaSiniestro = s.DatosSiniestro.TipologiaSiniestro;
|
// seiac.TipologiaSiniestro = s.DatosSiniestro.TipologiaSiniestro;
|
||||||
seiac.ImporteIndemnizacion = s.DatosSiniestro.ImporteIndemnizacion;
|
// seiac.ImporteIndemnizacion = s.DatosSiniestro.ImporteIndemnizacion;
|
||||||
seiac.ImporteReserva = s.DatosSiniestro.ImporteReserva;
|
// seiac.ImporteReserva = s.DatosSiniestro.ImporteReserva;
|
||||||
|
|
||||||
if (s.DatosSiniestro.LugarSiniestro != null)
|
// if (s.DatosSiniestro.LugarSiniestro != null)
|
||||||
{
|
// {
|
||||||
if (seiac.idLugarSiniestroNavigation == null)
|
// if (seiac.idLugarSiniestroNavigation == null)
|
||||||
{
|
// {
|
||||||
seiac.idLugarSiniestroNavigation = new direcciones();
|
// seiac.idLugarSiniestroNavigation = new direcciones();
|
||||||
}
|
// }
|
||||||
seiac.idLugarSiniestroNavigation.Direccion = s.DatosSiniestro.LugarSiniestro.ClaseVia + " " + s.DatosSiniestro.LugarSiniestro.NombreVia + " " + s.DatosSiniestro.LugarSiniestro.OtrosDatosVia;
|
// seiac.idLugarSiniestroNavigation.Direccion = s.DatosSiniestro.LugarSiniestro.ClaseVia + " " + s.DatosSiniestro.LugarSiniestro.NombreVia + " " + s.DatosSiniestro.LugarSiniestro.OtrosDatosVia;
|
||||||
seiac.idLugarSiniestroNavigation.CodigoPostal = s.DatosSiniestro.LugarSiniestro.CodigoPostal;
|
// seiac.idLugarSiniestroNavigation.CodigoPostal = s.DatosSiniestro.LugarSiniestro.CodigoPostal;
|
||||||
|
|
||||||
string codmun = bd.ObtieneCodigoMunicipioMasCoincidente(seiac.idLugarSiniestroNavigation.CodigoPostal, (string)s.DatosSiniestro.LugarSiniestro.Poblacion, true);
|
// string codmun = bd.ObtieneCodigoMunicipioMasCoincidente(seiac.idLugarSiniestroNavigation.CodigoPostal, (string)s.DatosSiniestro.LugarSiniestro.Poblacion, true);
|
||||||
if (string.IsNullOrEmpty(codmun))
|
// if (string.IsNullOrEmpty(codmun))
|
||||||
{
|
// {
|
||||||
seiac.idLugarSiniestroNavigation.Direccion += " " + s.DatosSiniestro.LugarSiniestro.Poblacion;
|
// seiac.idLugarSiniestroNavigation.Direccion += " " + s.DatosSiniestro.LugarSiniestro.Poblacion;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
seiac.idLugarSiniestroNavigation.CodigoMunicipio = codmun;
|
// seiac.idLugarSiniestroNavigation.CodigoMunicipio = codmun;
|
||||||
}
|
// }
|
||||||
seiac.idLugarSiniestroNavigation.Direccion = tsUtilidades.Extensiones.StringExtensions.Acortar(seiac.idLugarSiniestroNavigation.Direccion, 200);
|
// seiac.idLugarSiniestroNavigation.Direccion = tsUtilidades.Extensiones.StringExtensions.Acortar(seiac.idLugarSiniestroNavigation.Direccion, 200);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (s.DatosSiniestro.SituacionesSiniestro != null)
|
// if (s.DatosSiniestro.SituacionesSiniestro != null)
|
||||||
{
|
// {
|
||||||
var yaincorporados = new List<int>();
|
// var yaincorporados = new List<int>();
|
||||||
foreach (var sit in s.DatosSiniestro.SituacionesSiniestro)
|
// foreach (var sit in s.DatosSiniestro.SituacionesSiniestro)
|
||||||
{
|
// {
|
||||||
int numeroOrden = sit.NumeroOrden;
|
// int numeroOrden = sit.NumeroOrden;
|
||||||
if (numeroOrden == 0) numeroOrden = sit.GetHashCode();
|
// if (numeroOrden == 0) numeroOrden = sit.GetHashCode();
|
||||||
if (!yaincorporados.Contains(numeroOrden))
|
// if (!yaincorporados.Contains(numeroOrden))
|
||||||
{
|
// {
|
||||||
var est = seiac.estadossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
// var est = seiac.estadossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||||
if (est == null)
|
// if (est == null)
|
||||||
{
|
// {
|
||||||
est = new estadossiniestros_eiac { NumeroOrden = numeroOrden };
|
// est = new estadossiniestros_eiac { NumeroOrden = numeroOrden };
|
||||||
seiac.estadossiniestros_eiac.Add(est);
|
// seiac.estadossiniestros_eiac.Add(est);
|
||||||
}
|
// }
|
||||||
est.SituacionSiniestro = bdAsegasa.estadossiniestros_eiac.ObtieneSituacionSiniestroV6((string)sit.SituacionSiniestro);
|
// est.SituacionSiniestro = bdAsegasa.estadossiniestros_eiac.ObtieneSituacionSiniestroV6((string)sit.SituacionSiniestro);
|
||||||
est.DescripcionSituacion = tsUtilidades.Extensiones.StringExtensions.Acortar((string)sit.DescripcionSituacion, 45);
|
// est.DescripcionSituacion = tsUtilidades.Extensiones.StringExtensions.Acortar((string)sit.DescripcionSituacion, 45);
|
||||||
yaincorporados.Add(numeroOrden);
|
// yaincorporados.Add(numeroOrden);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (s.DatosSiniestro.PagosSiniestro != null)
|
// if (s.DatosSiniestro.PagosSiniestro != null)
|
||||||
{
|
// {
|
||||||
var yaincorporados = new List<int>();
|
// var yaincorporados = new List<int>();
|
||||||
foreach (var pag in s.DatosSiniestro.PagosSiniestro)
|
// foreach (var pag in s.DatosSiniestro.PagosSiniestro)
|
||||||
{
|
// {
|
||||||
int numeroOrden = pag.NumeroOrden;
|
// int numeroOrden = pag.NumeroOrden;
|
||||||
if (numeroOrden == 0) numeroOrden = pag.GetHashCode();
|
// if (numeroOrden == 0) numeroOrden = pag.GetHashCode();
|
||||||
if (!yaincorporados.Contains(numeroOrden))
|
// if (!yaincorporados.Contains(numeroOrden))
|
||||||
{
|
// {
|
||||||
var ps = seiac.pagossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
// var ps = seiac.pagossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||||
if (ps == null)
|
// if (ps == null)
|
||||||
{
|
// {
|
||||||
ps = new pagossiniestros_eiac { NumeroOrden = numeroOrden };
|
// ps = new pagossiniestros_eiac { NumeroOrden = numeroOrden };
|
||||||
seiac.pagossiniestros_eiac.Add(ps);
|
// seiac.pagossiniestros_eiac.Add(ps);
|
||||||
}
|
// }
|
||||||
ps.FechaPago = pag.FechaPago;
|
// ps.FechaPago = pag.FechaPago;
|
||||||
ps.FechaLiquidacion = pag.FechaLiquidacion;
|
// ps.FechaLiquidacion = pag.FechaLiquidacion;
|
||||||
ps.ImportePago = pag.ImportePago;
|
// ps.ImportePago = pag.ImportePago;
|
||||||
ps.DescripcionPago = tsUtilidades.Extensiones.StringExtensions.Acortar((string)pag.DescripcionPago, 255);
|
// ps.DescripcionPago = tsUtilidades.Extensiones.StringExtensions.Acortar((string)pag.DescripcionPago, 255);
|
||||||
ps.idTipoPago = bdAsegasa.siniestros_eiac.ObtenerTipoPagoV6((string)pag.FormaPago, ltpa);
|
// ps.idTipoPago = bdAsegasa.siniestros_eiac.ObtenerTipoPagoV6((string)pag.FormaPago, ltpa);
|
||||||
|
|
||||||
if (pag.FormaPago != null && pag.FormaPago.DatosCuentaCorriente != null)
|
// if (pag.FormaPago != null && pag.FormaPago.DatosCuentaCorriente != null)
|
||||||
{
|
// {
|
||||||
ps.IBAN = pag.FormaPago.DatosCuentaCorriente.IBAN;
|
// ps.IBAN = pag.FormaPago.DatosCuentaCorriente.IBAN;
|
||||||
}
|
// }
|
||||||
yaincorporados.Add(numeroOrden);
|
// yaincorporados.Add(numeroOrden);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (s.DatosSiniestro.AccionesSiniestro != null)
|
// if (s.DatosSiniestro.AccionesSiniestro != null)
|
||||||
{
|
// {
|
||||||
var yaincorporados = new List<int>();
|
// var yaincorporados = new List<int>();
|
||||||
foreach (var accs in s.DatosSiniestro.AccionesSiniestro)
|
// foreach (var accs in s.DatosSiniestro.AccionesSiniestro)
|
||||||
{
|
// {
|
||||||
int numeroOrden = accs.NumeroOrden;
|
// int numeroOrden = accs.NumeroOrden;
|
||||||
if (numeroOrden == 0) numeroOrden = accs.GetHashCode();
|
// if (numeroOrden == 0) numeroOrden = accs.GetHashCode();
|
||||||
if (!yaincorporados.Contains(numeroOrden))
|
// if (!yaincorporados.Contains(numeroOrden))
|
||||||
{
|
// {
|
||||||
var acs = seiac.accionessiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
// var acs = seiac.accionessiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||||
if (acs == null)
|
// if (acs == null)
|
||||||
{
|
// {
|
||||||
acs = new accionessiniestros_eiac { NumeroOrden = numeroOrden };
|
// acs = new accionessiniestros_eiac { NumeroOrden = numeroOrden };
|
||||||
seiac.accionessiniestros_eiac.Add(acs);
|
// seiac.accionessiniestros_eiac.Add(acs);
|
||||||
}
|
// }
|
||||||
acs.AccionSiniestro = bdAsegasa.accionessiniestros_eiac.ObtieneAccionSiniestroV6((string)accs.AccionSiniestro);
|
// acs.AccionSiniestro = bdAsegasa.accionessiniestros_eiac.ObtieneAccionSiniestroV6((string)accs.AccionSiniestro);
|
||||||
acs.FechaAccion = accs.FechaAccion;
|
// acs.FechaAccion = accs.FechaAccion;
|
||||||
acs.DescripcionAccion = accs.DescripcionAccion;
|
// acs.DescripcionAccion = accs.DescripcionAccion;
|
||||||
acs.SituacionAccion = bdAsegasa.accionessiniestros_eiac.ObtieneSituacionAccionV6((string)accs.SituacionAccion);
|
// acs.SituacionAccion = bdAsegasa.accionessiniestros_eiac.ObtieneSituacionAccionV6((string)accs.SituacionAccion);
|
||||||
yaincorporados.Add(numeroOrden);
|
// yaincorporados.Add(numeroOrden);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (s.DatosSiniestro.Expedientes != null)
|
// if (s.DatosSiniestro.Expedientes != null)
|
||||||
{
|
// {
|
||||||
var yaincorporados = new List<string>();
|
// var yaincorporados = new List<string>();
|
||||||
foreach (var exp in s.DatosSiniestro.Expedientes)
|
// foreach (var exp in s.DatosSiniestro.Expedientes)
|
||||||
{
|
// {
|
||||||
string numeroExpediente = exp.NumeroExpediente;
|
// string numeroExpediente = exp.NumeroExpediente;
|
||||||
if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
// if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
||||||
|
|
||||||
if (!yaincorporados.Contains(numeroExpediente))
|
// if (!yaincorporados.Contains(numeroExpediente))
|
||||||
{
|
// {
|
||||||
var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
// var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
||||||
if (ep == null)
|
// if (ep == null)
|
||||||
{
|
// {
|
||||||
ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
// ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
||||||
seiac.expedientessiniestros_eiac.Add(ep);
|
// seiac.expedientessiniestros_eiac.Add(ep);
|
||||||
}
|
// }
|
||||||
ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
// ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
||||||
ep.ImporteReserva = exp.ImporteReserva;
|
// ep.ImporteReserva = exp.ImporteReserva;
|
||||||
ep.TotalPagos = exp.TotalPagos;
|
// ep.TotalPagos = exp.TotalPagos;
|
||||||
ep.TotalRecobros = exp.TotalRecobros;
|
// ep.TotalRecobros = exp.TotalRecobros;
|
||||||
ep.FechaInicio = exp.FechaInicio;
|
// ep.FechaInicio = exp.FechaInicio;
|
||||||
ep.FechaFin = exp.FechaFin;
|
// ep.FechaFin = exp.FechaFin;
|
||||||
ep.NumeroOrden = exp.NumeroOrden;
|
// ep.NumeroOrden = exp.NumeroOrden;
|
||||||
yaincorporados.Add(numeroExpediente);
|
// yaincorporados.Add(numeroExpediente);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (seiac.idSiniestroNavigation == null)
|
// if (seiac.idSiniestroNavigation == null)
|
||||||
{
|
// {
|
||||||
var fi = seiac.FechaOcurrencia.AddDays(-5);
|
// var fi = seiac.FechaOcurrencia.AddDays(-5);
|
||||||
var ff = seiac.FechaOcurrencia.AddDays(5);
|
// var ff = seiac.FechaOcurrencia.AddDays(5);
|
||||||
|
|
||||||
|
|
||||||
var fechaInicio = DateOnly.FromDateTime(fi);
|
// var fechaInicio = DateOnly.FromDateTime(fi);
|
||||||
var fechaFinal = DateOnly.FromDateTime(ff);
|
// var fechaFinal = DateOnly.FromDateTime(ff);
|
||||||
|
|
||||||
sins = bd.siniestros.Where(x =>
|
// sins = bd.siniestros.Where(x =>
|
||||||
x.idPolizaNavigation.NumeroPoliza == seiac.NumeroPoliza &&
|
// x.idPolizaNavigation.NumeroPoliza == seiac.NumeroPoliza &&
|
||||||
x.FechaAccidente.HasValue &&
|
// x.FechaAccidente.HasValue &&
|
||||||
x.FechaAccidente >= fechaInicio &&
|
// x.FechaAccidente >= fechaInicio &&
|
||||||
x.FechaAccidente <= fechaFinal).ToList();
|
// x.FechaAccidente <= fechaFinal).ToList();
|
||||||
|
|
||||||
if (sins.Count == 1)
|
// if (sins.Count == 1)
|
||||||
{
|
// {
|
||||||
seiac.idSiniestroNavigation = sins[0];
|
// seiac.idSiniestroNavigation = sins[0];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
bool bModificados = false;
|
// bool bModificados = false;
|
||||||
if (bd.ChangeTracker.Entries().Any(e => e.State == EntityState.Added))
|
// if (bd.ChangeTracker.Entries().Any(e => e.State == EntityState.Added))
|
||||||
{
|
// {
|
||||||
bModificados = true;
|
// bModificados = true;
|
||||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.NUEVO;
|
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.NUEVO;
|
||||||
seiac.FechaSituacion = DateTime.Now;
|
// seiac.FechaSituacion = DateTime.Now;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
var prmods = bd.ChangeTracker.Entries().Where(e => e.State == EntityState.Modified).ToList();
|
// var prmods = bd.ChangeTracker.Entries().Where(e => e.State == EntityState.Modified).ToList();
|
||||||
if (prmods.Count > 0)
|
// if (prmods.Count > 0)
|
||||||
{
|
// {
|
||||||
foreach (var pr in prmods)
|
// foreach (var pr in prmods)
|
||||||
{
|
// {
|
||||||
var original = pr.OriginalValues;
|
// var original = pr.OriginalValues;
|
||||||
var nuevosvalores = pr.CurrentValues;
|
// var nuevosvalores = pr.CurrentValues;
|
||||||
foreach (var prop in original.Properties)
|
// foreach (var prop in original.Properties)
|
||||||
{
|
// {
|
||||||
var origVal = original[prop];
|
// var origVal = original[prop];
|
||||||
var newVal = nuevosvalores[prop];
|
// var newVal = nuevosvalores[prop];
|
||||||
|
|
||||||
if (origVal?.GetHashCode() != newVal?.GetHashCode())
|
// if (origVal?.GetHashCode() != newVal?.GetHashCode())
|
||||||
{
|
// {
|
||||||
bModificados = true;
|
// bModificados = true;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (bModificados) break;
|
// if (bModificados) break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (bModificados)
|
// if (bModificados)
|
||||||
{
|
// {
|
||||||
if (!seiac.SituacionAsegasa.HasValue || seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
// if (!seiac.SituacionAsegasa.HasValue || seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
||||||
{
|
// {
|
||||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.MODIFICADO;
|
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.MODIFICADO;
|
||||||
seiac.FechaSituacion = DateTime.Now;
|
// seiac.FechaSituacion = DateTime.Now;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var nact = new actualizacionessiniestros_eiac
|
// var nact = new actualizacionessiniestros_eiac
|
||||||
{
|
// {
|
||||||
idSiniestroEIACNavigation = seiac,
|
// idSiniestroEIACNavigation = seiac,
|
||||||
Fecha = DateTime.Now,
|
// Fecha = DateTime.Now,
|
||||||
idFicheroCompania = f.idFichero
|
// idFicheroCompania = f.idFichero
|
||||||
};
|
// };
|
||||||
bd.actualizacionessiniestros_eiac.Add(nact);
|
// bd.actualizacionessiniestros_eiac.Add(nact);
|
||||||
|
|
||||||
if (seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
// if (seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
||||||
{
|
// {
|
||||||
if (!seiac.idPoliza.HasValue)
|
// if (!seiac.idPoliza.HasValue)
|
||||||
{
|
// {
|
||||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.POLIZA_NO_ENCONTRADA;
|
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.POLIZA_NO_ENCONTRADA;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
if (sins == null || sins.Count == 0)
|
// if (sins == null || sins.Count == 0)
|
||||||
{
|
// {
|
||||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.SINIESTRO_NO_ENCONTRADO;
|
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.SINIESTRO_NO_ENCONTRADO;
|
||||||
}
|
// }
|
||||||
else if (sins.Count > 1)
|
// else if (sins.Count > 1)
|
||||||
{
|
// {
|
||||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.VARIOS_SINIESTROS_POSIBLES;
|
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.VARIOS_SINIESTROS_POSIBLES;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
f.FechaProcesado = DateTime.Now;
|
// f.FechaProcesado = DateTime.Now;
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
f.FechaError = DateTime.Now;
|
// f.FechaError = DateTime.Now;
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static void IncorporaExpSiniestrosEIACV6()
|
// public static void IncorporaExpSiniestrosEIACV6()
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
using var bd = tscgestionasegasa.NuevoContexto();
|
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||||
var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
// var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||||
int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
// int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||||
var ficspen = bd.ficheroscompanias
|
// var ficspen = bd.ficheroscompanias
|
||||||
.Where(x => x.Tipo == tipo && x.Version == "6.0")
|
// .Where(x => x.Tipo == tipo && x.Version == "6.0")
|
||||||
.OrderBy(x => x.idFichero)
|
// .OrderBy(x => x.idFichero)
|
||||||
.ToList();
|
// .ToList();
|
||||||
|
|
||||||
foreach (var f in ficspen)
|
// foreach (var f in ficspen)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
// Asumimos ProcesosEIAC_V6 existe y Utilizamos una librería genérica de serialización
|
// // Asumimos ProcesosEIAC_V6 existe y Utilizamos una librería genérica de serialización
|
||||||
dynamic DatosEIAC = tsUtilidades.Utilidades.Deserializa(f.Fichero, Type.GetType("ProcesosEIAC_V6.ProcesosEIAC") ?? typeof(object));
|
// dynamic DatosEIAC = tsUtilidades.Utilidades.Deserializa(f.Fichero, Type.GetType("ProcesosEIAC_V6.ProcesosEIAC") ?? typeof(object));
|
||||||
|
|
||||||
if (DatosEIAC?.Objetos?.Items != null)
|
// if (DatosEIAC?.Objetos?.Items != null)
|
||||||
{
|
// {
|
||||||
IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
// IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
||||||
var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
// var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
||||||
|
|
||||||
foreach (var s in lSins)
|
// foreach (var s in lSins)
|
||||||
{
|
// {
|
||||||
string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
// string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
||||||
var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
// var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
||||||
|
|
||||||
if (seiac != null)
|
// if (seiac != null)
|
||||||
{
|
// {
|
||||||
if (s.DatosSiniestro.Expedientes != null)
|
// if (s.DatosSiniestro.Expedientes != null)
|
||||||
{
|
// {
|
||||||
var yaincorporados = new List<string>();
|
// var yaincorporados = new List<string>();
|
||||||
foreach (var exp in s.DatosSiniestro.Expedientes)
|
// foreach (var exp in s.DatosSiniestro.Expedientes)
|
||||||
{
|
// {
|
||||||
string numeroExpediente = exp.NumeroExpediente;
|
// string numeroExpediente = exp.NumeroExpediente;
|
||||||
if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
// if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
||||||
|
|
||||||
if (!yaincorporados.Contains(numeroExpediente))
|
// if (!yaincorporados.Contains(numeroExpediente))
|
||||||
{
|
// {
|
||||||
var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
// var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
||||||
if (ep == null)
|
// if (ep == null)
|
||||||
{
|
// {
|
||||||
ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
// ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
||||||
seiac.expedientessiniestros_eiac.Add(ep);
|
// seiac.expedientessiniestros_eiac.Add(ep);
|
||||||
}
|
// }
|
||||||
ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
// ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
||||||
ep.ImporteReserva = exp.ImporteReserva;
|
// ep.ImporteReserva = exp.ImporteReserva;
|
||||||
ep.TotalPagos = exp.TotalPagos;
|
// ep.TotalPagos = exp.TotalPagos;
|
||||||
ep.TotalRecobros = exp.TotalRecobros;
|
// ep.TotalRecobros = exp.TotalRecobros;
|
||||||
ep.FechaInicio = exp.FechaInicio;
|
// ep.FechaInicio = exp.FechaInicio;
|
||||||
ep.FechaFin = exp.FechaFin;
|
// ep.FechaFin = exp.FechaFin;
|
||||||
ep.NumeroOrden = exp.NumeroOrden;
|
// ep.NumeroOrden = exp.NumeroOrden;
|
||||||
|
|
||||||
yaincorporados.Add(numeroExpediente);
|
// yaincorporados.Add(numeroExpediente);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// f.FechaProcesado = Now (Comentado en el código original)
|
// // f.FechaProcesado = Now (Comentado en el código original)
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
f.FechaError = DateTime.Now;
|
// f.FechaError = DateTime.Now;
|
||||||
bd.SaveChanges();
|
// bd.SaveChanges();
|
||||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
// tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
43
Servicio Gestion Asegasa/ProcesosConf.cs
Normal file
43
Servicio Gestion Asegasa/ProcesosConf.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using Servicio_Gestion_Asegasa.Procesos;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Servicio_Gestion_Asegasa
|
||||||
|
{
|
||||||
|
public class ProcesosConf
|
||||||
|
{
|
||||||
|
public static Configuracion Conf;
|
||||||
|
|
||||||
|
public static DateTime? HoraUtcUltimaEjecucionProcesos = null;
|
||||||
|
private static bool Procesando;
|
||||||
|
|
||||||
|
public static async Task ProcesarAsync()
|
||||||
|
{
|
||||||
|
if (!Procesando && (HoraUtcUltimaEjecucionProcesos.HasValue == false || DateTime.UtcNow.Subtract(HoraUtcUltimaEjecucionProcesos.Value).TotalSeconds > Conf.SegundosMinimosEntreProcesos))
|
||||||
|
{
|
||||||
|
Procesando = true;
|
||||||
|
HoraUtcUltimaEjecucionProcesos = DateTime.UtcNow;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ProcesosMensajes.EnviaSMSAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
Debug.WriteLine(@"Procesar: EXCEPCIÓN: " + ex.Message + " " + ex.StackTrace);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Procesando = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Quartz" Version="3.15.0" />
|
||||||
|
<PackageReference Include="Serilog.Extensions.Hosting" Version="9.0.0" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||||
<PackageReference Include="tsUtilidades" Version="1.1.10" />
|
<PackageReference Include="tsUtilidades" Version="1.1.10" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
|
using bdAsegasa;
|
||||||
using bdAsegasa.db;
|
using bdAsegasa.db;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
using Quartz;
|
||||||
|
using Quartz.Impl;
|
||||||
using Servicio_Gestion_Asegasa.Procesos;
|
using Servicio_Gestion_Asegasa.Procesos;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
|
||||||
namespace Servicio_Gestion_Asegasa
|
namespace Servicio_Gestion_Asegasa
|
||||||
{
|
{
|
||||||
@@ -8,24 +14,96 @@ namespace Servicio_Gestion_Asegasa
|
|||||||
{
|
{
|
||||||
private readonly ILogger<Worker> _logger;
|
private readonly ILogger<Worker> _logger;
|
||||||
|
|
||||||
public Worker(ILogger<Worker> logger)
|
public Worker(ILogger<Worker> logger, Configuracion Conf)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
ProcesosConf.Conf = Conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||||
{
|
{
|
||||||
|
|
||||||
// await ProcesosMensajes.EnviaSMSAsync();
|
string Mensaje = "Servicio Gestion Asegasa. Versi<73>n: " + tsUtilidades.Utilidades.ExtraeValorCadena(Assembly.GetExecutingAssembly().FullName, "Version");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
if (ProcesosConf.Conf.HoraProcesosDiarios != null)
|
||||||
|
{
|
||||||
|
Mensaje += " Hora Procesos Programados: " + ProcesosConf.Conf.HoraProcesosDiarios;
|
||||||
|
CreaTareaProcesosDiarios();
|
||||||
|
}
|
||||||
|
|
||||||
|
await Logs.A<EFBFBD>adeLogAsync(tsUtilidades.Enumeraciones.TipoLog.InicioServicio, "Inicio " + Mensaje);
|
||||||
|
|
||||||
while (!stoppingToken.IsCancellationRequested)
|
while (!stoppingToken.IsCancellationRequested)
|
||||||
{
|
|
||||||
if (_logger.IsEnabled(LogLevel.Information))
|
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
if (_logger.IsEnabled(LogLevel.Information))
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Servicio en ejecuci<63>n: {time}", DateTimeOffset.Now);
|
||||||
|
//Creo q aqui se deberia llamar a los servicios
|
||||||
|
}
|
||||||
|
await ProcesosConf.ProcesarAsync();
|
||||||
|
await System.Threading.Tasks.Task.Delay(1000 * 60 * 5, stoppingToken);
|
||||||
}
|
}
|
||||||
await Task.Delay(1000, stoppingToken);
|
|
||||||
}
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{
|
||||||
|
// Logs.A<>adeLog(tsUtilidades.Enumeraciones.TipoLog.FinServicio, "Detenci<63>n " + Mensaje);
|
||||||
|
// When the stopping token is canceled, for example, a call made from services.msc,
|
||||||
|
// we shouldn't exit with a non-zero exit code. In other words, this is expected...
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "{Message}", ex.Message);
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void CreaTareaProcesosDiarios()
|
||||||
|
{
|
||||||
|
ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
|
||||||
|
IScheduler scheduler = schedulerFactory.GetScheduler().Result;
|
||||||
|
scheduler.Start().Wait();
|
||||||
|
// Crear un trabajo
|
||||||
|
IJobDetail job = JobBuilder.Create<TareasProgramadas>()
|
||||||
|
.WithIdentity("TareasProgramadas", "Grupo1")
|
||||||
|
.Build();
|
||||||
|
// Crear un trigger que se ejecute diariamente a una hora espec<65>fica
|
||||||
|
|
||||||
|
|
||||||
|
int Hora = int.Parse(ProcesosConf.Conf.HoraProcesosDiarios.Split(":")[0]);
|
||||||
|
int Minutos = int.Parse(ProcesosConf.Conf.HoraProcesosDiarios.Split(":")[1]);
|
||||||
|
Quartz.ITrigger trigger = Quartz.TriggerBuilder.Create()
|
||||||
|
.WithIdentity("TareasProgramadas", "Grupo1")
|
||||||
|
.StartAt(DateBuilder.TodayAt(Hora, Minutos, 0))
|
||||||
|
.WithSimpleSchedule(x => x
|
||||||
|
.WithIntervalInHours(24)
|
||||||
|
.RepeatForever())
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
// Programar el trabajo con el trigger
|
||||||
|
scheduler.ScheduleJob(job, trigger).Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class TareasProgramadas : IJob
|
||||||
|
{
|
||||||
|
public 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
{
|
{
|
||||||
|
"Configuracion": {
|
||||||
|
"SegundosMinimosEntreProcesos": "60",
|
||||||
|
"HoraProcesosDiarios": "06:30",
|
||||||
|
"NombreConexionBD": "Producción Remoto"
|
||||||
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"TsNotificaciones": {
|
"TsNotificaciones": {
|
||||||
//"ApiUrl": "http://192.168.41.32:5000/", prod
|
//"ApiUrl": "http://192.168.41.32:5000/", prod
|
||||||
"ApiUrl": "https://catcher.tecnosis.online",
|
"ApiUrl": "https://catcher.tecnosis.online",
|
||||||
"IdAplicacion": 2,
|
"IdAplicacion": 2,
|
||||||
"ApiKey": "0a47a1eada0143278b9d4de4e8911100"
|
"ApiKey": "0a47a1eada0143278b9d4de4e8911100"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user