Sub GetPic
Try
' Dim req As DBRequestManager = req.Initialize(Me, $"http://${IPAddre.Text}:17178/rdcx"$)
' Dim cmd As DBCommand = CreateCommand("GetEmployees", Array())
Dim FN As String = ""
Dim FDir As String = ""
Dim H As HttpJob
H.Initialize("H", Me)
'Sleep(10)
Dim XXX As Int
#IF B4A
Dim B As Bitmap
B.InitializeMutable(TravPic.mBase.Width, TravPic.mBase.Height)
TravPic.Bitmap = B
#ELSE
' Dim C As Canvas
' C.Initialize("")
' Dim FX As JFX
' C.ClearRect(0, 0, 1000, 1000)
' C.DrawLine(0, 0, 8, 8, FX.Colors.Black , 5)
' TravPic.Bitmap = C.Snapshot
#END IF
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("PMPicTest", Array())
TextArea1.Text = "Getting 5 pictures"
Sleep(100)
Wait For (req.ExecuteQuery(cmd, 0, "")) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j, "req")
Wait For (req) req_Result(res As DBResult)
For Each row() As String In res.Rows
TextArea1.Text = $"${TextArea1.Text}
${row(0)}
"$
#IF B4J
FN = File.GetName(row(0))
FDir = File.GetFileParent(row(0))
If File.Exists(FDir, FN) Then
XXX = XXX+ 1
Wait For(GetPicFromServer(FN, FDir)) Complete(R As Boolean)
TextArea1.Text = TextArea1.Text & CRLF & "Wait 1 Second"
Sleep(1000)
If XXX > 5 Then Exit
End If
#ELSE
Dim FDir As String = row(0).SubString2(0, row(0).LastIndexOf("\"))
Dim FN As String = row(0).SubString(row(0).LastIndexOf("\") + 1)
XXX = XXX+ 1
Wait For(GetPicFromServer(FN, FDir)) Complete(R As Boolean)
TextArea1.Text = TextArea1.Text & CRLF & "Wait 1 Second"
Sleep(1000)
If XXX > 5 Then Exit
#END IF
Next
Else
Log("ERROR: " & j.ErrorMessage)
TextArea1.Text = TextArea1.Text & CRLF & j.ErrorMessage
End If
j.Release
Catch
Log(LastException)
End Try
End Sub
Sub GetPicFromServer(FN As String, FDir As String) As ResumableSub
Dim H As HttpJob
H.Initialize("H", Me)
Dim T As Long = DateTime.Now
H.Download2($"http://${IPAddre.Text}:17178/getfile"$, Array As String("FileName", FDir & "\" & FN, "Dir", FDir))
Wait For (H) JobDone(j As HttpJob)
If j.Success Then
TextArea1.Text = TextArea1.Text & "Got Picture in " & ((DateTime.Now - T) / 1000) & " Seconds."
If j.GetString2("UTF8").SubString2(0, 6).EqualsIgnoreCase("Failed") Then
TextArea1.Text = $"Couldn't find ${FDir}\${FN}"$
Else
T = DateTime.Now
TravPic.Bitmap = j.GetBitmap
TravPic.ResizeMode = "FIT"
TextArea1.Text = TextArea1.Text & CRLF & "Load Picture in " & ((DateTime.Now - T) / 1000) & " Seconds."
End If
End If
j.Release
Return True
End Sub