public Sub UploadMedia
Try
Dim MySQL As String
Dim Cursor1 As Cursor
Dim Qty As Int
Dim IsFTPOk As Boolean
MySQL="select ID, FileName from tblNotesMediaFiles "
MySQL= MySQL & "where PlacementLocalID=? And PlacementID=? And JobDate=? And Shift=? And ifnull(FTPDate,'1/1/1900')='1/1/1900'"
FileName=""
Cursor1=SQL1.ExecQuery2(MySQL,Array As String(Main.SelectedPlacementLocalID, Main.SelectedPlacementID, Main.SelectedDOS,Main.SelectedShift))
Qty=Cursor1.RowCount
Dim files As List,Records As List
Dim job As HttpJob
files.Initialize
Records.Initialize
For i =0 To Qty-1
Cursor1.Position=i
FileName=Cursor1.GetString("FileName")
If FileName<>"" Then
If File.Exists(Starter.FileDir,FileName) Then
RecordID=Cursor1.GetInt("ID")
Records.Add(RecordID)
Dim fd As MultipartFileData
fd.Initialize
If FileName.Contains("jpg") Then
fd.KeyName = "imagejpg"
fd.ContentType = "image/jpg"
Else
fd.KeyName = "audiowav"
fd.ContentType = "audio/wav"
End If
fd.FileName = FileName
fd.Dir = Starter.FileDir
files.Add(fd)
End If
End If
Next
Cursor1.Close
If files.Size>0 Then
For j=0 To files.Size-1
Dim CurrentFile As List,CurrentRecord As List
CurrentFile.Initialize
CurrentRecord.Initialize
CurrentFile.Add(files.Get(j))
CurrentRecord.Add(Records.Get(j))
Dim job As HttpJob
job.Initialize("Upload",Me)
job.PostMultipart(modFun.URL ,CreateMap("action":"upload", "Ticket":Main.Ticket,"RegKey":Main.RegKey,"WhatToDo":"receivefiles"),CurrentFile)
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
Dim response As String
response=job.GetString
Log("File was uploaded successfully " & job.GetString )
If IsFTPOk=False Then
modFun.ShowError("clsRefreshJobs_File upload has failed " & response & CRLF & modFun.NoConnection(Main.SQL1))
End If
Else
modFun.ShowError("clsRefreshJobs_HTTP Upload error " & LastException.Message & CRLF & modFun.NoConnection(Main.SQL1))
IsFTPOk=False
End If
job.Release
Next
End If
If IsFTPOk=False Then
Main.TestRet=False
End If
CallSubDelayed(Me,"UploadMedia_Complete")
Catch
ProgressDialogHide
Log("UploadMedia " & LastException.Message)
End Try
End Sub