1847 lines
96 KiB
C#
1847 lines
96 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data.Entity.Validation;
|
|||
|
|
using System.Data.Entity;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Web.Http;
|
|||
|
|
using ULA.Davivienda.PrendarioModel;
|
|||
|
|
using ULA.Davivienda.PrendarioModel.Prendario;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.Commons;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.CotizadorServiceLayer;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.Json;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFPrendarioSeguros;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFServiciosCobisGenerales;
|
|||
|
|
using Ultimus.Utilitarios;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.Xml;
|
|||
|
|
using ULA.Davivienda.PrestamoAutos.WCFServiciosGenerales;
|
|||
|
|
using System.Data.SqlClient;
|
|||
|
|
|
|||
|
|
namespace ULA.Davivienda.PrestamoAutos.ControllersWebApi
|
|||
|
|
{
|
|||
|
|
public class SolicitanteAPIController : ApiController
|
|||
|
|
{
|
|||
|
|
LogFile log = new LogFile();
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonSolicitante> ObtenerSolicitantes(int idSolicitud)
|
|||
|
|
{
|
|||
|
|
List<JsonSolicitante> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
registros = (from so in db.Solicitante.Where(s => s.IdSolicitud == idSolicitud)
|
|||
|
|
join cl in db.Cliente on so.IdCliente equals cl.IdCliente
|
|||
|
|
join tp in db.TipoSolicitante on so.IdTipoSolicitante equals tp.IdTipoSolicitante
|
|||
|
|
select new JsonSolicitante()
|
|||
|
|
{
|
|||
|
|
idCliente = cl.IdCliente,
|
|||
|
|
nombreCliente = tp.IdTipoSolicitante != 4 ? cl.PrimerNombre + (string.IsNullOrEmpty(cl.SegundoNombre) ? "" : " " + cl.SegundoNombre) + (string.IsNullOrEmpty(cl.PrimerApellido) ? "" : " " + cl.PrimerApellido) + (string.IsNullOrEmpty(cl.SegundoApellido) ? "" : " " + cl.SegundoApellido) : cl.NombreEmpresa,
|
|||
|
|
identificacionCliente = cl.Identificacion,
|
|||
|
|
tipoSolicitante = tp.Descripcion,
|
|||
|
|
solicitantePrincipal = so.EsPrincipal == null ? false : (bool)so.EsPrincipal
|
|||
|
|
}
|
|||
|
|
).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public bool EliminarSolicitante(int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
foreach (var item in db.Solicitante.Where(s => s.IdSolicitud == idSolicitud && s.IdCliente == idCliente).ToList())
|
|||
|
|
db.Entry(item).State = EntityState.Deleted;
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public List<JsonParticipante> ObtenerParticipante(int idSolicitud, int idCliente)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<JsonParticipante> registros = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
registros = (from so in db.Solicitante.Where(s => s.IdSolicitud == idSolicitud && s.IdCliente == idCliente)
|
|||
|
|
join cl in db.Cliente on so.IdCliente equals cl.IdCliente
|
|||
|
|
join pais in db.Nacionalidad on cl.IdPaisNacimiento equals pais.IdNacionalidad into temp1
|
|||
|
|
from pa in temp1.DefaultIfEmpty()
|
|||
|
|
join nacionalidad in db.Nacionalidad on cl.IdNacionalidad equals nacionalidad.IdNacionalidad into temp4
|
|||
|
|
from na in temp4.DefaultIfEmpty()
|
|||
|
|
join direccion in db.DireccionCliente.Where(t => t.IdTipoDireccion == "DM") on cl.IdCliente equals direccion.IdCliente into temp2
|
|||
|
|
from di in temp2.DefaultIfEmpty()
|
|||
|
|
join canton in db.Canton on di.IdCanton equals canton.IdCanton into temp3
|
|||
|
|
from ca in temp3.DefaultIfEmpty()
|
|||
|
|
select new JsonParticipante()
|
|||
|
|
{
|
|||
|
|
idSolicitud = so.IdCliente,
|
|||
|
|
idCliente = cl.IdCliente,
|
|||
|
|
TipoParticipante = so.IdTipoSolicitante == 2 ? 1 : 2,
|
|||
|
|
TipoPersona = so.IdTipoSolicitante != 4 ? 1 : 2,
|
|||
|
|
primerNombre = cl.PrimerNombre,
|
|||
|
|
segundoNombre = cl.SegundoNombre,
|
|||
|
|
primerApellido = cl.PrimerApellido,
|
|||
|
|
segundoApellido = cl.SegundoApellido,
|
|||
|
|
identificacion = cl.Identificacion,
|
|||
|
|
idTipoIdentificacion = cl.IdTipoIdentificacion,
|
|||
|
|
fechaNacimiento = cl.FeNacimiento,
|
|||
|
|
idPaisNacimiento = cl.IdPaisNacimiento,
|
|||
|
|
paisNacimiento = pa.Pais,
|
|||
|
|
idNacionalidad = cl.IdNacionalidad,
|
|||
|
|
nacionalidad = na.Descripcion,
|
|||
|
|
idSexo = cl.IdGenero,
|
|||
|
|
sexo = cl.Genero.Descripcion,
|
|||
|
|
idEstadoCivil = cl.IdEstadoCivil.Trim(),
|
|||
|
|
estadoCivil = cl.EstadoCivil.Descripcion,
|
|||
|
|
NumerosVecesEstadoCivil = cl.NumerosVecesEstadoCivil,
|
|||
|
|
idProfesion = cl.IdProfesion,
|
|||
|
|
profesion = cl.Profesion == null ? "" : cl.Profesion.Descripcion,
|
|||
|
|
dependientes = cl.NumeroDependientes,
|
|||
|
|
residente = cl.EsResidente,
|
|||
|
|
idNivelEducacion = cl.IdNivelEducacion,
|
|||
|
|
nivelEducacion = cl.NivelEducacion == null ? "" : cl.NivelEducacion.Descripcion,
|
|||
|
|
fechaVencimientoCedula = cl.FeVenceIdentificacion,
|
|||
|
|
tieneAuto = cl.TieneAuto,
|
|||
|
|
numeroPlaca = cl.NumPlacaAutoActual,
|
|||
|
|
CodGrupoEconomico = cl.CodGrupoEconomico, //IFRS
|
|||
|
|
idProvincia = di.IdProvincia,
|
|||
|
|
provincia = di.Provincia == null ? "" : di.Provincia.Descripcion,
|
|||
|
|
idCanton = di.IdCanton,
|
|||
|
|
canton = ca.Descripcion,
|
|||
|
|
idDistrito = di.IdDistrito,
|
|||
|
|
distrito = di.Distrito == null ? "" : di.Distrito.Descripcion,
|
|||
|
|
apartadoPostal = di.ApartadoPostal,
|
|||
|
|
codigoPostal = di.CodigoPostal,
|
|||
|
|
numeroCasaApto = di.NumCasaApto,
|
|||
|
|
zonaPostal = di.ZonaPostal,
|
|||
|
|
direccionExacta = di.DirExacta,
|
|||
|
|
telefonoResidencial = cl.TelefonoCliente.Where(t => t.IdTipoTelefono == "DM").Select(t => t.Telefono).FirstOrDefault(),
|
|||
|
|
telefonoCelular = cl.TelefonoCliente.Where(t => t.IdTipoTelefono == "DMM").Select(t => t.Telefono).FirstOrDefault(),
|
|||
|
|
telefonoFax = cl.TelefonoCliente.Where(t => t.IdTipoTelefono == "DMF").Select(t => t.Telefono).FirstOrDefault(),
|
|||
|
|
correoElectronico = cl.EmailCliente.Where(t => t.IdTipoEmail == 1).Select(t => t.Email).FirstOrDefault(),
|
|||
|
|
idCondicionVivienda = cl.IdCondicionVivienda,
|
|||
|
|
CondicionVivienda = cl.CondicionVivienda.Descripcion,
|
|||
|
|
NombreEmpresa = cl.NombreEmpresa,
|
|||
|
|
CapitalSocial = cl.CapitalSocial,
|
|||
|
|
ActividadEmpresa = cl.ActividadEmpresa,
|
|||
|
|
FechaVencimiento = cl.FechaVencimiento,
|
|||
|
|
NombreRepresentanteLegal = cl.NombreRepresentanteLegal,
|
|||
|
|
ResultadoEvaluacionCIC= cl.ResultadoCIC,
|
|||
|
|
EsValidado=cl.EsValidado
|
|||
|
|
}
|
|||
|
|
).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return registros;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonInfoClienteCotizacion ObtenerInfoClienteCotizacion(int idSolicitud)
|
|||
|
|
{
|
|||
|
|
JsonInfoClienteCotizacion respuesta = new JsonInfoClienteCotizacion();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
respuesta = (from sol in db.Solicitud.Where(x => x.IdSolicitud == idSolicitud)
|
|||
|
|
join c in db.Cotizacion on sol.IdCotizacion equals c.IdCotizacion
|
|||
|
|
select new JsonInfoClienteCotizacion
|
|||
|
|
{
|
|||
|
|
TipoIdentificacion = c.IdTipoIdentificacion,
|
|||
|
|
Identificacion = c.Identificacion,
|
|||
|
|
PrimerNombre = c.PrimerNombre,
|
|||
|
|
SegundoNombre = c.SegundoNombre,
|
|||
|
|
PrimerApellido = c.PrimerApellido,
|
|||
|
|
SegundoApellido = c.SegundoApellido,
|
|||
|
|
Email = c.Email
|
|||
|
|
}).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpPost]
|
|||
|
|
public JsonGuardarParticipanteResponse GuardarParticipante(JsonParticipante p)
|
|||
|
|
{
|
|||
|
|
JsonGuardarParticipanteResponse r = new JsonGuardarParticipanteResponse();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
Cliente c = new Cliente();
|
|||
|
|
Cliente pivot = new Cliente();
|
|||
|
|
List<Cliente> pivotList = null;
|
|||
|
|
|
|||
|
|
//Si no viene el número de IdCliente
|
|||
|
|
if (p.idCliente == 0)
|
|||
|
|
c.IdCliente = db.Cliente.Count() == 0 ? 1 : db.Cliente.Max(q => q.IdCliente) + 1;
|
|||
|
|
else
|
|||
|
|
c = db.Cliente.Where(t => t.IdCliente == p.idCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 0");
|
|||
|
|
|
|||
|
|
c.PrimerNombre = string.IsNullOrEmpty(p.primerNombre) ? p.primerNombre : p.primerNombre.ToUpper();
|
|||
|
|
c.SegundoNombre = string.IsNullOrEmpty(p.segundoNombre) ? p.segundoNombre: p.segundoNombre.ToUpper();
|
|||
|
|
c.PrimerApellido = string.IsNullOrEmpty(p.primerApellido) ? p.primerApellido : p.primerApellido.ToUpper();
|
|||
|
|
c.SegundoApellido = string.IsNullOrEmpty(p.segundoApellido) ? p.segundoApellido : p.segundoApellido.ToUpper();
|
|||
|
|
c.Identificacion = p.identificacion;
|
|||
|
|
c.IdTipoIdentificacion = p.idTipoIdentificacion;
|
|||
|
|
c.FeNacimiento = p.fechaNacimiento;
|
|||
|
|
c.IdPaisNacimiento = p.idPaisNacimiento;
|
|||
|
|
c.IdNacionalidad = p.idNacionalidad;
|
|||
|
|
c.IdGenero = string.IsNullOrWhiteSpace(p.idSexo) ? null : p.idSexo;
|
|||
|
|
c.IdEstadoCivil = string.IsNullOrWhiteSpace(p.idEstadoCivil) ? null : p.idEstadoCivil;
|
|||
|
|
c.NumerosVecesEstadoCivil = p.NumerosVecesEstadoCivil;
|
|||
|
|
c.IdProfesion = p.idProfesion;
|
|||
|
|
c.NumeroDependientes = p.dependientes;
|
|||
|
|
c.EsResidente = p.residente;
|
|||
|
|
c.IdNivelEducacion = p.idNivelEducacion;
|
|||
|
|
c.FeVenceIdentificacion = p.fechaVencimientoCedula;
|
|||
|
|
c.TieneAuto = p.tieneAuto;
|
|||
|
|
c.NumPlacaAutoActual = p.numeroPlaca;
|
|||
|
|
c.IdCondicionVivienda = p.idCondicionVivienda;
|
|||
|
|
c.NombreEmpresa = string.IsNullOrEmpty(p.NombreEmpresa) ? p.NombreEmpresa : p.NombreEmpresa.ToUpper();
|
|||
|
|
c.CapitalSocial = p.CapitalSocial;
|
|||
|
|
c.ActividadEmpresa = p.ActividadEmpresa;
|
|||
|
|
c.FechaVencimiento = p.FechaVencimiento;
|
|||
|
|
c.NombreRepresentanteLegal = p.NombreRepresentanteLegal;
|
|||
|
|
c.ResultadoCIC = p.ResultadoEvaluacionCIC == null ? c.ResultadoCIC : p.ResultadoEvaluacionCIC;
|
|||
|
|
c.TipoCliente = string.IsNullOrEmpty(p.tipoCliente) ? (string.IsNullOrEmpty(c.TipoCliente) ? "Nuevo" : c.TipoCliente) : p.tipoCliente;
|
|||
|
|
c.AcumuladoConBanco = (p.totalAcumuladoCompromisosConBanco == null ? c.AcumuladoConBanco : (decimal) p.totalAcumuladoCompromisosConBanco);
|
|||
|
|
c.EstadoConBanco = string.IsNullOrEmpty(p.estadoConBanco) ? c.EstadoConBanco : p.estadoConBanco;
|
|||
|
|
c.EnListaNegra = p.esListaNegra == null ? c.EnListaNegra : p.esListaNegra;
|
|||
|
|
c.Ente = string.IsNullOrEmpty(p.ente) ? c.Ente : p.ente;
|
|||
|
|
c.EsValidado = p.EsValidado;
|
|||
|
|
c.CodGrupoEconomico = p.CodGrupoEconomico;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 1");
|
|||
|
|
|
|||
|
|
|
|||
|
|
Solicitante solicitante = null;
|
|||
|
|
//Identifica el TipoSolicitante
|
|||
|
|
int IdTipoSolicitante = p.TipoParticipante == 1 ? 2 : (p.TipoParticipante == 2 ? (p.TipoPersona == 1 ? 3 : 4) : 1);
|
|||
|
|
if (IdTipoSolicitante == 1)
|
|||
|
|
{
|
|||
|
|
//Obtiene el ultimo cliente registrado filtrando por identificación
|
|||
|
|
pivotList = db.Cliente.Where(t => t.Identificacion == p.identificacion).ToList();
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (pivotList != null && pivotList.Count > 0)
|
|||
|
|
{
|
|||
|
|
pivot = pivotList.OrderByDescending(x => x.IdCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
//Obtiene la información donde asocia el cliente, solicitud y su participación como deudor
|
|||
|
|
solicitante = db.Solicitante.Where(x => x.IdCliente == pivot.IdCliente &&
|
|||
|
|
x.IdSolicitud == p.idSolicitud &&
|
|||
|
|
x.IdTipoSolicitante == 1).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Para los casos en los que no se pudo determinar que el cliente
|
|||
|
|
//ya estaba asociado y a nivel de formulario viene como nuevo
|
|||
|
|
if (solicitante == null && p.idCliente == 0)
|
|||
|
|
{
|
|||
|
|
db.Cliente.Add(c);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(c).State = EntityState.Detached;
|
|||
|
|
db.Cliente.Attach(c);
|
|||
|
|
db.Entry(c).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 2");
|
|||
|
|
|
|||
|
|
bool nuevo = false;
|
|||
|
|
Solicitante s = db.Solicitante.FirstOrDefault(t => t.IdSolicitud == p.idSolicitud && t.IdCliente == c.IdCliente);
|
|||
|
|
|
|||
|
|
if (s == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
s = new Solicitante();
|
|||
|
|
s.IdSolicitud = p.idSolicitud;
|
|||
|
|
s.IdCliente = c.IdCliente;
|
|||
|
|
s.IdTipoSolicitante = p.TipoParticipante == 1 ? 2 : (p.TipoParticipante == 2 ? (p.TipoPersona == 1 ? 3 : 4) : 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
s.EsPrincipal = s.IdTipoSolicitante == 1 ? true : false;
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.Solicitante.Add(s);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(s).State = EntityState.Detached;
|
|||
|
|
db.Solicitante.Attach(s);
|
|||
|
|
db.Entry(s).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 3");
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (s.EsPrincipal == true)
|
|||
|
|
{
|
|||
|
|
Cotizacion cot = db.Solicitud.Include(o => o.Cotizacion).Where(x => x.IdSolicitud == p.idSolicitud).Select(y => y.Cotizacion).FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (cot != null)
|
|||
|
|
{
|
|||
|
|
cot.PrimerNombre = string.IsNullOrEmpty(p.primerNombre) ? p.primerNombre : p.primerNombre.ToUpper();
|
|||
|
|
cot.SegundoNombre = string.IsNullOrEmpty(p.segundoNombre) ? p.segundoNombre : p.segundoNombre.ToUpper();
|
|||
|
|
cot.PrimerApellido = string.IsNullOrEmpty(p.primerApellido) ? p.primerApellido : p.primerApellido.ToUpper();
|
|||
|
|
cot.SegundoApellido = string.IsNullOrEmpty(p.segundoApellido) ? p.segundoApellido : p.segundoApellido.ToUpper();
|
|||
|
|
cot.Identificacion = p.identificacion;
|
|||
|
|
cot.IdTipoIdentificacion = p.idTipoIdentificacion;
|
|||
|
|
|
|||
|
|
db.Entry(cot).State = EntityState.Detached;
|
|||
|
|
db.Cotizacion.Attach(cot);
|
|||
|
|
db.Entry(cot).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex2)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "error al actualizar en cotizacion");
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex2);
|
|||
|
|
Exception ESC = ex2.InnerException;
|
|||
|
|
while (ESC != null)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ESC);
|
|||
|
|
ESC = ESC.InnerException;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 4");
|
|||
|
|
|
|||
|
|
|
|||
|
|
nuevo = false;
|
|||
|
|
DireccionCliente d = db.DireccionCliente.FirstOrDefault(t => t.IdCliente == c.IdCliente && t.IdTipoDireccion == "DM");
|
|||
|
|
|
|||
|
|
if (d == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
d = new DireccionCliente();
|
|||
|
|
d.IdCliente = c.IdCliente;
|
|||
|
|
d.IdTipoDireccion = "DM";
|
|||
|
|
d.IdDireccion = db.DireccionCliente.Where(t => t.IdCliente == c.IdCliente).Select(t => t.IdDireccion).DefaultIfEmpty(0).Max() + 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (p.secuencialDireccion != null) d.Secuencial = p.secuencialDireccion;
|
|||
|
|
d.IdProvincia = p.idProvincia;
|
|||
|
|
d.IdCanton = p.idCanton;
|
|||
|
|
d.IdDistrito = p.idDistrito;
|
|||
|
|
d.DirExacta = string.IsNullOrEmpty(p.direccionExacta)? p.direccionExacta : p.direccionExacta.ToUpper();
|
|||
|
|
d.ApartadoPostal = p.apartadoPostal;
|
|||
|
|
d.CodigoPostal = p.codigoPostal;
|
|||
|
|
d.ZonaPostal = p.zonaPostal;
|
|||
|
|
d.NumCasaApto = p.numeroCasaApto;
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.DireccionCliente.Add(d);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(d).State = EntityState.Detached;
|
|||
|
|
db.DireccionCliente.Attach(d);
|
|||
|
|
db.Entry(d).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 5");
|
|||
|
|
|
|||
|
|
nuevo = false;
|
|||
|
|
TelefonoCliente t1 = db.TelefonoCliente.FirstOrDefault(t => t.IdCliente == c.IdCliente && t.IdTipoTelefono == "DM");
|
|||
|
|
int idTelefono = db.TelefonoCliente.Where(t => t.IdCliente == c.IdCliente).Select(t => t.IdTelefono).DefaultIfEmpty(0).Max() + 1;
|
|||
|
|
|
|||
|
|
if (t1 == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
t1 = new TelefonoCliente();
|
|||
|
|
t1.IdCliente = c.IdCliente;
|
|||
|
|
t1.IdTipoTelefono = "DM";
|
|||
|
|
t1.IdTelefono = idTelefono++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (p.secuencialTelefonoResidencial != null) t1.Secuencial = p.secuencialTelefonoResidencial;
|
|||
|
|
t1.CodigoArea = "";
|
|||
|
|
t1.Telefono = p.telefonoResidencial;
|
|||
|
|
t1.Extension = "";
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.TelefonoCliente.Add(t1);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(t1).State = EntityState.Detached;
|
|||
|
|
db.TelefonoCliente.Attach(t1);
|
|||
|
|
db.Entry(t1).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 6");
|
|||
|
|
|
|||
|
|
|
|||
|
|
nuevo = false;
|
|||
|
|
TelefonoCliente t2 = db.TelefonoCliente.FirstOrDefault(t => t.IdCliente == c.IdCliente && t.IdTipoTelefono == "DMM");
|
|||
|
|
|
|||
|
|
if (t2 == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
t2 = new TelefonoCliente();
|
|||
|
|
t2.IdCliente = c.IdCliente;
|
|||
|
|
t2.IdTipoTelefono = "DMM";
|
|||
|
|
t2.IdTelefono = idTelefono++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (p.secuencialTelefonoCelular != null) t2.Secuencial = p.secuencialTelefonoCelular;
|
|||
|
|
t2.CodigoArea = "";
|
|||
|
|
t2.Telefono = p.telefonoCelular;
|
|||
|
|
t2.Extension = "";
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.TelefonoCliente.Add(t2);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(t2).State = EntityState.Detached;
|
|||
|
|
db.TelefonoCliente.Attach(t2);
|
|||
|
|
db.Entry(t2).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 7");
|
|||
|
|
|
|||
|
|
|
|||
|
|
nuevo = false;
|
|||
|
|
TelefonoCliente t3 = db.TelefonoCliente.FirstOrDefault(t => t.IdCliente == c.IdCliente && t.IdTipoTelefono == "DMF");
|
|||
|
|
|
|||
|
|
if (t3 == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
t3 = new TelefonoCliente();
|
|||
|
|
t3.IdCliente = c.IdCliente;
|
|||
|
|
t3.IdTipoTelefono = "DMF";
|
|||
|
|
t3.IdTelefono = idTelefono++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (p.secuencialTelefonoFax != null) t3.Secuencial = p.secuencialTelefonoFax;
|
|||
|
|
t3.CodigoArea = "";
|
|||
|
|
t3.Telefono = p.telefonoFax;
|
|||
|
|
t3.Extension = "";
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.TelefonoCliente.Add(t3);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(t3).State = EntityState.Detached;
|
|||
|
|
db.TelefonoCliente.Attach(t3);
|
|||
|
|
db.Entry(t3).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 8");
|
|||
|
|
|
|||
|
|
|
|||
|
|
nuevo = false;
|
|||
|
|
EmailCliente e = db.EmailCliente.FirstOrDefault(t => t.IdCliente == c.IdCliente && t.IdTipoEmail == 1);
|
|||
|
|
|
|||
|
|
if (e == null)
|
|||
|
|
{
|
|||
|
|
nuevo = true;
|
|||
|
|
e = new EmailCliente();
|
|||
|
|
e.IdCliente = c.IdCliente;
|
|||
|
|
e.IdTipoEmail = 1;
|
|||
|
|
e.IdEmail = db.EmailCliente.Where(t => t.IdCliente == c.IdCliente).Select(t => t.IdEmail).DefaultIfEmpty(0).Max() + 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (p.secuencialCorreoElectronico != null) e.Secuencial = p.secuencialCorreoElectronico;
|
|||
|
|
e.Email = string.IsNullOrEmpty(p.correoElectronico)? p.correoElectronico : p.correoElectronico.ToLower();
|
|||
|
|
|
|||
|
|
if (nuevo)
|
|||
|
|
{
|
|||
|
|
db.EmailCliente.Add(e);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(e).State = EntityState.Detached;
|
|||
|
|
db.EmailCliente.Attach(e);
|
|||
|
|
db.Entry(e).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", "Flag 9");
|
|||
|
|
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
r.IdCliente = c.IdCliente;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", exceptionMessage);
|
|||
|
|
}
|
|||
|
|
catch (SqlException ex)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
Exception ESC = ex.InnerException;
|
|||
|
|
while (ESC != null)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ESC);
|
|||
|
|
ESC = ESC.InnerException;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
r.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
r.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
Exception ESC = ex.InnerException;
|
|||
|
|
while (ESC != null)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ESC);
|
|||
|
|
ESC = ESC.InnerException;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return r;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonParticipante ObtenerInfoParticipanteCobis(int IdCliente, int IdSolicitud, string Identificacion, string TipoIdentificacion,string Proceso, string Usuario, decimal TipoCambio, int TipoParticipante, int TipoPersona)
|
|||
|
|
{
|
|||
|
|
JsonParticipante respuesta = null;
|
|||
|
|
JsonInfoLaboralDetalle infoLaboral = null;
|
|||
|
|
|
|||
|
|
InterfacesAPIController interfaces = null;
|
|||
|
|
ServiciosCobisConsultaCliente.ConsultarSolicitanteResponse resp = null;
|
|||
|
|
XmlDocument xmlDoc = null;
|
|||
|
|
XmlNode xmlDetalle = null;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
#region Inicializa los objetos complejos
|
|||
|
|
infoLaboral = new JsonInfoLaboralDetalle();
|
|||
|
|
infoLaboral.InformacionLaboralCliente = new InformacionLaboralCliente();
|
|||
|
|
respuesta = new JsonParticipante();
|
|||
|
|
|
|||
|
|
xmlDoc = new XmlDocument();
|
|||
|
|
interfaces = new InterfacesAPIController();
|
|||
|
|
|
|||
|
|
respuesta.idCliente = IdCliente;
|
|||
|
|
respuesta.idSolicitud = IdSolicitud;
|
|||
|
|
respuesta.EsValidado = true;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Invoca el metodo de consultar solicitante en Cobis
|
|||
|
|
resp = interfaces.ConsultarSolicitante(new ServiciosCobisConsultaCliente.ConsultarSolicitanteRequest()
|
|||
|
|
{
|
|||
|
|
Identificacion = Identificacion,
|
|||
|
|
Proceso = ServiciosCobisConsultaCliente.EnumeradorProcesoUltimus.PrestamoPrendario,
|
|||
|
|
TipoIdentificacion = TipoIdentificacion,
|
|||
|
|
UserName = Usuario,
|
|||
|
|
Password = string.Empty
|
|||
|
|
});
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Determina si existen errores
|
|||
|
|
if (resp.errCode == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception("Ha ocurrido un error en la respuesta del servicio" + resp.errMessage);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (string.IsNullOrEmpty(resp.resultado))
|
|||
|
|
{
|
|||
|
|
throw new Exception("No fue posible obtener el resultado de la consulta del deudor en Cobis.");
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Inicia el procesamiento de la informacion recibida de Cobis
|
|||
|
|
|
|||
|
|
|
|||
|
|
xmlDoc.LoadXml(resp.resultado);
|
|||
|
|
xmlDetalle = xmlDoc.DocumentElement.SelectSingleNode("//Resultado");
|
|||
|
|
|
|||
|
|
if (xmlDetalle.ChildNodes.Count <= 0)
|
|||
|
|
{
|
|||
|
|
throw new Exception("Error: No hubo Conexión con COBIS");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
var nodo_secundario = xmlDetalle.SelectSingleNode("Detalle");
|
|||
|
|
var nodoListaNegra = xmlDoc.DocumentElement.SelectSingleNode("ListaNegra");
|
|||
|
|
|
|||
|
|
var nodo_error = xmlDetalle.SelectSingleNode("Error");
|
|||
|
|
if (nodo_error != null)
|
|||
|
|
{
|
|||
|
|
throw new Exception("Error: " + nodo_error.InnerText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var co_ente = nodo_secundario.SelectSingleNode("co_ente").InnerText;
|
|||
|
|
|
|||
|
|
if (co_ente == "NoEncontrado")
|
|||
|
|
{
|
|||
|
|
respuesta.ente = string.Empty;
|
|||
|
|
respuesta.estadoConBanco = string.Empty;
|
|||
|
|
respuesta.tipoCliente = "Nuevo";
|
|||
|
|
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|||
|
|
respuesta.Alertas.Add("Solicitante no existe en el MIS");
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Informacion General
|
|||
|
|
|
|||
|
|
var co_tipo_identificacion = nodo_secundario.SelectSingleNode("g_co_tipo_identificacion").InnerText;
|
|||
|
|
var tipo_identificacion = nodo_secundario.SelectSingleNode("g_tipo_identificacion").InnerText;
|
|||
|
|
var identificacion_cobis = nodo_secundario.SelectSingleNode("g_identificacion_cobis").InnerText;
|
|||
|
|
|
|||
|
|
|
|||
|
|
var de_apellido_paterno = nodo_secundario.SelectSingleNode("apellido_paterno").InnerText;
|
|||
|
|
var de_apellido_materno = nodo_secundario.SelectSingleNode("apellido_materno").InnerText;
|
|||
|
|
var de_apellido_casada = nodo_secundario.SelectSingleNode("apellido_casada").InnerText;
|
|||
|
|
var de_primer_nombre = nodo_secundario.SelectSingleNode("primer_nombre").InnerText;
|
|||
|
|
var de_segundo_nombre = nodo_secundario.SelectSingleNode("segundo_nombre").InnerText;
|
|||
|
|
var dt_fecha_nacimiento = nodo_secundario.SelectSingleNode("fecha_nacimiento").InnerText;
|
|||
|
|
|
|||
|
|
var de_seguro_social = nodo_secundario.SelectSingleNode("seguro_social").InnerText;
|
|||
|
|
var co_nacionalidad = nodo_secundario.SelectSingleNode("co_nacionalidad").InnerText;
|
|||
|
|
var de_nacionalidad = nodo_secundario.SelectSingleNode("nacionalidad").InnerText;
|
|||
|
|
var co_estado_civil = nodo_secundario.SelectSingleNode("estado_civil").InnerText;
|
|||
|
|
var co_calificacion = nodo_secundario.SelectSingleNode("calificacion").InnerText;
|
|||
|
|
|
|||
|
|
var co_pais_nacimiento = nodo_secundario.SelectSingleNode("co_pais_nacimiento").InnerText;
|
|||
|
|
var pais_nacimiento = nodo_secundario.SelectSingleNode("pais_nacimiento").InnerText;
|
|||
|
|
|
|||
|
|
var estado_con_banco = nodo_secundario.SelectSingleNode("estado_con_banco").InnerText;
|
|||
|
|
var grupo_economico = nodo_secundario.SelectSingleNode("grupo_economico").InnerText;
|
|||
|
|
|
|||
|
|
|
|||
|
|
string oWarningEstadoCliente = string.Empty;
|
|||
|
|
if (Valida_Estado_Cliente(estado_con_banco, out oWarningEstadoCliente))
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ADVERTENCIA.ToString();
|
|||
|
|
respuesta.Alertas.Add("El deudor cuenta con un estado no permitido en el Banco<br>Por favor revisar con el encargado de MIS");
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(oWarningEstadoCliente))
|
|||
|
|
respuesta.Alertas.Add(oWarningEstadoCliente);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Determinar el Estado Civil a partir del codigo
|
|||
|
|
|
|||
|
|
var de_estado_civil = "";
|
|||
|
|
switch (co_estado_civil)
|
|||
|
|
{
|
|||
|
|
case "C":
|
|||
|
|
de_estado_civil = "CASADO(A)";
|
|||
|
|
break;
|
|||
|
|
case "D":
|
|||
|
|
de_estado_civil = "DIVORCIADO(A)";
|
|||
|
|
break;
|
|||
|
|
case "S":
|
|||
|
|
de_estado_civil = "SOLTERO(A)";
|
|||
|
|
break;
|
|||
|
|
case "U":
|
|||
|
|
de_estado_civil = "UNION LIBRE";
|
|||
|
|
break;
|
|||
|
|
case "V":
|
|||
|
|
de_estado_civil = "VIUDO(A)";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
var co_profesion = nodo_secundario.SelectSingleNode("co_profesion").InnerText;
|
|||
|
|
var de_profesion = nodo_secundario.SelectSingleNode("profesion").InnerText;
|
|||
|
|
var co_sexo = nodo_secundario.SelectSingleNode("co_sexo").InnerText;
|
|||
|
|
|
|||
|
|
var de_sexo = string.Empty;
|
|||
|
|
switch (co_sexo)
|
|||
|
|
{
|
|||
|
|
case "M":
|
|||
|
|
de_sexo = "MASCULINO";
|
|||
|
|
break;
|
|||
|
|
case "F":
|
|||
|
|
de_sexo = "FEMENINO";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
co_sexo = "I";
|
|||
|
|
de_sexo = "INDEFINIDO";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
respuesta.estadoConBanco = estado_con_banco;
|
|||
|
|
respuesta.ente = co_ente;
|
|||
|
|
respuesta.idTipoIdentificacion = GlobalAPIController.StringToInteger(co_tipo_identificacion);
|
|||
|
|
respuesta.identificacion = identificacion_cobis;
|
|||
|
|
|
|||
|
|
respuesta.primerApellido = de_apellido_paterno;
|
|||
|
|
respuesta.segundoApellido = de_apellido_materno;
|
|||
|
|
respuesta.primerNombre = de_primer_nombre;
|
|||
|
|
respuesta.segundoNombre = de_segundo_nombre;
|
|||
|
|
respuesta.CodGrupoEconomico = grupo_economico; // IFRS
|
|||
|
|
|
|||
|
|
string[] arrFechaNacimiento = dt_fecha_nacimiento.Split(new char[] { '/' });
|
|||
|
|
|
|||
|
|
if (arrFechaNacimiento.Length == 3)
|
|||
|
|
{
|
|||
|
|
respuesta.fechaNacimiento = new DateTime(int.Parse(arrFechaNacimiento[2]), int.Parse(arrFechaNacimiento[1]), int.Parse(arrFechaNacimiento[0]));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.idNacionalidad = GlobalAPIController.StringToInteger(co_nacionalidad);
|
|||
|
|
respuesta.nacionalidad = de_nacionalidad;
|
|||
|
|
|
|||
|
|
respuesta.idPaisNacimiento = GlobalAPIController.StringToInteger(co_pais_nacimiento);
|
|||
|
|
respuesta.paisNacimiento = pais_nacimiento;
|
|||
|
|
respuesta.idEstadoCivil = co_estado_civil;
|
|||
|
|
respuesta.estadoCivil = de_estado_civil;
|
|||
|
|
|
|||
|
|
respuesta.idProfesion = co_profesion;
|
|||
|
|
respuesta.profesion = de_profesion;
|
|||
|
|
respuesta.idSexo = co_sexo;
|
|||
|
|
respuesta.sexo = de_sexo;
|
|||
|
|
respuesta.tipoCliente = "Actual";
|
|||
|
|
respuesta.calificacion = co_calificacion;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Listas Negras
|
|||
|
|
|
|||
|
|
if (nodoListaNegra != null)
|
|||
|
|
{
|
|||
|
|
var de_lista_negra = nodoListaNegra.SelectSingleNode("EstaEnListaNegra").InnerText;
|
|||
|
|
respuesta.esListaNegra = de_lista_negra.ToUpper() == "SI" ? true : false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Direcciones
|
|||
|
|
//*******************************
|
|||
|
|
//_deuda.listaEmail = new List<EmailCliente>();
|
|||
|
|
//_deuda.listaDireccion = new List<DireccionCliente>();
|
|||
|
|
//_deuda.listaTelefono = new List<TelefonoCliente>();
|
|||
|
|
//_deuda.listaInformacionLaboral = new List<InformacionLaboralCliente>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
var nodoDirecciones = xmlDetalle.SelectSingleNode("Direcciones");
|
|||
|
|
if (nodoDirecciones != null)
|
|||
|
|
{
|
|||
|
|
var flag_DM = 0;
|
|||
|
|
var flag_DC = 0;
|
|||
|
|
|
|||
|
|
for (int current = 0; current < nodoDirecciones.ChildNodes.Count; current++)
|
|||
|
|
{
|
|||
|
|
var child = nodoDirecciones.ChildNodes.Item(current);
|
|||
|
|
var secuencial = child.SelectSingleNode("nu_direccion").InnerText;
|
|||
|
|
var co_tipo = child.SelectSingleNode("co_tipo").InnerText;
|
|||
|
|
var de_tipo = child.SelectSingleNode("de_tipo").InnerText;
|
|||
|
|
var co_pais = child.SelectSingleNode("co_pais").InnerText;
|
|||
|
|
var de_pais = child.SelectSingleNode("de_pais").InnerText;
|
|||
|
|
var co_provincia = child.SelectSingleNode("co_provincia").InnerText;
|
|||
|
|
var de_provincia = child.SelectSingleNode("de_provincia").InnerText;
|
|||
|
|
var co_canton = child.SelectSingleNode("co_canton").InnerText;
|
|||
|
|
var de_canton = child.SelectSingleNode("de_canton").InnerText;
|
|||
|
|
var co_distrito = child.SelectSingleNode("co_distrito").InnerText;
|
|||
|
|
var co_distrito_area_metro = child.SelectSingleNode("co_distrito_area_metro").InnerText;
|
|||
|
|
var de_distrito = child.SelectSingleNode("de_distrito").InnerText;
|
|||
|
|
var de_observacion = child.SelectSingleNode("de_observacion").InnerText;
|
|||
|
|
var nu_casa = child.SelectSingleNode("nu_casa").InnerText;
|
|||
|
|
|
|||
|
|
switch (co_tipo)
|
|||
|
|
{
|
|||
|
|
case "DM": //Residencial
|
|||
|
|
if (flag_DM == 0)
|
|||
|
|
{
|
|||
|
|
flag_DM = 1;
|
|||
|
|
respuesta.idProvincia = GlobalAPIController.StringToInteger(co_provincia);
|
|||
|
|
respuesta.provincia = de_provincia;
|
|||
|
|
respuesta.idCanton = GlobalAPIController.StringToInteger(co_canton);
|
|||
|
|
respuesta.canton = de_canton;
|
|||
|
|
respuesta.idDistrito = GlobalAPIController.StringToInteger(co_distrito);
|
|||
|
|
respuesta.distrito = de_distrito;
|
|||
|
|
respuesta.direccionExacta = de_observacion;
|
|||
|
|
respuesta.numeroCasaApto = nu_casa;
|
|||
|
|
respuesta.idDistritoAreaMetro = co_distrito_area_metro;
|
|||
|
|
respuesta.secuencialDireccion = GlobalAPIController.StringToInteger(secuencial);
|
|||
|
|
|
|||
|
|
//_deuda.listaDireccion.Add(new DireccionCliente()
|
|||
|
|
//{
|
|||
|
|
// IdCliente = IdCliente,
|
|||
|
|
// Secuencial = GlobalAPIController.StringToInteger(secuencial),
|
|||
|
|
// IdTipoDireccion = co_tipo,
|
|||
|
|
// IdProvincia = GlobalAPIController.StringToInteger(co_provincia),
|
|||
|
|
// IdCanton = GlobalAPIController.StringToInteger(co_canton),
|
|||
|
|
// IdDistrito = GlobalAPIController.StringToInteger(co_distrito),
|
|||
|
|
// DirExacta = de_observacion,
|
|||
|
|
// NumCasaApto = nu_casa,
|
|||
|
|
// CodigoAreaMetro = co_distrito_area_metro
|
|||
|
|
//});
|
|||
|
|
|
|||
|
|
|
|||
|
|
var nodoTelefonos = child.SelectSingleNode("Telefonos");
|
|||
|
|
if (nodoTelefonos != null)
|
|||
|
|
{
|
|||
|
|
for (int current2 = 0; current2 < nodoTelefonos.ChildNodes.Count; current2++)
|
|||
|
|
{
|
|||
|
|
var childTelefono = nodoTelefonos.ChildNodes.Item(current2);
|
|||
|
|
var secuencial_telefono = childTelefono.SelectSingleNode("co_telefono").InnerText;
|
|||
|
|
var de_telefono = childTelefono.SelectSingleNode("telefono").InnerText;
|
|||
|
|
var co_tipo_telefono = childTelefono.SelectSingleNode("tipo_telefono").InnerText;
|
|||
|
|
|
|||
|
|
switch (co_tipo_telefono)
|
|||
|
|
{
|
|||
|
|
case "1":
|
|||
|
|
respuesta.secuencialTelefonoResidencial = GlobalAPIController.StringToInteger(secuencial_telefono);
|
|||
|
|
respuesta.telefonoResidencial = de_telefono.Replace("-", "");
|
|||
|
|
co_tipo_telefono = "DM"; //Residencial
|
|||
|
|
break;
|
|||
|
|
case "5":
|
|||
|
|
respuesta.secuencialTelefonoFax = GlobalAPIController.StringToInteger(secuencial_telefono);
|
|||
|
|
respuesta.telefonoFax = de_telefono.Replace("-", "");
|
|||
|
|
co_tipo_telefono = "DMF";//Fax Residencial
|
|||
|
|
break;
|
|||
|
|
case "4":
|
|||
|
|
respuesta.secuencialTelefonoCelular = GlobalAPIController.StringToInteger(secuencial_telefono);
|
|||
|
|
respuesta.telefonoCelular = de_telefono.Replace("-", "");
|
|||
|
|
co_tipo_telefono = "DMM";//Celular Personal
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//_deuda.listaTelefono.Add(new TelefonoCliente()
|
|||
|
|
//{
|
|||
|
|
// IdCliente = IdCliente,
|
|||
|
|
// Secuencial = GlobalAPIController.StringToInteger(secuencial_telefono),
|
|||
|
|
// CodigoArea = "506",
|
|||
|
|
// Extension = null,
|
|||
|
|
// IdTipoTelefono = co_tipo_telefono,
|
|||
|
|
// Telefono = de_telefono.Replace("-","")
|
|||
|
|
//});
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case "DC": //Laboral
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (flag_DC == 0)
|
|||
|
|
{
|
|||
|
|
flag_DC = 1;
|
|||
|
|
|
|||
|
|
infoLaboral.Direccion = new DireccionCliente()
|
|||
|
|
{
|
|||
|
|
IdCliente = IdCliente,
|
|||
|
|
Secuencial = GlobalAPIController.StringToInteger(secuencial),
|
|||
|
|
IdTipoDireccion = co_tipo,
|
|||
|
|
IdProvincia = GlobalAPIController.StringToInteger(co_provincia),
|
|||
|
|
IdCanton = GlobalAPIController.StringToInteger(co_canton),
|
|||
|
|
IdDistrito = GlobalAPIController.StringToInteger(co_distrito),
|
|||
|
|
DirExacta = de_observacion
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//respuesta.listaDireccion.Add(new DireccionCliente()
|
|||
|
|
//{
|
|||
|
|
// IdCliente = IdCliente,
|
|||
|
|
// Secuencial = GlobalAPIController.StringToInteger(secuencial),
|
|||
|
|
// IdTipoDireccion = co_tipo,
|
|||
|
|
// IdProvincia = GlobalAPIController.StringToInteger(co_provincia),
|
|||
|
|
// IdCanton = GlobalAPIController.StringToInteger(co_canton),
|
|||
|
|
// IdDistrito = GlobalAPIController.StringToInteger(co_distrito),
|
|||
|
|
// DirExacta = de_observacion,
|
|||
|
|
//});
|
|||
|
|
|
|||
|
|
|
|||
|
|
var nodoTelefonos = child.SelectSingleNode("Telefonos");
|
|||
|
|
if (nodoTelefonos != null)
|
|||
|
|
{
|
|||
|
|
for (int current2 = 0; current2 < nodoTelefonos.ChildNodes.Count; current2++)
|
|||
|
|
{
|
|||
|
|
var childTelefono = nodoTelefonos.ChildNodes.Item(current2);
|
|||
|
|
var secuencial_telefono = childTelefono.SelectSingleNode("co_telefono").InnerText;
|
|||
|
|
var de_telefono = childTelefono.SelectSingleNode("telefono").InnerText;
|
|||
|
|
var co_tipo_telefono = childTelefono.SelectSingleNode("tipo_telefono").InnerText;
|
|||
|
|
string de_extension = null;
|
|||
|
|
|
|||
|
|
switch (co_tipo_telefono)
|
|||
|
|
{
|
|||
|
|
case "2":
|
|||
|
|
|
|||
|
|
co_tipo_telefono = "DC"; //Laboral
|
|||
|
|
de_extension = childTelefono.SelectSingleNode("extension").InnerText;
|
|||
|
|
infoLaboral.Telefono = new TelefonoCliente()
|
|||
|
|
{
|
|||
|
|
IdCliente = IdCliente,
|
|||
|
|
Secuencial = GlobalAPIController.StringToInteger(secuencial_telefono),
|
|||
|
|
CodigoArea = "506",
|
|||
|
|
Extension = de_extension,
|
|||
|
|
IdTipoTelefono = co_tipo_telefono,
|
|||
|
|
Telefono = de_telefono.Replace("-", "")
|
|||
|
|
};
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case "7":
|
|||
|
|
|
|||
|
|
co_tipo_telefono = "DCF"; //Fax Laboral
|
|||
|
|
infoLaboral.Fax = new TelefonoCliente()
|
|||
|
|
{
|
|||
|
|
IdCliente = IdCliente,
|
|||
|
|
Secuencial = GlobalAPIController.StringToInteger(secuencial_telefono),
|
|||
|
|
CodigoArea = "506",
|
|||
|
|
Extension = de_extension,
|
|||
|
|
IdTipoTelefono = co_tipo_telefono,
|
|||
|
|
Telefono = de_telefono.Replace("-", "")
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//respuesta.listaTelefono.Add(new TelefonoCliente()
|
|||
|
|
//{
|
|||
|
|
// IdCliente = IdCliente,
|
|||
|
|
// Secuencial = GlobalAPIController.StringToInteger(secuencial_telefono),
|
|||
|
|
// CodigoArea = "506",
|
|||
|
|
// Extension = de_extension,
|
|||
|
|
// IdTipoTelefono = co_tipo_telefono,
|
|||
|
|
// Telefono = de_telefono.Replace("-", "")
|
|||
|
|
//});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Correos electronicos
|
|||
|
|
//*******************************
|
|||
|
|
var nodoEmails = xmlDetalle.SelectSingleNode("Emails");
|
|||
|
|
if (nodoEmails != null)
|
|||
|
|
{
|
|||
|
|
for (int a = 0; a < nodoEmails.ChildNodes.Count; a++)
|
|||
|
|
{
|
|||
|
|
var childmails = nodoEmails.ChildNodes.Item(a);
|
|||
|
|
var secuencial_email = childmails.SelectSingleNode("co_email").InnerText;
|
|||
|
|
var de_email = childmails.SelectSingleNode("de_email").InnerText;
|
|||
|
|
|
|||
|
|
int? co_tipo_email = null;
|
|||
|
|
|
|||
|
|
if (a == 0)
|
|||
|
|
{
|
|||
|
|
co_tipo_email = 1; //Personal
|
|||
|
|
respuesta.secuencialCorreoElectronico = GlobalAPIController.StringToInteger(secuencial_email);
|
|||
|
|
respuesta.correoElectronico = de_email;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
co_tipo_email = 2; //Laboral
|
|||
|
|
infoLaboral.Email = new EmailCliente()
|
|||
|
|
{
|
|||
|
|
IdCliente = IdCliente,
|
|||
|
|
Secuencial = GlobalAPIController.StringToInteger(secuencial_email),
|
|||
|
|
Email = de_email,
|
|||
|
|
IdTipoEmail = co_tipo_email
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//respuesta.listaEmail.Add(new EmailCliente()
|
|||
|
|
//{
|
|||
|
|
// IdCliente = IdCliente,
|
|||
|
|
// Secuencial = GlobalAPIController.StringToInteger(secuencial_email),
|
|||
|
|
// Email = de_email,
|
|||
|
|
// IdTipoEmail = co_tipo_email
|
|||
|
|
//});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Fuentes de Ingresos
|
|||
|
|
|
|||
|
|
var nodoFuentesIngresos = xmlDetalle.SelectSingleNode("FuentesIngresos");
|
|||
|
|
if (nodoFuentesIngresos != null)
|
|||
|
|
{
|
|||
|
|
var nodoFuenteIngreso = nodoFuentesIngresos.SelectSingleNode("FuenteIngreso");
|
|||
|
|
|
|||
|
|
if (nodoFuenteIngreso != null)
|
|||
|
|
{
|
|||
|
|
var secuencial_fuenteIngreso = nodoFuenteIngreso.SelectSingleNode("nu_fuente_ingreso").InnerText;
|
|||
|
|
var mo_sueldo = nodoFuenteIngreso.SelectSingleNode("mo_sueldo").InnerText;
|
|||
|
|
var co_compania = nodoFuenteIngreso.SelectSingleNode("co_compania_catalogo").InnerText;
|
|||
|
|
var de_compania = nodoFuenteIngreso.SelectSingleNode("de_compania_normal").InnerText;
|
|||
|
|
var co_ocupacion = nodoFuenteIngreso.SelectSingleNode("co_ocupacion").InnerText;
|
|||
|
|
var de_ocupacion = nodoFuenteIngreso.SelectSingleNode("de_ocupacion").InnerText;
|
|||
|
|
var moneda_salario = nodoFuenteIngreso.SelectSingleNode("co_moneda").InnerText;
|
|||
|
|
|
|||
|
|
infoLaboral.InformacionLaboralCliente = new InformacionLaboralCliente()
|
|||
|
|
{
|
|||
|
|
IdCliente = IdCliente,
|
|||
|
|
Secuencial = GlobalAPIController.StringToInteger(secuencial_fuenteIngreso),
|
|||
|
|
NombreEmpresa = de_compania,
|
|||
|
|
IdPuestoActual = co_ocupacion
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//respuesta.listaInformacionLaboral.Add(new InformacionLaboralCliente() {
|
|||
|
|
// IdCliente= IdCliente,
|
|||
|
|
// Secuencial = GlobalAPIController.StringToInteger(secuencial_fuenteIngreso),
|
|||
|
|
// NombreEmpresa = de_compania,
|
|||
|
|
// IdPuestoActual = int.Parse(co_ocupacion)
|
|||
|
|
//});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Pasivos
|
|||
|
|
|
|||
|
|
var cadena_xml_pasivos = "";
|
|||
|
|
var nodoPasivos = xmlDetalle.SelectSingleNode("Pasivos");
|
|||
|
|
if (nodoPasivos != null)
|
|||
|
|
{
|
|||
|
|
//para guardar las operaciones del deudor en situacion actual
|
|||
|
|
cadena_xml_pasivos = nodoPasivos.OuterXml;
|
|||
|
|
//CUENTAS Y TIPOS DE CUENTAS
|
|||
|
|
var cad_nu_cuenta = "";
|
|||
|
|
var cad_tipo_cuenta = "";
|
|||
|
|
for (int k = 0; k < nodoPasivos.ChildNodes.Count; k++)
|
|||
|
|
{
|
|||
|
|
var child_pasivos = nodoPasivos.ChildNodes.Item(k);
|
|||
|
|
string moneda_cuenta = string.Empty;
|
|||
|
|
string nu_cuenta = string.Empty;
|
|||
|
|
string codigo_tipo_cuenta = string.Empty;
|
|||
|
|
|
|||
|
|
if (child_pasivos.SelectSingleNode("MONEDA") != null)
|
|||
|
|
moneda_cuenta = child_pasivos.SelectSingleNode("MONEDA").InnerText;
|
|||
|
|
|
|||
|
|
if (child_pasivos.SelectSingleNode("NUMEROCUENTA") != null)
|
|||
|
|
nu_cuenta = child_pasivos.SelectSingleNode("NUMEROCUENTA").InnerText;
|
|||
|
|
|
|||
|
|
if (child_pasivos.SelectSingleNode("CODIGOTIPOCUENTA") != null)
|
|||
|
|
codigo_tipo_cuenta = child_pasivos.SelectSingleNode("CODIGOTIPOCUENTA").InnerText;
|
|||
|
|
|
|||
|
|
if (moneda_cuenta.ToUpper() == "COLONES")
|
|||
|
|
{
|
|||
|
|
cad_tipo_cuenta += codigo_tipo_cuenta + "|";
|
|||
|
|
cad_nu_cuenta += nu_cuenta + "|";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
double dblAcumuladoTotal = 0;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Activos
|
|||
|
|
|
|||
|
|
var cadena_detalle_total = "";
|
|||
|
|
var cadena_xml_activos = "";
|
|||
|
|
var nodoActivos = xmlDetalle.SelectSingleNode("Activos");
|
|||
|
|
if (nodoActivos != null)
|
|||
|
|
{
|
|||
|
|
//*******************************
|
|||
|
|
//ACUMULADO
|
|||
|
|
//*******************************
|
|||
|
|
var acumulado_colones = nodoActivos.SelectSingleNode("ACUMULADOCOLONES").InnerText;
|
|||
|
|
var acumulado_dolares = nodoActivos.SelectSingleNode("ACUMULADODOLARES").InnerText;
|
|||
|
|
|
|||
|
|
double dblAcumuladoDolares = double.Parse(formatea_coma(acumulado_dolares));
|
|||
|
|
double dblAcumuladoColones = double.Parse(formatea_coma(acumulado_colones)) / (double)TipoCambio;
|
|||
|
|
|
|||
|
|
dblAcumuladoTotal = dblAcumuladoColones + dblAcumuladoDolares;
|
|||
|
|
|
|||
|
|
//obj1.setVarValue("E73", acumulado_total);
|
|||
|
|
|
|||
|
|
//*******************************
|
|||
|
|
//DETALLE DE LOS SALDOS
|
|||
|
|
//*******************************
|
|||
|
|
var xmlPrestamos = nodoActivos.SelectSingleNode("Prestamos");
|
|||
|
|
var cadena_detalle = "";
|
|||
|
|
for (int i = 0; i < xmlPrestamos.ChildNodes.Count; i++)
|
|||
|
|
{
|
|||
|
|
var childPrestamos = xmlPrestamos.ChildNodes.Item(i);
|
|||
|
|
var tipo_prestamo = childPrestamos.SelectSingleNode("TIPOOPERACION").InnerText;
|
|||
|
|
var saldo = childPrestamos.SelectSingleNode("SALDOACTUAL").InnerText;
|
|||
|
|
var moneda_registro = childPrestamos.SelectSingleNode("MONEDA").InnerText;
|
|||
|
|
|
|||
|
|
var moneda_caratula = (moneda_registro.ToUpper() == "DOLARES") ? "$" : "¢";
|
|||
|
|
cadena_detalle += tipo_prestamo + " por " + moneda_caratula + saldo + " mas ";
|
|||
|
|
|
|||
|
|
//para guardar las operaciones del deudor en situacion actual
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (childPrestamos.SelectSingleNode("OPERACION").InnerText.Substring(2, 3) == "5")
|
|||
|
|
{
|
|||
|
|
cadena_xml_activos += childPrestamos.OuterXml;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
respuesta.Alertas.Add("Ocurrio un problema al determinar el tipo de operacion:" + childPrestamos.SelectSingleNode("OPERACION").InnerText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cadena_xml_activos = "<Activos><Prestamos>" + cadena_xml_activos + "</Prestamos></Activos>";
|
|||
|
|
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
cadena_detalle_total = cadena_detalle.Substring(0, cadena_detalle.Length - 5);
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//obj1.setVarValue("E81", cadena_detalle_total);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Tarjetas
|
|||
|
|
|
|||
|
|
var cadena_xml_tarjetas = "";
|
|||
|
|
var nodoTarjetas = xmlDetalle.SelectSingleNode("TarjetasCredito");
|
|||
|
|
|
|||
|
|
if (nodoTarjetas != null)
|
|||
|
|
{
|
|||
|
|
//****************************************
|
|||
|
|
//para guardar las operaciones del deudor
|
|||
|
|
//****************************************
|
|||
|
|
cadena_xml_tarjetas = nodoTarjetas.OuterXml;
|
|||
|
|
|
|||
|
|
//*******************************
|
|||
|
|
//ACUMULADO DE TARJETAS
|
|||
|
|
//*******************************
|
|||
|
|
var acumulado_tarjeta_col = nodoTarjetas.SelectSingleNode("ACUMULADOCOLONES").InnerText;
|
|||
|
|
var acumulado_tarjeta_dol = nodoTarjetas.SelectSingleNode("ACUMULADODOLARES").InnerText;
|
|||
|
|
|
|||
|
|
double dblAcumuladoTarjetaDolares = double.Parse(formatea_coma(acumulado_tarjeta_dol));
|
|||
|
|
double dblAcumuladoTarjetaColones = double.Parse(formatea_coma(acumulado_tarjeta_col)) / (double)TipoCambio;
|
|||
|
|
|
|||
|
|
|
|||
|
|
dblAcumuladoTotal = dblAcumuladoTotal + dblAcumuladoTarjetaColones + dblAcumuladoTarjetaDolares;
|
|||
|
|
|
|||
|
|
//obj1.setVarValue("E73",acumulado_total);
|
|||
|
|
|
|||
|
|
//*******************************
|
|||
|
|
//DETALLE DE LAS TARJETAS
|
|||
|
|
//*******************************
|
|||
|
|
var xmlTarjetas = nodoTarjetas.SelectSingleNode("Tarjetas");
|
|||
|
|
var cadena_detalle_tarjetas = "";
|
|||
|
|
for (int j = 0; j < xmlTarjetas.ChildNodes.Count; j++)
|
|||
|
|
{
|
|||
|
|
var childTarjeta = xmlTarjetas.ChildNodes.Item(j);
|
|||
|
|
var limite_tarjetas = childTarjeta.SelectSingleNode("LIMITE").InnerText;
|
|||
|
|
var moneda_limite = childTarjeta.SelectSingleNode("MONEDA").InnerText;
|
|||
|
|
|
|||
|
|
var moneda_tarjeta = (moneda_limite.ToUpper() == "DOLARES") ? "$" : "¢";
|
|||
|
|
|
|||
|
|
cadena_detalle_tarjetas += "Tarjeta de Credito por: " + moneda_tarjeta + limite_tarjetas + " mas ";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
cadena_detalle_tarjetas = cadena_detalle_tarjetas.Substring(0, cadena_detalle_tarjetas.Length - 5);
|
|||
|
|
cadena_detalle_total += " - " + cadena_detalle_tarjetas;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//obj1.setVarValue("E81", cadena_detalle_total);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
respuesta.totalAcumuladoCompromisosConBanco = dblAcumuladoTotal;
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Scoring
|
|||
|
|
|
|||
|
|
var nodoScoring = xmlDetalle.SelectSingleNode("Scoring");
|
|||
|
|
var nodoScoringDetalle = xmlDetalle.SelectSingleNode("ScoringDetalle");
|
|||
|
|
|
|||
|
|
if (nodoScoring != null)
|
|||
|
|
{
|
|||
|
|
var morosidad = nodoScoring.SelectSingleNode("morosidad").InnerText;
|
|||
|
|
var arr_morosidad = new string[6]; var arr_newmorosidad = new string[6];
|
|||
|
|
arr_morosidad[0] = ""; arr_newmorosidad[0] = "";
|
|||
|
|
arr_morosidad[1] = "IGUAL O MENOR A 30 DIAS"; arr_newmorosidad[1] = "Igual o menor a 30 días";
|
|||
|
|
arr_morosidad[2] = "IGUAL O MENOR A 60 DIAS"; arr_newmorosidad[2] = "Igual o menor a 60 días";
|
|||
|
|
arr_morosidad[3] = "IGUAL O MENOR A 90 DIAS"; arr_newmorosidad[3] = "Igual o menor a 90 días";
|
|||
|
|
arr_morosidad[4] = "IGUAL O MENOR A 120 DIAS"; arr_newmorosidad[4] = "Igual o menor a 120 días";
|
|||
|
|
arr_morosidad[5] = "MAYOR A 120 DIAS"; arr_newmorosidad[5] = "Mayor a 120 días";
|
|||
|
|
|
|||
|
|
for (int i = 0; i < arr_morosidad.Length; i++)
|
|||
|
|
{
|
|||
|
|
if (morosidad == arr_morosidad[i])
|
|||
|
|
{
|
|||
|
|
morosidad = arr_newmorosidad[i];
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//obj1.setVarValue("E74",morosidad)
|
|||
|
|
//obj1.setVarValue("E100",morosidad)
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
XmlDocument xmlActivos = new XmlDocument();
|
|||
|
|
xmlActivos.LoadXml(cadena_xml_activos);
|
|||
|
|
var nodoActivosToSave = xmlActivos.DocumentElement;
|
|||
|
|
|
|||
|
|
respuesta.TipoParticipante = TipoParticipante;
|
|||
|
|
respuesta.TipoPersona = TipoPersona;
|
|||
|
|
|
|||
|
|
var respSave = GuardarParticipanteConsultaCobis(respuesta, //InfoGeneralCliente
|
|||
|
|
infoLaboral, //InfoLaboralCliente
|
|||
|
|
nodoScoring, //InfoScoring
|
|||
|
|
nodoScoringDetalle, //InfoScoringDetalle
|
|||
|
|
nodoActivosToSave, //InfoActivosToSaveCIC
|
|||
|
|
null, //InfoTarjetasToSaveCIC
|
|||
|
|
nodoActivos, //InfoActivosToSavePosicionCliente
|
|||
|
|
nodoPasivos, //InfoPasivosToSavePosicionCliente
|
|||
|
|
nodoTarjetas //InfoTarjetasToSavePosicionCliente
|
|||
|
|
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
//**********************************************************************
|
|||
|
|
//Obtiene el IDCliente que se guardó
|
|||
|
|
//**********************************************************************
|
|||
|
|
respuesta.idCliente = respSave.IdCliente;
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (respSave.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString() && respSave.IdCliente == 0)
|
|||
|
|
{
|
|||
|
|
throw new Exception(respSave.DescripcionRespuesta);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//**********************************************************************
|
|||
|
|
//Si no existe ningun Warning, setea como exitoso el codigo de repuesta
|
|||
|
|
//**********************************************************************
|
|||
|
|
if (string.IsNullOrEmpty(respuesta.CodigoRespuesta))
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
}
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private JsonGuardarParticipanteResponse GuardarParticipanteConsultaCobis(JsonParticipante _modelParticipante,
|
|||
|
|
JsonInfoLaboralDetalle _modelLaboral,
|
|||
|
|
XmlNode nodoScoring,
|
|||
|
|
XmlNode nodoScoringDetalle,
|
|||
|
|
XmlNode nodoActivosToSaveCIC,
|
|||
|
|
XmlNode nodoTarjetasToSaveCIC,
|
|||
|
|
XmlNode nodoActivosToSavePosicionCliente,
|
|||
|
|
XmlNode nodoPasivosToSavePosicionCliente,
|
|||
|
|
XmlNode nodoTarjetasToSavePosicionCliente)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
JsonGuardarParticipanteResponse resp = null;
|
|||
|
|
InfoLaboralAPIController _infoLaboralCtr = null;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
resp = new JsonGuardarParticipanteResponse();
|
|||
|
|
_infoLaboralCtr = new InfoLaboralAPIController();
|
|||
|
|
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
#region Cliente
|
|||
|
|
|
|||
|
|
//Guarda la informacion general del deudor, telefonos, direcciones y email resindeciales
|
|||
|
|
|
|||
|
|
|
|||
|
|
JsonGuardarParticipanteResponse respSave = GuardarParticipante(_modelParticipante);
|
|||
|
|
|
|||
|
|
if (respSave.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|||
|
|
{
|
|||
|
|
throw new Exception(respSave.DescripcionRespuesta);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Recupera el nuevo IdCliente
|
|||
|
|
resp.IdCliente = respSave.IdCliente;
|
|||
|
|
|
|||
|
|
|
|||
|
|
//Obtiene la Informacion de Posicion y Score del Cliente
|
|||
|
|
Cliente _modelCliente = db.Cliente
|
|||
|
|
.Include(x => x.DataScoring)
|
|||
|
|
.Include(x => x.DataScoringDetalle)
|
|||
|
|
.Where(x => x.IdCliente == respSave.IdCliente).FirstOrDefault();
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region InfoLaboral
|
|||
|
|
|
|||
|
|
InformacionLaboralCliente ilc = db.InformacionLaboralCliente.Where(q => q.IdCliente == resp.IdCliente).FirstOrDefault();
|
|||
|
|
if (ilc != null)
|
|||
|
|
{
|
|||
|
|
if (_modelLaboral.InformacionLaboralCliente != null) _modelLaboral.InformacionLaboralCliente.IdInfoLaboral = ilc.IdInfoLaboral;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_modelLaboral.InformacionLaboralCliente != null)
|
|||
|
|
{
|
|||
|
|
_modelLaboral.InformacionLaboralCliente.IdCliente = resp.IdCliente;
|
|||
|
|
|
|||
|
|
//Señala que no esta validado el registro de informacion laboral
|
|||
|
|
_modelLaboral.InformacionLaboralCliente.Valido = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (_modelLaboral.Direccion != null) _modelLaboral.Direccion.IdCliente = resp.IdCliente;
|
|||
|
|
if (_modelLaboral.Telefono != null) _modelLaboral.Telefono.IdCliente = resp.IdCliente;
|
|||
|
|
if (_modelLaboral.Fax != null) _modelLaboral.Fax.IdCliente = resp.IdCliente;
|
|||
|
|
if (_modelLaboral.Email != null) _modelLaboral.Email.IdCliente = resp.IdCliente;
|
|||
|
|
|
|||
|
|
_infoLaboralCtr.GuardarInfoLaboralDetalle(_modelLaboral);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region Scoring
|
|||
|
|
|
|||
|
|
if (nodoScoring != null)
|
|||
|
|
{
|
|||
|
|
//Procesa el registro de Informacion del SCORING
|
|||
|
|
XmlNode nodoScoringRoot = nodoScoring.SelectSingleNode("//Scoring");
|
|||
|
|
if (nodoScoringRoot.ChildNodes.Count > 0)
|
|||
|
|
{
|
|||
|
|
bool _isNewDataScoring = false;
|
|||
|
|
DataScoring _modelDataScoring = _modelCliente.DataScoring.FirstOrDefault();
|
|||
|
|
|
|||
|
|
if (_modelDataScoring == null)
|
|||
|
|
{
|
|||
|
|
_isNewDataScoring = true;
|
|||
|
|
|
|||
|
|
_modelDataScoring = new DataScoring();
|
|||
|
|
_modelDataScoring.IdDataScoring = 1;
|
|||
|
|
|
|||
|
|
if (db.DataScoring.Count() > 0)
|
|||
|
|
_modelDataScoring.IdDataScoring = db.DataScoring.Max(q => q.IdDataScoring) + 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
_modelDataScoring.IdCliente = _modelCliente.IdCliente;
|
|||
|
|
_modelDataScoring.IdSolicitud = _modelParticipante.idSolicitud;
|
|||
|
|
_modelDataScoring.FeCreacionEnte = nodoScoringRoot.SelectSingleNode("fe_creacion").InnerText;
|
|||
|
|
_modelDataScoring.FeUltProducto = nodoScoringRoot.SelectSingleNode("fe_ultimo_producto").InnerText;
|
|||
|
|
_modelDataScoring.OperCanceladas = GlobalAPIController.StringToInteger(nodoScoringRoot.SelectSingleNode("creditos_cancelados").InnerText);
|
|||
|
|
_modelDataScoring.ChequesDevueltos = GlobalAPIController.StringToInteger(nodoScoringRoot.SelectSingleNode("cheques_devueltos").InnerText);
|
|||
|
|
_modelDataScoring.Castigado = nodoScoringRoot.SelectSingleNode("castigado").InnerText;
|
|||
|
|
_modelDataScoring.MaxAtrasoHist = GlobalAPIController.StringToDecimal(nodoScoringRoot.SelectSingleNode("max_atraso_historico").InnerText);
|
|||
|
|
_modelDataScoring.MaxAtraso12m = GlobalAPIController.StringToDecimal(nodoScoringRoot.SelectSingleNode("max_atraso_12m").InnerText);
|
|||
|
|
_modelDataScoring.MaxAtraso6m = GlobalAPIController.StringToDecimal(nodoScoringRoot.SelectSingleNode("max_atraso_6m").InnerText);
|
|||
|
|
_modelDataScoring.MaxAtraso3m = GlobalAPIController.StringToDecimal(nodoScoringRoot.SelectSingleNode("max_atraso_3m").InnerText);
|
|||
|
|
_modelDataScoring.OperCanceladas6m = GlobalAPIController.StringToInteger(nodoScoringRoot.SelectSingleNode("operaciones_canceladas_6m").InnerText);
|
|||
|
|
_modelDataScoring.Atrasos30d = GlobalAPIController.StringToInteger(nodoScoringRoot.SelectSingleNode("atrasos_30dias").InnerText);
|
|||
|
|
_modelDataScoring.Morosidad = nodoScoringRoot.SelectSingleNode("morosidad").InnerText;
|
|||
|
|
_modelDataScoring.Reestructurado = GlobalAPIController.StringToInteger(nodoScoringRoot.SelectSingleNode("reestructurado").InnerText);
|
|||
|
|
|
|||
|
|
if (_isNewDataScoring)
|
|||
|
|
{
|
|||
|
|
db.DataScoring.Add(_modelDataScoring);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
db.Entry(_modelDataScoring).State = EntityState.Detached;
|
|||
|
|
db.DataScoring.Attach(_modelDataScoring);
|
|||
|
|
db.Entry(_modelDataScoring).State = System.Data.Entity.EntityState.Modified;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region ScoringDetalle
|
|||
|
|
|
|||
|
|
if (nodoScoringDetalle != null)
|
|||
|
|
{
|
|||
|
|
//Procesa el registro de Informacion del SCORINGDETALLE
|
|||
|
|
XmlNode nodoScoringDetalleRoot = nodoScoringDetalle.SelectSingleNode("//ScoringDetalle");
|
|||
|
|
if (nodoScoringDetalleRoot.ChildNodes.Count > 0)
|
|||
|
|
{
|
|||
|
|
//Elimina los registros existentes
|
|||
|
|
List<DataScoringDetalle> _modelDataScoringDetalleList = _modelCliente.DataScoringDetalle.ToList();
|
|||
|
|
db.DataScoringDetalle.RemoveRange(_modelDataScoringDetalleList);
|
|||
|
|
db.SaveChanges();
|
|||
|
|
|
|||
|
|
//Obtiene el Id nuevo para insertar en la tabla
|
|||
|
|
int newIdDataScoringDetalle = 1;
|
|||
|
|
if (db.DataScoringDetalle.Count() > 0)
|
|||
|
|
newIdDataScoringDetalle = db.DataScoringDetalle.Max(q => q.IdDataScoringDetalle) + 1;
|
|||
|
|
|
|||
|
|
//Recorre el xml de detalle de scoring
|
|||
|
|
foreach (XmlNode nodoScoringDetalleItem in nodoScoringDetalleRoot.ChildNodes)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
DataScoringDetalle _modelDataScoringDetalle = new DataScoringDetalle();
|
|||
|
|
|
|||
|
|
_modelDataScoringDetalle.IdDataScoringDetalle = newIdDataScoringDetalle;
|
|||
|
|
_modelDataScoringDetalle.IdCliente = _modelCliente.IdCliente;
|
|||
|
|
_modelDataScoringDetalle.IdSolicitud = _modelParticipante.idSolicitud;
|
|||
|
|
_modelDataScoringDetalle.TOperacion = nodoScoringDetalleItem.SelectSingleNode("toperacion").InnerText;
|
|||
|
|
_modelDataScoringDetalle.MaxAtrasoHist = GlobalAPIController.StringToInteger(nodoScoringDetalleItem.SelectSingleNode("max_atraso_hist").InnerText);
|
|||
|
|
_modelDataScoringDetalle.MaxAtraso3m = GlobalAPIController.StringToInteger(nodoScoringDetalleItem.SelectSingleNode("max_atraso_3m").InnerText);
|
|||
|
|
_modelDataScoringDetalle.MaxAtraso6m = GlobalAPIController.StringToInteger(nodoScoringDetalleItem.SelectSingleNode("max_atraso_6m").InnerText);
|
|||
|
|
_modelDataScoringDetalle.MaxAtraso12m = GlobalAPIController.StringToInteger(nodoScoringDetalleItem.SelectSingleNode("max_atraso_12m").InnerText);
|
|||
|
|
_modelDataScoringDetalle.MaxAtrasoAct = GlobalAPIController.StringToInteger(nodoScoringDetalleItem.SelectSingleNode("max_atraso_act").InnerText);
|
|||
|
|
_modelDataScoringDetalle.Atraso30d = GlobalAPIController.StringToInteger(nodoScoringDetalleItem.SelectSingleNode("ds_atraso_30d").InnerText);
|
|||
|
|
_modelDataScoringDetalle.ProdCastigado = GlobalAPIController.StringToInteger(nodoScoringDetalleItem.SelectSingleNode("prod_castigado").InnerText);
|
|||
|
|
|
|||
|
|
db.DataScoringDetalle.Add(_modelDataScoringDetalle);
|
|||
|
|
newIdDataScoringDetalle++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region ActivosCIC
|
|||
|
|
if (nodoActivosToSaveCIC != null)
|
|||
|
|
{
|
|||
|
|
//TODO
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region TarjetasCIC
|
|||
|
|
if (nodoTarjetasToSaveCIC != null)
|
|||
|
|
{
|
|||
|
|
//TODO
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region ActivosPosicionCliente
|
|||
|
|
if (nodoActivosToSavePosicionCliente != null)
|
|||
|
|
{
|
|||
|
|
#region Elimina los registros
|
|||
|
|
//Elimina los registros existentes
|
|||
|
|
List<PosicionActivos> _modelPosicionActivosList = _modelCliente.PosicionActivos.ToList();
|
|||
|
|
db.PosicionActivos.RemoveRange(_modelPosicionActivosList);
|
|||
|
|
db.SaveChanges();
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Obtiene el Id con que Inicia el Registrado en la Tabla
|
|||
|
|
//Obtiene el Id nuevo para insertar en la tabla
|
|||
|
|
int newIdPosicionActivos = 1;
|
|||
|
|
if (db.PosicionActivos.AsNoTracking().Count() > 0)
|
|||
|
|
newIdPosicionActivos = db.PosicionActivos.Max(q => q.IdPosicionActivos) + 1;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Ejecuta el barrido del XML para Registrar en la BD
|
|||
|
|
foreach (XmlNode nodoActivosToSavePosicionClienteItem in nodoActivosToSavePosicionCliente.SelectSingleNode("Prestamos").ChildNodes)
|
|||
|
|
{
|
|||
|
|
PosicionActivos _modelPosicionActivos = new PosicionActivos();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_modelPosicionActivos.IdPosicionActivos = newIdPosicionActivos;
|
|||
|
|
_modelPosicionActivos.IdCliente = _modelCliente.IdCliente;
|
|||
|
|
_modelPosicionActivos.IdSolicitud = _modelParticipante.idSolicitud;
|
|||
|
|
_modelPosicionActivos.TipoOperacion = nodoActivosToSavePosicionClienteItem.SelectSingleNode("TIPOOPERACION").InnerText;
|
|||
|
|
_modelPosicionActivos.NumOperacion = nodoActivosToSavePosicionClienteItem.SelectSingleNode("OPERACION").InnerText;
|
|||
|
|
_modelPosicionActivos.FeInicio = nodoActivosToSavePosicionClienteItem.SelectSingleNode("FECHAINICIO").InnerText;
|
|||
|
|
_modelPosicionActivos.FeVencimiento = nodoActivosToSavePosicionClienteItem.SelectSingleNode("FECHAVENCIMIENTO").InnerText;
|
|||
|
|
_modelPosicionActivos.MontoOriginal = GlobalAPIController.StringToDecimal(nodoActivosToSavePosicionClienteItem.SelectSingleNode("MONTOORIGINAL").InnerText);
|
|||
|
|
_modelPosicionActivos.CuotaActual = GlobalAPIController.StringToDecimal(nodoActivosToSavePosicionClienteItem.SelectSingleNode("CUOTAMENSUAL").InnerText);
|
|||
|
|
_modelPosicionActivos.SaldoActual = GlobalAPIController.StringToDecimal(nodoActivosToSavePosicionClienteItem.SelectSingleNode("SALDOACTUAL").InnerText);
|
|||
|
|
_modelPosicionActivos.DiasMora = GlobalAPIController.StringToDecimal(nodoActivosToSavePosicionClienteItem.SelectSingleNode("DIASMORA").InnerText);
|
|||
|
|
_modelPosicionActivos.Estado = nodoActivosToSavePosicionClienteItem.SelectSingleNode("ESTADO").InnerText;
|
|||
|
|
_modelPosicionActivos.Moneda = nodoActivosToSavePosicionClienteItem.SelectSingleNode("MONEDA").InnerText;
|
|||
|
|
db.PosicionActivos.Add(_modelPosicionActivos);
|
|||
|
|
}
|
|||
|
|
catch (Exception exActivos)
|
|||
|
|
{
|
|||
|
|
UltimusLogs.logger.Error(exActivos);
|
|||
|
|
}
|
|||
|
|
newIdPosicionActivos++;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region PasivosPosicionCliente
|
|||
|
|
if (nodoPasivosToSavePosicionCliente != null)
|
|||
|
|
{
|
|||
|
|
#region Elimina los registros
|
|||
|
|
//Elimina los registros existentes
|
|||
|
|
List<PosicionPasivos> _modelPosicionPasivosList = _modelCliente.PosicionPasivos.ToList();
|
|||
|
|
db.PosicionPasivos.RemoveRange(_modelPosicionPasivosList);
|
|||
|
|
db.SaveChanges();
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Obtiene el Id con que Inicia el Registrado en la Tabla
|
|||
|
|
//Obtiene el Id nuevo para insertar en la tabla
|
|||
|
|
int newIdPosicionPasivos = 1;
|
|||
|
|
if (db.PosicionPasivos.AsNoTracking().Count() > 0)
|
|||
|
|
newIdPosicionPasivos = db.PosicionPasivos.Max(q => q.IdPosicionPasivos) + 1;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Ejecuta el barrido del XML para Registrar en la BD
|
|||
|
|
foreach (XmlNode nodoPasivosToSavePosicionClienteItem in nodoPasivosToSavePosicionCliente.ChildNodes)
|
|||
|
|
{
|
|||
|
|
PosicionPasivos _modelPosicionPasivos = new PosicionPasivos();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_modelPosicionPasivos.IdPosicionPasivos = newIdPosicionPasivos;
|
|||
|
|
_modelPosicionPasivos.IdCliente = _modelCliente.IdCliente;
|
|||
|
|
_modelPosicionPasivos.IdSolicitud = _modelParticipante.idSolicitud;
|
|||
|
|
_modelPosicionPasivos.CoTipocuenta = nodoPasivosToSavePosicionClienteItem.SelectSingleNode("CODIGOTIPOCUENTA").InnerText;
|
|||
|
|
_modelPosicionPasivos.TipoCuenta = nodoPasivosToSavePosicionClienteItem.SelectSingleNode("TIPOCUENTA").InnerText;
|
|||
|
|
_modelPosicionPasivos.NumCuenta = nodoPasivosToSavePosicionClienteItem.SelectSingleNode("NUMEROCUENTA").InnerText;
|
|||
|
|
_modelPosicionPasivos.FeInicio = nodoPasivosToSavePosicionClienteItem.SelectSingleNode("FECHAINICIO").InnerText;
|
|||
|
|
_modelPosicionPasivos.SaldoPromedio = GlobalAPIController.StringToDecimal(nodoPasivosToSavePosicionClienteItem.SelectSingleNode("SALDOPROMEDIO").InnerText);
|
|||
|
|
_modelPosicionPasivos.CreditoPromedio = GlobalAPIController.StringToDecimal(nodoPasivosToSavePosicionClienteItem.SelectSingleNode("CREDITOPROMEDIO").InnerText);
|
|||
|
|
_modelPosicionPasivos.DebitosPromedio = GlobalAPIController.StringToDecimal(nodoPasivosToSavePosicionClienteItem.SelectSingleNode("DEBITOPROMEDIO").InnerText);
|
|||
|
|
_modelPosicionPasivos.Disponible = GlobalAPIController.StringToDecimal(nodoPasivosToSavePosicionClienteItem.SelectSingleNode("DISPONIBLE").InnerText);
|
|||
|
|
_modelPosicionPasivos.Moneda = nodoPasivosToSavePosicionClienteItem.SelectSingleNode("MONEDA").InnerText;
|
|||
|
|
db.PosicionPasivos.Add(_modelPosicionPasivos);
|
|||
|
|
}
|
|||
|
|
catch (Exception exPasivos)
|
|||
|
|
{
|
|||
|
|
UltimusLogs.logger.Error(exPasivos);
|
|||
|
|
}
|
|||
|
|
newIdPosicionPasivos++;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region TarjetasPosicionCliente
|
|||
|
|
if (nodoTarjetasToSavePosicionCliente != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
#region Elimina los registros
|
|||
|
|
//Elimina los registros existentes
|
|||
|
|
List<PosicionTarjetas> _modelPosicionTarjetasList = _modelCliente.PosicionTarjetas.ToList();
|
|||
|
|
db.PosicionTarjetas.RemoveRange(_modelPosicionTarjetasList);
|
|||
|
|
db.SaveChanges();
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Obtiene el Id con que Inicia el Registrado en la Tabla
|
|||
|
|
//Obtiene el Id nuevo para insertar en la tabla
|
|||
|
|
int newIdPosicionTarjetas = 1;
|
|||
|
|
if (db.PosicionTarjetas.AsNoTracking().Count() > 0)
|
|||
|
|
newIdPosicionTarjetas = db.PosicionTarjetas.Max(q => q.IdPosicionTarjetas) + 1;
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Ejecuta el barrido del XML para Registrar en la BD
|
|||
|
|
foreach (XmlNode nodoTarjetasToSavePosicionClienteItem in nodoTarjetasToSavePosicionCliente.SelectSingleNode("Tarjetas").ChildNodes)
|
|||
|
|
{
|
|||
|
|
PosicionTarjetas _modelPosicionTarjetas = new PosicionTarjetas();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
_modelPosicionTarjetas.IdPosicionTarjetas = newIdPosicionTarjetas;
|
|||
|
|
_modelPosicionTarjetas.IdCliente = _modelCliente.IdCliente;
|
|||
|
|
_modelPosicionTarjetas.IdSolicitud = _modelParticipante.idSolicitud;
|
|||
|
|
_modelPosicionTarjetas.TitularTarjeta = nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("TITULARTARJETA").InnerText;
|
|||
|
|
_modelPosicionTarjetas.LimiteCredito = nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("LIMITE").InnerText;
|
|||
|
|
_modelPosicionTarjetas.Saldo = nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("SALDO").InnerText;
|
|||
|
|
_modelPosicionTarjetas.PagoMinimo = string.IsNullOrEmpty(nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("PAGOMINIMO").InnerText) ? "0" : nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("PAGOMINIMO").InnerText;
|
|||
|
|
_modelPosicionTarjetas.ClasificacionPago = nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("CLASIFICACIONPAGO").InnerText;
|
|||
|
|
_modelPosicionTarjetas.Estado = nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("ESTADO").InnerText;
|
|||
|
|
_modelPosicionTarjetas.DiasAtraso = GlobalAPIController.StringToInteger(nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("DIASATRASO").InnerText);
|
|||
|
|
_modelPosicionTarjetas.FeApertura = nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("FECHAAPERTURA").InnerText;
|
|||
|
|
_modelPosicionTarjetas.FeUltimoPago = nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("FECHAULTIMOPAGO").InnerText;
|
|||
|
|
_modelPosicionTarjetas.Moneda = nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("MONEDA").InnerText;
|
|||
|
|
_modelPosicionTarjetas.MontoUltimoPago = string.IsNullOrEmpty(nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("MONTOULTIMOPAGO").InnerText) ? "0" : nodoTarjetasToSavePosicionClienteItem.SelectSingleNode("MONTOULTIMOPAGO").InnerText;
|
|||
|
|
db.PosicionTarjetas.Add(_modelPosicionTarjetas);
|
|||
|
|
}
|
|||
|
|
catch (Exception exTarjetas)
|
|||
|
|
{
|
|||
|
|
UltimusLogs.logger.Error(exTarjetas);
|
|||
|
|
}
|
|||
|
|
newIdPosicionTarjetas++;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
db.SaveChanges();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
resp.DescripcionRespuesta = "EXITOSO";
|
|||
|
|
}
|
|||
|
|
catch (DbEntityValidationException ex)
|
|||
|
|
{
|
|||
|
|
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
|
|||
|
|
var fullErrorMessage = string.Join("; ", errorMessages);
|
|||
|
|
var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);
|
|||
|
|
|
|||
|
|
UltimusLogs.logger.Error(exceptionMessage);
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = exceptionMessage;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
resp.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
resp.DescripcionRespuesta = ex.Message;
|
|||
|
|
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return resp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
private string formatea_coma(string val)
|
|||
|
|
{
|
|||
|
|
string sResult = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
sResult = val.Replace(",", "");
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
sResult = "0.00";
|
|||
|
|
}
|
|||
|
|
return sResult;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private bool Valida_Estado_Cliente(string estado, out string warning)
|
|||
|
|
{
|
|||
|
|
warning = string.Empty;
|
|||
|
|
bool no_permitido = false;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (estado == "3" || estado == "5")
|
|||
|
|
{
|
|||
|
|
no_permitido = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (estado == "9")
|
|||
|
|
{
|
|||
|
|
warning = "Cliente señalizado como Simplificado.<br>No podrá avanzar el trámite";
|
|||
|
|
no_permitido = true;
|
|||
|
|
}
|
|||
|
|
else if (estado != "1" && estado.Trim().Length > 0)
|
|||
|
|
{
|
|||
|
|
warning = "Ente con estado diferente de activo, debe activarse centralizadamente";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return no_permitido;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
no_permitido = false;
|
|||
|
|
}
|
|||
|
|
return no_permitido;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public JsonInformacionCliente ObtenerInformacionCliente(string tipoBusqueda, string cedula, int idTipoIdentificacion)
|
|||
|
|
{
|
|||
|
|
string cedulaFormatoBDI = string.Empty;
|
|||
|
|
|
|||
|
|
JsonInformacionCliente respuesta = new JsonInformacionCliente();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (ServiciosClient client = new ServiciosClient())
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if (idTipoIdentificacion == 1)
|
|||
|
|
{
|
|||
|
|
cedulaFormatoBDI = cedula.Replace("-", "");
|
|||
|
|
cedulaFormatoBDI = cedulaFormatoBDI.Substring(1, cedulaFormatoBDI.Length - 1);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
cedulaFormatoBDI = cedula;
|
|||
|
|
|
|||
|
|
ObtenerInformacionClienteResponse r = client.ObtenerInformacionCliente(new ObtenerInformacionClienteRequest()
|
|||
|
|
{
|
|||
|
|
TipoBusqueda = tipoBusqueda,
|
|||
|
|
Cedula = cedulaFormatoBDI
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
if (r.errCode == "00")
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|||
|
|
respuesta.Identificacion = r.cliente.Identificacion;
|
|||
|
|
respuesta.PrimerNombre = r.cliente.PrimerNombre;
|
|||
|
|
respuesta.SegundoNombre = r.cliente.SegundoNombre;
|
|||
|
|
respuesta.PrimerApellido = r.cliente.PrimerApellido;
|
|||
|
|
respuesta.SegundoApellido = r.cliente.SegundoApellido;
|
|||
|
|
respuesta.LugarNacimiento = r.cliente.LugarNacimiento;
|
|||
|
|
respuesta.FechaNacimiento = r.cliente.FechaNacimiento;
|
|||
|
|
respuesta.FechaExpiracionCedula = r.cliente.FechaExpiracionCedula;
|
|||
|
|
respuesta.Genero = r.cliente.Genero;
|
|||
|
|
respuesta.Nacionalidad = r.cliente.Nacionalidad;
|
|||
|
|
respuesta.Dependientes = r.cliente.Dependientes;
|
|||
|
|
respuesta.EstadoCivil = r.cliente.EstadoCivil;
|
|||
|
|
if (r.telefonos.Count(t => t.tipo == "Celular") > 0)
|
|||
|
|
respuesta.telefonoCelular = r.telefonos.FirstOrDefault(t => t.tipo == "Celular").numero;
|
|||
|
|
|
|||
|
|
if (r.telefonos.Count(t => t.tipo == "Residencial") > 0)
|
|||
|
|
respuesta.telefonoResidencial = r.telefonos.FirstOrDefault(t => t.tipo == "Residencial").numero;
|
|||
|
|
|
|||
|
|
if (r.direcciones != null && r.direcciones.Length > 0)
|
|||
|
|
respuesta.direccion = r.direcciones[0].direccionSena;
|
|||
|
|
|
|||
|
|
using (PrendarioContext db = new PrendarioContext())
|
|||
|
|
{
|
|||
|
|
if (r.cliente != null && !string.IsNullOrEmpty(r.cliente.LugarNacimiento))
|
|||
|
|
respuesta.lugarNacimiento = db.Nacionalidad.FirstOrDefault(t => t.Pais.ToLower().Contains(r.cliente.LugarNacimiento.ToLower()));
|
|||
|
|
|
|||
|
|
if (r.cliente != null && !string.IsNullOrEmpty(r.cliente.Nacionalidad))
|
|||
|
|
respuesta.nacionalidad = db.Nacionalidad.FirstOrDefault(t => t.Pais.ToLower().Contains(r.cliente.Nacionalidad.ToLower()));
|
|||
|
|
|
|||
|
|
if (r.cliente != null && !string.IsNullOrEmpty(r.cliente.Genero))
|
|||
|
|
respuesta.genero = db.Genero.FirstOrDefault(t => t.Descripcion.ToLower().Contains(r.cliente.Genero.ToLower()));
|
|||
|
|
|
|||
|
|
if (r.cliente != null && !string.IsNullOrEmpty(r.cliente.EstadoCivil))
|
|||
|
|
respuesta.estadoCivil = db.EstadoCivil.FirstOrDefault(t => t.Descripcion.ToLower().Contains(r.cliente.EstadoCivil.ToLower()));
|
|||
|
|
|
|||
|
|
if (r.direcciones != null && r.direcciones.Length > 0)
|
|||
|
|
{
|
|||
|
|
Direccion d = r.direcciones[0];
|
|||
|
|
if (!string.IsNullOrEmpty(d.provincia))
|
|||
|
|
respuesta.provincia = db.Provincia.FirstOrDefault(t => t.Descripcion.ToLower().Contains(d.provincia.ToLower()));
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(d.canton) && respuesta.provincia != null)
|
|||
|
|
respuesta.canton = db.Canton.FirstOrDefault(t => t.IdProvincia == respuesta.provincia.IdProvincia && t.Descripcion.ToLower().Contains(d.canton.ToLower()));
|
|||
|
|
|
|||
|
|
if (!string.IsNullOrEmpty(d.distrito) && respuesta.canton != null)
|
|||
|
|
respuesta.distrito = db.Distrito.FirstOrDefault(t => t.IdCanton == respuesta.canton.IdCanton && t.Descripcion.ToLower().Contains(d.distrito.ToLower()));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = r.errMessage;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
log.EscribirArchivo("ULA.Davivienda.PrestamoAutos", ex);
|
|||
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|||
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return respuesta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|