Good morning everyone.
I am developing an application which basically is a reservations manager and queue for bars and restaurants.
Using a tablet attendant accesses this application and making the booking for each client, providing the name, mobile and receive SMS or not. After confirming the reservation, the client is placed in a queue in the same order of booking, and this will receive two SMS one confirming their position in the queue and the other with instructions commands (if authorized sending SMS on reservation).
The database is on a PC with MS SQL Server, and communication with the tablet PC is via Webservice. Both Queue Reservations as Queue are created in an array object in memory on the tablet, and are updated every 60 seconds via the thread that calls the respective methods of the webservice.
Segunte error is occurring upon confirmation of booking:
This error occurs in HttpJob, I use to call the methods of the webservice, which in this case could be a sequence of calls (the end of a method can call another). The booking confirmation is a method that transfers customers queue booking for the queue, and soon after termination methods are called to update the arrays of rows
Booking Confirmation Method
Reload position in the queue
Method Returns Reservations
Method Returns Qeue
JobDone
Confirmation by sending SMS (add a table to track the shipment)
What can be done to eliminate this error?
I am developing an application which basically is a reservations manager and queue for bars and restaurants.
Using a tablet attendant accesses this application and making the booking for each client, providing the name, mobile and receive SMS or not. After confirming the reservation, the client is placed in a queue in the same order of booking, and this will receive two SMS one confirming their position in the queue and the other with instructions commands (if authorized sending SMS on reservation).
The database is on a PC with MS SQL Server, and communication with the tablet PC is via Webservice. Both Queue Reservations as Queue are created in an array object in memory on the tablet, and are updated every 60 seconds via the thread that calls the respective methods of the webservice.
Segunte error is occurring upon confirmation of booking:
An error occurred in sub: httpjoj_getstring2 (B4A line: 108)
tr.Initialize2 (File.OpenInput (HttpUtils2Service.TempFolder, taskId), Encoding)
java.io.FileNotFoundException: / data/data/br.com.consultatech.smartline/cache/99: open failed: ENOENT (No such file or directory)
This error occurs in HttpJob, I use to call the methods of the webservice, which in this case could be a sequence of calls (the end of a method can call another). The booking confirmation is a method that transfers customers queue booking for the queue, and soon after termination methods are called to update the arrays of rows
Booking Confirmation Method
B4X:
Sub Confirma_Reserva_WS
Dim reqConfirmar_Reserva As HttpRequest
Dim Endereco, Pr As String
Dim Para() As Byte
Dim Connect As Boolean
Dim Inp As InputStream
Dim conv As ByteConverter
'Checagem da versão do ANDROID (Cria objeto Versao e carrega a string da versão do sistema)
Dim Versao As ApplicationWS '
Versao.Initialize
Versao.setVersionString(OS.Release)
Pr = ""
Connect = True
If Versao.getVersionString_Number() < "3" Then ' Versão do ANDROID menor que 3.0 utiliza a lib HTTP ( classes HttpClient e HttpRequest )
' para requisições ao WEB Service
Endereco = parametro.getWeb_Service & "/ConfirmarReserva"
HttpConfirmarReserva.Initialize("HttpConfirmarReserva")
reqConfirmar_Reserva.initializeget(Endereco)
reqConfirmar_Reserva.Timeout = nTimeOut
If HttpConfirmarReserva.Execute(reqConfirmar_Reserva, 0) = False Then
Connect = False
End If
Else ' Versão do ANDROID maior ou igual que 3.0 utiliza a classe HttpJob
' para requisições ao WEB Service
Endereco = parametro.getWeb_Service & "/ConfirmarReserva"
HJConfirmarReserva.Initialize("ConfirmarReserva",Me)
HJConfirmarReserva.PostString(Endereco,Pr)
'Connect = HJConfirmarReserva.Success
End If
If Connect = False Then Return False
Return True
End Sub
'#########################################################################################################
'# HttpConfirmarReserva #
'#########################################################################################################
Sub HttpConfirmarReserva_ResponseSuccess (Response As HttpResponse, TaskId As Int)
lConfirma_Reserva = True
Atualizar_Posicao_Fila_Espera_WS
End Sub
Sub HttpConfirmarReserva_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
Dim msg As String
ProgressDialogHide
lConfirma_Reserva = False
msg = "Erro ao conectar no Web Service." & CRLF & "Confirmar a Reserva"
If Reason <> Null Then
msg = msg & CRLF & "(" & StatusCode & ") " & Reason
End If
ToastMessageShow(msg, True)
End Sub
Reload position in the queue
B4X:
Sub Atualizar_Posicao_Fila_Espera_WS
Dim reqAtualizar_Posicao As HttpRequest
Dim Endereco, Pr As String
Dim Para() As Byte
Dim Connect As Boolean
Dim Inp As InputStream
Dim conv As ByteConverter
'Checagem da versão do ANDROID (Cria objeto Versao e carrega a string da versão do sistema)
Dim Versao As ApplicationWS '
Versao.Initialize
Versao.setVersionString(OS.Release)
Pr = ""
Connect = True
If Versao.getVersionString_Number() < "3" Then ' Versão do ANDROID menor que 3.0 utiliza a lib HTTP ( classes HttpClient e HttpRequest )
' para requisições ao WEB Service
Endereco = parametro.getWeb_Service & "/AtualizarPosicaoFilaEspera"
HttpAtualizar_Posicao.Initialize("HttpAtualizar_Posicao")
reqAtualizar_Posicao.initializeget(Endereco)
reqAtualizar_Posicao.Timeout = nTimeOut
If HttpAtualizar_Posicao.Execute(reqAtualizar_Posicao, 0) = False Then
Connect = False
End If
Else ' Versão do ANDROID maior ou igual que 3.0 utiliza a classe HttpJob
' para requisições ao WEB Service
Endereco = parametro.getWeb_Service & "/AtualizarPosicaoFilaEspera"
Pr = ""
HJAtualizar_Posicao.Initialize("Atualizar_Posicao",Me)
HJAtualizar_Posicao.PostString(Endereco,Pr)
'Connect = HJAtualizar_Posicao.Success
End If
If Connect = False Then Return False
Return True
End Sub
'#########################################################################################################
'# HttpAtualizar_Posicao #
'#########################################################################################################
Sub HttpAtualizar_Posicao_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Retorna_Reservas_WS
Retorna_Fila_Espera_WS
End Sub
Sub HttpAtualizar_Posicao_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
Dim msg As String
'Log(Reason)
'Log(StatusCode)
ProgressDialogHide
msg = "Erro ao conectar no Web Service." & CRLF & "Atualizar a Posição na Fila de Espera"
If Reason <> Null Then
msg = msg & CRLF & "(" & StatusCode & ") " & Reason
End If
ToastMessageShow(msg, True)
End Sub
Method Returns Reservations
B4X:
'#########################################################################################################
'# RESERVAS #
'#########################################################################################################
Sub Retorna_Reservas_WS() As Boolean
Dim reqReservas As HttpRequest
Dim Endereco, Pr As String
Dim Para() As Byte
Dim Connect As Boolean
Dim Inp As InputStream
Dim conv As ByteConverter
'Checagem da versão do ANDROID (Cria objeto Versao e carrega a string da versão do sistema)
Dim Versao As ApplicationWS '
Versao.Initialize
Versao.setVersionString(OS.Release)
Pr = ""
Connect = True
If Versao.getVersionString_Number() < "3" Then ' Versão do ANDROID menor que 3.0 utiliza a lib HTTP ( classes HttpClient e HttpRequest )
' para requisições ao WEB Service
Endereco = parametro.getWeb_Service & "/RetornaReservasFull"
HttpReserva.Initialize("HttpReserva")
reqReservas.initializeget(Endereco)
reqReservas.Timeout = nTimeOut
If HttpReserva.Execute(reqReservas, 0) = False Then
Connect = False
End If
Else ' Versão do ANDROID maior ou igual que 3.0 utiliza a classe HttpJob
' para requisições ao WEB Service
Endereco = parametro.getWeb_Service & "/RetornaReservasFull"
Pr = ""
HJReserva.Initialize("Reserva",Me)
HJReserva.PostString(Endereco,Pr)
'Connect = HJReserva.Success
End If
If Connect = False Then Return False
Return True
End Sub
Sub HttpReserva_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim result As String
Dim In As InputStream
'Log("ResponseSuccess")
ProgressDialogHide
result = Response.GetString("UTF8") 'Convert the response to a string
'Log(result)
'Msgbox(result, "")
'Usuarios
'ProgressDialogShow("Atualizando Tabela Usuarios...")
If File.Exists(File.DirDefaultExternal,"Reserva.xml") = True Then
File.Delete(File.DirDefaultExternal,"Reserva.xml")
End If
File.WriteString(File.DirDefaultExternal,"Reserva.xml",result)
parserReserva.Initialize
'parse the xml file
In = File.OpenInput(File.DirDefaultExternal, "Reserva.xml")
parserReserva.parse(In, "parserReserva")
In.Close
File.Delete(File.DirDefaultExternal, "Reserva.xml")
'ProgressDialogHide
End Sub
Sub HttpReserva_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
Dim msg As String
'Log(Reason)
'Log(StatusCode)
'ProgressDialogHide
msg = "Erro ao conectar no Web Service." & CRLF & "Reserva"
If Reason <> Null Then
msg = msg & CRLF & "(" & StatusCode & ") " & Reason
End If
ToastMessageShow (msg, True)
End Sub
Sub parserReserva_StartElement (Uri As String, Name As String, Attributes As Attributes)
If Name = "DataSet" Then
Reservas_Inicializa
End If
If Name = "Table" Then
Reserva.Initialize
End If
End Sub
Sub parserReserva_EndElement (Uri As String, Name As String, Text As StringBuilder)
Dim cData, cHora As String
'ToastMessageShow("Mesas" & CRLF & Uri & CRLF & Name & CRLF & Text,False)
DoEvents
If Name = "ID_Reservas" Then
Reserva.setID_Reservas(Text)
End If
If Name = "Data" Then
cData = Text.ToString.SubString2(8,10) & "/" & Text.ToString.SubString2(5,7) & "/" & Text.ToString.SubString2(0,4)
cHora = Text.ToString.SubString2(11,19)
Try
Reserva.setData(DateTime.DateTimeParse(cData,cHora))
Catch
Reserva.setData(0)
End Try
End If
If Name = "Nome" Then
Reserva.setNome(Text)
End If
If Name = "Telefone" Then
Reserva.setTelefone(Text)
End If
If Name = "SMS" Then
Reserva.setSMS(Text)
End If
If Name = "Confirmado" Then
Reserva.setConfirmado(Text)
End If
If Name = "Table" Then
If MaxReserva <= 999 Then
MaxReserva = MaxReserva + 1
lReserva(MaxReserva).Assign(Reserva)
End If
End If
If Name = "DataSet" Then
Atualiza_Reservas
End If
End Sub
Method Returns Qeue
B4X:
'#########################################################################################################
'# FILA_ESPERA #
'#########################################################################################################
Sub Retorna_Fila_Espera_WS() As Boolean
Dim reqFila_Espera As HttpRequest
Dim Endereco, Pr As String
Dim Para() As Byte
Dim Connect As Boolean
Dim Inp As InputStream
Dim conv As ByteConverter
'Checagem da versão do ANDROID (Cria objeto Versao e carrega a string da versão do sistema)
Dim Versao As ApplicationWS '
Versao.Initialize
Versao.setVersionString(OS.Release)
Pr = ""
Connect = True
If Versao.getVersionString_Number() < "3" Then ' Versão do ANDROID menor que 3.0 utiliza a lib HTTP ( classes HttpClient e HttpRequest )
' para requisições ao WEB Service
Endereco = parametro.getWeb_Service & "/RetornaFilaFull"
HttpFila_Espera.Initialize("HttpFila_Espera")
reqFila_Espera.initializeget(Endereco)
reqFila_Espera.Timeout = nTimeOut
If HttpFila_Espera.Execute(reqFila_Espera, 0) = False Then
Connect = False
End If
Else ' Versão do ANDROID maior ou igual que 3.0 utiliza a classe HttpJob
' para requisições ao WEB Service
Endereco = parametro.getWeb_Service & "/RetornaFilaFull"
Pr = ""
HJFila_Espera.Initialize("Fila_Espera",Me)
HJFila_Espera.PostString(Endereco,Pr)
'Connect = HJReserva.Success
End If
If Connect = False Then Return False
Return True
End Sub
Sub HttpFila_Espera_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim result As String
Dim In As InputStream
'Log("ResponseSuccess")
ProgressDialogHide
result = Response.GetString("UTF8") 'Convert the response to a string
'Log(result)
'Msgbox(result, "")
'Fila_Espera
'ProgressDialogShow("Atualizando Tabela Fila_Espera...")
If File.Exists(File.DirDefaultExternal,"Fila_Espera.xml") = True Then
File.Delete(File.DirDefaultExternal,"Fila_Espera.xml")
End If
File.WriteString(File.DirDefaultExternal,"Fila_Espera.xml",result)
parserFila_Espera.Initialize
'parse the xml file
In = File.OpenInput(File.DirDefaultExternal, "Fila_Espera.xml")
parserFila_Espera.parse(In, "parserFila_Espera")
In.Close
File.Delete(File.DirDefaultExternal, "Fila_Espera.xml")
'ProgressDialogHide
End Sub
Sub HttpFila_Espera_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
Dim msg As String
'Log(Reason)
'Log(StatusCode)
'ProgressDialogHide
lConfirma_Reserva = False
msg = "Erro ao conectar no Web Service." & CRLF & "Fila_Espera"
If Reason <> Null Then
msg = msg & CRLF & "(" & StatusCode & ") " & Reason
End If
ToastMessageShow (msg, True)
End Sub
Sub parserFila_Espera_StartElement (Uri As String, Name As String, Attributes As Attributes)
If Name = "DataSet" Then
Fila_Espera_Inicializa
End If
If Name = "Table" Then
Fila_Espera.Initialize
End If
End Sub
Sub parserFila_Espera_EndElement (Uri As String, Name As String, Text As StringBuilder)
Dim cData, cHora, msg As String
'ToastMessageShow("Mesas" & CRLF & Uri & CRLF & Name & CRLF & Text,False)
DoEvents
If Name = "ID_Fila_Espera" Then
Fila_Espera.setID_Fila_Espera(Text)
End If
If Name = "Posicao" Then
Fila_Espera.setPosicao(Text)
End If
If Name = "Data" Then
cData = Text.ToString.SubString2(8,10) & "/" & Text.ToString.SubString2(5,7) & "/" & Text.ToString.SubString2(0,4)
cHora = Text.ToString.SubString2(11,19)
Try
Fila_Espera.setData(DateTime.DateTimeParse(cData,cHora))
Catch
Fila_Espera.setData(0)
End Try
End If
If Name = "Nome" Then
Fila_Espera.setNome(Text)
End If
If Name = "Telefone" Then
Fila_Espera.setTelefone(Text)
End If
If Name = "SMS" Then
Fila_Espera.setSMS(Text)
End If
If Name = "SMS_Qtd" Then
Fila_Espera.setSMS_Qtd(Text)
End If
If Name = "Check_In" Then
cData = Text.ToString.SubString2(8,10) & "/" & Text.ToString.SubString2(5,7) & "/" & Text.ToString.SubString2(0,4)
cHora = Text.ToString.SubString2(11,19)
Try
Fila_Espera.setCheck_In(DateTime.DateTimeParse(cData,cHora))
Catch
Fila_Espera.setCheck_In(-1)
End Try
End If
If Name = "ID_Reservas" Then
Fila_Espera.setID_Reservas(Text)
End If
If Name = "Liberado" Then
Fila_Espera.setLiberado(Text)
End If
If Name = "Desistiu" Then
Fila_Espera.setDesistiu(Text)
End If
If Name = "Table" Then
If MaxFila_Espera <= 999 Then
MaxFila_Espera = MaxFila_Espera + 1
lFila_Espera(MaxFila_Espera).Assign(Fila_Espera)
End If
End If
If Name = "DataSet" Then
Atualiza_Fila_Espera
If lConfirma_Reserva = True Then
Envia_SMS_Confirmacao
End If
If nPosicao_Desistir_Fila <> -1 Then
'Envio do SMS (adiciona na fila de envio)
msg = SmartConfig.getMsg_Desistir().Replace("<#nome>", lFila_Espera(nPosicao_Desistir_Fila).getNome).Replace("<#pos>", lFila_Espera(nPosicao_Desistir_Fila).getPosicao)
Add_SMS_Fila( lFila_Espera(nPosicao_Desistir_Fila).getTelefone, msg & CRLF & " " & CRLF & _
SmartConfig.getMsg_Promocional )
End If
GridFila_Espera_Select
lConfirma_Reserva = False
End If
End Sub
JobDone
B4X:
'#########################################################################################################
'# HTTPJOB JobDone #
'#########################################################################################################
Sub JobDone (Job As HttpJob)
Dim In As InputStream
Dim result As String
ProgressDialogHide
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
result = Job.GetString 'Convert the response to a string
Select Job.JobName
Case "Reserva"
'print the result to the logs
'Log(result)
'Msgbox(result,"Reserva")
If File.Exists(File.DirDefaultExternal,"Reserva.xml") = True Then
File.Delete(File.DirDefaultExternal,"Reserva.xml")
End If
File.WriteString(File.DirDefaultExternal,"Reserva.xml",result)
parserReserva.Initialize
'parse the xml file
In = File.OpenInput(File.DirDefaultExternal, "Reserva.xml")
parserReserva.parse(In, "parserReserva")
In.Close
File.Delete(File.DirDefaultExternal, "Reserva.xml")
Case "Fila_Espera"
'print the result to the logs
'Log(result)
'Msgbox(result,"Fila_Espera")
If File.Exists(File.DirDefaultExternal,"Fila_Espera.xml") = True Then
File.Delete(File.DirDefaultExternal,"Fila_Espera.xml")
End If
File.WriteString(File.DirDefaultExternal,"Fila_Espera.xml",result)
parserFila_Espera.Initialize
'parse the xml file
In = File.OpenInput(File.DirDefaultExternal, "Fila_Espera.xml")
parserFila_Espera.parse(In, "parserFila_Espera")
In.Close
File.Delete(File.DirDefaultExternal, "Fila_Espera.xml")
Case "SmartConfig"
'print the result to the logs
'Log(result)
'Msgbox(result,"SmartConfig")
If File.Exists(File.DirDefaultExternal,"SmartConfig.xml") = True Then
File.Delete(File.DirDefaultExternal,"SmartConfig.xml")
End If
File.WriteString(File.DirDefaultExternal,"SmartConfig.xml",result)
parserSmartConfig.Initialize
'parse the xml file
In = File.OpenInput(File.DirDefaultExternal, "SmartConfig.xml")
parserSmartConfig.parse(In, "parserSmartConfig")
In.Close
File.Delete(File.DirDefaultExternal, "SmartConfig.xml")
Case "ApagarReserva"
Retorna_Reservas_WS
Case "ConfirmarReserva"
lConfirma_Reserva = True
Atualizar_Posicao_Fila_Espera_WS
Case "Atualizar_Posicao"
Retorna_Reservas_WS
Retorna_Fila_Espera_WS
Case "CheckIn_Fila"
Atualizar_Posicao_Fila_Espera_WS
Case "Desistir_Fila"
Atualizar_Posicao_Fila_Espera_WS
Case "Chamar_Fila"
Atualizar_Posicao_Fila_Espera_WS
nPosicao_Desistir_Fila = -1
End Select
Else
Select Job.JobName
Case "Fila_Espera"
lConfirma_Reserva = False
Case "ConfirmarReserva"
lConfirma_Reserva = False
Case "Desistir_Fila"
nPosicao_Desistir_Fila = -1
End Select
Log("Erro: " & Job.ErrorMessage)
ToastMessageShow("Erro: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Confirmation by sending SMS (add a table to track the shipment)
B4X:
Sub Envia_SMS_Confirmacao
Dim msg As String
Dim nFila_Espera_Ant As Int
For x = 0 To MaxFila_Espera
If lFila_Espera(x).getPosicao <> 0 _
AND lFila_Espera(x).getLiberado = "S" _
AND lFila_Espera(x).getSms = "S" _
AND lFila_Espera(x).getSMS_Qtd = 0 _
AND lFila_Espera(x).getCheck_In = (-1) Then
'Envio do SMS Boas Vindas (adiciona na fila de envio)
msg = SmartConfig.getMsg_BoasVindas().Replace("<#nome>", lFila_Espera(x).getNome).Replace("<#pos>", lFila_Espera(x).getPosicao)
Add_SMS_Fila( lFila_Espera(x).getTelefone, msg & CRLF & " " & CRLF & SmartConfig.getMsg_Promocional )
'Envio do SMS Instruções (adiciona na fila de envio)
msg = SmartConfig.getMsg_Instrucao().Replace("<#nome>", lFila_Espera(x).getNome).Replace("<#pos>", lFila_Espera(x).getPosicao)
Add_SMS_Fila( lFila_Espera(x).getTelefone, msg & CRLF & " " & CRLF & SmartConfig.getMsg_Promocional )
'Atualiza Chamadas
nFila_Espera_Ant = nFila_Espera
nFila_Espera = x
Chamar_Fila_WS
nFila_Espera = nFila_Espera_Ant
End If
Next
End Sub
What can be done to eliminate this error?