255 lines
10 KiB
VB.net
255 lines
10 KiB
VB.net
Imports System.Text.RegularExpressions
|
|
Public Class frmDetalleHit
|
|
|
|
Private Util As New ClassMyUtils
|
|
Public Id As Integer
|
|
Public IdOT As String
|
|
Public CadenaOT As String
|
|
Public Detalles As String
|
|
Public IdUsuario1 As Integer
|
|
Public IdUsuario2 As Integer
|
|
Public IdUsuarioOC As Integer
|
|
Public calif1 As Boolean
|
|
Public calif2 As Boolean
|
|
Public califOC As Boolean
|
|
Public IsOk As Boolean
|
|
Private review As Boolean
|
|
Private compli As Boolean
|
|
Private IdUser As Integer
|
|
|
|
Private Enum IdUsr
|
|
Usr1
|
|
Usr2
|
|
UsrOC
|
|
Calificado
|
|
Err
|
|
End Enum
|
|
Private EIdUsr As IdUsr
|
|
|
|
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles btnSalir.Click
|
|
Salir()
|
|
End Sub
|
|
|
|
Private Sub frmDetalleHit_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
|
|
Util.LogProcesoHit("frmDetalleHit_Load", "Iniciando")
|
|
review = VariablesGlobales.breview
|
|
Util.LogProcesoHit("frmDetalleHit_Load", "Review: " & review)
|
|
compli = VariablesGlobales.bcompli
|
|
Util.LogProcesoHit("frmDetalleHit_Load", "Compliance: " & compli)
|
|
IdUser = VariablesGlobales.gblIdUsuario
|
|
Util.LogProcesoHit("frmDetalleHit_Load", "IdUser: " & IdUser)
|
|
verificarCalificado()
|
|
CadenaDetalle()
|
|
Util.LogProcesoHit("frmDetalleHit_Load", "Finalizando")
|
|
End Sub
|
|
|
|
Private Function verificarCalificado() As Boolean
|
|
Util.LogProcesoHit("verificarCalificado", "Iniciando")
|
|
Try
|
|
If IsOk Then
|
|
EIdUsr = IdUsr.Calificado
|
|
ElseIf IdUsuario1 <> 0 And IdUsuario2 <> 0 And IdUsuarioOC <> 0 Then
|
|
EIdUsr = IdUsr.Calificado
|
|
ElseIf IdUsuario1 <> 0 And IdUsuario2 <> 0 And Not calif1 And Not calif2 Then
|
|
EIdUsr = IdUsr.Calificado
|
|
ElseIf (IdUsuario1 = 0 Or IdUsuario2 = 0) And compli Then
|
|
EIdUsr = IdUsr.Calificado
|
|
ElseIf IdUser = IdUsuario1 Or IdUser = IdUsuario2 Then
|
|
EIdUsr = IdUsr.Calificado
|
|
ElseIf IdUsuario1 = 0 And review Then
|
|
EIdUsr = IdUsr.Usr1
|
|
ElseIf IdUsuario2 = 0 And review Then
|
|
EIdUsr = IdUsr.Usr2
|
|
ElseIf IdUsuarioOC = 0 And compli Then
|
|
EIdUsr = IdUsr.UsrOC
|
|
Else
|
|
EIdUsr = IdUsr.Err
|
|
End If
|
|
|
|
Util.LogProcesoHit("verificarCalificado", "EIdUsr: " & EIdUsr)
|
|
|
|
If EIdUsr = IdUsr.Calificado Or EIdUsr = IdUsr.Err Then
|
|
btnHit.Enabled = False
|
|
btnNoHit.Enabled = False
|
|
End If
|
|
Catch ex As Exception
|
|
MessageBox.Show(ex.Message)
|
|
Util.LogProcesoHit("verificarCalificado", "Error: " & ex.Message)
|
|
End Try
|
|
End Function
|
|
|
|
Private Function CadenaDetalle() As Boolean
|
|
Dim Detalle() As String
|
|
Util.LogProcesoHit("CadenaDetalle", "Iniciando")
|
|
Try
|
|
Util.LogProcesoHit("CadenaDetalle", "Preparando cadena detalle")
|
|
Label1.Text = "IdOT: " & IdOT
|
|
rtxtDetalle.Text = ""
|
|
rtxtCadena.Text = Regex.Replace(CadenaOT, "-(.*?)}", New MatchEvaluator(AddressOf UpperEvaluator))
|
|
|
|
Detalle = Regex.Split(Detalles, "~", RegexOptions.IgnoreCase)
|
|
For Each s As String In Detalle
|
|
Dim detallito() As String = s.Split("|")
|
|
If detallito.Length = 1 And s.Trim().Length > 0 Then
|
|
rtxtDetalle.Text += "País Hit: " & vbCr & s & vbCr & vbCr
|
|
End If
|
|
If detallito.Length = 9 Then
|
|
rtxtDetalle.Text += detallito(8) & vbCr
|
|
rtxtDetalle.Text += "Buscado: " & detallito(7) & vbCr
|
|
rtxtDetalle.Text += "Porcentaje Nombre: " & detallito(5) & "%" & vbCr
|
|
rtxtDetalle.Text += "Porcentaje Observaciones: " & detallito(6) & "%" & vbCr
|
|
rtxtDetalle.Text += "Coincidencia: " & detallito(1) & vbCr
|
|
rtxtDetalle.Text += detallito(2) & vbCr
|
|
rtxtDetalle.Text += detallito(3) & vbCr & vbCr
|
|
End If
|
|
Next
|
|
Util.LogProcesoHit("CadenaDetalle", "Fin")
|
|
Catch ex As Exception
|
|
MessageBox.Show("Error cargando datos." & vbCr & ex.Message)
|
|
Util.LogProcesoHit("CadenaDetalle", "Error: " & ex.Message)
|
|
End Try
|
|
'rtxtDetalle.Text = Detalles.Replace("¿|?", vbCr).Replace("|", vbCr)
|
|
|
|
End Function
|
|
|
|
Function UpperEvaluator(ByVal match As Match) As String
|
|
Return match.Value + vbCr
|
|
End Function
|
|
|
|
Private Sub rtxtCadena_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles rtxtCadena.KeyPress
|
|
e.KeyChar = vbNullChar
|
|
End Sub
|
|
|
|
Private Sub rtxtDetalle_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles rtxtDetalle.KeyPress
|
|
e.KeyChar = vbNullChar
|
|
End Sub
|
|
|
|
Private Sub btnHit_Click(sender As System.Object, e As System.EventArgs) Handles btnHit.Click
|
|
Calificar(True)
|
|
End Sub
|
|
|
|
Private Function EnviaServicio(resultado As String) As Boolean
|
|
Dim DTO As New ServiceMT.MindsResponseDTO
|
|
Dim srv As New ServiceMT.ServiceMTmessageIntegratorClient("BasicHttpBinding_IServiceMTmessageIntegrator")
|
|
Dim respuesta As String
|
|
Util.LogProcesoHit("EnviaServicio", "Iniciando")
|
|
EnviaServicio = False
|
|
Try
|
|
Util.LogProcesoHit("EnviaServicio", "Enviando mensaje a ServiceMTmessageIntegratorClient")
|
|
DTO.MtMessageId = IdOT
|
|
Util.LogProcesoHit("EnviaServicio", "Enviando IdOT: " & IdOT)
|
|
DTO.Comments = ""
|
|
Util.LogProcesoHit("EnviaServicio", "Comments: ")
|
|
DTO.Response = resultado
|
|
Util.LogProcesoHit("EnviaServicio", "Response: " & resultado)
|
|
|
|
Util.LogProcesoHit("EnviaServicio", "URL: " & srv.Endpoint.Address.ToString())
|
|
respuesta = srv.SetMindsResponse(DTO)
|
|
Util.LogProcesoHit("EnviaServicio", "Hubo Respuesta")
|
|
Util.LogProcesoHit("EnviaServicio", "Respuesta: " & respuesta)
|
|
srv.Close()
|
|
If respuesta = "OK" Then
|
|
EnviaServicio = True
|
|
Else
|
|
MessageBox.Show("Ocurrió un error intente nuevamente más tarde." & vbCr & respuesta, "EnviaServicio Else")
|
|
Util.LogProcesoHit("EnviaServicio", "Reversando")
|
|
ReversoCalificar()
|
|
End If
|
|
GuardarRespuestaIntegrador(respuesta)
|
|
Util.LogProcesoHit("EnviaServicio", "Fin")
|
|
Catch ex As Exception
|
|
MessageBox.Show(ex.Message, "EnviaServicio Error")
|
|
ReversoCalificar()
|
|
Util.LogProcesoHit("CadenaDetalle", "Error: " & ex.Message)
|
|
End Try
|
|
End Function
|
|
|
|
Private Function GuardarRespuestaIntegrador(respuesta As String) As Boolean
|
|
Dim Ssql As String
|
|
Dim cls As clsComplejo
|
|
GuardarRespuestaIntegrador = False
|
|
Util.LogProcesoHit("GuardarRespuestaIntegrador", "Inicio")
|
|
Try
|
|
cls = New clsComplejo()
|
|
Ssql = "spU_procesoHITCalificarIntegrador " & Id & ",'" & respuesta & "'"
|
|
cls.fnInserta(Ssql)
|
|
GuardarRespuestaIntegrador = True
|
|
Util.LogProcesoHit("GuardarRespuestaIntegrador", "Fin")
|
|
Catch ex As Exception
|
|
MessageBox.Show(ex.Message)
|
|
Util.LogProcesoHit("GuardarRespuestaIntegrador", "Error: " & ex.Message)
|
|
End Try
|
|
End Function
|
|
|
|
Private Function ReversoCalificar() As Boolean
|
|
Dim Ssql As String
|
|
Dim cls As clsComplejo
|
|
ReversoCalificar = False
|
|
Util.LogProcesoHit("ReversoCalificar", "Inicio")
|
|
Try
|
|
cls = New clsComplejo()
|
|
Util.LogProcesoHit("ReversoCalificar", "Reversando Id: " & Id & "EIdUsr: " & EIdUsr)
|
|
Ssql = "spU_procesoHITCalificarReverso " & Id & "," & EIdUsr
|
|
cls.fnInserta(Ssql)
|
|
ReversoCalificar = True
|
|
Util.LogProcesoHit("ReversoCalificar", "Fin")
|
|
Catch ex As Exception
|
|
MessageBox.Show(ex.Message)
|
|
Util.LogProcesoHit("ReversoCalificar", "Error: " & ex.Message)
|
|
End Try
|
|
End Function
|
|
|
|
Private Function Calificar(calificacion As Boolean) As Boolean
|
|
Dim Usuario As Integer
|
|
Dim Ssql As String
|
|
Dim cls As clsComplejo
|
|
Dim ds As New DataSet
|
|
Dim resultado As String
|
|
Calificar = False
|
|
Cursor = Cursors.WaitCursor
|
|
Util.LogProcesoHit("Calificar", "Inicio")
|
|
Try
|
|
cls = New clsComplejo()
|
|
Util.LogProcesoHit("Calificando", "ID: " & Int(calificacion) & " IdUser: " & IdUser & " EIdUsr:" & EIdUsr)
|
|
Ssql = "spI_procesoHITCalificar " & Id & "," & Int(calificacion) & "," & IdUser & "," & EIdUsr
|
|
|
|
If EIdUsr = IdUsr.Usr1 Then
|
|
resultado = cls.fnInserta(Ssql)
|
|
If resultado.Trim.Length = 0 Then
|
|
MessageBox.Show("Calificación registrada con éxito")
|
|
End If
|
|
End If
|
|
|
|
If EIdUsr = IdUsr.Usr2 Or EIdUsr = IdUsr.UsrOC Then
|
|
ds = cls.fdtDataSetTablaESP(Ssql)
|
|
resultado = IIf(IsDBNull(ds.Tables(0).Rows(0)(0)), "", ds.Tables(0).Rows(0)(0))
|
|
If resultado.Trim.Length > 0 Then
|
|
If Not EnviaServicio(resultado) Then
|
|
Exit Function
|
|
End If
|
|
End If
|
|
MessageBox.Show("Calificación registrada con éxito")
|
|
Util.LogProcesoHit("Calificar", "Calificación registrada con éxito")
|
|
End If
|
|
|
|
Me.Close()
|
|
Calificar = True
|
|
Util.LogProcesoHit("Calificar", "Fin")
|
|
Catch ex As Exception
|
|
MessageBox.Show(ex.Message)
|
|
Util.LogProcesoHit("Calificar", "Error: " & ex.Message)
|
|
Finally
|
|
Cursor = Cursors.Default
|
|
End Try
|
|
|
|
End Function
|
|
|
|
|
|
Private Sub btnNoHit_Click(sender As System.Object, e As System.EventArgs) Handles btnNoHit.Click
|
|
Calificar(False)
|
|
End Sub
|
|
|
|
Private Function Salir() As Boolean
|
|
Me.Close()
|
|
End Function
|
|
End Class |