Dim ssql As SQL
Dim hc As OkHttpClient
Dim req As OkHttpRequest
Dim Query As String
'-----------------------
hc.InitializeAcceptAll("hc")
'-----------------------
Query="SELECT idLot, nlote FROM lotes"
req.InitializePost2("http://200.234.54.12/mysql/datos.php", Query.GetBytes("UTF8"))
hc.Execute(req, 1) '--> tarea = 1
'-----------------------
Sub hc_ResponseSuccess (Response As OkHttpResponse, tarea As Int) 'TaskId
Dim res As String
Dim cant, idact As Int ', tarea
out.InitializeToBytesArray(0)
'Log("tarea:" & tarea)
'res = Response.GetString("UTF8")
Response.GetAsynchronously("res", out, False, tarea)
res = BytesToString(out.ToBytesArray, 0, out.ToBytesArray.Length, "utf8")
Log(res)
If tarea = 1 Then
Try
Dim jsonp As JSONParser
jsonp.Initialize(res)
Dim l As List
l.Initialize
l = jsonp.NextArray
If l.Size > 0 Then
Dim m As Map
Dim k As Int
Dim t As String
For i = 0 To l.Size - 1
m = l.Get(i)
k = i+1
t = m.Get("idLot") &" - "& m.Get("nlote")
ssql.ExecNonQuery("INSERT OR IGNORE INTO Combos (key,id,value) VALUES ("& k &",'LOTE','"& t &"')")
Next
Msgbox("Lotes actualizados, reinicie...", "Atención")
Else
Msgbox("Se presento un error, repita el proceso...", "Error")
End If
Catch
Msgbox("Se presento un error, repita el proceso...", "Error")
End Try
End If
Response.Release
End Sub