726 lines
No EOL
34 KiB
C#
726 lines
No EOL
34 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.IO;
|
|
using System.Web.Http;
|
|
using System.Data.Entity;
|
|
using Ultimus.Utilitarios;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
using ULA.Cathay.CreditoModel.DAL.Credito;
|
|
using ULA.Cathay.Credito.Json;
|
|
using Ultimus.Interfaces;
|
|
using Newtonsoft.Json;
|
|
using Ultimus.Interfaces.UltimusIntegration;
|
|
using ULA.Cathay.CreditoModel.Entidades;
|
|
using ULA.Cathay.CreditoModel.History;
|
|
using ULA.Cathay.CreditoModel.DAL.History;
|
|
|
|
|
|
namespace ULA.Cathay.Credito.ControllersWebApi
|
|
{
|
|
public class AnalisisAPIController : ApiController
|
|
{
|
|
UltimusLogs logs = new UltimusLogs("AnalisisAPIController");
|
|
BitacoraControlAprobacionDAL ContApDal = new BitacoraControlAprobacionDAL();
|
|
|
|
public AnalisisAPIController()
|
|
{
|
|
GlobalAPIController.SetRegionalConfig();
|
|
}
|
|
|
|
#region ObtenerHistorialAprobacion
|
|
[HttpPost]
|
|
public JsonDataGrid ObtenerHistorialAprobacion(UltimusJson solicitud)
|
|
{
|
|
JsonDataGrid model = new JsonDataGrid();
|
|
|
|
try
|
|
{
|
|
var lista = ContApDal.Obtener(solicitud.IdSolicitud, solicitud.UltimusStep, solicitud.UltimusIncident);
|
|
|
|
|
|
if (lista != null)
|
|
model.JSONData = JsonConvert.SerializeObject(lista);
|
|
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
|
|
}
|
|
|
|
return model;
|
|
}
|
|
#endregion
|
|
|
|
#region CargarAprobacion
|
|
[HttpPost]
|
|
public ControlAprobacionJSON CargarAprobacion(ControlAprobacionJSON model)
|
|
{
|
|
EtapasDAL EtapasDal = new EtapasDAL();
|
|
int IDSolicitud = 0;
|
|
|
|
try
|
|
{
|
|
IDSolicitud = model.DatosGeneralesAnalisis.IdSolicitud;
|
|
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
Etapas etapa = EtapasDal.ObtenerEtapa(model.UltimusStep, model.UltimusProcess);
|
|
|
|
model.Aprobacion = model.Aprobacion ?? new BitacoraControlAprobacion();
|
|
model.Aprobacion.Etapas = etapa;
|
|
|
|
if (model.UltimusStep.In(EnumEtapas.AN_Rev_Doc_Clasificar, EnumEtapas.AN_Preanalisis))
|
|
{
|
|
model.ListaDecicionesAccionRechazo = db.Decision.Where(c => c.IdDecision == 18 || c.IdDecision == 19).ToList();
|
|
model.DatosGeneralesAnalisis = db.DatosGeneralesAnalisis.Where(c => c.IdSolicitud == IDSolicitud).FirstOrDefault();
|
|
}
|
|
|
|
|
|
Solicitante solicitante = db.Solicitante.Include(c => c.Cliente).Where(c => c.IdSolicitud == IDSolicitud).FirstOrDefault();
|
|
|
|
#region DOCUMENTOS INFORME ANALISIS
|
|
//documentos por tipo de cliente
|
|
int IdTipoCliente = solicitante.Cliente.IdTipoCliente.HasValue ? solicitante.Cliente.IdTipoCliente.Value : 0;
|
|
|
|
var lista = from a in db.AnalisisClienteDocumentos
|
|
where a.IdTipoCliente == IdTipoCliente
|
|
select a.IdTipoDocumento;
|
|
|
|
int[] ListaIdDocumentos = lista.ToArray();
|
|
|
|
List<BitacoraDocumentosInformeAnalisis> bitacora = db.BitacoraDocumentosInformeAnalisis.Include(c => c.TipoDocumento).Where(c => c.IdCliente == solicitante.IdCliente).ToList();
|
|
|
|
if (bitacora == null || bitacora.Count == 0)
|
|
{
|
|
var ListaDocumentos = db.TipoDocumento.Where(c => ListaIdDocumentos.Contains(c.IdTipoDocumento)).ToList();
|
|
|
|
bitacora = new List<BitacoraDocumentosInformeAnalisis>();
|
|
foreach (var doc in ListaDocumentos)
|
|
{
|
|
string ruta = doc.RutaMachote != null ? doc.RutaMachote.Replace("\\", "/") : string.Empty;
|
|
ruta = ruta.Replace("C:/Ultimus/UltimusAttachment/", new ObtieneParametros().GetValueKeyRegedit("UltimusAttachmentUrl", false));
|
|
bitacora.Add(
|
|
new BitacoraDocumentosInformeAnalisis()
|
|
{
|
|
IdTipoDocumento = doc.IdTipoDocumento,
|
|
IdCliente = solicitante.IdCliente,
|
|
CodDocumentoAdjunto = null,
|
|
Fecha = null,
|
|
TipoDocumento = doc,
|
|
RutaDescarga = ruta
|
|
}
|
|
);
|
|
}
|
|
|
|
db.BitacoraDocumentosInformeAnalisis.AddRange(bitacora);
|
|
db.SaveChanges();
|
|
}
|
|
|
|
model.ListaDocumentosInforme = bitacora;
|
|
#endregion
|
|
|
|
#region DOCUMENTOS SEGUIMIENTO
|
|
int[] ListaIdDocumentosSeguimiento = new int[] { 48, 49, 50, 51 };
|
|
|
|
List<BitacoraDocumentosSeguimientoAnalisis> bitacora_seguimiento = db.BitacoraDocumentosSeguimientoAnalisis.Include(c => c.TipoDocumento).Where(c => c.IdCliente == solicitante.IdCliente).ToList();
|
|
|
|
if (bitacora_seguimiento == null || bitacora_seguimiento.Count == 0)
|
|
{
|
|
var ListaDocumentos = db.TipoDocumento.Where(c => ListaIdDocumentosSeguimiento.Contains(c.IdTipoDocumento)).ToList();
|
|
|
|
bitacora_seguimiento = new List<BitacoraDocumentosSeguimientoAnalisis>();
|
|
foreach (var doc in ListaDocumentos)
|
|
{
|
|
bitacora_seguimiento.Add(
|
|
new BitacoraDocumentosSeguimientoAnalisis()
|
|
{
|
|
IdTipoDocumento = doc.IdTipoDocumento,
|
|
IdCliente = solicitante.IdCliente,
|
|
Fecha = DateTime.Now,
|
|
TipoDocumento = doc,
|
|
}
|
|
);
|
|
}
|
|
|
|
db.BitacoraDocumentosSeguimientoAnalisis.AddRange(bitacora_seguimiento);
|
|
db.SaveChanges();
|
|
}
|
|
|
|
model.ListaDocumentosSeguimiento = bitacora_seguimiento;
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
if (model.UltimusProcess.In("Credito", "Formalizacion"))
|
|
{
|
|
using (UltimusIntegrationAPIController IntegrationClient = new UltimusIntegrationAPIController())
|
|
{
|
|
List<UltimusUser> ListaUsuariosAnalisis = IntegrationClient.GetJobFunctionGroupMembers("Cathay OC", "Analista de crédito");
|
|
}
|
|
}
|
|
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
|
|
}
|
|
|
|
return model;
|
|
}
|
|
#endregion
|
|
|
|
#region GuardarAprobacion
|
|
[HttpPost]
|
|
public ControlAprobacionJSON GuardarAprobacion(ControlAprobacionJSON model)
|
|
{
|
|
try
|
|
{
|
|
|
|
ContApDal.Insertar(model.Aprobacion);
|
|
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
|
|
}
|
|
|
|
return model;
|
|
}
|
|
#endregion
|
|
|
|
#region CargarAnalisis
|
|
[HttpGet]
|
|
public AnalisisJSON CargarAnalisis(int IdSolicitud)
|
|
{
|
|
AnalisisJSON model = new AnalisisJSON();
|
|
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
model.DatosGeneralesAnalisis = db.DatosGeneralesAnalisis.Where(c => c.IdSolicitud == IdSolicitud).FirstOrDefault();
|
|
|
|
Solicitante solicitante = db.Solicitante.Include(c => c.Cliente).Where(c => c.IdSolicitud == IdSolicitud).FirstOrDefault();
|
|
|
|
|
|
#region DOCUMENTOS INFORME ANALISIS
|
|
//documentos por tipo de cliente
|
|
int IdTipoCliente = solicitante.Cliente.IdTipoCliente.HasValue ? solicitante.Cliente.IdTipoCliente.Value : 0;
|
|
|
|
var lista = from a in db.AnalisisClienteDocumentos
|
|
where a.IdTipoCliente == IdTipoCliente
|
|
select a.IdTipoDocumento;
|
|
|
|
int[] ListaIdDocumentos = lista.ToArray();
|
|
|
|
List<BitacoraDocumentosInformeAnalisis> bitacora = db.BitacoraDocumentosInformeAnalisis.Include(c => c.TipoDocumento).Where(c => c.IdCliente == solicitante.IdCliente).ToList();
|
|
|
|
if (bitacora == null || bitacora.Count == 0)
|
|
{
|
|
var ListaDocumentos = db.TipoDocumento.Where(c => ListaIdDocumentos.Contains(c.IdTipoDocumento)).ToList();
|
|
|
|
bitacora = new List<BitacoraDocumentosInformeAnalisis>();
|
|
foreach (var doc in ListaDocumentos)
|
|
{
|
|
bitacora.Add(
|
|
new BitacoraDocumentosInformeAnalisis()
|
|
{
|
|
IdTipoDocumento = doc.IdTipoDocumento,
|
|
IdCliente = solicitante.IdCliente,
|
|
CodDocumentoAdjunto = null,
|
|
Fecha = null,
|
|
TipoDocumento = doc,
|
|
}
|
|
);
|
|
}
|
|
|
|
db.BitacoraDocumentosInformeAnalisis.AddRange(bitacora);
|
|
db.SaveChanges();
|
|
}
|
|
|
|
model.ListaDocumentosInforme = bitacora;
|
|
#endregion
|
|
|
|
#region DOCUMENTOS SEGUIMIENTO
|
|
int[] ListaIdDocumentosSeguimiento = new int[] { 48, 49, 50, 51 };
|
|
|
|
List<BitacoraDocumentosSeguimientoAnalisis> bitacora_seguimiento = db.BitacoraDocumentosSeguimientoAnalisis.Include(c => c.TipoDocumento).Where(c => c.IdCliente == solicitante.IdCliente).ToList();
|
|
|
|
if (bitacora_seguimiento == null || bitacora_seguimiento.Count == 0)
|
|
{
|
|
var ListaDocumentos = db.TipoDocumento.Where(c => ListaIdDocumentosSeguimiento.Contains(c.IdTipoDocumento)).ToList();
|
|
|
|
bitacora_seguimiento = new List<BitacoraDocumentosSeguimientoAnalisis>();
|
|
foreach (var doc in ListaDocumentos)
|
|
{
|
|
bitacora_seguimiento.Add(
|
|
new BitacoraDocumentosSeguimientoAnalisis()
|
|
{
|
|
IdTipoDocumento = doc.IdTipoDocumento,
|
|
IdCliente = solicitante.IdCliente,
|
|
Fecha = DateTime.Now,
|
|
TipoDocumento = doc,
|
|
}
|
|
);
|
|
}
|
|
|
|
db.BitacoraDocumentosSeguimientoAnalisis.AddRange(bitacora_seguimiento);
|
|
db.SaveChanges();
|
|
}
|
|
|
|
model.ListaDocumentosSeguimiento = bitacora_seguimiento;
|
|
|
|
#endregion
|
|
}
|
|
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
|
|
}
|
|
|
|
return model;
|
|
}
|
|
#endregion
|
|
|
|
#region GuardarAnalisis
|
|
[HttpPost]
|
|
public AnalisisJSON GuardarAnalisis(AnalisisJSON model)
|
|
{
|
|
Etapas etapa;
|
|
DocumentosAdjuntosCategoriaJSON DocAdjuntosJSON;
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
etapa = db.Etapas.Where(c => c.DescripcionEtapa == model.UltimusStep).FirstOrDefault();
|
|
|
|
var modeloActual = db.DatosGeneralesAnalisis.AsNoTracking().Where(c => c.IdSolicitud == model.DatosGeneralesAnalisis.IdSolicitud).FirstOrDefault();
|
|
if (modeloActual == null)
|
|
{
|
|
model.DatosGeneralesAnalisis.Fecha_InicioAnalisis = null;
|
|
model.DatosGeneralesAnalisis.FechaCreacion = DateTime.Now;
|
|
|
|
db.DatosGeneralesAnalisis.Add(model.DatosGeneralesAnalisis);
|
|
}
|
|
else
|
|
{
|
|
|
|
if (model.UltimusStep == EnumEtapas.AN_Preanalisis && !model.DatosGeneralesAnalisis.Fecha_InicioAnalisis.HasValue)
|
|
model.DatosGeneralesAnalisis.Fecha_InicioAnalisis = DateTime.Now;
|
|
|
|
if (model.UltimusStep == EnumEtapas.AN_Preanalisis
|
|
&& model.DatosGeneralesAnalisis.Completado_PreAnalisis == true
|
|
&& modeloActual.FechaCompletado_PreAnalisis == null)
|
|
model.DatosGeneralesAnalisis.FechaCompletado_PreAnalisis = DateTime.Now;
|
|
|
|
if (model.DatosGeneralesAnalisis.Decision != null)
|
|
model.DatosGeneralesAnalisis.Decision = null;
|
|
db.Entry(model.DatosGeneralesAnalisis).State = EntityState.Modified;
|
|
|
|
}
|
|
|
|
if (model.ListaDocumentosSeguimiento != null)
|
|
{
|
|
foreach (var item in model.ListaDocumentosSeguimiento)
|
|
{
|
|
item.Cliente = null;
|
|
item.TipoDocumento = null;
|
|
db.Entry(item).State = EntityState.Modified;
|
|
}
|
|
}
|
|
|
|
|
|
db.SaveChanges();
|
|
|
|
#region Actualizar Datos Desde Excel
|
|
|
|
#region Obtiene el documento de Aceptacion Empresarial de la BitacoraDocumentosInformeAnalisis
|
|
List<Cliente> Cliente = new ClienteDAL().ObtenerListaCliente(model.IdSolicitud);
|
|
|
|
#endregion
|
|
|
|
|
|
#region Obtiene Documentos Adjuntos Complement
|
|
|
|
DocAdjuntosJSON = new DocumentosAPIController().CargarDocumentosAdjuntos(new JsonSolicitud()
|
|
{
|
|
Solicitud = new Solicitud()
|
|
{
|
|
IdSolicitud = model.IdSolicitud
|
|
},
|
|
UltimusProcess = model.UltimusProcess
|
|
});
|
|
|
|
if (DocAdjuntosJSON.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
model.CodigoRespuesta = DocAdjuntosJSON.CodigoRespuesta;
|
|
model.DescripcionRespuesta = "Ocurrio un problema al obtener la información de documentos adjuntos desde el Ultimus Complement";
|
|
return model;
|
|
}
|
|
|
|
#endregion
|
|
|
|
List<BitacoraDocumentosCliente> ListExcelAceptacionEmpresarial = db.Solicitante.Where(x => x.IdSolicitud==model.IdSolicitud).Select(c=>c.Cliente.BitacoraDocumentosCliente.FirstOrDefault(b=>b.IdTipoDocumento == 41)).ToList(); //Aceptación Empresarial
|
|
|
|
if (ListExcelAceptacionEmpresarial != null && ListExcelAceptacionEmpresarial.Count > 0)
|
|
{
|
|
foreach (var cli in Cliente)
|
|
{
|
|
|
|
BitacoraDocumentosCliente ExcelAceptacionEmpresarial = ListExcelAceptacionEmpresarial.FirstOrDefault(c => c.IdCliente == cli.IdCliente);
|
|
|
|
if (ExcelAceptacionEmpresarial != null)
|
|
{
|
|
#region Llama metodo de Actualizacion de Datos desde Excel
|
|
|
|
string RutaDocumento = DocAdjuntosJSON.ListaDocumentos.Where(x => x.CodDocumento == ExcelAceptacionEmpresarial.CodDocumentoAdjunto).Select(x => x.RutaFisica).FirstOrDefault();
|
|
|
|
if (!string.IsNullOrEmpty(RutaDocumento) && model.GuardarAceptacion)
|
|
{
|
|
|
|
var respActExcel = ActualizarCaratulaDesdeExcel(cli, RutaDocumento);
|
|
|
|
if (respActExcel.CodigoRespuesta == TipoCodigoRespuesta.ERROR.ToString())
|
|
{
|
|
model.CodigoRespuesta = respActExcel.CodigoRespuesta;
|
|
model.DescripcionRespuesta = respActExcel.DescripcionRespuesta;
|
|
return model;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
EnvioCorreoAPIController CorreoAPI = new EnvioCorreoAPIController();
|
|
|
|
if (model.UltimusStep == EnumEtapas.AN_Preanalisis && model.DatosGeneralesAnalisis.SolicitarDocumentos_Seguimiento == true)
|
|
{
|
|
CorreosAutomaticosPendientes Correo = new CorreosAutomaticosPendientes();
|
|
|
|
#region NOTIFICACION SEGUIMIENTO
|
|
|
|
if (model.DatosGeneralesAnalisis.NotificacionSeguimientoEnviada != true)
|
|
{
|
|
Correo.IdCorreo = 0;
|
|
Correo.IdSolicitud = model.DatosGeneralesAnalisis.IdSolicitud;
|
|
Correo.IdEtapa = etapa.IdEtapa;
|
|
Correo.NombreFiltroCorreo = "NotificacionSeguimientoAnalisis";
|
|
|
|
Correo.UserID = model.UltimusUserID;
|
|
|
|
CorreoAPI.EnviarCorreoAutomatico(Correo);
|
|
|
|
model.DatosGeneralesAnalisis.NotificacionSeguimientoEnviada = true;
|
|
db.Entry(model.DatosGeneralesAnalisis).State = EntityState.Modified;
|
|
db.SaveChanges();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region RECORDATORIO SEGUIMIENTO
|
|
if (model.DatosGeneralesAnalisis.IdCorreo_RecordatorioSeguimiento == null)
|
|
{
|
|
Correo.IdCorreo = 0;
|
|
Correo.IdSolicitud = model.DatosGeneralesAnalisis.IdSolicitud;
|
|
Correo.IdEtapa = etapa.IdEtapa;
|
|
Correo.NombreFiltroCorreo = "RecordatorioSeguimientoAnalisis";
|
|
Correo.TotalDiasEspera = 15;
|
|
Correo.UserID = model.UltimusUserID;
|
|
|
|
Correo = CorreoAPI.RegistrarCorreoAutomatico(Correo);
|
|
|
|
if (Correo.IdCorreo != 0)
|
|
{
|
|
model.DatosGeneralesAnalisis.IdCorreo_RecordatorioSeguimiento = Correo.IdCorreo;
|
|
db.Entry(model.DatosGeneralesAnalisis).State = EntityState.Modified;
|
|
db.SaveChanges();
|
|
}
|
|
|
|
}
|
|
else if (!model.ListaDocumentosSeguimiento.Where(c => c.SolicitarCliente == true && c.ClienteEntrego != true).Any())
|
|
{
|
|
CorreoAPI.CancelarCorreoAutomatico(new CorreosAutomaticosPendientes
|
|
{
|
|
IdCorreo = model.DatosGeneralesAnalisis.IdCorreo_RecordatorioSeguimiento.Value
|
|
});
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
model.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
|
|
}
|
|
finally
|
|
{
|
|
DocAdjuntosJSON = null;
|
|
}
|
|
|
|
return model;
|
|
}
|
|
#endregion
|
|
|
|
#region ObtenerAnalista
|
|
[HttpGet]
|
|
public List<EjecutivoCatalogoJSON> ObtenerAnalista(int id)
|
|
{
|
|
List<EjecutivoCatalogoJSON> model = new List<EjecutivoCatalogoJSON>();
|
|
try
|
|
{
|
|
using (UltimusIntegrationAPIController IntegrationClient = new UltimusIntegrationAPIController())
|
|
{
|
|
List<UltimusUser> ListaUsuarios;
|
|
|
|
ListaUsuarios = IntegrationClient.GetJobFunctionGroupMembers("Cathay OC", "Analista de crédito");
|
|
|
|
if (ListaUsuarios != null)
|
|
{
|
|
foreach (var item in ListaUsuarios)
|
|
{
|
|
model.Add(new EjecutivoCatalogoJSON
|
|
{
|
|
codigo = (ListaUsuarios.IndexOf(item) + 1).ToString(),
|
|
descripcion = item.strUserFullName,
|
|
UserId = item.strUserName
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
|
|
return model;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region ActualizarCaratulaDesdeExcel
|
|
[HttpGet]
|
|
public BaseJson ActualizarCaratulaDesdeExcel(Cliente ObjCliente, string RutaDocumento)
|
|
{
|
|
BaseJson respuesta = new BaseJson();
|
|
ClienteDAL connCliente = new ClienteDAL();
|
|
try
|
|
{
|
|
#region Valida el archivo
|
|
if (!File.Exists(RutaDocumento))
|
|
throw new Exception(string.Format("El archivo {0} no existe.", RutaDocumento));
|
|
|
|
string ExtensionFile = Path.GetExtension(RutaDocumento);
|
|
if (!ExtensionFile.In(".xls", ".xlsx", ".xlsm"))
|
|
throw new Exception(string.Format("El archivo {0} no es un archivo con formato excel.", RutaDocumento));
|
|
#endregion
|
|
|
|
using (MetodosCathayServicioAPIController connMetodosCathay = new MetodosCathayServicioAPIController())
|
|
{
|
|
#region Crea la Estructura
|
|
var oUExcelJson = new ServicioMetodosCathay.UExcelJson()
|
|
{
|
|
RutaDocumento = RutaDocumento,
|
|
ListaSpreadSheet = new List<ServicioMetodosCathay.UExcelSpreadSheet>() {
|
|
new ServicioMetodosCathay.UExcelSpreadSheet(){
|
|
NoItem = 1,
|
|
Celdas = new List<ServicioMetodosCathay.UExcelCeldasSpreadSheet>(){
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "A", Referencia = "Cliente.CategoriaRiesgo"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "B", Referencia = "Cliente.CodClasificacionMetodologia"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "C", Referencia = "Cliente.DescClasificacionMetodologia"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "D", Referencia = "Cliente.CodRiesgoCambiario"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "E", Referencia = "Cliente.DescRiesgoCambiario"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "F", Referencia = "Cliente.CodNivelCapacidadPago"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "G", Referencia = "Cliente.DesNivelCapacidadPago"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "H", Referencia = "Cliente.CodGeneraMonedaExtrangera"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "I", Referencia = "Cliente.DescGeneraMonedaExtrangera"}},
|
|
new ServicioMetodosCathay.UExcelCeldasSpreadSheet(){ Celda= new ServicioMetodosCathay.UExcelCelda(){ Fila= 2, Columna = "J", Referencia = "Cliente.CoberturaServicioDeuda"}},
|
|
}
|
|
}
|
|
}
|
|
};
|
|
#endregion
|
|
|
|
#region Invoca el Servicio
|
|
oUExcelJson = connMetodosCathay.LeerExcel(oUExcelJson);
|
|
|
|
if (oUExcelJson.CodigoRespuesta != TipoCodigoRespuesta.EXITOSO.ToString())
|
|
throw new Exception(respuesta.DescripcionRespuesta);
|
|
#endregion
|
|
|
|
#region Actualiza en Base de Datos
|
|
|
|
var oCliente = ObjCliente;
|
|
|
|
#region CategoriaRiesgo
|
|
string sCategoriaRiesgo = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CategoriaRiesgo").FirstOrDefault().Valor).FirstOrDefault();
|
|
|
|
if (!string.IsNullOrEmpty(sCategoriaRiesgo))
|
|
{
|
|
oCliente.CategoriaRiesgo = sCategoriaRiesgo;
|
|
}
|
|
#endregion
|
|
|
|
#region ClasificacionMetodologia
|
|
|
|
string sCodClasificacionMetodologia = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CodClasificacionMetodologia").FirstOrDefault().Valor).FirstOrDefault();//oUExcelJson.ListaSpreadSheet.Where(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CodClasificacionMetodologia").Any()).Select(x => x.Celdas.FirstOrDefault().Valor).FirstOrDefault();
|
|
string sDescClasificacionMetodologia = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.DescClasificacionMetodologia").FirstOrDefault().Valor).FirstOrDefault();//oUExcelJson.ListaSpreadSheet.Where(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.DescClasificacionMetodologia").Any()).Select(x => x.Celdas.FirstOrDefault().Valor).FirstOrDefault();
|
|
|
|
if (!string.IsNullOrEmpty(sCodClasificacionMetodologia) && !string.IsNullOrEmpty(sDescClasificacionMetodologia))
|
|
{
|
|
oCliente.CodClasificacionMetodologia = int.Parse(sCodClasificacionMetodologia);
|
|
oCliente.DescClasificacionMetodologia = sDescClasificacionMetodologia;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region RiesgoCambiario
|
|
|
|
string sCodRiesgoCambiario = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CodRiesgoCambiario").FirstOrDefault().Valor).FirstOrDefault();//oUExcelJson.ListaSpreadSheet.Where(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CodRiesgoCambiario").Any()).Select(x => x.Celdas.FirstOrDefault().Valor).FirstOrDefault();
|
|
string sDescRiesgoCambiario = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.DescRiesgoCambiario").FirstOrDefault().Valor).FirstOrDefault();//oUExcelJson.ListaSpreadSheet.Where(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.DescRiesgoCambiario").Any()).Select(x => x.Celdas.FirstOrDefault().Valor).FirstOrDefault();
|
|
|
|
if (!string.IsNullOrEmpty(sCodRiesgoCambiario) && !string.IsNullOrEmpty(sDescRiesgoCambiario))
|
|
{
|
|
oCliente.CodRiesgoCambiario = int.Parse(sCodRiesgoCambiario);
|
|
oCliente.DescRiesgoCambiario = sDescRiesgoCambiario;
|
|
}
|
|
#endregion
|
|
|
|
#region NivelCapacidadPago
|
|
|
|
string sCodNivelCapacidadPago = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CodNivelCapacidadPago").FirstOrDefault().Valor).FirstOrDefault();//oUExcelJson.ListaSpreadSheet.Where(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CodNivelCapacidadPago").Any()).Select(x => x.Celdas.FirstOrDefault().Valor).FirstOrDefault();
|
|
string sDescNivelCapacidadPago = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.DesNivelCapacidadPago").FirstOrDefault().Valor).FirstOrDefault();//oUExcelJson.ListaSpreadSheet.Where(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.DesNivelCapacidadPago").Any()).Select(x => x.Celdas.FirstOrDefault().Valor).FirstOrDefault();
|
|
|
|
if (!string.IsNullOrEmpty(sCodNivelCapacidadPago) && !string.IsNullOrEmpty(sDescNivelCapacidadPago))
|
|
{
|
|
oCliente.CodNivelCapacidadPago = sCodNivelCapacidadPago;
|
|
oCliente.DescNivelCapacidadPago = sDescNivelCapacidadPago;
|
|
}
|
|
#endregion
|
|
|
|
#region GeneraMonedaExtrangera
|
|
string sCodGeneraMonedaExtrangera = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CodGeneraMonedaExtrangera").FirstOrDefault().Valor).FirstOrDefault();//oUExcelJson.ListaSpreadSheet.Where(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CodGeneraMonedaExtrangera").Any()).Select(x => x.Celdas.FirstOrDefault().Valor).FirstOrDefault();
|
|
string sDescGeneraMonedaExtrangera = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.DescGeneraMonedaExtrangera").FirstOrDefault().Valor).FirstOrDefault(); //oUExcelJson.ListaSpreadSheet.Where(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.DescGeneraMonedaExtrangera").Any()).Select(x => x.Celdas.FirstOrDefault().Valor).FirstOrDefault();
|
|
|
|
if (!string.IsNullOrEmpty(sCodGeneraMonedaExtrangera) && !string.IsNullOrEmpty(sDescGeneraMonedaExtrangera))
|
|
{
|
|
oCliente.CodGeneraMonedaExtrangera = sCodGeneraMonedaExtrangera;
|
|
oCliente.DescGeneraMonedaExtrangera = sDescGeneraMonedaExtrangera;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CoberturaServicioDeuda
|
|
string CoberturaServicioDeuda = oUExcelJson.ListaSpreadSheet.Select(x => x.Celdas.Where(y => y.Celda.Referencia == "Cliente.CoberturaServicioDeuda").FirstOrDefault().Valor).FirstOrDefault();
|
|
|
|
if (!string.IsNullOrEmpty(CoberturaServicioDeuda))
|
|
{
|
|
|
|
oCliente.CoberturaServicioDeuda = Convert.ToDecimal(CoberturaServicioDeuda);
|
|
}
|
|
#endregion
|
|
|
|
var resp = connCliente.InsertarActualizar(oCliente);
|
|
|
|
if (resp.CodigoRespuesta != TipoCodigoRespuesta.EXITOSO.ToString())
|
|
throw new Exception(resp.DescripcionRespuesta);
|
|
|
|
#endregion
|
|
}
|
|
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.EXITOSO.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
respuesta.CodigoRespuesta = TipoCodigoRespuesta.ERROR.ToString();
|
|
respuesta.DescripcionRespuesta = ex.Message;
|
|
logs.Error(ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
#endregion
|
|
|
|
[HttpPost]
|
|
public DatosGeneralesAnalisis ObtenerInfoDocumentosAdicionales(DatosGeneralesAnalisis model)
|
|
{
|
|
DatosGeneralesAnalisis respuesta = new DatosGeneralesAnalisis();
|
|
try
|
|
{
|
|
respuesta = new DatosGeneralesAnalisisDAL().Obtener(model.IdSolicitud);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
|
|
[HttpPost]
|
|
public BaseJson GuardarInfoDocumentosAdicionales(DatosGeneralesAnalisis model)
|
|
{
|
|
BaseJson respuesta = new BaseJson();
|
|
try
|
|
{
|
|
respuesta = new DatosGeneralesAnalisisDAL().GuardarActualizarAnalisis(model);
|
|
if (respuesta.CodigoRespuesta == "EXITOSO")
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
public history_task ObtenerTask(int Incidente, string Step)
|
|
{
|
|
history_task respuesta = new history_task();
|
|
try
|
|
{
|
|
respuesta = new history_taskDAL().ObtnerTask(Incidente, Step);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
return respuesta;
|
|
}
|
|
|
|
}
|
|
} |