Hi, how do I add a HttpJob or name to a Job, then call them on the JobDone?
Ex:
I have 2 commands, one to insert and one to consult. One uses ExecuteQuery and another uses ExecuteBatch, as I give them a name and then call them on the JobDone?
Ex:
B4X:
Sub button1_Click
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "select_animal"
reqManager.ExecuteQuery(cmd, 0, Null)
End Sub
Sub Button2_Click
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = "insert_animal"
cmd.Parameters = Array As Object("1","imagen", reqManager.FileToBytes(File.DirAssets, "icon.png"))
reqManager.ExecuteBatch(Array(cmd), Null)
End Sub
B4X:
Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
Dim ser As B4XSerializator
Dim data() As Byte = ser.ConvertObjectToBytes(CreateMap("command": Command, "limit": Limit, "version": VERSION))
SendJob(data, Tag, "query2")
End Sub
Private Sub SendJob(Data() As Byte, Tag As Object, Method As String)
Dim j As HttpJob
j.Initialize("DBRequest", mTarget)
j.Tag = Tag
j.PostBytes(link & "?method=" & Method , Data)
Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object)
Dim ser As B4XSerializator
ser.Tag = Tag
ser.ConvertObjectToBytesAsync(CreateMap("commands": ListOfCommands, "version": VERSION), "ser")
End Sub
B4X:
Sub JobDone(Job As HttpJob)
If Job.Success = False Then
Log("Error: " & Job.ErrorMessage)
Else
Dim result As DBResult = reqManager.HandleJob(Job)
Select Job.JobName
Case case1
Case case2
End Select
End If
Job.Release
End Sub
I have 2 commands, one to insert and one to consult. One uses ExecuteQuery and another uses ExecuteBatch, as I give them a name and then call them on the JobDone?