Cambio de formato de respuesta en facturacion masiva del pescadito

This commit is contained in:
2020-07-20 20:58:13 -07:00
parent ecae4cf4bd
commit 9204a091e4

View File

@@ -13,38 +13,62 @@ Imports Modelos
Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState
Private Property CveEmpresaFacturar As Integer = 143
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "application/json" context.Response.ContentType = "text/plain"
Dim Retorno As Boolean = False
Try Try
If context.Request.InputStream IsNot Nothing Then 'If context.Request.InputStream IsNot Nothing Then
Using reader As New StreamReader(context.Request.InputStream) ' Using reader As New StreamReader(context.Request.InputStream)
Dim json = reader.ReadToEnd ' Dim json = reader.ReadToEnd
If Not String.IsNullOrEmpty(json) Then ' If Not String.IsNullOrEmpty(json) Then
Dim JsonRequest As JObject = JObject.Parse(json) ' Dim JsonRequest As JObject = JObject.Parse(json)
If JsonRequest IsNot Nothing Then ' If JsonRequest IsNot Nothing Then
Dim Metodo = JsonRequest("Metodo").ToString() ' Dim Metodo = JsonRequest("Metodo").ToString()
If Metodo = "FactMasivaRemisiones" Then ' If Metodo = "FactMasivaRemisiones" Then
Dim pCveEmpresa = JsonRequest("CveEmpresa").ToString() ' Dim pCveEmpresa = JsonRequest("CveEmpresa").ToString()
Dim pFechaI As String = "" ' Dim pFechaI As String = ""
Dim pFechaF As String = "" ' Dim pFechaF As String = ""
If JsonRequest("FechaI") IsNot Nothing AndAlso JsonRequest("FechaF") IsNot Nothing Then ' If JsonRequest("FechaI") IsNot Nothing AndAlso JsonRequest("FechaF") IsNot Nothing Then
pFechaI = JsonRequest("FechaI") ' pFechaI = JsonRequest("FechaI")
pFechaF = JsonRequest("FechaF") ' pFechaF = JsonRequest("FechaF")
End If ' End If
IniciaFacturacionMasiva(context, pCveEmpresa, pFechaI, pFechaF) ' IniciaFacturacionMasiva(context, CveEmpresaFacturar, pFechaI, pFechaF)
End If ' End If
End If ' End If
End If ' End If
End Using ' End Using
'End If
Dim Metodo = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString())
If Metodo = "FactMasivaRemisiones" Then
Dim pFechaI As String = ""
Dim pFechaF As String = ""
If context.Request("FechaI") IsNot Nothing AndAlso context.Request("FechaF") IsNot Nothing Then
pFechaI = context.Request("FechaI")
pFechaF = context.Request("FechaF")
End If
Retorno = IniciaFacturacionMasiva(CveEmpresaFacturar, pFechaI, pFechaF)
End If End If
Catch ex As Exception Catch ex As Exception
ex.GuardaLog(ex.Message) ex.GuardaLog(ex.Message)
End Try End Try
If Retorno Then
context.Response.Write("True")
Else
context.Response.Write("False")
End If
End Sub End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
@@ -53,7 +77,8 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState
End Get End Get
End Property End Property
Private Sub IniciaFacturacionMasiva(ByVal context As HttpContext, pCveEmpresa As String, pFechaI As String, pFechaF As String) Private Function IniciaFacturacionMasiva(pCveEmpresa As String, pFechaI As String, pFechaF As String) As Boolean
Dim Retorno As Boolean = True
Dim JsonRetorno As New JObject() Dim JsonRetorno As New JObject()
Dim CveEmpresa As Integer = pCveEmpresa.ToEntero() Dim CveEmpresa As Integer = pCveEmpresa.ToEntero()
If CveEmpresa > 0 Then If CveEmpresa > 0 Then
@@ -72,6 +97,9 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState
FechaF = New DateTime(Sabado.Year, Sabado.Month, Sabado.Day, 23, 59, 59) FechaF = New DateTime(Sabado.Year, Sabado.Month, Sabado.Day, 23, 59, 59)
JsonRetorno = EjecutarFacturacionMasiva(Usuario, FechaI, FechaF, Usuario.Empresa.FacturaProduccion) JsonRetorno = EjecutarFacturacionMasiva(Usuario, FechaI, FechaF, Usuario.Empresa.FacturaProduccion)
Else
Retorno = False
GuardaLogFacturacion("Ejecución no permitida, no es el dia permitido para ejecucion o no se espeficaron las fechas")
End If End If
Else Else
FechaI = pFechaI.ToDateTime() FechaI = pFechaI.ToDateTime()
@@ -79,11 +107,13 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState
JsonRetorno = EjecutarFacturacionMasiva(Usuario, FechaI, FechaF, Usuario.Empresa.FacturaProduccion) JsonRetorno = EjecutarFacturacionMasiva(Usuario, FechaI, FechaF, Usuario.Empresa.FacturaProduccion)
End If End If
End If End If
context.Response.Write(JsonRetorno)
End Sub GuardaLogFacturacion("Ejecución Exitosa, se generaron las siguientes facturas:")
GuardaLogFacturacion(JsonRetorno.ToString())
Return Retorno
End Function
Public Shared Function GetNextWeekday(ByVal start As DateTime, ByVal day As DayOfWeek, hora As TimeSpan) As DateTime Public Shared Function GetNextWeekday(ByVal start As DateTime, ByVal day As DayOfWeek, hora As TimeSpan) As DateTime