143 lines
4.4 KiB
Plaintext
143 lines
4.4 KiB
Plaintext
<%@ WebHandler Language="VB" Class="MobileHandler" %>
|
|
|
|
Imports System.Web
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.Text
|
|
|
|
|
|
|
|
Public Class MobileHandler : Implements IHttpHandler
|
|
Private Property Contexto As HttpContext
|
|
|
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
|
Contexto = context
|
|
|
|
If context.Request("Opcion") IsNot Nothing Then
|
|
Dim Opcion As String = context.Request("Opcion")
|
|
|
|
Select Case Opcion
|
|
Case "ValidaUsuario"
|
|
ValidaUsuario()
|
|
Case "Simpatizantes"
|
|
If IfNull(Contexto.Request("Agrupador"), "0").ToString <> "0" Then
|
|
RepSimpatizantes(IfNull(Contexto.Request("Agrupador"), "0").ToString.ToEntero, 41)
|
|
End If
|
|
Case "Metas"
|
|
If IfNull(Contexto.Request("Agrupador"), "0").ToString <> "0" Then
|
|
RepMetas(IfNull(Contexto.Request("Agrupador"), "0").ToString.ToEntero, 41)
|
|
End If
|
|
Case "Actividades"
|
|
If IfNull(Contexto.Request("Agrupador"), "0").ToString <> "0" Then
|
|
RepActividadesRecientes(41)
|
|
End If
|
|
|
|
End Select
|
|
End If
|
|
End Sub
|
|
|
|
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
|
Get
|
|
Return False
|
|
End Get
|
|
End Property
|
|
|
|
|
|
Private Sub ValidaUsuario()
|
|
Dim NombreCadena As String = ClsPaginas.GlobalNombreCadenaConexion(41)
|
|
Dim ObjUsuario As New ClsSisUsuarioAutenticacion(NombreCadena:=NombreCadena)
|
|
Dim User As Usuario
|
|
|
|
Dim IP As String
|
|
|
|
IP = clsUtilerias.GetIP4Address 'Request.ServerVariables("REMOTE_ADDR").ToString()
|
|
|
|
If IP = "::1" Then
|
|
IP = "127.0.0.1"
|
|
|
|
End If
|
|
|
|
Dim Json As New StringBuilder
|
|
|
|
User = ObjUsuario.ValidaUsuario(Contexto.Request("Usuario"), Contexto.Request("Password"), 41)
|
|
|
|
If User IsNot Nothing Then
|
|
|
|
Dim Token As String = String.Format("{0}*{1}*{2}", ClsPaginas.NowADS().ToString, IP, User.CveUsuario)
|
|
Token = Encripta(Token)
|
|
Json.AppendFormat("{{ ""CveUsuario"" : ""{0}"", ""Nombre"" : ""{1}"", ""Token"" : ""{2}"" }} ", User.CveUsuario, User.Nombre, Token)
|
|
Else
|
|
Json.Append("{ ""CveUsuario"" : ""-1"", ""Nombre"" : ""No valido"" } ")
|
|
End If
|
|
ObjUsuario.Dispose()
|
|
Contexto.Response.Write(Json.ToString)
|
|
End Sub
|
|
|
|
|
|
Private Sub RepActividadesRecientes(CveEmpresa As Integer)
|
|
Dim Json As String = ""
|
|
Dim Ind As New ClsProspectos
|
|
|
|
If Ind.GetProspectosSupervisor(CveEmpresa) Then
|
|
|
|
Json = DataTableToJSON(Ind.DtResultados)
|
|
|
|
End If
|
|
|
|
Ind.Dispose()
|
|
|
|
|
|
Contexto.Response.Write(Json)
|
|
End Sub
|
|
|
|
Private Sub RepSimpatizantes(Agrupador As Integer, CveEmpresa As Integer)
|
|
Dim Json As String = ""
|
|
Dim Ind As New ClsProspectos
|
|
|
|
If Ind.GetProspectosAgrupados2(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, Agrupador, CveEmpresa) Then
|
|
Dim yValues As New ArrayList
|
|
Dim xValues As New ArrayList
|
|
|
|
'cuando es por edades, ordena por la claverango
|
|
Dim dt As DataTable = Ind.DtResultados.FiltraParametros("CveAgrupador > 0", If(Agrupador = 9, "CveRangoEdad", "Total Desc"))
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
Json = DataTableToJSON(Ind.DtResultados)
|
|
End If
|
|
End If
|
|
|
|
|
|
Ind.Dispose()
|
|
|
|
|
|
Contexto.Response.Write(Json)
|
|
End Sub
|
|
|
|
|
|
Private Sub RepMetas(Opcion As Integer, CveEmpresa As Integer)
|
|
Dim ObjProspectos As New ClsProspectos
|
|
Dim dt As DataTable
|
|
Dim Json As String = ""
|
|
If ObjProspectos.GetProspectosAgrupadosMetas(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, CveEmpresa) Then
|
|
dt = ObjProspectos.DtResultados
|
|
If Opcion = 1 Then
|
|
dt = dt.FiltraParametros("CveCoordinador > 0 AND CveAgrupador IS NULL")
|
|
Else
|
|
dt = dt.FiltraParametros("CveSupervisor > 0 AND CveCoordinador IS NULL")
|
|
|
|
End If
|
|
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
Json = DataTableToJSON(dt)
|
|
End If
|
|
End If
|
|
|
|
ObjProspectos.Dispose()
|
|
Contexto.Response.Write(Json)
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
End Class
|
|
|