271 lines
No EOL
7.6 KiB
C#
271 lines
No EOL
7.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using Newtonsoft.Json;
|
|
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using ULA.Cathay.CreditoModel.Entidades;
|
|
using Ultimus.Utilitarios;
|
|
using ULA.Cathay.ModuloMantenimiento.IntegracionesSAP;
|
|
using System.Globalization;
|
|
using System.Threading;
|
|
using Ultimus.Interfaces;
|
|
using ULA.Cathay.CreditoModel.Credito;
|
|
|
|
namespace ULA.Cathay.ModuloMantenimiento.ControllersWebApi
|
|
{
|
|
public class SAPServicioIntegracionAPIController : ApiController
|
|
{
|
|
private UltimusLogs logs = new UltimusLogs("SAPServicioIntegracionAPI");
|
|
|
|
System.ServiceModel.BasicHttpBinding BindingSAP;
|
|
System.ServiceModel.EndpointAddress EndpointSAP;
|
|
public static void SetRegionalConfig()
|
|
{
|
|
try
|
|
{
|
|
CultureInfo CInfo_esCR = new CultureInfo("es-CR");
|
|
CInfo_esCR.NumberFormat.CurrencyDecimalDigits = 2;
|
|
CInfo_esCR.NumberFormat.CurrencyDecimalSeparator = ".";
|
|
CInfo_esCR.NumberFormat.CurrencyGroupSeparator = ",";
|
|
|
|
CInfo_esCR.NumberFormat.NumberDecimalDigits = 2;
|
|
CInfo_esCR.NumberFormat.NumberDecimalSeparator = ".";
|
|
CInfo_esCR.NumberFormat.NumberGroupSeparator = ",";
|
|
Thread.CurrentThread.CurrentCulture = CInfo_esCR;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
public SAPServicioIntegracionAPIController()
|
|
{
|
|
|
|
try
|
|
{
|
|
SetRegionalConfig();
|
|
|
|
EndpointSAP = new System.ServiceModel.EndpointAddress(new ObtieneParametros().GetValueKeyRegedit("UltimusIntegracionesSAPUrl", false));
|
|
|
|
BindingSAP = new System.ServiceModel.BasicHttpBinding();
|
|
BindingSAP.MaxReceivedMessageSize = int.MaxValue;
|
|
BindingSAP.MaxBufferPoolSize = int.MaxValue;
|
|
System.ServiceModel.HttpTransportSecurity security = new System.ServiceModel.HttpTransportSecurity();
|
|
security.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None;
|
|
BindingSAP.Security.Transport = security;
|
|
|
|
BindingSAP.OpenTimeout = new TimeSpan(0, 5, 0);
|
|
BindingSAP.CloseTimeout = new TimeSpan(0, 5, 0);
|
|
BindingSAP.SendTimeout = new TimeSpan(0, 5, 0);
|
|
BindingSAP.ReceiveTimeout = new TimeSpan(0, 5, 0);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public List<JsonCatalogos> ObtenerMorosidad(int? filtro = null)
|
|
{
|
|
List<JsonCatalogos> model = new List<JsonCatalogos>();
|
|
try
|
|
{
|
|
using (CreditoContex db = new CreditoContex())
|
|
{
|
|
if (filtro == null)
|
|
{
|
|
model = (
|
|
from s in db.Morosidad.Where(c => c.Estado == true).ToList()
|
|
select new JsonCatalogos
|
|
{
|
|
codigo = s.IdMorosidad.ToString(),
|
|
descripcion = s.Descripcion
|
|
}).ToList();
|
|
}
|
|
else
|
|
{
|
|
var Items = db.Morosidad.Where(c => c.DiasTope >= filtro).ToList();
|
|
|
|
if (Items != null && Items.Count > 0)
|
|
{
|
|
var Item = Items.OrderBy(x => x.DiasTope).Select(s => new JsonCatalogos
|
|
{
|
|
codigo = s.IdMorosidad.ToString(),
|
|
descripcion = s.Descripcion
|
|
}).FirstOrDefault();
|
|
|
|
model.Add(Item);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
|
|
return model;
|
|
}
|
|
|
|
#region ConsultaBP
|
|
[HttpPost]
|
|
public BpResponse ConsultaBP(DatosEntrada Entrada)
|
|
{
|
|
BpResponse Resultados = new BpResponse();
|
|
try
|
|
{
|
|
using (IntegracionesSAPClient Conn = new IntegracionesSAPClient(BindingSAP, EndpointSAP))
|
|
Resultados = Conn.ConsultaBP(Entrada.NumeroCliente, Entrada.Identificacion, Entrada.TipoConsulta, Entrada.EsResumen);
|
|
|
|
|
|
#region Carga Catalogo Interno
|
|
try
|
|
{
|
|
var ListaMorosidad = ObtenerMorosidad(Resultados.DiasAtraso);
|
|
|
|
if (ListaMorosidad != null && ListaMorosidad.Count > 0)
|
|
{
|
|
Resultados.Morosidad = ListaMorosidad.Select(x => new CatalogoResponse()
|
|
{
|
|
Codigo = x.codigo,
|
|
Descripcion = x.descripcion
|
|
|
|
}).FirstOrDefault();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex2)
|
|
{
|
|
logs.Error(ex2);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
return Resultados;
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
public BpResponse ConsultaNumeroBP(DatosEntrada Entrada)
|
|
{
|
|
BpResponse Resultados = new BpResponse();
|
|
try
|
|
{
|
|
using (IntegracionesSAPClient Conn = new IntegracionesSAPClient(BindingSAP, EndpointSAP))
|
|
Resultados = Conn.ConsultaNumeroBP(Entrada.NumeroCliente, Entrada.Identificacion);
|
|
|
|
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
return Resultados;
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region ConsultaRegistroCivil
|
|
[HttpPost]
|
|
public RegistroCivil ConsultaRegistroCivil(DatosEntrada Entrada)
|
|
{
|
|
RegistroCivil Resultados = new RegistroCivil();
|
|
try
|
|
{
|
|
using (IntegracionesSAPClient Conn = new IntegracionesSAPClient(BindingSAP, EndpointSAP))
|
|
Resultados = Conn.ConsultaRegistroCivil(Entrada.Identificacion);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
return Resultados;
|
|
}
|
|
#endregion
|
|
|
|
#region ConsultaRegistroNacional
|
|
[HttpPost]
|
|
public RegistroNacional ConsultaRegistroNacional(DatosEntrada Entrada)
|
|
{
|
|
RegistroNacional Resultados = new RegistroNacional();
|
|
try
|
|
{
|
|
using (IntegracionesSAPClient Conn = new IntegracionesSAPClient(BindingSAP, EndpointSAP))
|
|
Resultados = Conn.ConsultaRegistroNacional(Entrada.Identificacion);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logs.Error(ex);
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
return Resultados;
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public class DatosEntrada
|
|
{
|
|
public string NumeroCliente { get; set; }
|
|
public string Identificacion { get; set; }
|
|
public string NumeroLinea { get; set; }
|
|
public string NumeroSolicitud { get; set; }
|
|
public bool? EsResumen { get; set; }
|
|
public int TipoConsulta { get; set; }
|
|
}
|
|
|
|
} |