364 lines
18 KiB
VB.net
364 lines
18 KiB
VB.net
|
|
Imports System.Web
|
|||
|
|
Imports ULA.Davivienda.WCFServiciosCobisCartera.DAL
|
|||
|
|
Imports ULA.Davivienda.WCFServiciosCobisCartera.Entidades
|
|||
|
|
|
|||
|
|
Public Class Desembolso
|
|||
|
|
|
|||
|
|
|
|||
|
|
#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 "RegistrarDesembolso"
|
|||
|
|
Public Function RegistrarDesembolsoCartera(ByVal Solicitud As String,
|
|||
|
|
ByVal Proceso As String,
|
|||
|
|
ByVal NumOperacion As String,
|
|||
|
|
ByVal strXML As String,
|
|||
|
|
ByVal Usuario As String) As String
|
|||
|
|
|
|||
|
|
Dim strError As String = String.Empty
|
|||
|
|
|
|||
|
|
Dim respXML As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
|
|||
|
|
Dim xmlFormado As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
Dim rootElemento As MSXML2.IXMLDOMNode
|
|||
|
|
Dim nElemento, nElemento2 As MSXML2.IXMLDOMNode
|
|||
|
|
Dim objPI As MSXML2.IXMLDOMProcessingInstruction
|
|||
|
|
|
|||
|
|
'---------------------------------
|
|||
|
|
Dim strXMLCrearDesembolso As String = String.Empty
|
|||
|
|
'-------------------------------------------------------------------
|
|||
|
|
Dim strSP, strFuenteDatos As String
|
|||
|
|
Dim aNombreParametro(2), aValorParametro(2) As String
|
|||
|
|
Dim strRespXML As String
|
|||
|
|
Dim xmlEsquemaDev As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
Dim xmlRoot As MSXML2.IXMLDOMNode
|
|||
|
|
Dim strEstadoProceso As String = String.Empty
|
|||
|
|
|
|||
|
|
|
|||
|
|
objPI = xmlFormado.createProcessingInstruction("xml", "version='1.0' encoding='utf-8'")
|
|||
|
|
xmlFormado.appendChild(objPI)
|
|||
|
|
rootElemento = xmlFormado.createElement("Resultado")
|
|||
|
|
xmlFormado.appendChild(rootElemento)
|
|||
|
|
|
|||
|
|
nElemento = xmlFormado.createElement("DatosRegistrarDesembolsoCartera")
|
|||
|
|
rootElemento.appendChild(nElemento)
|
|||
|
|
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
'*************************************************************************************
|
|||
|
|
'OBTIENE LAS FORMAS DE DESEMBOLSO REGISTRADAS
|
|||
|
|
'*************************************************************************************
|
|||
|
|
strSP = "usp_cp_forma_desembolso"
|
|||
|
|
strFuenteDatos = Entidades.Enumerador.FuenteDatosUltimus.BPMPRENDARIO.ToString()
|
|||
|
|
|
|||
|
|
aNombreParametro(1) = "@i_opcion" : aValorParametro(1) = "1"
|
|||
|
|
aNombreParametro(2) = "@i_solicitud" : aValorParametro(2) = Solicitud
|
|||
|
|
|
|||
|
|
|
|||
|
|
strRespXML = outConector.EjecutarComandoSQLArreglo(gProceso, strFuenteDatos, strSP, aNombreParametro, aValorParametro, 0)
|
|||
|
|
xmlEsquemaDev.loadXML(strRespXML)
|
|||
|
|
|
|||
|
|
xmlRoot = xmlEsquemaDev.selectSingleNode("//NewDataSet")
|
|||
|
|
|
|||
|
|
'*************************************************************************************
|
|||
|
|
'LECTURA DE FORMAS DE DESEMBOLSO REGISTRADAS
|
|||
|
|
'*************************************************************************************
|
|||
|
|
For i As Integer = 0 To xmlRoot.childNodes.length - 1
|
|||
|
|
|
|||
|
|
Dim fd_forma_desembolso As String = xmlRoot.childNodes(i).selectSingleNode("forma_desembolso").text
|
|||
|
|
Dim fd_monto As String = xmlRoot.childNodes(i).selectSingleNode("monto").text.Replace(",", "")
|
|||
|
|
Dim fd_beneficiario As String = xmlRoot.childNodes(i).selectSingleNode("beneficiario").text
|
|||
|
|
Dim fd_cuenta As String = xmlRoot.childNodes(i).selectSingleNode("cuenta").text
|
|||
|
|
Dim fd_sucursal As String = CInt(xmlRoot.childNodes(i).selectSingleNode("co_sucursal").text).ToString()
|
|||
|
|
Dim fd_sec_cobis As String = CInt(xmlRoot.childNodes(i).selectSingleNode("sec_cobis").text).ToString()
|
|||
|
|
Dim fd_llave As String = xmlRoot.childNodes(i).selectSingleNode("llave").text
|
|||
|
|
Dim fd_xml As String = xmlRoot.childNodes(i).selectSingleNode("xml_desembolso").text
|
|||
|
|
Dim fd_id_moneda As String = xmlRoot.childNodes(i).selectSingleNode("id_moneda").text
|
|||
|
|
Dim strFechaPago As String = Format(Now(), "yyyy-MM-dd")
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
'*************************************************************************************
|
|||
|
|
'SI LA FORMA DE DESEMBOLSO ESTA REGISTRADA EN COBIS
|
|||
|
|
'*************************************************************************************
|
|||
|
|
If (fd_sec_cobis = 1) Then
|
|||
|
|
nElemento.text &= fd_xml
|
|||
|
|
Else
|
|||
|
|
Dim xmlDocRec As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
xmlDocRec.async = False
|
|||
|
|
xmlDocRec.validateOnParse = False
|
|||
|
|
xmlDocRec.resolveExternals = False
|
|||
|
|
xmlDocRec.load(AppDomain.CurrentDomain().BaseDirectory & "/XmlSoap/Desembolso.xml")
|
|||
|
|
|
|||
|
|
Dim nodoRoot As MSXML2.IXMLDOMNode = xmlDocRec.documentElement.childNodes(1).childNodes(0).childNodes(0)
|
|||
|
|
|
|||
|
|
nodoRoot.selectSingleNode("dto:codMonedaDesembolso").text = fd_id_moneda.Trim()
|
|||
|
|
nodoRoot.selectSingleNode("dto:codMonedaOperacion").text = fd_id_moneda.Trim()
|
|||
|
|
nodoRoot.selectSingleNode("dto:comentario").text = "DESEMBOLSO ULTIMUS"
|
|||
|
|
nodoRoot.selectSingleNode("dto:cotizacionMonedaDesembolso").text = "1.0"
|
|||
|
|
nodoRoot.selectSingleNode("dto:cotizacionMonedaOperacion").text = "1.0"
|
|||
|
|
nodoRoot.selectSingleNode("dto:descripTransaccion").text = "Desembolso-Ultimus-Prendario"
|
|||
|
|
nodoRoot.selectSingleNode("dto:formaDesembolso").text = fd_forma_desembolso
|
|||
|
|
nodoRoot.selectSingleNode("dto:montoDesembolsar").text = fd_monto
|
|||
|
|
nodoRoot.selectSingleNode("dto:nombreBeneficiario").text = fd_beneficiario
|
|||
|
|
nodoRoot.selectSingleNode("dto:numCuenta").text = fd_cuenta
|
|||
|
|
nodoRoot.selectSingleNode("dto:numOperacion").text = NumOperacion
|
|||
|
|
nodoRoot.selectSingleNode("dto:oficinaChg").text = fd_sucursal
|
|||
|
|
nodoRoot.selectSingleNode("dto:oficinaImpChq").text = fd_sucursal
|
|||
|
|
nodoRoot.selectSingleNode("dto:secuencialDesembolso").text = i
|
|||
|
|
nodoRoot.selectSingleNode("dto:secuencialOperacion").text = "1"
|
|||
|
|
nodoRoot.selectSingleNode("dto:tipoCotizacionDesembolso").text = "N"
|
|||
|
|
nodoRoot.selectSingleNode("dto:tipoCotizacionOperacion").text = "N"
|
|||
|
|
|
|||
|
|
'*************************************************************************************
|
|||
|
|
'CREACION DE LAS FORMAS DE DESEMBOLSO EN COBIS
|
|||
|
|
'*************************************************************************************
|
|||
|
|
strEstadoProceso = ExecuteDesembolso(Proceso, xmlDocRec.xml, strXMLCrearDesembolso, Usuario)
|
|||
|
|
|
|||
|
|
Dim xmlDocRec2 As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
Dim xmlNode1 As MSXML2.IXMLDOMNode
|
|||
|
|
Dim xmlNode2 As MSXML2.IXMLDOMNode
|
|||
|
|
|
|||
|
|
xmlDocRec2.async = False
|
|||
|
|
xmlDocRec2.validateOnParse = False
|
|||
|
|
xmlDocRec2.resolveExternals = False
|
|||
|
|
xmlDocRec2.loadXML(strXMLCrearDesembolso)
|
|||
|
|
|
|||
|
|
xmlNode1 = xmlDocRec2.selectSingleNode("DatosDesembolso")
|
|||
|
|
xmlNode2 = xmlNode1.selectSingleNode("ESTADOPROCESO")
|
|||
|
|
|
|||
|
|
xmlNode1.text = ""
|
|||
|
|
xmlNode1.text &= "<LLAVE>" & fd_llave & "</LLAVE>"
|
|||
|
|
xmlNode1.text &= "<FORMADESEMBOLSO>" & fd_forma_desembolso & "</FORMADESEMBOLSO>"
|
|||
|
|
xmlNode1.text &= xmlNode2.xml
|
|||
|
|
xmlNode1.text = gHttpServer.HtmlDecode(xmlNode1.xml)
|
|||
|
|
nElemento.text &= xmlNode1.text
|
|||
|
|
|
|||
|
|
If (strEstadoProceso.Trim() <> "S") Then
|
|||
|
|
Throw New Exception("Estado resultante de la ejecucion incorrecto.")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
'*************************************************************************************
|
|||
|
|
'GUARDA INDICADORES DE FORMAS DE DESEMBOLSO ALMACENADO
|
|||
|
|
'*************************************************************************************
|
|||
|
|
GrabarSecuencialCobis(fd_llave, "1", Proceso, xmlNode1.text, Usuario)
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
nElemento2 = xmlFormado.createElement("ESTADOPROCESO")
|
|||
|
|
nElemento2.text = "OK"
|
|||
|
|
nElemento.appendChild(nElemento2)
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
strError = "RegistrarDesembolsoCartera - " & 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 "ExecuteDesembolso"
|
|||
|
|
Private Function ExecuteDesembolso(ByVal Proceso As String,
|
|||
|
|
ByVal strXML As String,
|
|||
|
|
ByRef strXMLout As String,
|
|||
|
|
ByVal Usuario As String
|
|||
|
|
) As String
|
|||
|
|
|
|||
|
|
Dim strXMLDesembolso As String = String.Empty
|
|||
|
|
Dim xmlDoc As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
Dim xmlRootDoc As MSXML2.IXMLDOMNode
|
|||
|
|
Dim xmlRootProc As MSXML2.IXMLDOMNode
|
|||
|
|
Dim strEstadoProceso As String = String.Empty
|
|||
|
|
Dim strError As String = String.Empty
|
|||
|
|
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
xmlDoc.async = False
|
|||
|
|
xmlDoc.preserveWhiteSpace = True
|
|||
|
|
xmlDoc.validateOnParse = False
|
|||
|
|
|
|||
|
|
strXMLDesembolso = Desembolso(Proceso, strXML, Usuario)
|
|||
|
|
xmlDoc.loadXML(strXMLDesembolso)
|
|||
|
|
|
|||
|
|
xmlRootDoc = xmlDoc.documentElement
|
|||
|
|
If (Not IsNothing(xmlRootDoc.selectSingleNode("ERROR"))) Then
|
|||
|
|
Throw New Exception(xmlRootDoc.selectSingleNode("ERROR").text)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If (Not IsNothing(xmlRootDoc.selectSingleNode("DatosDesembolso"))) Then
|
|||
|
|
xmlRootProc = xmlRootDoc.selectSingleNode("DatosDesembolso")
|
|||
|
|
strEstadoProceso = xmlRootProc.selectSingleNode("ESTADOPROCESO").text
|
|||
|
|
strXMLout = xmlRootProc.xml
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
strError = "ExecuteDesembolso - " & ex.Message
|
|||
|
|
Throw New Exception(strError)
|
|||
|
|
End Try
|
|||
|
|
Return strEstadoProceso
|
|||
|
|
End Function
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "Desembolso"
|
|||
|
|
Private Function Desembolso(ByVal Proceso As String,
|
|||
|
|
ByVal strXML As String,
|
|||
|
|
ByVal Usuario As String
|
|||
|
|
) As String
|
|||
|
|
|
|||
|
|
Dim strError As String = String.Empty
|
|||
|
|
|
|||
|
|
Dim respXML As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
Dim node As MSXML2.IXMLDOMNode
|
|||
|
|
Dim xmlFormado As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
Dim rootElemento As MSXML2.IXMLDOMNode
|
|||
|
|
Dim nElemento, nElemento2 As MSXML2.IXMLDOMNode
|
|||
|
|
Dim objPI As MSXML2.IXMLDOMProcessingInstruction
|
|||
|
|
'-------------------------------------------------------------------
|
|||
|
|
Dim strSuccess As String = String.Empty
|
|||
|
|
Dim strCode As String = "0"
|
|||
|
|
Dim strMessage As String = String.Empty
|
|||
|
|
Dim strType As String = "0"
|
|||
|
|
Dim xmNodeMessages As MSXML2.IXMLDOMNode
|
|||
|
|
'-------------------------------------------------------------------
|
|||
|
|
|
|||
|
|
objPI = xmlFormado.createProcessingInstruction("xml", "version='1.0' encoding='utf-8'")
|
|||
|
|
xmlFormado.appendChild(objPI)
|
|||
|
|
rootElemento = xmlFormado.createElement("Resultado")
|
|||
|
|
xmlFormado.appendChild(rootElemento)
|
|||
|
|
|
|||
|
|
nElemento = xmlFormado.createElement("DatosDesembolso")
|
|||
|
|
rootElemento.appendChild(nElemento)
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
'◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄
|
|||
|
|
'Solo dummy
|
|||
|
|
'◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄
|
|||
|
|
'Dim objXMLIn As MSXML2.DOMDocument = New MSXML2.DOMDocument()
|
|||
|
|
'objXMLIn.load("C:\inetpub\wwwroot\Proyectos\Ultimus\Generales\WS\integracionCobisGeneral\XmlSoap\Desembolso.xml")
|
|||
|
|
'strXML = objXMLIn.xml
|
|||
|
|
'◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄◄
|
|||
|
|
|
|||
|
|
respXML.async = False
|
|||
|
|
respXML.preserveWhiteSpace = True
|
|||
|
|
respXML.validateOnParse = False
|
|||
|
|
respXML = outSoapConector.InvocaWebServiceSoap(strXML, strError, arrPrefix, Proceso, Usuario)
|
|||
|
|
|
|||
|
|
If (strError.Trim().Length > 0) Then
|
|||
|
|
Throw New Exception(strError)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
'***************************************************************************************
|
|||
|
|
'Valida estructura de control de errores
|
|||
|
|
'***************************************************************************************
|
|||
|
|
If (Not IsNothing(respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(2) & ":success"))) Then
|
|||
|
|
strSuccess = respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(2) & ":success").text
|
|||
|
|
If (strSuccess.Trim().ToLower() = "false") Then
|
|||
|
|
If (Not IsNothing(respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(2) & ":messages"))) Then
|
|||
|
|
xmNodeMessages = respXML.childNodes(0).childNodes(0).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(respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(5) & ":estadoProceso"))) Then
|
|||
|
|
If (respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(5) & ":estadoProceso").text.Trim() = "N") Then
|
|||
|
|
strCode = respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(5) & ":codigoError").text
|
|||
|
|
strMessage = respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(5) & ":descripError").text
|
|||
|
|
|
|||
|
|
strError = "Error: Code:" & strCode & " - Message:" & strMessage
|
|||
|
|
Throw New Exception(strError)
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
'***************************************************************************************
|
|||
|
|
node = respXML.childNodes(0).childNodes(0)
|
|||
|
|
'***************************************************************************************
|
|||
|
|
'idTransaccion
|
|||
|
|
'***************************************************************************************
|
|||
|
|
If node.selectSingleNode(arrPrefix(5) & ":estadoProceso") Is Nothing Then
|
|||
|
|
Throw New Exception("No se encontro la variable de salida: ns5:estadoProceso")
|
|||
|
|
End If
|
|||
|
|
nElemento2 = xmlFormado.createElement("ESTADOPROCESO")
|
|||
|
|
nElemento2.text = node.selectSingleNode(arrPrefix(5) & ":estadoProceso").text
|
|||
|
|
nElemento.appendChild(nElemento2)
|
|||
|
|
'***************************************************************************************
|
|||
|
|
Catch ex As Exception
|
|||
|
|
strError = "Desembolso - " & ex.Message
|
|||
|
|
Finally
|
|||
|
|
If strError <> "" Then
|
|||
|
|
nElemento = xmlFormado.createElement("ERROR")
|
|||
|
|
nElemento.text = strError
|
|||
|
|
rootElemento.appendChild(nElemento)
|
|||
|
|
End If
|
|||
|
|
Desembolso = xmlFormado.xml
|
|||
|
|
End Try
|
|||
|
|
End Function
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "GrabarSecuencialCobis"
|
|||
|
|
Private Sub GrabarSecuencialCobis(ByVal llave As String,
|
|||
|
|
ByVal sec_cobis As String,
|
|||
|
|
ByVal proceso As String,
|
|||
|
|
ByVal strXML As String,
|
|||
|
|
ByVal Usuario As String)
|
|||
|
|
|
|||
|
|
Dim xmlRespuesta As New MSXML2.DOMDocument
|
|||
|
|
|
|||
|
|
Dim strFuenteDatos As String
|
|||
|
|
Dim strSP As String
|
|||
|
|
Dim strRespXml As String
|
|||
|
|
Dim aNombreParametro(4), aValorParametro(4) As String
|
|||
|
|
Dim excError As Exception
|
|||
|
|
Dim strError As String = String.Empty
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
strFuenteDatos = Entidades.Enumerador.FuenteDatosUltimus.BPMPRENDARIO.ToString()
|
|||
|
|
strSP = "usp_cp_forma_desembolso"
|
|||
|
|
|
|||
|
|
aNombreParametro(1) = "@i_opcion" : aValorParametro(1) = "7"
|
|||
|
|
aNombreParametro(2) = "@i_llave" : aValorParametro(2) = llave
|
|||
|
|
aNombreParametro(3) = "@i_sec_cobis" : aValorParametro(3) = sec_cobis
|
|||
|
|
aNombreParametro(4) = "@i_xml" : aValorParametro(4) = strXML
|
|||
|
|
|
|||
|
|
strRespXml = outConector.EjecutarComandoSQLArreglo(gProceso, strFuenteDatos, strSP, aNombreParametro, aValorParametro, 0)
|
|||
|
|
|
|||
|
|
Catch excError
|
|||
|
|
strError = "GrabarSecuencialCobis - " & excError.Message
|
|||
|
|
Throw New Exception(strError)
|
|||
|
|
End Try
|
|||
|
|
End Sub
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Class
|