72 lines
2.4 KiB
Plaintext
72 lines
2.4 KiB
Plaintext
<%@ WebHandler Language="VB" Class="SIGCRM" %>
|
|
|
|
Imports System
|
|
Imports System.Web
|
|
Imports System.Data
|
|
Imports Newtonsoft.Json
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
|
|
Public Class SIGCRM : Implements IHttpHandler, IRequiresSessionState
|
|
|
|
#Region "P R O P I E D A D E S"
|
|
ReadOnly Property UsuarioActual(ByVal context As HttpContext) As Usuario
|
|
Get
|
|
UsuarioActual = DirectCast(context.Session("UsuarioSIG"), Usuario)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
|
|
Get
|
|
Return False
|
|
End Get
|
|
End Property
|
|
Private Function Parametros(Cadena As String) As Hashtable
|
|
Dim P1() As String = Cadena.Split("&"c)
|
|
Dim Tmp As String
|
|
Dim P2() As String
|
|
|
|
Dim URLParametros As New Hashtable
|
|
|
|
For Each Tmp In P1
|
|
P2 = Tmp.Replace("%26%", "&").Split("="c)
|
|
URLParametros.Add(P2(0).ToString.ToUpper, P2(1))
|
|
Next
|
|
Return URLParametros
|
|
End Function
|
|
#End Region
|
|
|
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
|
context.Response.ContentType = "text/plain"
|
|
Try
|
|
Select Case context.Request("metodo")
|
|
Case "getimgacercamiento"
|
|
GetImgAcercamiento(context)
|
|
End Select
|
|
Catch ex As Exception
|
|
ex.GuardaLog(ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub GetImgAcercamiento(ByVal context As HttpContext)
|
|
Dim params As String = Decripta(context.Request("r").ToString)
|
|
Dim Parametros = Me.Parametros(params)
|
|
Dim Archivo As String = Parametros("ARCHIVO").ToString()
|
|
Dim CveAcercamiento As Integer = Parametros("CVEACERCAMIENTO").ToString().ToEntero()
|
|
Dim Extension As String = Path.GetExtension(Archivo).Replace(".", "")
|
|
Dim Usuario As Usuario = UsuarioActual(context)
|
|
|
|
If Not IsNothing(Usuario) Then
|
|
Dim Url = String.Format("{0}Acercamientos\{1}\Imagenes\{2}", Usuario.Empresa.Ruta, CveAcercamiento, Archivo)
|
|
|
|
If File.Exists(Url) Then
|
|
context.Response.ContentType = String.Format("image/{0}", Extension)
|
|
context.Response.Flush()
|
|
context.Response.WriteFile(Url)
|
|
context.Response.End()
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
End Class |