I have this code that send all the selected records to a REST server:
I tested and works, but I don't know if is the best way to send records in batch.
Any advices are welcome.
B4X:
Dim lst As List = GetSelectedIDs 'insert in the list all the selected id's
For i = 0 To lst.Size - 1
Dim m As Map
m = DBUtils.ExecuteMap(Starter.SQL1, "SELECT name, city FROM profile WHERE id = " & lst.Get(i), Null)
If (m <> Null) And (m.IsInitialized = True) Then
Dim j As HttpJob
j.Initialize("", Me)
Dim objMap As Map: objMap.Initialize
objMap.Put("name", m.Get("name"))
objMap.Put("city", m.Get("city"))
Dim objJSon As JSONGenerator: objJSon.Initialize(objMap)
j.PostBytes("http://" & ip & ":8080/InsertRecord", objJSon.ToString.GetBytes("ISO-8859-1"))
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
ToastMessageShow(m.Get("name") & " sended with success", False)
End If
j.Release
End If
Next
I tested and works, but I don't know if is the best way to send records in batch.
Any advices are welcome.