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.IO;
|
||||
using System.Linq;
|
||||
using System.IO.Compression;
|
||||
using System.Collections.Generic;
|
||||
using Renci.SshNet;
|
||||
using Renci.SshNet.Common;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
using bdAsegasa.db;
|
||||
using tsUtilidades.Enumeraciones;
|
||||
//using System;
|
||||
//using System.IO;
|
||||
//using System.Linq;
|
||||
//using System.IO.Compression;
|
||||
//using System.Collections.Generic;
|
||||
//using Renci.SshNet;
|
||||
//using Renci.SshNet.Common;
|
||||
//using tsUtilidades;
|
||||
//using tsUtilidades.Extensiones;
|
||||
//using bdAsegasa.db;
|
||||
//using tsUtilidades.Enumeraciones;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosCaser
|
||||
{
|
||||
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||
//{
|
||||
// public class ProcesosCaser
|
||||
// {
|
||||
|
||||
public static async Task GuardarEnBDFicherosDisponiblesSFTPAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var bd = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
||||
using (var bdtmp = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
||||
{
|
||||
var idCaser = bd.companias.First(x => x.Codigo == "0017").idCompania;
|
||||
// public static async Task GuardarEnBDFicherosDisponiblesSFTPAsync()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using (var bd = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
||||
// using (var bdtmp = bdAsegasa.db.gestionasegasaEntities.NuevoContextoCN())
|
||||
// {
|
||||
// var idCaser = bd.companias.First(x => x.Codigo == "0017").idCompania;
|
||||
|
||||
var keybAuth = new KeyboardInteractiveAuthenticationMethod("ca071106");
|
||||
keybAuth.AuthenticationPrompt += HandleKeyEvent;
|
||||
var conInfo = new ConnectionInfo("ftp.caser.es", 22, "ca071106", keybAuth);
|
||||
// var keybAuth = new KeyboardInteractiveAuthenticationMethod("ca071106");
|
||||
// keybAuth.AuthenticationPrompt += HandleKeyEvent;
|
||||
// var conInfo = new ConnectionInfo("ftp.caser.es", 22, "ca071106", keybAuth);
|
||||
|
||||
using (var sftp = new SftpClient(conInfo))
|
||||
{
|
||||
sftp.Connect();
|
||||
var lf = sftp.ListDirectory("ca071106").Where(x => x.IsDirectory == false);
|
||||
// using (var sftp = new SftpClient(conInfo))
|
||||
// {
|
||||
// sftp.Connect();
|
||||
// var lf = sftp.ListDirectory("ca071106").Where(x => x.IsDirectory == false);
|
||||
|
||||
foreach (var F in lf)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (F.Name.StartsWith("EIAC_REC_") || F.Name.StartsWith("EIAC_POL_") || F.Name.StartsWith("EIAC_SIN_"))
|
||||
{
|
||||
string nomfic;
|
||||
bool Eszip;
|
||||
if (F.Name.EndsWith(".txt"))
|
||||
{
|
||||
nomfic = F.Name.Substring(0, F.Name.Length - 4);
|
||||
Eszip = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
nomfic = Path.ChangeExtension(F.Name, "xml");
|
||||
Eszip = true;
|
||||
}
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
sftp.DownloadFile(F.FullName, ms);
|
||||
ms.Position = 0;
|
||||
// foreach (var F in lf)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (F.Name.StartsWith("EIAC_REC_") || F.Name.StartsWith("EIAC_POL_") || F.Name.StartsWith("EIAC_SIN_"))
|
||||
// {
|
||||
// string nomfic;
|
||||
// bool Eszip;
|
||||
// if (F.Name.EndsWith(".txt"))
|
||||
// {
|
||||
// nomfic = F.Name.Substring(0, F.Name.Length - 4);
|
||||
// Eszip = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// nomfic = Path.ChangeExtension(F.Name, "xml");
|
||||
// Eszip = true;
|
||||
// }
|
||||
// using (var ms = new MemoryStream())
|
||||
// {
|
||||
// sftp.DownloadFile(F.FullName, ms);
|
||||
// ms.Position = 0;
|
||||
|
||||
byte[] b;
|
||||
if (Eszip)
|
||||
{
|
||||
using (var zip = new ZipArchive(ms, ZipArchiveMode.Read))
|
||||
{
|
||||
var firstEntry = zip.Entries.First();
|
||||
using (var msxml = new MemoryStream())
|
||||
{
|
||||
using (var entryStream = firstEntry.Open())
|
||||
{
|
||||
entryStream.CopyTo(msxml);
|
||||
}
|
||||
msxml.Position = 0;
|
||||
b = msxml.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
b = ms.ToArray();
|
||||
}
|
||||
// byte[] b;
|
||||
// if (Eszip)
|
||||
// {
|
||||
// using (var zip = new ZipArchive(ms, ZipArchiveMode.Read))
|
||||
// {
|
||||
// var firstEntry = zip.Entries.First();
|
||||
// using (var msxml = new MemoryStream())
|
||||
// {
|
||||
// using (var entryStream = firstEntry.Open())
|
||||
// {
|
||||
// entryStream.CopyTo(msxml);
|
||||
// }
|
||||
// msxml.Position = 0;
|
||||
// b = msxml.ToArray();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// b = ms.ToArray();
|
||||
// }
|
||||
|
||||
var sha1 = tsUtilidades.crypt.SHA1(b);
|
||||
if (bdtmp.ficheroscompanias.Any(x => x.SHA1 == sha1 && x.idCompania == idCaser) == false)
|
||||
{
|
||||
var nf = new bdAsegasa.db.ficheroscompanias();
|
||||
nf.FechaCreacion = DateTime.Now;
|
||||
nf.idCompania = idCaser;
|
||||
nf.Fichero = b;
|
||||
nf.NombreFichero = nomfic;
|
||||
nf.SHA1 = sha1;
|
||||
// var sha1 = tsUtilidades.crypt.SHA1(b);
|
||||
// if (bdtmp.ficheroscompanias.Any(x => x.SHA1 == sha1 && x.idCompania == idCaser) == false)
|
||||
// {
|
||||
// var nf = new bdAsegasa.db.ficheroscompanias();
|
||||
// nf.FechaCreacion = DateTime.Now;
|
||||
// nf.idCompania = idCaser;
|
||||
// nf.Fichero = b;
|
||||
// nf.NombreFichero = nomfic;
|
||||
// nf.SHA1 = sha1;
|
||||
|
||||
switch (F.Name.Split('_')[1])
|
||||
{
|
||||
case "REC":
|
||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.RECIBOS_EIAC;
|
||||
break;
|
||||
case "POL":
|
||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.POLIZAS_EIAC;
|
||||
break;
|
||||
case "SIN":
|
||||
nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
break;
|
||||
}
|
||||
bd.ficheroscompanias.Add(nf);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
sftp.RenameFile(F.FullName, F.FullName.Replace(F.Name, "PROCESADOS/" + F.Name));
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
throw new Exception(EX.Message + " Fichero: " + F.FullName, EX);
|
||||
}
|
||||
}
|
||||
sftp.Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception EX)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GuardarEnBDFicherosDisponibles CASER", EX.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// switch (F.Name.Split('_')[1])
|
||||
// {
|
||||
// case "REC":
|
||||
// nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.RECIBOS_EIAC;
|
||||
// break;
|
||||
// case "POL":
|
||||
// nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.POLIZAS_EIAC;
|
||||
// break;
|
||||
// case "SIN":
|
||||
// nf.Tipo = (int)bdAsegasa.db.ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
// break;
|
||||
// }
|
||||
// bd.ficheroscompanias.Add(nf);
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// sftp.RenameFile(F.FullName, F.FullName.Replace(F.Name, "PROCESADOS/" + F.Name));
|
||||
// }
|
||||
// catch (Exception EX)
|
||||
// {
|
||||
// throw new Exception(EX.Message + " Fichero: " + F.FullName, EX);
|
||||
// }
|
||||
// }
|
||||
// sftp.Disconnect();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception EX)
|
||||
// {
|
||||
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GuardarEnBDFicherosDisponibles CASER", EX.Message, tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
private static void HandleKeyEvent(object? sender, AuthenticationPromptEventArgs e)
|
||||
{
|
||||
foreach (var prompt in e.Prompts)
|
||||
{
|
||||
if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
|
||||
{
|
||||
prompt.Response = "As69gs73";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// private static void HandleKeyEvent(object? sender, AuthenticationPromptEventArgs e)
|
||||
// {
|
||||
// foreach (var prompt in e.Prompts)
|
||||
// {
|
||||
// if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
|
||||
// {
|
||||
// prompt.Response = "As69gs73";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,139 +1,139 @@
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
//using bdAsegasa;
|
||||
//using bdAsegasa.db;
|
||||
//using bdAsegasa.dbcontext;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosContabilidad
|
||||
{
|
||||
public static void CompruebaContabilidad()
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
string sDestinatarios = "sevilla@tecnosis.net";
|
||||
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||
//{
|
||||
// public class ProcesosContabilidad
|
||||
// {
|
||||
// public static void CompruebaContabilidad()
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
// string sDestinatarios = "sevilla@tecnosis.net";
|
||||
|
||||
var asis = bd.asientos.Where(x =>
|
||||
x.Fecha < x.idEjercicioNavigation.FechaInicio ||
|
||||
x.Fecha > x.idEjercicioNavigation.FechaFin ||
|
||||
x.apuntes.Any(y => y.idCuentaNavigation.idEjercicio != x.idEjercicio)
|
||||
).ToList();
|
||||
// var asis = bd.asientos.Where(x =>
|
||||
// x.Fecha < x.idEjercicioNavigation.FechaInicio ||
|
||||
// x.Fecha > x.idEjercicioNavigation.FechaFin ||
|
||||
// x.apuntes.Any(y => y.idCuentaNavigation.idEjercicio != x.idEjercicio)
|
||||
// ).ToList();
|
||||
|
||||
if (asis.Count > 0)
|
||||
{
|
||||
var lFechaErronea = new List<asientos>();
|
||||
foreach (var asi in asis)
|
||||
{
|
||||
var ej = bd.ejercicioscontables.FirstOrDefault(x =>
|
||||
x.FechaCierre == null &&
|
||||
(x.FechaInicio <= asi.Fecha && x.FechaFin >= asi.Fecha)
|
||||
);
|
||||
// if (asis.Count > 0)
|
||||
// {
|
||||
// var lFechaErronea = new List<asientos>();
|
||||
// foreach (var asi in asis)
|
||||
// {
|
||||
// var ej = bd.ejercicioscontables.FirstOrDefault(x =>
|
||||
// x.FechaCierre == null &&
|
||||
// (x.FechaInicio <= asi.Fecha && x.FechaFin >= asi.Fecha)
|
||||
// );
|
||||
|
||||
if (ej != null)
|
||||
{
|
||||
lFechaErronea.Add(asi);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asi.idEjercicio != ej.idEjercicio)
|
||||
{
|
||||
asi.idEjercicio = ej.idEjercicio;
|
||||
}
|
||||
foreach (var ap in asi.apuntes)
|
||||
{
|
||||
ap.idCuenta = bd.cuentas.First(x => x.NumeroCuenta == ap.idCuentaNavigation.NumeroCuenta && x.idEjercicio == asi.idEjercicio).idCuenta;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (ej != null)
|
||||
// {
|
||||
// lFechaErronea.Add(asi);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (asi.idEjercicio != ej.idEjercicio)
|
||||
// {
|
||||
// asi.idEjercicio = ej.idEjercicio;
|
||||
// }
|
||||
// foreach (var ap in asi.apuntes)
|
||||
// {
|
||||
// ap.idCuenta = bd.cuentas.First(x => x.NumeroCuenta == ap.idCuentaNavigation.NumeroCuenta && x.idEjercicio == asi.idEjercicio).idCuenta;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
bd.SaveChanges();
|
||||
// bd.SaveChanges();
|
||||
|
||||
if (lFechaErronea.Count > 0)
|
||||
{
|
||||
var lae = lFechaErronea.Select(x => new
|
||||
{
|
||||
NumeroAsiento = x.idAsiento,
|
||||
Fecha = x.Fecha,
|
||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
}).ToList();
|
||||
// if (lFechaErronea.Count > 0)
|
||||
// {
|
||||
// var lae = lFechaErronea.Select(x => new
|
||||
// {
|
||||
// NumeroAsiento = x.idAsiento,
|
||||
// Fecha = x.Fecha,
|
||||
// Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
// }).ToList();
|
||||
|
||||
byte[] fe = tsUtilidades.Excel.IEnumerableAExcel(lae);
|
||||
// byte[] fe = tsUtilidades.Excel.IEnumerableAExcel(lae);
|
||||
|
||||
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 (Se corrige el asiento)",
|
||||
cta, fe, "AsientosFechaErronea-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
"Asientos Con Fecha Erronea " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
sDestinatarios);
|
||||
// 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 (Se corrige el asiento)",
|
||||
// cta, fe, "AsientosFechaErronea-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
// "Asientos Con Fecha Erronea " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// sDestinatarios);
|
||||
|
||||
var idsErrores = lae.Select(y => y.NumeroAsiento).ToList();
|
||||
asis = asis.Where(x => !idsErrores.Contains(x.idAsiento)).ToList();
|
||||
}
|
||||
// var idsErrores = lae.Select(y => y.NumeroAsiento).ToList();
|
||||
// asis = asis.Where(x => !idsErrores.Contains(x.idAsiento)).ToList();
|
||||
// }
|
||||
|
||||
var la = asis.Select(x => new
|
||||
{
|
||||
NumeroAsiento = x.idAsiento,
|
||||
Fecha = x.Fecha,
|
||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
}).ToList();
|
||||
// var la = asis.Select(x => new
|
||||
// {
|
||||
// NumeroAsiento = x.idAsiento,
|
||||
// Fecha = x.Fecha,
|
||||
// Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
// }).ToList();
|
||||
|
||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
// byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
|
||||
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)",
|
||||
cta, f, "ApuntesIncoherentes-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
"Apuntes Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
sDestinatarios);
|
||||
}
|
||||
// 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)",
|
||||
// cta, f, "ApuntesIncoherentes-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
// "Apuntes Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// 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)
|
||||
{
|
||||
var la = asis.Select(x => new
|
||||
{
|
||||
NumeroAsiento = x.idAsiento,
|
||||
Fecha = x.Fecha,
|
||||
Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
}).ToList();
|
||||
// if (asis.Count > 0)
|
||||
// {
|
||||
// var la = asis.Select(x => new
|
||||
// {
|
||||
// NumeroAsiento = x.idAsiento,
|
||||
// Fecha = x.Fecha,
|
||||
// Ejercicio = x.idEjercicioNavigation.Descripcion
|
||||
// }).ToList();
|
||||
|
||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
// byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
"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",
|
||||
"Asientos Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
sDestinatarios);
|
||||
}
|
||||
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
// "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",
|
||||
// "Asientos Incoherentes " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// 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)
|
||||
{
|
||||
var la = asis.Select(x => new
|
||||
{
|
||||
NumeroAsiento = x.idAsiento,
|
||||
Fecha = x.Fecha,
|
||||
Ejercicio = x.idEjercicioNavigation.Descripcion,
|
||||
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)
|
||||
}).ToList();
|
||||
// if (asis.Count > 0)
|
||||
// {
|
||||
// var la = asis.Select(x => new
|
||||
// {
|
||||
// NumeroAsiento = x.idAsiento,
|
||||
// Fecha = x.Fecha,
|
||||
// Ejercicio = x.idEjercicioNavigation.Descripcion,
|
||||
// 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)
|
||||
// }).ToList();
|
||||
|
||||
byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
// byte[] f = tsUtilidades.Excel.IEnumerableAExcel(la);
|
||||
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
"Existen asientos descuadrados",
|
||||
"Existen asientos descuadrados",
|
||||
cta, f, "AsientosDescuadrados-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
"Asientos Descuadrados " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
sDestinatarios);
|
||||
}
|
||||
// bdAsegasa.db.correos.GeneraRegistroCorreoConAdjunto(bd,
|
||||
// "Existen asientos descuadrados",
|
||||
// "Existen asientos descuadrados",
|
||||
// cta, f, "AsientosDescuadrados-" + DateTime.Now.ToString("yyyy-MM-dd") + ".xlsx",
|
||||
// "Asientos Descuadrados " + DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
// 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.db;
|
||||
using bdAsegasa.dbcontext;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
//using bdAsegasa;
|
||||
//using bdAsegasa.db;
|
||||
//using bdAsegasa.dbcontext;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
//using System.Linq;
|
||||
//using tsUtilidades;
|
||||
//using tsUtilidades.Extensiones;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosGestionesVarias
|
||||
{
|
||||
public static async Task GeneraCorreoRestablecimientoContraseñaAsync()
|
||||
{
|
||||
string sProceso = "GeneraCorreoRestablecimientoContraseña";
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto(); ;
|
||||
var idTgag = bd.enumeraciones.First(x => x.Codigo == "TGV.CCAG").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 urlaseg = bd.enumeraciones.First(x => x.Codigo == "CONF.URLWC").ValorAlfabeticoLargo;
|
||||
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||
//{
|
||||
// public class ProcesosGestionesVarias
|
||||
// {
|
||||
// public static async Task GeneraCorreoRestablecimientoContraseñaAsync()
|
||||
// {
|
||||
// string sProceso = "GeneraCorreoRestablecimientoContraseña";
|
||||
// try
|
||||
// {
|
||||
// var bd = tscgestionasegasa.NuevoContexto(); ;
|
||||
// var idTgag = bd.enumeraciones.First(x => x.Codigo == "TGV.CCAG").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 urlaseg = bd.enumeraciones.First(x => x.Codigo == "CONF.URLWC").ValorAlfabeticoLargo;
|
||||
|
||||
foreach (var g in gess)
|
||||
{
|
||||
string sDestinatario;
|
||||
string sAsunto;
|
||||
// foreach (var g in gess)
|
||||
// {
|
||||
// string sDestinatario;
|
||||
// string sAsunto;
|
||||
|
||||
if (g.idTipo == idTgag)
|
||||
{
|
||||
var ag = bd.agentes.First(x => x.idAgente != 0);
|
||||
sDestinatario = ag.Email;
|
||||
sAsunto = "Solicitud de cambio de contraseña al Agente " + ag.Nombre + " (Nº " + ag.Codigo + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
var sag = bd.subagentes.First(x => x.idAgente != 0);
|
||||
sDestinatario = sag.Email;
|
||||
sAsunto = "Solicitud de cambio de contraseña al SubAgente " + sag.Nombre + " (Nº " + sag.idAgenteNavigation.Codigo + "-" + sag.Codigo + ")";
|
||||
}
|
||||
// if (g.idTipo == idTgag)
|
||||
// {
|
||||
// var ag = bd.agentes.First(x => x.idAgente != 0);
|
||||
// sDestinatario = ag.Email;
|
||||
// sAsunto = "Solicitud de cambio de contraseña al Agente " + ag.Nombre + " (Nº " + ag.Codigo + ")";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var sag = bd.subagentes.First(x => x.idAgente != 0);
|
||||
// sDestinatario = sag.Email;
|
||||
// sAsunto = "Solicitud de cambio de contraseña al SubAgente " + sag.Nombre + " (Nº " + sag.idAgenteNavigation.Codigo + "-" + sag.Codigo + ")";
|
||||
// }
|
||||
|
||||
if (Directory.Exists(@"c:\tecnosis.tfs"))
|
||||
{
|
||||
sDestinatario = "sevilla@tecnosis.net";
|
||||
}
|
||||
// if (Directory.Exists(@"c:\tecnosis.tfs"))
|
||||
// {
|
||||
// sDestinatario = "sevilla@tecnosis.net";
|
||||
// }
|
||||
|
||||
if (sDestinatario.EsEmailValido())
|
||||
{
|
||||
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;
|
||||
// if (sDestinatario.EsEmailValido())
|
||||
// {
|
||||
// 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 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>";
|
||||
// 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>";
|
||||
|
||||
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);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FechaProcesado = DateTime.Now;
|
||||
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);
|
||||
// g.idCorreo = bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, cta, sDestinatario);
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// g.FechaProcesado = DateTime.Now;
|
||||
// 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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreoRestablecimientoContraseña.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En GeneraCorreoRestablecimientoContraseña.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static async Task EnviaAlertaCredencialesProximasACaducarAsync()
|
||||
{
|
||||
string sProceso = "EnviaAlertaCredencialesProximasACaducar";
|
||||
try
|
||||
{
|
||||
var bd = tscgestionasegasa.NuevoContexto();
|
||||
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;
|
||||
// public static async Task EnviaAlertaCredencialesProximasACaducarAsync()
|
||||
// {
|
||||
// string sProceso = "EnviaAlertaCredencialesProximasACaducar";
|
||||
// try
|
||||
// {
|
||||
// var bd = tscgestionasegasa.NuevoContexto();
|
||||
// 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;
|
||||
|
||||
foreach (var c in ctaspc)
|
||||
{
|
||||
string sAsunto;
|
||||
sAsunto = "Crecenciales de la cuenta de correo " + c.Remitente + " próxima a caducar.";
|
||||
// foreach (var c in ctaspc)
|
||||
// {
|
||||
// string sAsunto;
|
||||
// sAsunto = "Crecenciales de la cuenta de correo " + c.Remitente + " próxima a caducar.";
|
||||
|
||||
if (Directory.Exists(@"c:\tecnosis.tfs"))
|
||||
{
|
||||
dest = "sevilla@tecnosis.net";
|
||||
}
|
||||
// if (Directory.Exists(@"c:\tecnosis.tfs"))
|
||||
// {
|
||||
// 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.";
|
||||
bdAsegasa.db.correos.GeneraRegistroCorreo(bd, sAsunto, sCuerpo, c, dest);
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await tsUtilidades.TsNotificacionesClient.RegistrarAsync("En EnviaAlertaCredencialesProximasACaducar.", "Rutina: GeneraCorreoRestablecimientoContraseña. " + " " + ex.Message, TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// 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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using tsUtilidades;
|
||||
using tsUtilidades.Extensiones;
|
||||
using tsUtilidades.Enumeraciones;
|
||||
using bdAsegasa.db;
|
||||
using bdAsegasa.dbcontext;
|
||||
using bdAsegasa.Presupuestos;
|
||||
using bdAsegasa.Informes;
|
||||
using bdAsegasa;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.IO;
|
||||
//using System.Linq;
|
||||
//using System.Threading.Tasks;
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
//using tsUtilidades;
|
||||
//using tsUtilidades.Extensiones;
|
||||
//using tsUtilidades.Enumeraciones;
|
||||
//using bdAsegasa.db;
|
||||
//using bdAsegasa.dbcontext;
|
||||
//using bdAsegasa.Presupuestos;
|
||||
//using bdAsegasa.Informes;
|
||||
//using bdAsegasa;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosRecibos
|
||||
{
|
||||
public static async Task EstableceFechaPagoRecibosAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd =tscgestionasegasa.NuevoContexto();
|
||||
var idtippag = bd.enumeraciones.First(x => x.Codigo == "TIPP.AG").idEnumeracion;
|
||||
var idtipppe = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||
var idSitPag = bd.enumeraciones.First(x => x.Codigo == "SITR.PA").idEnumeracion;
|
||||
var idE = bd.enumeraciones.First(x => x.Codigo == "TRC.E").idEnumeracion;
|
||||
var idES = bd.enumeraciones.First(x => x.Codigo == "TRC.ES").idEnumeracion;
|
||||
var idEX = bd.enumeraciones.First(x => x.Codigo == "TRC.EX").idEnumeracion;
|
||||
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||
//{
|
||||
// public class ProcesosRecibos
|
||||
// {
|
||||
// public static async Task EstableceFechaPagoRecibosAsync()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd =tscgestionasegasa.NuevoContexto();
|
||||
// var idtippag = bd.enumeraciones.First(x => x.Codigo == "TIPP.AG").idEnumeracion;
|
||||
// var idtipppe = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||
// var idSitPag = bd.enumeraciones.First(x => x.Codigo == "SITR.PA").idEnumeracion;
|
||||
// var idE = bd.enumeraciones.First(x => x.Codigo == "TRC.E").idEnumeracion;
|
||||
// var idES = bd.enumeraciones.First(x => x.Codigo == "TRC.ES").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 && (
|
||||
(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();
|
||||
// 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.idTipo == idE || r.idTipo == idES || r.idTipo == idEX ? 15 : r.NumeroDiasRemesaPago)))).ToList();
|
||||
|
||||
var lrp = new List<bdAsegasa.db.recibos>();
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
var Cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
Cont.ValorNumerico1 += 1;
|
||||
bd.SaveChanges();
|
||||
// var lrp = new List<bdAsegasa.db.recibos>();
|
||||
// if (recs.Count > 0)
|
||||
// {
|
||||
// var Cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
// Cont.ValorNumerico1 += 1;
|
||||
// bd.SaveChanges();
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
r.FechaPago = hoy;
|
||||
r.idSituacion = idSitPag;
|
||||
lrp.Add(r);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
await bd.Database.ExecuteSqlRawAsync($"UPDATE registrosactualizados SET FechaCreacion=Now() where FechaCreacion Is null and NumeroGeneracion={Cont.ValorNumerico1};");
|
||||
}
|
||||
// foreach (var r in recs)
|
||||
// {
|
||||
// r.FechaPago = hoy;
|
||||
// r.idSituacion = idSitPag;
|
||||
// lrp.Add(r);
|
||||
// }
|
||||
// bd.SaveChanges();
|
||||
// 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 cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
// var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
var lr = lrp.Select(x => new
|
||||
{
|
||||
x.CodigoRecibo,
|
||||
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
||||
NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
||||
Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
||||
BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
||||
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
||||
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre
|
||||
}).ToList();
|
||||
// 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);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var lr = lrp.Select(x => new
|
||||
// {
|
||||
// x.CodigoRecibo,
|
||||
// NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
||||
// NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
||||
// Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
||||
// BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
||||
// Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
||||
// Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre
|
||||
// }).ToList();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibos.", $"Rutina: EstableceFechaPagoRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibos.", $"Rutina: EstableceFechaPagoRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static async Task EstableceFechaPagoRecibosAGAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Assuming this method exists in the C# domain model for recibos
|
||||
bdAsegasa.db.recibos.ContabilizaRecibosPagoAG();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibosAG.", $"Rutina: EstableceFechaPagoRecibosAG. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// public static async Task EstableceFechaPagoRecibosAGAsync()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// // Assuming this method exists in the C# domain model for recibos
|
||||
// bdAsegasa.db.recibos.ContabilizaRecibosPagoAG();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En EstableceFechaPagoRecibosAG.", $"Rutina: EstableceFechaPagoRecibosAG. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static async Task EstableceFechaBajaRecibosAsync(int DiasLimiteCartaImperativo = -10)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
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 idFP = bd.enumeraciones.First(x => x.Codigo == "CABA.FP").idEnumeracion;
|
||||
var confEmail = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var sDestinatarios = $"{confEmail};lolaherrera@asegasa.es";
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
// public static async Task EstableceFechaBajaRecibosAsync(int DiasLimiteCartaImperativo = -10)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// 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 idFP = bd.enumeraciones.First(x => x.Codigo == "CABA.FP").idEnumeracion;
|
||||
// var confEmail = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
// var sDestinatarios = $"{confEmail};lolaherrera@asegasa.es";
|
||||
// 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()
|
||||
.Where(x => x.LimiteEfectoSobrePasadoFechaBaja && idtipS.Contains(x.idTipoPago.Value)).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();
|
||||
|
||||
enumeraciones? cont = null;
|
||||
int Numrec = 0;
|
||||
var hoy = DateOnly.FromDateTime(DateTime.Today);
|
||||
// enumeraciones? cont = null;
|
||||
// int Numrec = 0;
|
||||
// var hoy = DateOnly.FromDateTime(DateTime.Today);
|
||||
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
cont.ValorNumerico1 += 1;
|
||||
bd.SaveChanges();
|
||||
// if (recs.Count > 0)
|
||||
// {
|
||||
// cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
// cont.ValorNumerico1 += 1;
|
||||
// bd.SaveChanges();
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
Numrec += 1;
|
||||
r.FechaBaja = hoy;
|
||||
r.idCausaBaja = idFP;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
// foreach (var r in recs)
|
||||
// {
|
||||
// Numrec += 1;
|
||||
// r.FechaBaja = hoy;
|
||||
// r.idCausaBaja = idFP;
|
||||
// }
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
|
||||
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()
|
||||
.Where(x => x.FechaDevolucionBanco.Value <= FechaLimiteDev && !idtipS.Contains(x.idTipoPago.Value)).ToList();
|
||||
// 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()
|
||||
// .Where(x => x.FechaDevolucionBanco.Value <= FechaLimiteDev && !idtipS.Contains(x.idTipoPago.Value)).ToList();
|
||||
|
||||
|
||||
if (recsdb.Count > 0)
|
||||
{
|
||||
if (cont == null)
|
||||
{
|
||||
cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
cont.ValorNumerico1 += 1;
|
||||
bd.SaveChanges();
|
||||
}
|
||||
foreach (var r in recsdb)
|
||||
{
|
||||
Numrec += 1;
|
||||
r.FechaBaja = hoy;
|
||||
r.idCausaBaja = idFP;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
// if (recsdb.Count > 0)
|
||||
// {
|
||||
// if (cont == null)
|
||||
// {
|
||||
// cont = bd.enumeraciones.First(x => x.Codigo == "CONT.NUMGEN");
|
||||
// cont.ValorNumerico1 += 1;
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// foreach (var r in recsdb)
|
||||
// {
|
||||
// Numrec += 1;
|
||||
// r.FechaBaja = hoy;
|
||||
// r.idCausaBaja = idFP;
|
||||
// }
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
|
||||
if (cont != null)
|
||||
{
|
||||
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
|
||||
{
|
||||
x.CodigoRecibo,
|
||||
NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
||||
NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
||||
Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
||||
BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
||||
Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
||||
Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
|
||||
FormaPago = x.idTipoPagoNavigation?.Descripcion,
|
||||
Agente = x.idPolizaNavigation.idAgenteNavigation?.CodigoYNombre
|
||||
}).ToList();
|
||||
// if (cont != null)
|
||||
// {
|
||||
// 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
|
||||
// {
|
||||
// x.CodigoRecibo,
|
||||
// NumeroPoliza = x.idPolizaNavigation.NumeroPoliza,
|
||||
// NumeroSuplemento = x.idPolizaNavigation.NumeroSuplemento,
|
||||
// Tomador = x.idPolizaNavigation.Tomador?.RazonSocial,
|
||||
// BinesAsegurados = x.idPolizaNavigation.BienesAsegurados,
|
||||
// Ramo = x.idPolizaNavigation.idRamoNavigation.Descripcion,
|
||||
// Compañía = x.idPolizaNavigation.idCompaniaNavigation.Nombre,
|
||||
// FormaPago = x.idTipoPagoNavigation?.Descripcion,
|
||||
// Agente = x.idPolizaNavigation.idAgenteNavigation?.CodigoYNombre
|
||||
// }).ToList();
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En EstableceFechaBajaRecibos.", $"Rutina: EstableceFechaBajaRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En EstableceFechaBajaRecibos.", $"Rutina: EstableceFechaBajaRecibos. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static async Task GeneraApuntesContadoAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
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 idTippPE = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||
var idCbPGO = bd.enumeraciones.First(x => x.Codigo == "CABA.PGO").idEnumeracion;
|
||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
// public static async Task GeneraApuntesContadoAsync()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// 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 idTippPE = bd.enumeraciones.First(x => x.Codigo == "TIPP.PE").idEnumeracion;
|
||||
// var idCbPGO = bd.enumeraciones.First(x => x.Codigo == "CABA.PGO").idEnumeracion;
|
||||
// var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
// 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)
|
||||
{
|
||||
var recsnv = recs.Where(x => x.idTipoPago == idTippPE && x.CuentaContableTomadorErronea).ToList();
|
||||
if (recsnv.Any())
|
||||
{
|
||||
var lre = recsnv.Select(x => new
|
||||
{
|
||||
x.CodigoRecibo,
|
||||
x.NumeroPoliza,
|
||||
x.NumeroSuplemento,
|
||||
x.Tomador,
|
||||
BinesAsegurados = x.BienesAsegurados,
|
||||
x.Ramo,
|
||||
x.Compania
|
||||
}).ToList();
|
||||
// if (recs.Count > 0)
|
||||
// {
|
||||
// var recsnv = recs.Where(x => x.idTipoPago == idTippPE && x.CuentaContableTomadorErronea).ToList();
|
||||
// if (recsnv.Any())
|
||||
// {
|
||||
// var lre = recsnv.Select(x => new
|
||||
// {
|
||||
// x.CodigoRecibo,
|
||||
// x.NumeroPoliza,
|
||||
// x.NumeroSuplemento,
|
||||
// x.Tomador,
|
||||
// BinesAsegurados = x.BienesAsegurados,
|
||||
// x.Ramo,
|
||||
// x.Compania
|
||||
// }).ToList();
|
||||
|
||||
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);
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
|
||||
recs = recs.Where(x => !x.CuentaContableTomadorErronea).ToList();
|
||||
if (recs.Count > 0)
|
||||
{
|
||||
bdAsegasa.db.asientos.GeneraAsientoRecibosContado(bd, recs, DelegadoErrorNoControlado);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraApuntesContado.", $"Rutina: GeneraApuntesContado. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// recs = recs.Where(x => !x.CuentaContableTomadorErronea).ToList();
|
||||
// if (recs.Count > 0)
|
||||
// {
|
||||
// bdAsegasa.db.asientos.GeneraAsientoRecibosContado(bd, recs, DelegadoErrorNoControlado);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En GeneraApuntesContado.", $"Rutina: GeneraApuntesContado. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
private static void DelegadoErrorNoControlado(string Aplicacion, Exception ex)
|
||||
{
|
||||
_ = TsNotificacionesClient.RegistrarAsync($"En {Aplicacion}", $"Rutina: {Aplicacion} {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
// private static void DelegadoErrorNoControlado(string Aplicacion, Exception ex)
|
||||
// {
|
||||
// _ = TsNotificacionesClient.RegistrarAsync($"En {Aplicacion}", $"Rutina: {Aplicacion} {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
|
||||
public static async Task CompruebaRecibosNoRemesadosAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var FechaLimite = DateOnly.FromDateTime(DateTime.Today.AddDays(-10));
|
||||
var hoy = DateOnly.FromDateTime(DateTime.Today);
|
||||
// public static async Task CompruebaRecibosNoRemesadosAsync()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var FechaLimite = DateOnly.FromDateTime(DateTime.Today.AddDays(-10));
|
||||
// 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)
|
||||
{
|
||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
// if (recs.Count > 0)
|
||||
// {
|
||||
// var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCONTA").ValorAlfabeticoLargo;
|
||||
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
var lr = recs.Select(x => x.AListadoGestionCobro()).ToList();
|
||||
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);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En CompruebaRecibosNoRemesados.", $"Rutina: CompruebaRecibosNoRemesados. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// var lr = recs.Select(x => x.AListadoGestionCobro()).ToList();
|
||||
// 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);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En CompruebaRecibosNoRemesados.", $"Rutina: CompruebaRecibosNoRemesados. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static async Task CompruebaCarteraPerdidaAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var ultl = bd.enumeraciones.First(x => x.Codigo == "CONF.ULTLCP");
|
||||
var FechaInicio = ultl.Fecha1.Value.AddDays(1);
|
||||
var FechaFin = DateTime.Today;
|
||||
var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCARPER").ValorAlfabeticoLargo;
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
// public static async Task CompruebaCarteraPerdidaAsync()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var ultl = bd.enumeraciones.First(x => x.Codigo == "CONF.ULTLCP");
|
||||
// var FechaInicio = ultl.Fecha1.Value.AddDays(1);
|
||||
// var FechaFin = DateTime.Today;
|
||||
// var sDestinatarios = bd.enumeraciones.First(x => x.Codigo == "CONF.EMAILCARPER").ValorAlfabeticoLargo;
|
||||
// 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)
|
||||
{
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
// 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);
|
||||
// }
|
||||
// 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);
|
||||
// }
|
||||
|
||||
ultl.Fecha1 = DateTime.Today;
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En CompruebaCarteraPerdida.", $"Rutina: CompruebaCarteraPerdida. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// ultl.Fecha1 = DateTime.Today;
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En CompruebaCarteraPerdida.", $"Rutina: CompruebaCarteraPerdida. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static async Task GeneraComunicacionesRecibosAsync()
|
||||
{
|
||||
// Case 1: Remittance warning
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaRemesa();
|
||||
bdAsegasa.db.recibos.GeneraAvisoRemesa(lr, bd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Remesa). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
// public static async Task GeneraComunicacionesRecibosAsync()
|
||||
// {
|
||||
// // Case 1: Remittance warning
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaRemesa();
|
||||
// bdAsegasa.db.recibos.GeneraAvisoRemesa(lr, bd);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Remesa). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
|
||||
// Case 2: Legal notice
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosAvisoImperativoLegal(bd);
|
||||
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%";
|
||||
bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_IMPERATIVO_LEGAL, sAsunto, sCuerpo, bd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Legal). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
// // Case 2: Legal notice
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var lr = bdAsegasa.db.recibos.ObtieneRecibosAvisoImperativoLegal(bd);
|
||||
// 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%";
|
||||
// bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_IMPERATIVO_LEGAL, sAsunto, sCuerpo, bd);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Legal). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
|
||||
// Case 3: Cancellation notice
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaBaja(bd);
|
||||
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%";
|
||||
bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_BAJA_POLIZA, sAsunto, sCuerpo, bd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Baja). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
// // Case 3: Cancellation notice
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var lr = bdAsegasa.db.recibos.ObtieneRecibosCartaBaja(bd);
|
||||
// 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%";
|
||||
// bdAsegasa.db.recibos.GeneraAviso(lr, bdAsegasa.db.recibos.TipoGeneracionEnum.AVISO_BAJA_POLIZA, sAsunto, sCuerpo, bd);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Baja). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
|
||||
// Case 4: Bank return notice
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var lr = bdAsegasa.db.recibos.ObtieneRecibosComunicacionDevueltoBanco(bd);
|
||||
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%";
|
||||
bdAsegasa.db.recibos.GeneraAviso(lr,bdAsegasa.db.recibos.TipoGeneracionEnum.COMUNICACION_DEVUELTO_BANCO, sAsunto, sCuerpo, bd);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Devuelto). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// // Case 4: Bank return notice
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var lr = bdAsegasa.db.recibos.ObtieneRecibosComunicacionDevueltoBanco(bd);
|
||||
// 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%";
|
||||
// bdAsegasa.db.recibos.GeneraAviso(lr,bdAsegasa.db.recibos.TipoGeneracionEnum.COMUNICACION_DEVUELTO_BANCO, sAsunto, sCuerpo, bd);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En GeneraComunicacionesRecibo.", $"Rutina: GeneraComunicacionesRecibo (Devuelto). {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static async Task GeneraRecibosPolizasColectivasAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var enums = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "CP").ToList();
|
||||
foreach (var pc in enums)
|
||||
{
|
||||
var idCia = bd.companias.First(x => x.Codigo == pc.ValorAlfabetico2).idCompania;
|
||||
var PrimaNeta = pc.ValorNumerico1 ?? 0;
|
||||
var PorcentajeImpuestos = pc.ValorNumerico2 ?? 0;
|
||||
var Impuestos = Math.Round(PrimaNeta * PorcentajeImpuestos / 100, 2);
|
||||
var Flim = DateTime.Today.AddDays(40);
|
||||
// public static async Task GeneraRecibosPolizasColectivasAsync()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var enums = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "CP").ToList();
|
||||
// foreach (var pc in enums)
|
||||
// {
|
||||
// var idCia = bd.companias.First(x => x.Codigo == pc.ValorAlfabetico2).idCompania;
|
||||
// var PrimaNeta = pc.ValorNumerico1 ?? 0;
|
||||
// var PorcentajeImpuestos = pc.ValorNumerico2 ?? 0;
|
||||
// var Impuestos = Math.Round(PrimaNeta * PorcentajeImpuestos / 100, 2);
|
||||
// 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)
|
||||
{
|
||||
p.GeneraReciboPolizaColectivo(bd, PrimaNeta, Impuestos, 0);
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraRecibosPolizasColectivas.", $"Rutina: GeneraRecibosPolizasColectivas. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// foreach (var p in pols)
|
||||
// {
|
||||
// p.GeneraReciboPolizaColectivo(bd, PrimaNeta, Impuestos, 0);
|
||||
// }
|
||||
// }
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En GeneraRecibosPolizasColectivas.", $"Rutina: GeneraRecibosPolizasColectivas. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static async Task GeneraEmailPolizasColectivas0057Async()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var idCia = bd.companias.First(x => x.Codigo == "0057").idCompania;
|
||||
var idRamo = bd.ramos.First(x => x.Codigo == "2-8-1").idRamo;
|
||||
// public static async Task GeneraEmailPolizasColectivas0057Async()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var idCia = bd.companias.First(x => x.Codigo == "0057").idCompania;
|
||||
// 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)
|
||||
{
|
||||
var Polcol = bd.enumeraciones.First(x => x.Codigo == "CP.TRACTORESEUROP");
|
||||
var laltas = new List<DatoReciboColectivo0057>();
|
||||
var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
// if (recs.Count > 0)
|
||||
// {
|
||||
// var Polcol = bd.enumeraciones.First(x => x.Codigo == "CP.TRACTORESEUROP");
|
||||
// var laltas = new List<DatoReciboColectivo0057>();
|
||||
// var cta = bd.cuentascorreo.First(x => x.Codigo == "SEG.GENERALES");
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
var dp = (TractoresEuropAssistance)tsUtilidades.Utilidades.Deserializa(r.idPolizaNavigation.idFicheroPresupuestoNavigation.Fichero, typeof(TractoresEuropAssistance));
|
||||
var nd = new DatoReciboColectivo0057
|
||||
{
|
||||
Contrato = Polcol.ValorAlfabetico1,
|
||||
Codigo_Producto = Polcol.ValorAlfabetico3,
|
||||
País = "ESPAÑA",
|
||||
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),
|
||||
Matrícula = dp.Matricula,
|
||||
Marca = dp.Marca,
|
||||
Modelo = dp.Modelo,
|
||||
Fecha_Matriculacion = dp.FechaMatriculacion,
|
||||
Referencia_Externa = $"{r.idPolizaNavigation.Tomador.CIF} {r.idPolizaNavigation.Tomador.RazonSocial}"
|
||||
};
|
||||
laltas.Add(nd);
|
||||
}
|
||||
// foreach (var r in recs)
|
||||
// {
|
||||
// var dp = (TractoresEuropAssistance)tsUtilidades.Utilidades.Deserializa(r.idPolizaNavigation.idFicheroPresupuestoNavigation.Fichero, typeof(TractoresEuropAssistance));
|
||||
// var nd = new DatoReciboColectivo0057
|
||||
// {
|
||||
// Contrato = Polcol.ValorAlfabetico1,
|
||||
// Codigo_Producto = Polcol.ValorAlfabetico3,
|
||||
// País = "ESPAÑA",
|
||||
// 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),
|
||||
// Matrícula = dp.Matricula,
|
||||
// Marca = dp.Marca,
|
||||
// Modelo = dp.Modelo,
|
||||
// Fecha_Matriculacion = dp.FechaMatriculacion,
|
||||
// Referencia_Externa = $"{r.idPolizaNavigation.Tomador.CIF} {r.idPolizaNavigation.Tomador.RazonSocial}"
|
||||
// };
|
||||
// laltas.Add(nd);
|
||||
// }
|
||||
|
||||
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 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");
|
||||
|
||||
foreach (var r in recs)
|
||||
{
|
||||
var tg = new gestionesrecibos
|
||||
{
|
||||
idRecibo = r.idRecibo,
|
||||
FormaComunicacion = (int)FormaComunicacionEnum.NINGUNA,
|
||||
Tipo = (int)TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA,
|
||||
GestionesRealizadas = TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA.ToString().Replace("_", " "),
|
||||
Fecha = DateTime.Now,
|
||||
idCorreo = idCorreo,
|
||||
Observaciones = ""
|
||||
};
|
||||
bd.gestionesrecibos.Add(tg);
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await TsNotificacionesClient.RegistrarAsync("En GeneraEmailPolizasColectivas0057.", $"Rutina: GeneraEmailPolizasColectivas0057. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
// foreach (var r in recs)
|
||||
// {
|
||||
// var tg = new gestionesrecibos
|
||||
// {
|
||||
// idRecibo = r.idRecibo,
|
||||
// FormaComunicacion = (int)FormaComunicacionEnum.NINGUNA,
|
||||
// Tipo = (int)TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA,
|
||||
// GestionesRealizadas = TipoGestionEnum.COMUNICACIÓN_EMISION_RECIBO_A_LA_COMPAÑÍA.ToString().Replace("_", " "),
|
||||
// Fecha = DateTime.Now,
|
||||
// idCorreo = idCorreo,
|
||||
// Observaciones = ""
|
||||
// };
|
||||
// bd.gestionesrecibos.Add(tg);
|
||||
// }
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// await TsNotificacionesClient.RegistrarAsync("En GeneraEmailPolizasColectivas0057.", $"Rutina: GeneraEmailPolizasColectivas0057. {ex.Message}", TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public class DatoReciboColectivo0057
|
||||
{
|
||||
public string Contrato { get; set; }
|
||||
public string Codigo_Producto { get; set; }
|
||||
public DateTime Fecha_Inicio { get; set; }
|
||||
public DateTime Fecha_Fin { get; set; }
|
||||
public string País { get; set; }
|
||||
public string Matrícula { get; set; }
|
||||
public string Marca { get; set; }
|
||||
public string Modelo { get; set; }
|
||||
public DateTime Fecha_Matriculacion { get; set; }
|
||||
public string Referencia_Externa { get; set; }
|
||||
}
|
||||
}
|
||||
// public class DatoReciboColectivo0057
|
||||
// {
|
||||
// public string Contrato { get; set; }
|
||||
// public string Codigo_Producto { get; set; }
|
||||
// public DateTime Fecha_Inicio { get; set; }
|
||||
// public DateTime Fecha_Fin { get; set; }
|
||||
// public string País { get; set; }
|
||||
// public string Matrícula { get; set; }
|
||||
// public string Marca { get; set; }
|
||||
// public string Modelo { get; set; }
|
||||
// public DateTime Fecha_Matriculacion { get; set; }
|
||||
// public string Referencia_Externa { get; set; }
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,388 +1,388 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
//using System;
|
||||
//using System.Linq;
|
||||
//using System.Collections.Generic;
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
//using bdAsegasa;
|
||||
//using bdAsegasa.db;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa.Procesos
|
||||
{
|
||||
public class ProcesosSiniestros
|
||||
{
|
||||
public static void IncorporaSiniestrosEIACV6()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = gestionasegasaEntities.NuevoContexto();
|
||||
var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||
int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
//namespace Servicio_Gestion_Asegasa.Procesos
|
||||
//{
|
||||
// public class ProcesosSiniestros
|
||||
// {
|
||||
// public static void IncorporaSiniestrosEIACV6()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = gestionasegasaEntities.NuevoContexto();
|
||||
// var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||
// int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
|
||||
var ficspen = bd.ficheroscompanias
|
||||
.Where(x => x.FechaProcesado == null &&
|
||||
x.FechaError == null &&
|
||||
x.Tipo == tipo &&
|
||||
x.Version == "6.0")
|
||||
.OrderBy(x => x.idFichero)
|
||||
.ToList();
|
||||
// var ficspen = bd.ficheroscompanias
|
||||
// .Where(x => x.FechaProcesado == null &&
|
||||
// x.FechaError == null &&
|
||||
// x.Tipo == tipo &&
|
||||
// x.Version == "6.0")
|
||||
// .OrderBy(x => x.idFichero)
|
||||
// .ToList();
|
||||
|
||||
foreach (var f in ficspen)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 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));
|
||||
// foreach (var f in ficspen)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// // 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));
|
||||
|
||||
if (DatosEIAC?.Objetos?.Items != null)
|
||||
{
|
||||
IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
||||
var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
||||
// if (DatosEIAC?.Objetos?.Items != null)
|
||||
// {
|
||||
// IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
||||
// var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
||||
|
||||
foreach (var s in lSins)
|
||||
{
|
||||
List<siniestros> sins = null;
|
||||
string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
||||
// foreach (var s in lSins)
|
||||
// {
|
||||
// List<siniestros> sins = null;
|
||||
// string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
||||
|
||||
var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
||||
if (seiac == null)
|
||||
{
|
||||
seiac = new siniestros_eiac
|
||||
{
|
||||
idSiniestroEntidad = idSiniestroEntidad,
|
||||
idFicheroCompania = f.idFichero,
|
||||
idCompania = f.idCompania
|
||||
};
|
||||
bd.siniestros_eiac.Add(seiac);
|
||||
}
|
||||
// var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
||||
// if (seiac == null)
|
||||
// {
|
||||
// seiac = new siniestros_eiac
|
||||
// {
|
||||
// idSiniestroEntidad = idSiniestroEntidad,
|
||||
// idFicheroCompania = f.idFichero,
|
||||
// idCompania = f.idCompania
|
||||
// };
|
||||
// bd.siniestros_eiac.Add(seiac);
|
||||
// }
|
||||
|
||||
seiac.NumeroPoliza = s.DatosPoliza.IdPoliza;
|
||||
var pol = bd.polizassg
|
||||
.Where(x => x.NumeroPoliza == seiac.NumeroPoliza && x.idCompania == seiac.idCompania)
|
||||
.OrderByDescending(x => x.NumeroSuplemento)
|
||||
.FirstOrDefault();
|
||||
// seiac.NumeroPoliza = s.DatosPoliza.IdPoliza;
|
||||
// var pol = bd.polizassg
|
||||
// .Where(x => x.NumeroPoliza == seiac.NumeroPoliza && x.idCompania == seiac.idCompania)
|
||||
// .OrderByDescending(x => x.NumeroSuplemento)
|
||||
// .FirstOrDefault();
|
||||
|
||||
if (pol != null)
|
||||
seiac.idPoliza = pol.idPoliza;
|
||||
// if (pol != null)
|
||||
// seiac.idPoliza = pol.idPoliza;
|
||||
|
||||
seiac.NumeroSuplemento = s.DatosPoliza.NumeroSuplemento;
|
||||
seiac.FechaDeclaracion = s.DatosSiniestro.FechaDeclaracion;
|
||||
seiac.FechaOcurrencia = s.DatosSiniestro.FechaOcurrencia;
|
||||
seiac.PosicionSiniestro = (int)bdAsegasa.db.siniestros_eiac.ObtienePosicionSiniestroV6((string)s.DatosSiniestro.PosicionSiniestro);
|
||||
seiac.DescripcionSiniestro = tsUtilidades.Extensiones.StringExtensions.Acortar((string)s.DatosSiniestro.DescripcionSiniestro, 2048);
|
||||
seiac.TipologiaSiniestro = s.DatosSiniestro.TipologiaSiniestro;
|
||||
seiac.ImporteIndemnizacion = s.DatosSiniestro.ImporteIndemnizacion;
|
||||
seiac.ImporteReserva = s.DatosSiniestro.ImporteReserva;
|
||||
// seiac.NumeroSuplemento = s.DatosPoliza.NumeroSuplemento;
|
||||
// seiac.FechaDeclaracion = s.DatosSiniestro.FechaDeclaracion;
|
||||
// seiac.FechaOcurrencia = s.DatosSiniestro.FechaOcurrencia;
|
||||
// seiac.PosicionSiniestro = (int)bdAsegasa.db.siniestros_eiac.ObtienePosicionSiniestroV6((string)s.DatosSiniestro.PosicionSiniestro);
|
||||
// seiac.DescripcionSiniestro = tsUtilidades.Extensiones.StringExtensions.Acortar((string)s.DatosSiniestro.DescripcionSiniestro, 2048);
|
||||
// seiac.TipologiaSiniestro = s.DatosSiniestro.TipologiaSiniestro;
|
||||
// seiac.ImporteIndemnizacion = s.DatosSiniestro.ImporteIndemnizacion;
|
||||
// seiac.ImporteReserva = s.DatosSiniestro.ImporteReserva;
|
||||
|
||||
if (s.DatosSiniestro.LugarSiniestro != null)
|
||||
{
|
||||
if (seiac.idLugarSiniestroNavigation == null)
|
||||
{
|
||||
seiac.idLugarSiniestroNavigation = new direcciones();
|
||||
}
|
||||
seiac.idLugarSiniestroNavigation.Direccion = s.DatosSiniestro.LugarSiniestro.ClaseVia + " " + s.DatosSiniestro.LugarSiniestro.NombreVia + " " + s.DatosSiniestro.LugarSiniestro.OtrosDatosVia;
|
||||
seiac.idLugarSiniestroNavigation.CodigoPostal = s.DatosSiniestro.LugarSiniestro.CodigoPostal;
|
||||
// if (s.DatosSiniestro.LugarSiniestro != null)
|
||||
// {
|
||||
// if (seiac.idLugarSiniestroNavigation == null)
|
||||
// {
|
||||
// seiac.idLugarSiniestroNavigation = new direcciones();
|
||||
// }
|
||||
// seiac.idLugarSiniestroNavigation.Direccion = s.DatosSiniestro.LugarSiniestro.ClaseVia + " " + s.DatosSiniestro.LugarSiniestro.NombreVia + " " + s.DatosSiniestro.LugarSiniestro.OtrosDatosVia;
|
||||
// seiac.idLugarSiniestroNavigation.CodigoPostal = s.DatosSiniestro.LugarSiniestro.CodigoPostal;
|
||||
|
||||
string codmun = bd.ObtieneCodigoMunicipioMasCoincidente(seiac.idLugarSiniestroNavigation.CodigoPostal, (string)s.DatosSiniestro.LugarSiniestro.Poblacion, true);
|
||||
if (string.IsNullOrEmpty(codmun))
|
||||
{
|
||||
seiac.idLugarSiniestroNavigation.Direccion += " " + s.DatosSiniestro.LugarSiniestro.Poblacion;
|
||||
}
|
||||
else
|
||||
{
|
||||
seiac.idLugarSiniestroNavigation.CodigoMunicipio = codmun;
|
||||
}
|
||||
seiac.idLugarSiniestroNavigation.Direccion = tsUtilidades.Extensiones.StringExtensions.Acortar(seiac.idLugarSiniestroNavigation.Direccion, 200);
|
||||
}
|
||||
// string codmun = bd.ObtieneCodigoMunicipioMasCoincidente(seiac.idLugarSiniestroNavigation.CodigoPostal, (string)s.DatosSiniestro.LugarSiniestro.Poblacion, true);
|
||||
// if (string.IsNullOrEmpty(codmun))
|
||||
// {
|
||||
// seiac.idLugarSiniestroNavigation.Direccion += " " + s.DatosSiniestro.LugarSiniestro.Poblacion;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// seiac.idLugarSiniestroNavigation.CodigoMunicipio = codmun;
|
||||
// }
|
||||
// seiac.idLugarSiniestroNavigation.Direccion = tsUtilidades.Extensiones.StringExtensions.Acortar(seiac.idLugarSiniestroNavigation.Direccion, 200);
|
||||
// }
|
||||
|
||||
if (s.DatosSiniestro.SituacionesSiniestro != null)
|
||||
{
|
||||
var yaincorporados = new List<int>();
|
||||
foreach (var sit in s.DatosSiniestro.SituacionesSiniestro)
|
||||
{
|
||||
int numeroOrden = sit.NumeroOrden;
|
||||
if (numeroOrden == 0) numeroOrden = sit.GetHashCode();
|
||||
if (!yaincorporados.Contains(numeroOrden))
|
||||
{
|
||||
var est = seiac.estadossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
if (est == null)
|
||||
{
|
||||
est = new estadossiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
seiac.estadossiniestros_eiac.Add(est);
|
||||
}
|
||||
est.SituacionSiniestro = bdAsegasa.estadossiniestros_eiac.ObtieneSituacionSiniestroV6((string)sit.SituacionSiniestro);
|
||||
est.DescripcionSituacion = tsUtilidades.Extensiones.StringExtensions.Acortar((string)sit.DescripcionSituacion, 45);
|
||||
yaincorporados.Add(numeroOrden);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (s.DatosSiniestro.SituacionesSiniestro != null)
|
||||
// {
|
||||
// var yaincorporados = new List<int>();
|
||||
// foreach (var sit in s.DatosSiniestro.SituacionesSiniestro)
|
||||
// {
|
||||
// int numeroOrden = sit.NumeroOrden;
|
||||
// if (numeroOrden == 0) numeroOrden = sit.GetHashCode();
|
||||
// if (!yaincorporados.Contains(numeroOrden))
|
||||
// {
|
||||
// var est = seiac.estadossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
// if (est == null)
|
||||
// {
|
||||
// est = new estadossiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
// seiac.estadossiniestros_eiac.Add(est);
|
||||
// }
|
||||
// est.SituacionSiniestro = bdAsegasa.estadossiniestros_eiac.ObtieneSituacionSiniestroV6((string)sit.SituacionSiniestro);
|
||||
// est.DescripcionSituacion = tsUtilidades.Extensiones.StringExtensions.Acortar((string)sit.DescripcionSituacion, 45);
|
||||
// yaincorporados.Add(numeroOrden);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (s.DatosSiniestro.PagosSiniestro != null)
|
||||
{
|
||||
var yaincorporados = new List<int>();
|
||||
foreach (var pag in s.DatosSiniestro.PagosSiniestro)
|
||||
{
|
||||
int numeroOrden = pag.NumeroOrden;
|
||||
if (numeroOrden == 0) numeroOrden = pag.GetHashCode();
|
||||
if (!yaincorporados.Contains(numeroOrden))
|
||||
{
|
||||
var ps = seiac.pagossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
if (ps == null)
|
||||
{
|
||||
ps = new pagossiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
seiac.pagossiniestros_eiac.Add(ps);
|
||||
}
|
||||
ps.FechaPago = pag.FechaPago;
|
||||
ps.FechaLiquidacion = pag.FechaLiquidacion;
|
||||
ps.ImportePago = pag.ImportePago;
|
||||
ps.DescripcionPago = tsUtilidades.Extensiones.StringExtensions.Acortar((string)pag.DescripcionPago, 255);
|
||||
ps.idTipoPago = bdAsegasa.siniestros_eiac.ObtenerTipoPagoV6((string)pag.FormaPago, ltpa);
|
||||
// if (s.DatosSiniestro.PagosSiniestro != null)
|
||||
// {
|
||||
// var yaincorporados = new List<int>();
|
||||
// foreach (var pag in s.DatosSiniestro.PagosSiniestro)
|
||||
// {
|
||||
// int numeroOrden = pag.NumeroOrden;
|
||||
// if (numeroOrden == 0) numeroOrden = pag.GetHashCode();
|
||||
// if (!yaincorporados.Contains(numeroOrden))
|
||||
// {
|
||||
// var ps = seiac.pagossiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
// if (ps == null)
|
||||
// {
|
||||
// ps = new pagossiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
// seiac.pagossiniestros_eiac.Add(ps);
|
||||
// }
|
||||
// ps.FechaPago = pag.FechaPago;
|
||||
// ps.FechaLiquidacion = pag.FechaLiquidacion;
|
||||
// ps.ImportePago = pag.ImportePago;
|
||||
// ps.DescripcionPago = tsUtilidades.Extensiones.StringExtensions.Acortar((string)pag.DescripcionPago, 255);
|
||||
// ps.idTipoPago = bdAsegasa.siniestros_eiac.ObtenerTipoPagoV6((string)pag.FormaPago, ltpa);
|
||||
|
||||
if (pag.FormaPago != null && pag.FormaPago.DatosCuentaCorriente != null)
|
||||
{
|
||||
ps.IBAN = pag.FormaPago.DatosCuentaCorriente.IBAN;
|
||||
}
|
||||
yaincorporados.Add(numeroOrden);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (pag.FormaPago != null && pag.FormaPago.DatosCuentaCorriente != null)
|
||||
// {
|
||||
// ps.IBAN = pag.FormaPago.DatosCuentaCorriente.IBAN;
|
||||
// }
|
||||
// yaincorporados.Add(numeroOrden);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (s.DatosSiniestro.AccionesSiniestro != null)
|
||||
{
|
||||
var yaincorporados = new List<int>();
|
||||
foreach (var accs in s.DatosSiniestro.AccionesSiniestro)
|
||||
{
|
||||
int numeroOrden = accs.NumeroOrden;
|
||||
if (numeroOrden == 0) numeroOrden = accs.GetHashCode();
|
||||
if (!yaincorporados.Contains(numeroOrden))
|
||||
{
|
||||
var acs = seiac.accionessiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
if (acs == null)
|
||||
{
|
||||
acs = new accionessiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
seiac.accionessiniestros_eiac.Add(acs);
|
||||
}
|
||||
acs.AccionSiniestro = bdAsegasa.accionessiniestros_eiac.ObtieneAccionSiniestroV6((string)accs.AccionSiniestro);
|
||||
acs.FechaAccion = accs.FechaAccion;
|
||||
acs.DescripcionAccion = accs.DescripcionAccion;
|
||||
acs.SituacionAccion = bdAsegasa.accionessiniestros_eiac.ObtieneSituacionAccionV6((string)accs.SituacionAccion);
|
||||
yaincorporados.Add(numeroOrden);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (s.DatosSiniestro.AccionesSiniestro != null)
|
||||
// {
|
||||
// var yaincorporados = new List<int>();
|
||||
// foreach (var accs in s.DatosSiniestro.AccionesSiniestro)
|
||||
// {
|
||||
// int numeroOrden = accs.NumeroOrden;
|
||||
// if (numeroOrden == 0) numeroOrden = accs.GetHashCode();
|
||||
// if (!yaincorporados.Contains(numeroOrden))
|
||||
// {
|
||||
// var acs = seiac.accionessiniestros_eiac.FirstOrDefault(x => x.NumeroOrden == numeroOrden);
|
||||
// if (acs == null)
|
||||
// {
|
||||
// acs = new accionessiniestros_eiac { NumeroOrden = numeroOrden };
|
||||
// seiac.accionessiniestros_eiac.Add(acs);
|
||||
// }
|
||||
// acs.AccionSiniestro = bdAsegasa.accionessiniestros_eiac.ObtieneAccionSiniestroV6((string)accs.AccionSiniestro);
|
||||
// acs.FechaAccion = accs.FechaAccion;
|
||||
// acs.DescripcionAccion = accs.DescripcionAccion;
|
||||
// acs.SituacionAccion = bdAsegasa.accionessiniestros_eiac.ObtieneSituacionAccionV6((string)accs.SituacionAccion);
|
||||
// yaincorporados.Add(numeroOrden);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (s.DatosSiniestro.Expedientes != null)
|
||||
{
|
||||
var yaincorporados = new List<string>();
|
||||
foreach (var exp in s.DatosSiniestro.Expedientes)
|
||||
{
|
||||
string numeroExpediente = exp.NumeroExpediente;
|
||||
if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
||||
// if (s.DatosSiniestro.Expedientes != null)
|
||||
// {
|
||||
// var yaincorporados = new List<string>();
|
||||
// foreach (var exp in s.DatosSiniestro.Expedientes)
|
||||
// {
|
||||
// string numeroExpediente = exp.NumeroExpediente;
|
||||
// if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
||||
|
||||
if (!yaincorporados.Contains(numeroExpediente))
|
||||
{
|
||||
var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
||||
if (ep == null)
|
||||
{
|
||||
ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
||||
seiac.expedientessiniestros_eiac.Add(ep);
|
||||
}
|
||||
ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
||||
ep.ImporteReserva = exp.ImporteReserva;
|
||||
ep.TotalPagos = exp.TotalPagos;
|
||||
ep.TotalRecobros = exp.TotalRecobros;
|
||||
ep.FechaInicio = exp.FechaInicio;
|
||||
ep.FechaFin = exp.FechaFin;
|
||||
ep.NumeroOrden = exp.NumeroOrden;
|
||||
yaincorporados.Add(numeroExpediente);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (!yaincorporados.Contains(numeroExpediente))
|
||||
// {
|
||||
// var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
||||
// if (ep == null)
|
||||
// {
|
||||
// ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
||||
// seiac.expedientessiniestros_eiac.Add(ep);
|
||||
// }
|
||||
// ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
||||
// ep.ImporteReserva = exp.ImporteReserva;
|
||||
// ep.TotalPagos = exp.TotalPagos;
|
||||
// ep.TotalRecobros = exp.TotalRecobros;
|
||||
// ep.FechaInicio = exp.FechaInicio;
|
||||
// ep.FechaFin = exp.FechaFin;
|
||||
// ep.NumeroOrden = exp.NumeroOrden;
|
||||
// yaincorporados.Add(numeroExpediente);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (seiac.idSiniestroNavigation == null)
|
||||
{
|
||||
var fi = seiac.FechaOcurrencia.AddDays(-5);
|
||||
var ff = seiac.FechaOcurrencia.AddDays(5);
|
||||
// if (seiac.idSiniestroNavigation == null)
|
||||
// {
|
||||
// var fi = seiac.FechaOcurrencia.AddDays(-5);
|
||||
// var ff = seiac.FechaOcurrencia.AddDays(5);
|
||||
|
||||
|
||||
var fechaInicio = DateOnly.FromDateTime(fi);
|
||||
var fechaFinal = DateOnly.FromDateTime(ff);
|
||||
// var fechaInicio = DateOnly.FromDateTime(fi);
|
||||
// var fechaFinal = DateOnly.FromDateTime(ff);
|
||||
|
||||
sins = bd.siniestros.Where(x =>
|
||||
x.idPolizaNavigation.NumeroPoliza == seiac.NumeroPoliza &&
|
||||
x.FechaAccidente.HasValue &&
|
||||
x.FechaAccidente >= fechaInicio &&
|
||||
x.FechaAccidente <= fechaFinal).ToList();
|
||||
// sins = bd.siniestros.Where(x =>
|
||||
// x.idPolizaNavigation.NumeroPoliza == seiac.NumeroPoliza &&
|
||||
// x.FechaAccidente.HasValue &&
|
||||
// x.FechaAccidente >= fechaInicio &&
|
||||
// x.FechaAccidente <= fechaFinal).ToList();
|
||||
|
||||
if (sins.Count == 1)
|
||||
{
|
||||
seiac.idSiniestroNavigation = sins[0];
|
||||
}
|
||||
}
|
||||
// if (sins.Count == 1)
|
||||
// {
|
||||
// seiac.idSiniestroNavigation = sins[0];
|
||||
// }
|
||||
// }
|
||||
|
||||
bool bModificados = false;
|
||||
if (bd.ChangeTracker.Entries().Any(e => e.State == EntityState.Added))
|
||||
{
|
||||
bModificados = true;
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.NUEVO;
|
||||
seiac.FechaSituacion = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
var prmods = bd.ChangeTracker.Entries().Where(e => e.State == EntityState.Modified).ToList();
|
||||
if (prmods.Count > 0)
|
||||
{
|
||||
foreach (var pr in prmods)
|
||||
{
|
||||
var original = pr.OriginalValues;
|
||||
var nuevosvalores = pr.CurrentValues;
|
||||
foreach (var prop in original.Properties)
|
||||
{
|
||||
var origVal = original[prop];
|
||||
var newVal = nuevosvalores[prop];
|
||||
// bool bModificados = false;
|
||||
// if (bd.ChangeTracker.Entries().Any(e => e.State == EntityState.Added))
|
||||
// {
|
||||
// bModificados = true;
|
||||
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.NUEVO;
|
||||
// seiac.FechaSituacion = DateTime.Now;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var prmods = bd.ChangeTracker.Entries().Where(e => e.State == EntityState.Modified).ToList();
|
||||
// if (prmods.Count > 0)
|
||||
// {
|
||||
// foreach (var pr in prmods)
|
||||
// {
|
||||
// var original = pr.OriginalValues;
|
||||
// var nuevosvalores = pr.CurrentValues;
|
||||
// foreach (var prop in original.Properties)
|
||||
// {
|
||||
// var origVal = original[prop];
|
||||
// var newVal = nuevosvalores[prop];
|
||||
|
||||
if (origVal?.GetHashCode() != newVal?.GetHashCode())
|
||||
{
|
||||
bModificados = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bModificados) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (origVal?.GetHashCode() != newVal?.GetHashCode())
|
||||
// {
|
||||
// bModificados = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (bModificados) break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
if (bModificados)
|
||||
{
|
||||
if (!seiac.SituacionAsegasa.HasValue || seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
||||
{
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.MODIFICADO;
|
||||
seiac.FechaSituacion = DateTime.Now;
|
||||
}
|
||||
// if (bModificados)
|
||||
// {
|
||||
// if (!seiac.SituacionAsegasa.HasValue || seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
||||
// {
|
||||
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.MODIFICADO;
|
||||
// seiac.FechaSituacion = DateTime.Now;
|
||||
// }
|
||||
|
||||
var nact = new actualizacionessiniestros_eiac
|
||||
{
|
||||
idSiniestroEIACNavigation = seiac,
|
||||
Fecha = DateTime.Now,
|
||||
idFicheroCompania = f.idFichero
|
||||
};
|
||||
bd.actualizacionessiniestros_eiac.Add(nact);
|
||||
// var nact = new actualizacionessiniestros_eiac
|
||||
// {
|
||||
// idSiniestroEIACNavigation = seiac,
|
||||
// Fecha = DateTime.Now,
|
||||
// idFicheroCompania = f.idFichero
|
||||
// };
|
||||
// bd.actualizacionessiniestros_eiac.Add(nact);
|
||||
|
||||
if (seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
||||
{
|
||||
if (!seiac.idPoliza.HasValue)
|
||||
{
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.POLIZA_NO_ENCONTRADA;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sins == null || sins.Count == 0)
|
||||
{
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.SINIESTRO_NO_ENCONTRADO;
|
||||
}
|
||||
else if (sins.Count > 1)
|
||||
{
|
||||
seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.VARIOS_SINIESTROS_POSIBLES;
|
||||
}
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
f.FechaProcesado = DateTime.Now;
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
f.FechaError = DateTime.Now;
|
||||
bd.SaveChanges();
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
// if (seiac.SituacionAsegasa.Value != (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.DESCARTADO)
|
||||
// {
|
||||
// if (!seiac.idPoliza.HasValue)
|
||||
// {
|
||||
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.POLIZA_NO_ENCONTRADA;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (sins == null || sins.Count == 0)
|
||||
// {
|
||||
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.SINIESTRO_NO_ENCONTRADO;
|
||||
// }
|
||||
// else if (sins.Count > 1)
|
||||
// {
|
||||
// seiac.SituacionAsegasa = (int)bdAsegasa.siniestros_eiac.SituacionAsegasaENUM.VARIOS_SINIESTROS_POSIBLES;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// f.FechaProcesado = DateTime.Now;
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// f.FechaError = DateTime.Now;
|
||||
// bd.SaveChanges();
|
||||
// tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void IncorporaExpSiniestrosEIACV6()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var bd = tscgestionasegasa.NuevoContexto();
|
||||
var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||
int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
var ficspen = bd.ficheroscompanias
|
||||
.Where(x => x.Tipo == tipo && x.Version == "6.0")
|
||||
.OrderBy(x => x.idFichero)
|
||||
.ToList();
|
||||
// public static void IncorporaExpSiniestrosEIACV6()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// using var bd = tscgestionasegasa.NuevoContexto();
|
||||
// var ltpa = bd.enumeraciones.Where(x => x.idGrupoEnumeracionNavigation.Grupo == "TIPP").ToList();
|
||||
// int tipo = (int)ficheroscompanias.TipoFicheroCompania.SINIESTROS_EIAC;
|
||||
// var ficspen = bd.ficheroscompanias
|
||||
// .Where(x => x.Tipo == tipo && x.Version == "6.0")
|
||||
// .OrderBy(x => x.idFichero)
|
||||
// .ToList();
|
||||
|
||||
foreach (var f in ficspen)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 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));
|
||||
// foreach (var f in ficspen)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// // 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));
|
||||
|
||||
if (DatosEIAC?.Objetos?.Items != null)
|
||||
{
|
||||
IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
||||
var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
||||
// if (DatosEIAC?.Objetos?.Items != null)
|
||||
// {
|
||||
// IEnumerable<dynamic> items = DatosEIAC.Objetos.Items;
|
||||
// var lSins = items.Where(x => x != null && x.GetType().Name == "tipo_siniestro");
|
||||
|
||||
foreach (var s in lSins)
|
||||
{
|
||||
string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
||||
var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
||||
// foreach (var s in lSins)
|
||||
// {
|
||||
// string idSiniestroEntidad = s.DatosSiniestro.IdSiniestroEntidad;
|
||||
// var seiac = bd.siniestros_eiac.FirstOrDefault(x => x.idSiniestroEntidad == idSiniestroEntidad);
|
||||
|
||||
if (seiac != null)
|
||||
{
|
||||
if (s.DatosSiniestro.Expedientes != null)
|
||||
{
|
||||
var yaincorporados = new List<string>();
|
||||
foreach (var exp in s.DatosSiniestro.Expedientes)
|
||||
{
|
||||
string numeroExpediente = exp.NumeroExpediente;
|
||||
if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
||||
// if (seiac != null)
|
||||
// {
|
||||
// if (s.DatosSiniestro.Expedientes != null)
|
||||
// {
|
||||
// var yaincorporados = new List<string>();
|
||||
// foreach (var exp in s.DatosSiniestro.Expedientes)
|
||||
// {
|
||||
// string numeroExpediente = exp.NumeroExpediente;
|
||||
// if (string.IsNullOrEmpty(numeroExpediente)) numeroExpediente = exp.GetHashCode().ToString();
|
||||
|
||||
if (!yaincorporados.Contains(numeroExpediente))
|
||||
{
|
||||
var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
||||
if (ep == null)
|
||||
{
|
||||
ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
||||
seiac.expedientessiniestros_eiac.Add(ep);
|
||||
}
|
||||
ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
||||
ep.ImporteReserva = exp.ImporteReserva;
|
||||
ep.TotalPagos = exp.TotalPagos;
|
||||
ep.TotalRecobros = exp.TotalRecobros;
|
||||
ep.FechaInicio = exp.FechaInicio;
|
||||
ep.FechaFin = exp.FechaFin;
|
||||
ep.NumeroOrden = exp.NumeroOrden;
|
||||
// if (!yaincorporados.Contains(numeroExpediente))
|
||||
// {
|
||||
// var ep = seiac.expedientessiniestros_eiac.FirstOrDefault(x => x.NumeroExpediente == numeroExpediente);
|
||||
// if (ep == null)
|
||||
// {
|
||||
// ep = new expedientessiniestros_eiac { NumeroExpediente = numeroExpediente };
|
||||
// seiac.expedientessiniestros_eiac.Add(ep);
|
||||
// }
|
||||
// ep.EstadoExpediente = bdAsegasa.expedientessiniestros_eiac.ObtieneEstadoExpedienteV6((string)exp.EstadoExpediente);
|
||||
// ep.ImporteReserva = exp.ImporteReserva;
|
||||
// ep.TotalPagos = exp.TotalPagos;
|
||||
// ep.TotalRecobros = exp.TotalRecobros;
|
||||
// ep.FechaInicio = exp.FechaInicio;
|
||||
// ep.FechaFin = exp.FechaFin;
|
||||
// ep.NumeroOrden = exp.NumeroOrden;
|
||||
|
||||
yaincorporados.Add(numeroExpediente);
|
||||
}
|
||||
}
|
||||
bd.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// f.FechaProcesado = Now (Comentado en el código original)
|
||||
bd.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
f.FechaError = DateTime.Now;
|
||||
bd.SaveChanges();
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// yaincorporados.Add(numeroExpediente);
|
||||
// }
|
||||
// }
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // f.FechaProcesado = Now (Comentado en el código original)
|
||||
// bd.SaveChanges();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// f.FechaError = DateTime.Now;
|
||||
// bd.SaveChanges();
|
||||
// tsUtilidades.TsNotificacionesClient.RegistrarAsync("En IncorporaSiniestrosEIACV6.", $"Rutina: IncorporaSiniestrosEIACV6. Fichero:{f.NombreFichero} {ex.Message}", tsUtilidades.TsNotificacionesClient.TipoNotificacionEnum.ERROR);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// 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>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
using bdAsegasa;
|
||||
using bdAsegasa.db;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Quartz;
|
||||
using Quartz.Impl;
|
||||
using Servicio_Gestion_Asegasa.Procesos;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace Servicio_Gestion_Asegasa
|
||||
{
|
||||
@@ -8,24 +14,96 @@ namespace Servicio_Gestion_Asegasa
|
||||
{
|
||||
private readonly ILogger<Worker> _logger;
|
||||
|
||||
public Worker(ILogger<Worker> logger)
|
||||
public Worker(ILogger<Worker> logger, Configuracion Conf)
|
||||
{
|
||||
_logger = logger;
|
||||
ProcesosConf.Conf = Conf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
if (_logger.IsEnabled(LogLevel.Information))
|
||||
{
|
||||
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||
_logger.LogInformation("Servicio en ejecuci<63>n: {time}", DateTimeOffset.Now);
|
||||
//Creo q aqui se deberia llamar a los servicios
|
||||
}
|
||||
await Task.Delay(1000, stoppingToken);
|
||||
await ProcesosConf.ProcesarAsync();
|
||||
await System.Threading.Tasks.Task.Delay(1000 * 60 * 5, 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,4 +1,9 @@
|
||||
{
|
||||
"Configuracion": {
|
||||
"SegundosMinimosEntreProcesos": "60",
|
||||
"HoraProcesosDiarios": "06:30",
|
||||
"NombreConexionBD": "Producción Remoto"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
@@ -11,4 +16,4 @@
|
||||
"IdAplicacion": 2,
|
||||
"ApiKey": "0a47a1eada0143278b9d4de4e8911100"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user