TFS_ANTIGUO/PrendarioDavivienda/ULA.Davivienda.WCFServiciosCobisCartera/ULA.Davivienda.WCFServiciosCobisCartera.BL/ActualizacionOperacion.vb

356 lines
16 KiB
VB.net
Raw Permalink Normal View History

Imports System.Web
Imports ULA.Davivienda.WCFServiciosCobisCartera.DAL
Public Class ActualizacionOperacion
#Region "PROPIEDADES"
Dim gProceso As String
Dim gHttpServer As HttpServerUtility
Dim arrPrefix As String() = New String() {}
#End Region
#Region "Constructor"
Public Sub New(Proceso As String, ByRef httpServer As HttpServerUtility)
gProceso = Proceso
gHttpServer = httpServer
End Sub
#End Region
#Region "RegistrarOperacionCartera"
Public Function ActualizarOperacionCartera(ByVal Solicitud As String,
ByVal Proceso As String,
ByVal strXML As String,
ByVal Usuario As String,
ByVal EstadoEtapa As Integer) As String
Dim strCode As String = "0"
Dim strType As String = "0"
Dim strError As String = String.Empty
Dim strSuccess As String = String.Empty
Dim strMessage As String = String.Empty
'-------------------------------------------------------------------
Dim nElemento As MSXML2.IXMLDOMNode = Nothing
Dim xmlFormado As MSXML2.DOMDocument = Nothing
Dim rootElemento As MSXML2.IXMLDOMNode = Nothing
Dim objPI As MSXML2.IXMLDOMProcessingInstruction = Nothing
'-------------------------------------------------------------------
Dim strEsOperacionLiquidada As String = String.Empty
Dim strXMLActualizarOperacion As String = String.Empty
Dim arrXMLActualizarOperacion() As String = New String(7) {"", "", "", "", "", "", "", ""}
Try
'***********************************************************************************
'SE INICIALIZA EL XML DE SALIDA
'***********************************************************************************
xmlFormado = New MSXML2.DOMDocument()
objPI = xmlFormado.createProcessingInstruction("xml", "version='1.0' encoding='utf-8'")
xmlFormado.appendChild(objPI)
rootElemento = xmlFormado.createElement("Resultado")
xmlFormado.appendChild(rootElemento)
nElemento = xmlFormado.createElement("DatosActualizarOperacionCartera")
rootElemento.appendChild(nElemento)
'***********************************************************************************
'SI ETAPA EN ESTADO ACTIVO - SIMPRE REGENERA SINO SIEMPRE CONSULTA DE LA BD LOCAL
'***********************************************************************************
If ((EstadoEtapa = UtilitariaBD.ULT_STATUS_TSK_ACTIVE)) Then
'*******************************************************************************
'REGENERA LA INFORMACION DE LA OPERACION
'*******************************************************************************
ExecuteActualizarOperacion(Proceso, strXML, strXMLActualizarOperacion, Usuario)
nElemento.text &= strXMLActualizarOperacion
'*******************************************************************************
'REGISTRAR OPERACION SQL
'*******************************************************************************
UtilitariaBD.GuardaActualizacionOperacionSQL(Proceso, Solicitud, strXMLActualizarOperacion, Usuario)
'*******************************************************************************
'LIMPIA FLAG DE DESEMBOLSOS REGISTRADOS EN COBIS
'*******************************************************************************
UtilitariaBD.LimpiarFlagDesembolsoRegistradoSQL(Proceso, Solicitud, Usuario)
Else
'***********************************************************************************
'OBTIENE LA DATA DE LA OPERACION
'***********************************************************************************
arrXMLActualizarOperacion = UtilitariaBD.BuscaOperacionSQL(Proceso, Solicitud, Usuario)
strXMLActualizarOperacion = arrXMLActualizarOperacion(2)
strEsOperacionLiquidada = arrXMLActualizarOperacion(3)
'***********************************************************************************
'SI YA FUE REGENERADA
'***********************************************************************************
If (strXMLActualizarOperacion.Trim() <> "") Then
nElemento.text &= strXMLActualizarOperacion
Else
Throw New Exception("No fue posible obtener de Ultimus los datos de la información actualizada de la operación.")
End If
End If
Catch ex As Exception
strError = "ActualizarOperacionCartera - " & ex.Message
Finally
If strError <> "" Then
nElemento = xmlFormado.createElement("ERROR")
nElemento.text = strError
rootElemento.appendChild(nElemento)
End If
End Try
Return gHttpServer.HtmlDecode(xmlFormado.xml)
End Function
#End Region
#Region "ExecuteActualizarOperacion"
Private Sub ExecuteActualizarOperacion(ByVal Proceso As String,
ByVal strXML As String,
ByRef strXMLout As String,
ByVal Usuario As String)
Dim strXMLActualizarOperacion As String = String.Empty
Dim xmlDoc As MSXML2.DOMDocument = New MSXML2.DOMDocument()
Dim xmlRootDoc As MSXML2.IXMLDOMNode
Dim strError As String = String.Empty
Try
xmlDoc.async = False
xmlDoc.preserveWhiteSpace = True
xmlDoc.validateOnParse = False
strXMLActualizarOperacion = ActualizarOperacion(Proceso, strXML, Usuario)
xmlDoc.loadXML(strXMLActualizarOperacion)
xmlRootDoc = xmlDoc.documentElement
If (Not IsNothing(xmlRootDoc.selectSingleNode("ERROR"))) Then
Throw New Exception(xmlRootDoc.selectSingleNode("ERROR").text)
End If
If (Not IsNothing(xmlRootDoc.selectSingleNode("DatosOperacionCartera"))) Then
strXMLout = xmlRootDoc.selectSingleNode("DatosOperacionCartera").xml
End If
Catch ex As Exception
strError = "ExecuteActualizarOperacion - " & ex.Message
Throw New Exception(strError)
End Try
End Sub
#End Region
#Region "ActualizarOperacion"
Private Function ActualizarOperacion(ByVal Proceso As String,
ByVal strXML As String,
ByVal Usuario As String) As String
Dim strCode As String = "0"
Dim strType As String = "0"
Dim aCampos(34), aSoap(34) As String
Dim strError As String = String.Empty
Dim strSuccess As String = String.Empty
Dim strMessage As String = String.Empty
'--------------------------------------------------------
Dim node As MSXML2.IXMLDOMNode = Nothing
Dim nElemento As MSXML2.IXMLDOMNode = Nothing
Dim nElemento2 As MSXML2.IXMLDOMNode = Nothing
Dim rootElemento As MSXML2.IXMLDOMNode = Nothing
Dim xmNodeMessages As MSXML2.IXMLDOMNode = Nothing
Dim objPI As MSXML2.IXMLDOMProcessingInstruction = Nothing
'--------------------------------------------------------
Dim respXML As MSXML2.DOMDocument = Nothing
Dim xmlFormado As MSXML2.DOMDocument = Nothing
'--------------------------------------------------------
Try
'****************************************************
'Instanacia los objetos de trabajo
'****************************************************
respXML = New MSXML2.DOMDocument()
xmlFormado = New MSXML2.DOMDocument()
'****************************************************
'Inicializa el XML de Salida
'****************************************************
objPI = xmlFormado.createProcessingInstruction("xml", "version='1.0' encoding='utf-8'")
xmlFormado.appendChild(objPI)
rootElemento = xmlFormado.createElement("Resultado")
xmlFormado.appendChild(rootElemento)
nElemento = xmlFormado.createElement("DatosOperacionCartera")
rootElemento.appendChild(nElemento)
'****************************************************
'Invoca el WebService de Cobis
'****************************************************
respXML.async = False
respXML.preserveWhiteSpace = True
respXML.validateOnParse = False
respXML = outSoapConector.InvocaWebServiceSoap(strXML, strError, arrPrefix, Proceso, Usuario)
'****************************************************
'Valida si ocurrió un error de integración
'****************************************************
If (strError.Trim().Length > 0) Then
Throw New Exception(strError)
End If
'****************************************************
'Obtiene el ROOT del XML de Salida de la Interface de Cobis
'****************************************************
node = respXML.childNodes(0).childNodes(0)
'****************************************************
'Valida estructura de control de errores
'****************************************************
If (Not IsNothing(node.selectSingleNode(arrPrefix(2) & ":success"))) Then
strSuccess = node.selectSingleNode(arrPrefix(2) & ":success").text
If (strSuccess.Trim().ToLower() = "false") Then
If (Not IsNothing(node.selectSingleNode(arrPrefix(2) & ":messages"))) Then
xmNodeMessages = node.selectSingleNode(arrPrefix(2) & ":messages")
strCode = xmNodeMessages.selectSingleNode("code").text
strMessage = xmNodeMessages.selectSingleNode("message").text
End If
strError = "Error: Code:" & strCode & " - Message:" & strMessage & " - Type:" & strType
Throw New Exception(strError)
End If
End If
'****************************************************
'Valida tags de control de Errores
'****************************************************
If (Not IsNothing(node.selectSingleNode(arrPrefix(16) & ":estadoProceso"))) Then
If (node.selectSingleNode(arrPrefix(16) & ":estadoProceso").text.Trim() = "N") Then
strCode = node.selectSingleNode(arrPrefix(16) & ":codigoError").text
strMessage = node.selectSingleNode(arrPrefix(16) & ":descripcionError").text
strError = "Error: Code:" & strCode & " - Message:" & strMessage
Throw New Exception(strError)
End If
End If
'****************************************************
'Numero de Operacion
'****************************************************
If node.selectSingleNode(arrPrefix(16) & ":banco") Is Nothing Then
Throw New Exception("No se encontro la variable de salida: " & arrPrefix(16) & ":banco")
End If
'****************************************************
'Constuye la extructura de Salida
'****************************************************
aCampos(0) = "num_operacion"
aCampos(1) = "fecha_inicio"
aCampos(2) = "fecha_vencim"
aCampos(3) = "num_cuotas"
aCampos(4) = "fe_1_pago_cap"
aCampos(5) = "fe_1_pago_int"
aCampos(6) = "plazo_dias"
aCampos(7) = "fe_rev_tasa"
aCampos(8) = "nu_ope_vigentes"
aCampos(9) = "plazo"
aCampos(10) = "fecha_pago_men"
aCampos(11) = "dia_pago"
aCampos(12) = "tasa_interes"
aCampos(13) = "comision"
aCampos(14) = "mora1"
aCampos(15) = "mora2"
aCampos(16) = "nom_fiador"
aCampos(17) = "ced_fiador"
aCampos(18) = "cuota_mens"
aCampos(19) = "deudor"
aCampos(20) = "nom_ejecutivo"
aCampos(21) = "nom_sucursal"
aCampos(22) = "calidades"
aCampos(23) = "dir_cliente"
aCampos(24) = "nom_acreedor"
aCampos(25) = "cedula_acreedor"
aCampos(26) = "periodo_gracia"
aCampos(27) = "forma_pago"
aCampos(28) = "fe_prox_pago"
aCampos(29) = "spread"
aCampos(30) = "base_operacion"
aCampos(31) = "base_operacion1"
aCampos(32) = "monto_mora"
aCampos(33) = "tipo_tasa_base"
aCampos(34) = "monto_desembolso"
aSoap(0) = arrPrefix(16) & ":banco"
aSoap(1) = arrPrefix(16) & ":fechaIni"
aSoap(2) = arrPrefix(16) & ":fechaFin"
aSoap(3) = arrPrefix(16) & ":numCuotas"
aSoap(4) = arrPrefix(16) & ":pagoCap"
aSoap(5) = arrPrefix(16) & ":pagoInt"
aSoap(6) = arrPrefix(16) & ":plazoDias"
aSoap(7) = arrPrefix(16) & ":fechaRev"
aSoap(8) = arrPrefix(16) & ":numOperaciones"
aSoap(9) = arrPrefix(16) & ":plazoMeses"
aSoap(10) = arrPrefix(16) & ":fechaPago"
aSoap(11) = arrPrefix(16) & ":diaPago"
aSoap(12) = arrPrefix(16) & ":tasaInt"
aSoap(13) = arrPrefix(16) & ":comision"
aSoap(14) = arrPrefix(16) & ":mora1"
aSoap(15) = arrPrefix(16) & ":mora2"
aSoap(16) = arrPrefix(16) & ":nomFiador"
aSoap(17) = arrPrefix(16) & ":cedFiador"
aSoap(18) = arrPrefix(16) & ":cuotaMensual"
aSoap(19) = arrPrefix(16) & ":deudor"
aSoap(20) = arrPrefix(16) & ":ejecutivo"
aSoap(21) = arrPrefix(16) & ":sucursal"
aSoap(22) = arrPrefix(16) & ":calidades"
aSoap(23) = arrPrefix(16) & ":direccionCliente"
aSoap(24) = arrPrefix(16) & ":nombreBanco"
aSoap(25) = arrPrefix(16) & ":cedulaBanco"
aSoap(26) = arrPrefix(16) & ":diasGraciaInt"
aSoap(27) = arrPrefix(16) & ":fpagoTdividendo"
aSoap(28) = arrPrefix(16) & ":fproxPago"
aSoap(29) = arrPrefix(16) & ":spread"
aSoap(30) = arrPrefix(16) & ":baseOp"
aSoap(31) = arrPrefix(16) & ":baseOp1"
aSoap(32) = arrPrefix(16) & ":montoMora"
aSoap(33) = arrPrefix(16) & ":tipoTasaBase"
aSoap(34) = arrPrefix(16) & ":montoDesembolso"
For J As Integer = 0 To aCampos.Length() - 1
outSoapConector.AgregarNodeValue(node, xmlFormado, nElemento2, nElemento, aSoap(J), aCampos(J))
Next
Catch ex As Exception
strError = "ActualizarOperacion - " & ex.Message
Finally
If strError <> "" Then
nElemento = xmlFormado.createElement("ERROR")
nElemento.text = strError
rootElemento.appendChild(nElemento)
End If
End Try
Return xmlFormado.xml
End Function
#End Region
End Class