310 lines
13 KiB
VB.net
310 lines
13 KiB
VB.net
|
|
Imports System.Web
|
|||
|
|
Imports ULA.Davivienda.WCFServiciosCobisCartera.DAL
|
|||
|
|
|
|||
|
|
Public Class Liquidacion
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "PROPIEDADES"
|
|||
|
|
Dim gProceso As String
|
|||
|
|
Dim gHttpServer As HttpServerUtility
|
|||
|
|
Dim arrPrefix As String() = New String() {}
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "Constructor"
|
|||
|
|
Public Sub New(ByVal Proceso As String,
|
|||
|
|
ByRef httpServer As HttpServerUtility)
|
|||
|
|
|
|||
|
|
gProceso = Proceso
|
|||
|
|
gHttpServer = httpServer
|
|||
|
|
End Sub
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "RegistrarLiquidacion"
|
|||
|
|
Public Function RegistrarLiquidacion(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 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 strEstadoProceso As String = String.Empty
|
|||
|
|
Dim strXMLLiquidacion 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("DatosRegistrarLiquidacion")
|
|||
|
|
rootElemento.appendChild(nElemento)
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
|
|||
|
|
'***********************************************************************************
|
|||
|
|
'OBTIENE LA DATA DE LA LIQUIDACION DE LA SOLICITUD
|
|||
|
|
'***********************************************************************************
|
|||
|
|
strXMLLiquidacion = BuscaLiquidacionSQL(Proceso, Solicitud, Usuario)
|
|||
|
|
|
|||
|
|
'***********************************************************************************
|
|||
|
|
'SI YA FUE LIQUIDADO
|
|||
|
|
'***********************************************************************************
|
|||
|
|
If (strXMLLiquidacion.Trim() <> "") Then
|
|||
|
|
nElemento.text &= strXMLLiquidacion
|
|||
|
|
Else
|
|||
|
|
'*******************************************************************************
|
|||
|
|
'LIQUIDA LA OPERACION
|
|||
|
|
'*******************************************************************************
|
|||
|
|
strEstadoProceso = ExecuteLiquidacion(Proceso, strXML, strXMLLiquidacion, Usuario)
|
|||
|
|
nElemento.text &= strXMLLiquidacion
|
|||
|
|
|
|||
|
|
'*******************************************************************************
|
|||
|
|
'REGISTRAR LIQUIDACION SQL
|
|||
|
|
'*******************************************************************************
|
|||
|
|
GuardaLiquidacionSQL(Proceso, Solicitud, NumOperacion, strXMLLiquidacion, Usuario)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
strError = "RegistrarLiquidacion - " & 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 "ExecuteLiquidacion"
|
|||
|
|
Private Function ExecuteLiquidacion(ByVal Proceso As String,
|
|||
|
|
ByVal strXML As String,
|
|||
|
|
ByRef strXMLout As String,
|
|||
|
|
ByVal Usuario As String
|
|||
|
|
) As String
|
|||
|
|
|
|||
|
|
Dim strXMLLiquidacion 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
|
|||
|
|
|
|||
|
|
strXMLLiquidacion = Liquidacion(Proceso, strXML, Usuario)
|
|||
|
|
xmlDoc.loadXML(strXMLLiquidacion)
|
|||
|
|
|
|||
|
|
xmlRootDoc = xmlDoc.documentElement
|
|||
|
|
If (Not IsNothing(xmlRootDoc.selectSingleNode("ERROR"))) Then
|
|||
|
|
Throw New Exception(xmlRootDoc.selectSingleNode("ERROR").text)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If (Not IsNothing(xmlRootDoc.selectSingleNode("DatosLiquidacion"))) Then
|
|||
|
|
xmlRootProc = xmlRootDoc.selectSingleNode("DatosLiquidacion")
|
|||
|
|
strEstadoProceso = xmlRootProc.selectSingleNode("ESTADOPROCESO").text
|
|||
|
|
strXMLout = xmlRootProc.xml
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
strError = "ExecuteLiquidacion - " & ex.Message
|
|||
|
|
Throw New Exception(strError)
|
|||
|
|
End Try
|
|||
|
|
Return strEstadoProceso
|
|||
|
|
End Function
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "Liquidacion"
|
|||
|
|
Private Function Liquidacion(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("DatosLiquidacion")
|
|||
|
|
rootElemento.appendChild(nElemento)
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
|
|||
|
|
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(22) & ":estadoProceso"))) Then
|
|||
|
|
If (respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(22) & ":estadoProceso").text.Trim() = "N") Then
|
|||
|
|
strCode = respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(22) & ":codigoError").text
|
|||
|
|
strMessage = respXML.childNodes(0).childNodes(0).selectSingleNode(arrPrefix(22) & ":descripcionError").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(22) & ":estadoProceso") Is Nothing Then
|
|||
|
|
Throw New Exception("No se encontro la variable de salida: ns7:estadoProceso")
|
|||
|
|
End If
|
|||
|
|
nElemento2 = xmlFormado.createElement("ESTADOPROCESO")
|
|||
|
|
nElemento2.text = node.selectSingleNode(arrPrefix(22) & ":estadoProceso").text
|
|||
|
|
nElemento.appendChild(nElemento2)
|
|||
|
|
'***************************************************************************************
|
|||
|
|
Catch ex As Exception
|
|||
|
|
strError = "Liquidacion - " & ex.Message
|
|||
|
|
Finally
|
|||
|
|
If strError <> "" Then
|
|||
|
|
nElemento = xmlFormado.createElement("ERROR")
|
|||
|
|
nElemento.text = strError
|
|||
|
|
rootElemento.appendChild(nElemento)
|
|||
|
|
End If
|
|||
|
|
Liquidacion = xmlFormado.xml
|
|||
|
|
End Try
|
|||
|
|
End Function
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "GuardaLiquidacionSQL"
|
|||
|
|
Private Sub GuardaLiquidacionSQL(ByVal Proceso As String,
|
|||
|
|
ByVal Solicitud As String,
|
|||
|
|
ByVal NumOperacion As String,
|
|||
|
|
ByVal xmlLiquidacion As String,
|
|||
|
|
ByVal Usuario As String)
|
|||
|
|
|
|||
|
|
Dim strFuenteDatos As String
|
|||
|
|
Dim strSP As String
|
|||
|
|
Dim strRespXml As String
|
|||
|
|
Dim aNombreParametro(4), aValorParametro(4) As String
|
|||
|
|
Dim strError As String = String.Empty
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
strFuenteDatos = Entidades.Enumerador.FuenteDatosUltimus.BPMPRENDARIO.ToString()
|
|||
|
|
strSP = "usp_cp_numero_operacion"
|
|||
|
|
|
|||
|
|
aNombreParametro(1) = "@i_opcion" : aValorParametro(1) = "5"
|
|||
|
|
aNombreParametro(2) = "@i_solicitud" : aValorParametro(2) = Solicitud
|
|||
|
|
aNombreParametro(3) = "@i_tramite_liquidado" : aValorParametro(3) = "1"
|
|||
|
|
aNombreParametro(4) = "@i_xml_liquidacion" : aValorParametro(4) = xmlLiquidacion
|
|||
|
|
|
|||
|
|
strRespXml = outConector.EjecutarComandoSQLArreglo(gProceso, strFuenteDatos, strSP, aNombreParametro, aValorParametro, 0)
|
|||
|
|
|
|||
|
|
Catch excError As Exception
|
|||
|
|
strError = "GuardaLiquidacionSQL - " & excError.Message
|
|||
|
|
Throw New Exception(strError)
|
|||
|
|
End Try
|
|||
|
|
End Sub
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
#Region "BuscaLiquidacionSQL"
|
|||
|
|
Public Function BuscaLiquidacionSQL(ByVal Proceso As String,
|
|||
|
|
ByVal Solicitud As String,
|
|||
|
|
ByVal Usuario As String) As String
|
|||
|
|
|
|||
|
|
Dim xmlRespuesta As New MSXML2.DOMDocument()
|
|||
|
|
Dim xmlRoot As MSXML2.IXMLDOMNode
|
|||
|
|
|
|||
|
|
Dim strFuenteDatos As String
|
|||
|
|
Dim strSP As String
|
|||
|
|
Dim strRespXml As String
|
|||
|
|
Dim aNombreParametro(2), aValorParametro(2) As String
|
|||
|
|
Dim strError As String = String.Empty
|
|||
|
|
Dim strXMLOperacion As String = String.Empty
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
strFuenteDatos = Entidades.Enumerador.FuenteDatosUltimus.BPMPRENDARIO.ToString()
|
|||
|
|
strSP = "usp_cp_numero_operacion"
|
|||
|
|
|
|||
|
|
aNombreParametro(1) = "@i_opcion" : aValorParametro(1) = "1"
|
|||
|
|
aNombreParametro(2) = "@i_solicitud" : aValorParametro(2) = Solicitud
|
|||
|
|
|
|||
|
|
|
|||
|
|
strRespXml = outConector.EjecutarComandoSQLArreglo(gProceso, strFuenteDatos, strSP, aNombreParametro, aValorParametro, 0)
|
|||
|
|
xmlRespuesta.loadXML(strRespXml)
|
|||
|
|
|
|||
|
|
xmlRoot = xmlRespuesta.documentElement
|
|||
|
|
If (Not IsNothing(xmlRoot.selectSingleNode("Table"))) Then
|
|||
|
|
strXMLOperacion = xmlRoot.selectSingleNode("Table/df_xml_liquidacion").text
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Catch excError As Exception
|
|||
|
|
strError = "BuscaLiquidacionSQL - " & excError.Message
|
|||
|
|
Throw New Exception(strError)
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
BuscaLiquidacionSQL = strXMLOperacion
|
|||
|
|
End Function
|
|||
|
|
#End Region
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Class
|