-- integración con kiosko
This commit is contained in:
389
Ashx/E140.ashx
389
Ashx/E140.ashx
@@ -6,6 +6,7 @@ Imports System.Data
|
|||||||
Imports Newtonsoft.Json
|
Imports Newtonsoft.Json
|
||||||
Imports Extensiones
|
Imports Extensiones
|
||||||
Imports System.IO
|
Imports System.IO
|
||||||
|
Imports Newtonsoft.Json.Linq
|
||||||
Imports Microsoft.Reporting.WebForms
|
Imports Microsoft.Reporting.WebForms
|
||||||
|
|
||||||
Public Class E140 : Implements IHttpHandler, IRequiresSessionState
|
Public Class E140 : Implements IHttpHandler, IRequiresSessionState
|
||||||
@@ -14,18 +15,325 @@ Public Class E140 : Implements IHttpHandler, IRequiresSessionState
|
|||||||
Return False
|
Return False
|
||||||
End Get
|
End Get
|
||||||
End Property
|
End Property
|
||||||
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
Public Shared ReadOnly Property EsProduccion As Boolean
|
||||||
|
Get
|
||||||
|
If IsNothing(System.Configuration.ConfigurationManager.AppSettings("EsProduccion")) Then
|
||||||
|
Return False
|
||||||
|
Else
|
||||||
|
Return (System.Configuration.ConfigurationManager.AppSettings("EsProduccion").ToString() = "1")
|
||||||
|
End If
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
Private ReadOnly Property CveEmpresa As Integer = 140
|
||||||
|
Private ReadOnly Property UsuarioWSE140 As String = "bdh_apiuser_"
|
||||||
|
Private ReadOnly Property PasswordWSE140 As String = "*863.fy03pon.8kmn_vbtu"
|
||||||
|
Public ReadOnly Property TokenAutorizacion As String
|
||||||
|
Get
|
||||||
|
Return "$2y$10$LGqtRWUloKQmAt.jcUldc.PmS5LJ6l.WU2w1G4PBOTLMVKZRNQFPS"
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Private Function ValidaUsuarioSistema(CveUsuario As Integer, CveEmpresa As Integer) As Usuario
|
||||||
|
Dim UsuarioActual As Usuario = Nothing
|
||||||
|
Dim NombreCadena As String = ClsPaginas.GlobalNombreCadenaConexion(CveEmpresa)
|
||||||
|
Dim ObjUsuarios As New ClsSisUsuarioAutenticacion(NombreCadena:=NombreCadena)
|
||||||
|
UsuarioActual = ObjUsuarios.GetUsuarioDetalle(100, CveEmpresa)
|
||||||
|
If UsuarioActual IsNot Nothing Then
|
||||||
|
HttpContext.Current.Session("UsuarioSIG") = UsuarioActual
|
||||||
|
'CreaObjetoEmpresa(UsuarioActual)
|
||||||
|
End If
|
||||||
|
ObjUsuarios.Dispose()
|
||||||
|
|
||||||
|
Return UsuarioActual
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
|
||||||
|
Dim retorno As String
|
||||||
Try
|
Try
|
||||||
Select Case context.Request("metodo")
|
Dim Metodo As String = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString())
|
||||||
|
Select Case Metodo
|
||||||
Case "MetasVendedores"
|
Case "MetasVendedores"
|
||||||
MetasVendedores(context)
|
MetasVendedores(context)
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
|
If Metodo = "ConsultaRemisiones" Then
|
||||||
|
context.Response.ContentType = "application/json"
|
||||||
|
Dim Auth As AuthMessage = ValidarSolicitud(context)
|
||||||
|
|
||||||
|
If Auth.IsSucces Then
|
||||||
|
retorno = ConsultaRemisiones(context, "")
|
||||||
|
Else
|
||||||
|
context.Response.StatusCode = Auth.StatusCode
|
||||||
|
retorno = JsonConvert.SerializeObject(Auth.ErrorMessage)
|
||||||
|
End If
|
||||||
|
context.Response.Write(retorno)
|
||||||
|
ElseIf Metodo = "RegistraPago" Then
|
||||||
|
context.Response.ContentType = "application/json"
|
||||||
|
Dim Auth As AuthMessage = ValidarSolicitud(context)
|
||||||
|
|
||||||
|
If Auth.IsSucces Then
|
||||||
|
retorno = RegistraPagoRemision(context, "")
|
||||||
|
Else
|
||||||
|
context.Response.StatusCode = Auth.StatusCode
|
||||||
|
retorno = JsonConvert.SerializeObject(Auth.ErrorMessage)
|
||||||
|
End If
|
||||||
|
context.Response.Write(retorno)
|
||||||
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
ex.GuardaLog(ex.Message)
|
ex.GuardaLog(ex.Message)
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Function ValidarSolicitud(ByVal context As HttpContext) As AuthMessage
|
||||||
|
Dim unauthorized As Boolean = True
|
||||||
|
Dim respuesta As New AuthMessage
|
||||||
|
|
||||||
|
Dim authHeader = context.Request.Headers("Authorization")
|
||||||
|
If authHeader IsNot Nothing Then
|
||||||
|
Dim basicAuth As String = authHeader.Replace("Basic ", "")
|
||||||
|
|
||||||
|
Dim usernamePasswordArray = Encoding.UTF8.GetString(Convert.FromBase64String(basicAuth)).Split(":"c)
|
||||||
|
|
||||||
|
Dim userName = usernamePasswordArray(0)
|
||||||
|
Dim password = usernamePasswordArray(1)
|
||||||
|
unauthorized = Not (userName = Me.UsuarioWSE140 AndAlso password = Me.PasswordWSE140)
|
||||||
|
|
||||||
|
Else
|
||||||
|
respuesta.ErrorMessage = New AppsResponseError() With {.message = "el usuario y/o contraseña son requeridos"}
|
||||||
|
respuesta.IsSucces = False
|
||||||
|
respuesta.StatusCode = 200
|
||||||
|
|
||||||
|
Return respuesta
|
||||||
|
End If
|
||||||
|
|
||||||
|
If unauthorized Then
|
||||||
|
respuesta.ErrorMessage = New AppsResponseError() With {.message = "el usuario y/o contraseña no son validos"}
|
||||||
|
respuesta.IsSucces = False
|
||||||
|
respuesta.StatusCode = 200
|
||||||
|
|
||||||
|
Return respuesta
|
||||||
|
Else
|
||||||
|
respuesta.ErrorMessage = Nothing
|
||||||
|
respuesta.IsSucces = True
|
||||||
|
respuesta.StatusCode = 200
|
||||||
|
|
||||||
|
Return respuesta
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function ConsultaRemisiones(ByVal context As HttpContext, Codigo As String) As String
|
||||||
|
Dim Respuesta As New AppsResponse
|
||||||
|
Dim RespuestaError As New AppsResponseError
|
||||||
|
Dim TieneError As Boolean = False
|
||||||
|
Dim CveSubProyecto As String = "11790"
|
||||||
|
|
||||||
|
Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa)
|
||||||
|
Dim data As New JArray
|
||||||
|
Dim dtt As New DataTable
|
||||||
|
Dim ObjVentas As New ClsVentas
|
||||||
|
If ObjVentas.GetRepRemisionesSinFacturar(Now.AddYears(-2).ToShortDateString, Now.ToShortDateString, Now.ToShortDateString, CveSubProyecto, -1, -1, "-1", CveEmpresa, CveUsuarioConsulta:=100, PrimerProducto:=True) Then
|
||||||
|
dtt = ObjVentas.DtResultados.FiltraParametros("CveVenta > 0")
|
||||||
|
End If
|
||||||
|
ObjVentas.Dispose()
|
||||||
|
|
||||||
|
If dtt IsNot Nothing Then
|
||||||
|
Try
|
||||||
|
For Each Row As DataRow In dtt.Rows
|
||||||
|
Dim objVenta As New JObject(
|
||||||
|
New JProperty("cveventa", Row("CveVenta")),
|
||||||
|
New JProperty("folio", Row("Folio")),
|
||||||
|
New JProperty("cliente", Row("Cliente")),
|
||||||
|
New JProperty("fecha", Row("Fecha")),
|
||||||
|
New JProperty("total", Row("Total")),
|
||||||
|
New JProperty("moneda", Row("Abreviatura")),
|
||||||
|
New JProperty("primerproducto", Row("PrimerCodigoPS"))
|
||||||
|
)
|
||||||
|
data.Add(objVenta)
|
||||||
|
Next
|
||||||
|
Catch ex As Exception
|
||||||
|
TieneError = True
|
||||||
|
RespuestaError.message = "Ocurrió un error al obtener las remisiones pendientes."
|
||||||
|
End Try
|
||||||
|
dtt.Dispose()
|
||||||
|
Else
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
Respuesta.data = data
|
||||||
|
|
||||||
|
If TieneError Then
|
||||||
|
context.Response.StatusCode = 200
|
||||||
|
Return JsonConvert.SerializeObject(RespuestaError)
|
||||||
|
Else
|
||||||
|
context.Response.StatusCode = 200
|
||||||
|
Return JsonConvert.SerializeObject(Respuesta)
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function RegistraPagoRemision(ByVal context As HttpContext, CveVenta As String) As String
|
||||||
|
Dim Respuesta As New AppsResponse
|
||||||
|
Dim RespuestaError As New AppsResponseError
|
||||||
|
Dim TieneError As Boolean = False
|
||||||
|
Dim CveSubProyecto As String = "11790"
|
||||||
|
Dim JsonRequest As JObject = Nothing
|
||||||
|
|
||||||
|
If context.Request.InputStream IsNot Nothing Then
|
||||||
|
Using reader As New StreamReader(context.Request.InputStream)
|
||||||
|
Dim json = reader.ReadToEnd
|
||||||
|
If Not String.IsNullOrEmpty(json) Then
|
||||||
|
JsonRequest = JObject.Parse(json)
|
||||||
|
If JsonRequest Is Nothing Then
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim UsuarioActual As Usuario = ValidaUsuarioSistema(100, CveEmpresa)
|
||||||
|
Dim data As New JArray
|
||||||
|
Dim dtt As New DataTable
|
||||||
|
Dim MsgError As String = ""
|
||||||
|
Dim CveCuentaBancaria As Integer = 8075
|
||||||
|
Dim ImportePago As Decimal = JsonRequest("importe_pago").ToString.ToDecimal
|
||||||
|
Dim FechaPago As Date = JsonRequest("fecha_pago").ToString.ToDate
|
||||||
|
Dim FolioPago As String = JsonRequest("referencia_pago").ToString
|
||||||
|
Dim CveTipoTransaccion As Integer = If(JsonRequest("referencia_pago").ToString = "tdc", 12, 11)
|
||||||
|
Dim CveMonedaPago As Integer = If(JsonRequest("moneda_pago").ToString = "USD", 2, 1)
|
||||||
|
Dim pCveVenta As Integer = JsonRequest("cveventa").ToString.ToEntero
|
||||||
|
Dim Referencia As String = ""
|
||||||
|
'validaciones
|
||||||
|
|
||||||
|
Dim ObjVenta As New ClsVentas()
|
||||||
|
Dim ObjClientes As New ClsClientes
|
||||||
|
If ObjVenta.GetVenta(pCveVenta, CveEmpresa) Then
|
||||||
|
If ObjVenta.DtResultados IsNot Nothing AndAlso ObjVenta.DtResultados.Rows.Count > 0 Then
|
||||||
|
Dim dr As DataRow = ObjVenta.DtResultados.Rows(0)
|
||||||
|
'importe y forma de pago.
|
||||||
|
Dim VentaRemision As New ClsPaginas.Venta(UsuarioActual)
|
||||||
|
VentaRemision.CveVenta = dr("CveVenta").ToString.ToEntero
|
||||||
|
VentaRemision.Fecha = dr("Fecha").ToString.ToDate
|
||||||
|
VentaRemision.CveCliente = dr("CveCliente").ToString.ToEntero
|
||||||
|
VentaRemision.CveMoneda = dr("CveMoneda").ToString.ToEntero
|
||||||
|
VentaRemision.TipoDocto = dr("TipoDocto").ToString
|
||||||
|
VentaRemision.SerieFolio = dr("SerieFolio").ToString
|
||||||
|
VentaRemision.ClienteNombre = dr("ClienteNombre").ToString
|
||||||
|
VentaRemision.TC = dr("TipoCambio").ToString.ToDecimal
|
||||||
|
VentaRemision.Total = dr("Total").ToString.ToDecimal
|
||||||
|
VentaRemision.IVA = dr("IVA").ToString.ToDecimal
|
||||||
|
VentaRemision.IEPS = dr("IEPS").ToString.ToDecimal
|
||||||
|
VentaRemision.RetIVA = dr("RetIVA").ToString.ToDecimal
|
||||||
|
VentaRemision.RetISR = dr("RetISR").ToString.ToDecimal
|
||||||
|
VentaRemision.PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal
|
||||||
|
VentaRemision.CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero
|
||||||
|
|
||||||
|
Dim ObjFactura = Modelos.Factura.CrearVentaNueva(UsuarioActual, VentaRemision.CveSubProyecto, VentaRemision.CveCliente, VentaRemision.CveMoneda, "Ing")
|
||||||
|
ObjFactura.CveMoneda = VentaRemision.CveMoneda
|
||||||
|
ObjFactura.CveVendedor = dr("CveVendedor").ToString.ToEntero
|
||||||
|
ObjFactura.CveFormaPago = dr("CveFormaPago33").ToString.ToEntero
|
||||||
|
'ObjFactura.ClaveFormaPagoSAT = "99"
|
||||||
|
ObjFactura.CveMetodoPago = dr("CveMetodoPago").ToString.ToEntero
|
||||||
|
'ObjFactura.ClaveMetodoPagoSAT = "PPD"
|
||||||
|
Dim DtRemisionesPS As DataTable = Nothing
|
||||||
|
If ObjClientes.GetVentasRemisionesTotales(VentaRemision.CveCliente, VentaRemision.CveVenta.ToString(), 1, CveEmpresa) Then
|
||||||
|
DtRemisionesPS = ObjClientes.DtResultados.Copy()
|
||||||
|
End If
|
||||||
|
For Each drr As DataRow In DtRemisionesPS.Rows
|
||||||
|
ObjFactura.AgregarPS(drr("CvePS").ToString().ToEntero(), drr("Cantidad").ToString().ToDecimal(), drr("PU").ToString().ToDecimal(), drr("Descuento").ToString().ToDecimal, drr("Obs").ToString(), CveUM:=drr("CveUM").ToString().ToEntero(),
|
||||||
|
CveProyecto:=drr("CveProyecto").ToString().ToEntero(), CveSubProyecto:=drr("CveSubProyecto").ToString().ToEntero(), CveVentaDetallePadre:=drr("CveVentaDetalle").ToString().ToEntero(), CveVentaDetalleRemision:=drr("CveVentaDetalle").ToString().ToEntero(),
|
||||||
|
PorcentajeIVA:=drr("PorcentajeIVA").ToString().ToDecimal(), CvePromocionDetalle:=drr("CvePromocionDetalle").ToString.ToEntero)
|
||||||
|
Next
|
||||||
|
|
||||||
|
ObjFactura.GenerarSalidaAlmacen = True
|
||||||
|
ObjFactura.DtInventario = ObjFactura.DtDetalle.FiltraParametros("CveTipoPS = 2").Copy()
|
||||||
|
'ObjFactura.CveAlmacen = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 1 AND CveSubProyecto = {VentaRemision.CveSubProyecto}", "Orden").ToString().ToEntero()
|
||||||
|
|
||||||
|
ObjFactura.CalculaTotales()
|
||||||
|
|
||||||
|
Dim ObjConta As New ClsContabilidad()
|
||||||
|
Dim ObjIE As New ClsBancos(ObjConta.IniciaTransacSQL())
|
||||||
|
Dim ObjVentas As New ClsVentas(ObjConta.IniciaTransacSQL())
|
||||||
|
Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Ashx/E140", 4, 0, 0, 1, FechaPago, "Venta Kiosco", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||||
|
|
||||||
|
If CvePrePoliza > 0 Then
|
||||||
|
'registro de venta y pago
|
||||||
|
|
||||||
|
Dim Retorno As Modelos.Factura.MMensajeFactura = Nothing
|
||||||
|
Retorno = ObjFactura.EmitirFactura(False, Transac:=ObjVentas.IniciaTransacSQL(), Modulo:="Cobranza/GuardarVenta", MostrarURL:=True)
|
||||||
|
Retorno.Factura = ObjFactura
|
||||||
|
|
||||||
|
If Retorno IsNot Nothing AndAlso Retorno.CveVenta > 0 Then
|
||||||
|
VentaRemision.CveVenta = ObjFactura.CveVenta
|
||||||
|
'Respuesta.data = Retorno.SerieFolio
|
||||||
|
|
||||||
|
If TieneError Then
|
||||||
|
Dim sb As New StringBuilder()
|
||||||
|
For Each msg As String In Retorno.Mensajes
|
||||||
|
sb.AppendFormat("{0}. ", msg)
|
||||||
|
Next
|
||||||
|
RespuestaError.message = sb.ToString()
|
||||||
|
End If
|
||||||
|
'11- tdd, 12-tdc
|
||||||
|
Dim CveIE As Integer = ObjIE.AddBancos_IE(CveCuentaBancaria, CveTipoTransaccion, FechaPago, "-1", "", ImportePago, VentaRemision.CveMoneda,
|
||||||
|
VentaRemision.TC, "", "", False, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||||
|
|
||||||
|
If CveIE > 0 Then
|
||||||
|
'Importe de pago
|
||||||
|
Dim Pago As New ClsPaginas.VentaPago
|
||||||
|
Pago.TipoPago = "XXX"
|
||||||
|
Pago.Fecha = FechaPago
|
||||||
|
Pago.CveIE = CveIE
|
||||||
|
Pago.CveMonedaPago = CveMonedaPago
|
||||||
|
Pago.ImportePago = ImportePago
|
||||||
|
Pago.ImportePagoVenta = ImportePago
|
||||||
|
Pago.Referencia = Referencia
|
||||||
|
|
||||||
|
If MsgError = "" AndAlso ClsPaginas.AplicaPrePolizaPagoVenta(VentaRemision, Pago, CvePrePoliza, ObjConta) Then
|
||||||
|
MsgError = "No se pudo insertar la póliza"
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
MsgError = "No se pudo insertar el pago"
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
TieneError = True
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
If Not TieneError Then
|
||||||
|
Dim bytesPDF As Byte() = DescargarFactura(ObjFactura.SerieFolio, CveEmpresa, ObjFactura.CveVenta) 'ClsPaginas.PdfFactura(ObjFactura, AplicaPagare:="0", Guardar:=True, RegenerarQR:=True, EsTicket:=False)
|
||||||
|
|
||||||
|
'generar el pdf y mandarlo
|
||||||
|
Dim objretorno As New JObject(
|
||||||
|
New JProperty("CveVenta", ObjFactura.CveVenta),
|
||||||
|
New JProperty("SerieFolio", ObjFactura.SerieFolio),
|
||||||
|
New JProperty("pdf", Convert.ToBase64String(bytesPDF))
|
||||||
|
)
|
||||||
|
data.Add(objretorno)
|
||||||
|
Respuesta.data = data
|
||||||
|
ObjConta.RollBack()
|
||||||
|
'ObjConta.Commit()
|
||||||
|
Else
|
||||||
|
ObjConta.RollBack()
|
||||||
|
End If
|
||||||
|
ObjConta.Dispose()
|
||||||
|
ObjIE.Dispose()
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
ObjVenta.Dispose()
|
||||||
|
ObjClientes.Dispose()
|
||||||
|
|
||||||
|
Respuesta.data = data
|
||||||
|
|
||||||
|
If TieneError Then
|
||||||
|
context.Response.StatusCode = 200
|
||||||
|
Return JsonConvert.SerializeObject(RespuestaError)
|
||||||
|
Else
|
||||||
|
context.Response.StatusCode = 200
|
||||||
|
Return JsonConvert.SerializeObject(Respuesta)
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
#Region "M E T A S V E N D E D O R E S"
|
||||||
|
|
||||||
Private Shared Sub MetasVendedores(ByVal context As HttpContext)
|
Private Shared Sub MetasVendedores(ByVal context As HttpContext)
|
||||||
|
|
||||||
@@ -128,7 +436,6 @@ Public Class E140 : Implements IHttpHandler, IRequiresSessionState
|
|||||||
|
|
||||||
For Each dRow As System.Data.DataRow In DTVendedores.Rows
|
For Each dRow As System.Data.DataRow In DTVendedores.Rows
|
||||||
|
|
||||||
|
|
||||||
Dim CorreoSupervisor As String = dRow("Correo").ToString()
|
Dim CorreoSupervisor As String = dRow("Correo").ToString()
|
||||||
Dim Sucursal As String = dRow("Sucursal").ToString
|
Dim Sucursal As String = dRow("Sucursal").ToString
|
||||||
Dim Vendedor As String = dRow("Nombre").ToString()
|
Dim Vendedor As String = dRow("Nombre").ToString()
|
||||||
@@ -226,6 +533,30 @@ Public Class E140 : Implements IHttpHandler, IRequiresSessionState
|
|||||||
Next
|
Next
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
#End Region
|
||||||
|
Private Function DescargarFactura(FilePDF As String, CveEmpresa As Integer, CveVenta As Integer) As Byte()
|
||||||
|
'
|
||||||
|
Dim Url = New Uri(String.Format("{0}://{1}:{2}/Compras/PopUpVerFactura.aspx?P={3}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, HttpContext.Current.Request.Url.Port, Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=1&GUARDAR=1®ENERAR=1", CveVenta))))
|
||||||
|
Dim File As Byte() = Nothing
|
||||||
|
Try
|
||||||
|
Using httpClient = New System.Net.Http.HttpClient()
|
||||||
|
httpClient.Timeout = New TimeSpan(0, 1, 0)
|
||||||
|
Using request = New System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, Url)
|
||||||
|
request.Headers.Add("ADSToken", Encripta(String.Format("CVEEMPRESA={0}&TICKS={1}&CVEUSUARIO=100", CveEmpresa, DateTime.UtcNow.Ticks)))
|
||||||
|
Dim response = httpClient.SendAsync(request).Result
|
||||||
|
If response.StatusCode = Net.HttpStatusCode.OK Then
|
||||||
|
File = response.Content.ReadAsByteArrayAsync().Result
|
||||||
|
End If
|
||||||
|
End Using
|
||||||
|
End Using
|
||||||
|
Catch ex As Exception
|
||||||
|
File = Nothing
|
||||||
|
OnError("Ocurrió un error al descargar la factura", ex)
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return File
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Private Shared Sub MandaCorreo(Para As String, Cuerpo As String, bytes As Byte())
|
Private Shared Sub MandaCorreo(Para As String, Cuerpo As String, bytes As Byte())
|
||||||
Try
|
Try
|
||||||
@@ -247,15 +578,51 @@ Public Class E140 : Implements IHttpHandler, IRequiresSessionState
|
|||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Shared Function IsValidJson(ByVal strInput As String) As Boolean
|
||||||
|
If String.IsNullOrWhiteSpace(strInput) Then
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
|
||||||
Public Shared ReadOnly Property EsProduccion As Boolean
|
strInput = strInput.Trim()
|
||||||
Get
|
|
||||||
If IsNothing(System.Configuration.ConfigurationManager.AppSettings("EsProduccion")) Then
|
If (strInput.StartsWith("{") AndAlso strInput.EndsWith("}")) OrElse (strInput.StartsWith("[") AndAlso strInput.EndsWith("]")) Then
|
||||||
|
|
||||||
|
Try
|
||||||
|
Dim obj = JToken.Parse(strInput)
|
||||||
|
Return True
|
||||||
|
Catch jex As JsonReaderException
|
||||||
|
Console.WriteLine(jex.Message)
|
||||||
Return False
|
Return False
|
||||||
Else
|
Catch ex As Exception
|
||||||
Return (System.Configuration.ConfigurationManager.AppSettings("EsProduccion").ToString() = "1")
|
Console.WriteLine(ex.ToString())
|
||||||
End If
|
Return False
|
||||||
End Get
|
End Try
|
||||||
End Property
|
Else
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Class AppsResponse
|
||||||
|
Sub New()
|
||||||
|
status = "success"
|
||||||
|
End Sub
|
||||||
|
Public Property status As String
|
||||||
|
Public Property data As Object
|
||||||
|
Public Property message As String
|
||||||
|
End Class
|
||||||
|
|
||||||
|
Private Class AppsResponseError
|
||||||
|
Sub New()
|
||||||
|
status = "error"
|
||||||
|
End Sub
|
||||||
|
Public Property status As String
|
||||||
|
Public Property message As String
|
||||||
|
End Class
|
||||||
|
|
||||||
|
Private Class AuthMessage
|
||||||
|
Public Property IsSucces As Boolean
|
||||||
|
Public Property ErrorMessage As AppsResponseError
|
||||||
|
Public Property StatusCode As Integer
|
||||||
|
End Class
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
Reference in New Issue
Block a user