private Sub DownloadPhotoHTTP()
Try
Dim J As HttpJob
Dim URL As String
Dim F As Boolean,FL As Boolean
Dim S As Int,FS As Int
Dim MySQL As String
Dim Cursor1 As Cursor
Dim Res As Boolean
Dim Photo As String
Dim Logo As String
MySQL="select FacilityID,FacilityName,ProviderID,UserID,ProviderPhoto,ProviderName,Address,City,State,Zip,Phone,Logo from tblFacility order by FacilityName"
Cursor1=SQL1.ExecQuery(MySQL)
For i=0 To Cursor1.RowCount-1
Cursor1.Position=i
Photo=Cursor1.GetString("ProviderPhoto")
If Photo="" Then
Continue
End If
F=File.Exists(Main.filedir, Photo)
S=File.Size(Main.filedir, Photo)
If F = False Or s=0 Then
URL= "http://www.servername.com/"& Photo
j.Initialize("", Me)
j.Download(URL)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(Main.FileDir, Photo, False)
File.Copy2(j.GetInputStream, out)
out.Close '<------ very important
Log("Photo " & Photo & " downloaded Ok")
Main.TestRet=True
Else
modFun.ShowError("clsRefreshResume_HTTP Download error " & CRLF & "Try again later with better connection and check if photo exists on a provider profile.")
Main.TestRet=False
End If
j.Release
End If
Next
i=0
For i=0 To Cursor1.RowCount-1
Cursor1.Position=i
Logo=Cursor1.GetString("Logo")
If Logo="" Then
Continue
End If
FL=File.Exists(Main.filedir, Logo)
FS=File.Size(Main.filedir, Logo)
If FL = False Or FS=0 Then
URL= modFun.URLImage & Logo
j.Initialize("", Me)
j.Download(URL)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(Main.FileDir, Logo, False)
File.Copy2(j.GetInputStream, out)
out.Close '<------ very important
Log("Logo " & Logo & " downloaded Ok")
Main.TestRet=True
Else
modFun.ShowError("clsRefreshResume_HTTP Download error. Try again later with better connection. Also check if the profile has a photo.")
Main.TestRet=False
End If
j.Release
End If
Next
Cursor1.Close
Log("DownloadPhotoHTTP " & Main.TestRet)
CallSubDelayed(Me,"DownloadPhotoHTTP_Complete")
Catch
Log("DownloadPhotoHTTP " & LastException)
modFun.ShowError("clsRefreshResume_DownloadPhotoHTTP " & LastException)
Main.TestRet=False
End Try
End Sub