This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2020-06-07 02:06:11 -07:00
parent 2a7879bfac
commit c080abce6f
4 changed files with 1908 additions and 63 deletions

View File

@@ -43,7 +43,10 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
ActualizaPrePoliza(context) ActualizaPrePoliza(context)
Case "getpersonal" Case "getpersonal"
getpersonal(context) getpersonal(context)
Case "GettingCURP"
context.Response.Write(GettingCURP(context.Request("Curp").ToString(), context.Request("year").ToString().ToEntero()))
Case "ValidaCURP"
context.Response.Write(ValidaCURP(context.Request("Curp").ToString()))
End Select End Select
Catch ex As Exception Catch ex As Exception
ex.GuardaLog(ex.Message) ex.GuardaLog(ex.Message)
@@ -181,6 +184,225 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState
End Sub End Sub
#End Region #End Region
Private Shared Function sendURL(ByVal URL As String, Optional Methodo As String = "POST", Optional Cookie As String = "", Optional maxTimeMilliseconds As Integer = 120000) As String
Dim resultado As String = ""
Try
Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest)
request.Timeout = maxTimeMilliseconds
request.Method = Methodo
request.ContentType = "text/html; charset=utf-8" '"text/xml; charset=utf-8"
If Not String.IsNullOrEmpty(Cookie) Then
request.Headers.Add("Cookie", Cookie)
End If
'Using stream As IO.Stream = request.GetRequestStream()
' Using stmw As IO.StreamWriter = New IO.StreamWriter(stream)
' stmw.Write("")
' End Using
'End Using
Dim response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse)
Dim sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream())
resultado = sr.ReadToEnd()
sr.Close()
Catch ex As Exception
ex.ToString().GuardaLog()
'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}")
End Try
Return resultado
End Function
Public Shared Function GettingCURP(ByVal Curp As String, year As Integer) As String
Dim abc As String() = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
Dim numeric01 As String() = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
Dim rule1 As String() = If(year < 2000, numeric01, abc)
Dim curpresult As String = ""
Dim i As Integer = 0
While curpresult.Length = 0 AndAlso i < rule1.Length
Dim z As Integer = 0
While curpresult.Length = 0 AndAlso z < numeric01.Length
curpresult = String.Format("{0}{1}{2}", Curp, rule1(i), numeric01(z))
Dim respuesta As String = sendURL(String.Format("http://www.renapo.sep.gob.mx/wsrenapo/MainControllerParam?curp={0}", curpresult), "GET")
Dim trlines As New List(Of String)
Dim keydict As New System.Collections.Concurrent.ConcurrentDictionary(Of String, String)
Dim indexttr As Integer = 0
Dim indexttrB As Integer = 0
Dim indexttd As Integer = 0
Dim indextdiv As Integer = 0
Dim indexinittext As Integer = 0
While Not IsNothing(respuesta) AndAlso respuesta.Length > 0
indexttr = respuesta.IndexOf("<tr")
If indexttr >= 0 Then
indexttrB = respuesta.Substring(indexttr + 3).IndexOf("<tr")
If indexttrB >= 0 Then
trlines.Add(respuesta.Substring(indexttr, indexttrB))
Else
trlines.Add(respuesta.Substring(indexttr))
End If
respuesta = respuesta.Substring(indexttr + 3)
Else
respuesta = ""
End If
End While
Dim key As String = ""
Dim keyvalue As String = ""
For Each item As String In trlines
key = ""
keyvalue = ""
indexttd = item.IndexOf("<td")
indextdiv = item.IndexOf("<div")
If indextdiv >= 0 Then
indexttr = indextdiv
indexttrB = item.IndexOf("</div")
Else
indexttr = indexttd
indexttrB = item.IndexOf("</td")
End If
If indexttr >= 0 Then
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
key = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
item = item.Substring(indexttrB + 3)
Else
item = ""
End If
If item.Length > 0 Then
indexttd = item.IndexOf("<td")
indextdiv = item.IndexOf("<div")
If indextdiv >= 0 Then
indexttr = indextdiv
indexttrB = item.IndexOf("</div")
Else
indexttr = indexttd
indexttrB = item.IndexOf("</td")
End If
If indexttr >= 0 Then
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
keyvalue = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
item = item.Substring(indexttr + 3)
Else
item = ""
End If
End If
If key.Length > 0 Then
keydict.TryAdd(key.Replace(":", "").Trim(), keyvalue.Trim().ToLower())
End If
Next
Dim Apellido1 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
Dim Apellido2 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
Dim Nombres As String = "" : keydict.TryGetValue("Nombres", Nombres)
If Nombres Is Nothing OrElse Nombres.Length = 0 Then
curpresult = ""
End If
System.Threading.Thread.Sleep(100)
z = z + 1
End While
i = i + 1
End While
Return curpresult
End Function
Public Shared Function ValidaCURP(ByVal Curp As String) As String
Dim respuesta As String = sendURL(String.Format("http://www.renapo.sep.gob.mx/wsrenapo/MainControllerParam?curp={0}", Curp), "GET")
Dim trlines As New List(Of String)
Dim keydict As New System.Collections.Concurrent.ConcurrentDictionary(Of String, String)
Dim indexttr As Integer = 0
Dim indexttrB As Integer = 0
Dim indexttd As Integer = 0
Dim indextdiv As Integer = 0
Dim indexinittext As Integer = 0
While Not IsNothing(respuesta) AndAlso respuesta.Length > 0
indexttr = respuesta.IndexOf("<tr")
If indexttr >= 0 Then
indexttrB = respuesta.Substring(indexttr + 3).IndexOf("<tr")
If indexttrB >= 0 Then
trlines.Add(respuesta.Substring(indexttr, indexttrB))
Else
trlines.Add(respuesta.Substring(indexttr))
End If
respuesta = respuesta.Substring(indexttr + 3)
Else
respuesta = ""
End If
End While
Dim key As String = ""
Dim keyvalue As String = ""
For Each item As String In trlines
key = ""
keyvalue = ""
indexttd = item.IndexOf("<td")
indextdiv = item.IndexOf("<div")
If indextdiv >= 0 Then
indexttr = indextdiv
indexttrB = item.IndexOf("</div")
Else
indexttr = indexttd
indexttrB = item.IndexOf("</td")
End If
If indexttr >= 0 Then
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
key = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
item = item.Substring(indexttrB + 3)
Else
item = ""
End If
If item.Length > 0 Then
indexttd = item.IndexOf("<td")
indextdiv = item.IndexOf("<div")
If indextdiv >= 0 Then
indexttr = indextdiv
indexttrB = item.IndexOf("</div")
Else
indexttr = indexttd
indexttrB = item.IndexOf("</td")
End If
If indexttr >= 0 Then
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
keyvalue = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
item = item.Substring(indexttr + 3)
Else
item = ""
End If
End If
If key.Length > 0 Then
keydict.TryAdd(key.Replace(":", "").Trim(), keyvalue.Trim().ToLower())
End If
Next
Dim Apellido1 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
Dim Apellido2 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
Dim Nombres As String = "" : keydict.TryGetValue("Nombres", Nombres)
If Nombres Is Nothing OrElse Nombres.Length = 0 Then
Curp = ""
End If
Return Curp
End Function
#Region "Get Cliente" #Region "Get Cliente"
Private Function GetClientes(ByVal context As HttpContext) As String Private Function GetClientes(ByVal context As HttpContext) As String
Dim retorno As String = "" Dim retorno As String = ""

View File

@@ -1759,7 +1759,7 @@ Partial Class RegPoliza
End Sub End Sub
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String) Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
Dim dt As New DataTable Dim dt As New DataTable
Dim Conexion As Odbc.OdbcConnection = Nothing 'Dim Conexion As Odbc.OdbcConnection = Nothing
Dim ErrorArchivo = False Dim ErrorArchivo = False
Dim n As Integer = 0 Dim n As Integer = 0
Try Try
@@ -1772,7 +1772,7 @@ Partial Class RegPoliza
'cmd.CommandText = "Select * FROM [Hoja1$]" 'cmd.CommandText = "Select * FROM [Hoja1$]"
'Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) 'Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
'DataAdapter.Fill(dt) 'DataAdapter.Fill(dt)
dt = Extensiones.ModExtensiones.ReadExcelFile(String.Format("{0}{1}", Ruta, FileName), True) dt = Extensiones.ModExtensiones.ReadExcelFile(String.Format("{1}", Ruta, FileName), True)
Case Else Case Else
Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError) Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
Exit Sub Exit Sub
@@ -1781,7 +1781,7 @@ Partial Class RegPoliza
ErrorArchivo = True ErrorArchivo = True
OnError("Ocurrio un Error al leer el archivo <br/>" & ex.Message, ex) OnError("Ocurrio un Error al leer el archivo <br/>" & ex.Message, ex)
End Try End Try
Conexion.Close() 'Conexion.Close()
If Not ErrorArchivo Then If Not ErrorArchivo Then
If Not dt.Columns(0).ColumnName = "Referencia" Then If Not dt.Columns(0).ColumnName = "Referencia" Then
Alert("El nombre de la primera columna debe ser 'Referencia'.Favor de corregirlo", TipoMensaje.MsgError) Alert("El nombre de la primera columna debe ser 'Referencia'.Favor de corregirlo", TipoMensaje.MsgError)
@@ -1881,7 +1881,7 @@ Partial Class RegPoliza
Dim file As Archivo = TxtExcel.getfiles().Archivos(0) Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.patch Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & file.patch
Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb", "xls"), "EXCEL", "CSV") Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb", "xls"), "EXCEL", "CSV")
CargarArchivo(Directorio, file.filename, Tipo) CargarArchivo(Directorio, file.FileUrl, Tipo)
Else Else
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError) Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
End If End If

File diff suppressed because it is too large Load Diff

View File

@@ -8,6 +8,8 @@ Imports System.IO
Imports System.Data Imports System.Data
Imports Microsoft.Reporting.WebForms Imports Microsoft.Reporting.WebForms
Imports System.Globalization Imports System.Globalization
Imports System.Xml
Imports System.Web.Script.Services
Partial Class RH_Personal Partial Class RH_Personal
Inherits ClsPaginas Inherits ClsPaginas
@@ -615,6 +617,136 @@ Partial Class RH_Personal
#End Region #End Region
Private Shared Function sendURL(ByVal URL As String, Optional Methodo As String = "POST", Optional Cookie As String = "", Optional maxTimeMilliseconds As Integer = 120000) As String
Dim resultado As String = ""
Try
Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest)
request.Timeout = maxTimeMilliseconds
request.Method = Methodo
request.ContentType = "text/html; charset=utf-8" '"text/xml; charset=utf-8"
If Not String.IsNullOrEmpty(Cookie) Then
request.Headers.Add("Cookie", Cookie)
End If
'Using stream As IO.Stream = request.GetRequestStream()
' Using stmw As IO.StreamWriter = New IO.StreamWriter(stream)
' stmw.Write("")
' End Using
'End Using
Dim response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse)
Dim sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream())
resultado = sr.ReadToEnd()
sr.Close()
Catch ex As Exception
ex.ToString().GuardaLog()
'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}")
End Try
Return resultado
End Function
'<ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Json)>
<System.Web.Services.WebMethod()>
Public Shared Function gettingCURP(ByVal Curp As String, year As Integer) As String
Dim abc As String() = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
Dim numeric01 As String() = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
Dim rule1 As String() = If(year < 2000, numeric01, abc)
Dim curpresult As String = ""
Dim i As Integer = 0
While Curp.Length = 0 AndAlso i < rule1.Length
Dim z As Integer = 0
While Curp.Length = 0 AndAlso z < numeric01.Length
curpresult = String.Format("{0}{1}{2}", Curp, rule1(i), numeric01(z))
Dim respuesta As String = sendURL(String.Format("http://www.renapo.sep.gob.mx/wsrenapo/MainControllerParam?curp={0}", curpresult), "GET")
Dim trlines As New List(Of String)
Dim keydict As New System.Collections.Concurrent.ConcurrentDictionary(Of String, String)
Dim indexttr As Integer = 0
Dim indexttrB As Integer = 0
Dim indexttd As Integer = 0
Dim indextdiv As Integer = 0
Dim indexinittext As Integer = 0
While Not IsNothing(respuesta) AndAlso respuesta.Length > 0
indexttr = respuesta.IndexOf("<tr")
If indexttr >= 0 Then
indexttrB = respuesta.Substring(indexttr + 3).IndexOf("<tr")
If indexttrB >= 0 Then
trlines.Add(respuesta.Substring(indexttr, indexttrB))
Else
trlines.Add(respuesta.Substring(indexttr))
End If
respuesta = respuesta.Substring(indexttr + 3)
Else
respuesta = ""
End If
End While
Dim key As String = ""
Dim keyvalue As String = ""
For Each item As String In trlines
key = ""
keyvalue = ""
indexttd = item.IndexOf("<td")
indextdiv = item.IndexOf("<div")
If indextdiv >= 0 Then
indexttr = indextdiv
indexttrB = item.IndexOf("</div")
Else
indexttr = indexttd
indexttrB = item.IndexOf("</td")
End If
If indexttr >= 0 Then
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
key = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
item = item.Substring(indexttrB + 3)
Else
item = ""
End If
If item.Length > 0 Then
indexttd = item.IndexOf("<td")
indextdiv = item.IndexOf("<div")
If indextdiv >= 0 Then
indexttr = indextdiv
indexttrB = item.IndexOf("</div")
Else
indexttr = indexttd
indexttrB = item.IndexOf("</td")
End If
If indexttr >= 0 Then
indexinittext = item.Substring(indexttr + 3).IndexOf(">")
keyvalue = item.Substring(indexinittext + indexttr + 4, (indexttrB - (indexinittext + indexttr + 4)))
item = item.Substring(indexttr + 3)
Else
item = ""
End If
End If
If key.Length > 0 Then
keydict.TryAdd(key.Replace(":", "").Trim(), keyvalue.Trim().ToLower())
End If
Next
Dim Apellido1 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
Dim Apellido2 As String = "" : keydict.TryGetValue("Apellido1", Apellido1)
Dim Nombres As String = "" : keydict.TryGetValue("Nombres", Nombres)
If Nombres Is Nothing OrElse Nombres.Length = 0 Then
curpresult = ""
End If
z = z + 1
End While
i = i + 1
End While
Return curpresult
End Function
Const wdPageBreak As Integer = 7 Const wdPageBreak As Integer = 7
Const wdCharacter As Integer = 1 Const wdCharacter As Integer = 1
@@ -624,6 +756,8 @@ Partial Class RH_Personal
If UsuarioActual.CveEmpresa = 72 OrElse UsuarioActual.CveEmpresa = 80 Then If UsuarioActual.CveEmpresa = 72 OrElse UsuarioActual.CveEmpresa = 80 Then
pnlSalarioIMSS.Visible = False pnlSalarioIMSS.Visible = False
End If End If
'
ViewState("Orden") = "" ViewState("Orden") = ""
ViewState("Orden1") = "" ViewState("Orden1") = ""