Private Sub OutFTP(o() As Object)As ResumableSub
Dim lg As List
lg.Initialize
DateTime.DateFormat = "yyyyMMdd"
DateTime.TimeFormat = "HHmmdd"
Dim lgl As List
lgl.Initialize
pbRow = o(12)
pbRow.Progress = 0
Dim la As Label = o(13)
' scelta file da uploadare
Dim l As List = File.ListFiles(o(20))
If l.IsInitialized Then
Dim ff As List
ff.Initialize
' selezione dei files da inviare
For i = 0 To l.size-1
Dim s As String = l.Get(i)
Dim ss As String = s.ToUpperCase
If File.IsDirectory(o(20),s) Then Continue
' contiene il cliente
If o(2) <> "" Then
If s.Contains(o(2)) Or ss.Contains(o(2)) Then
' contiene il nome file
If o(3) <> "" Then
If s.Contains(o(3)) Or ss.Contains(o(3)) Then
ff.Add(s)
End If
Else
' se non ho il nome del file ma c'è il cliente spedisco tutto al cliente
ff.Add(s)
End If
End If
Else
' contiene il nome file
If o(3) <> "" Then
If s.Contains(o(3)) Or ss.Contains(o(3)) Then
ff.Add(s)
End If
Else
' se non contiene il nome del file e nemmeno il nome del cliente invio tutto
' perchè spero sia una cartella esclusiva del cliente
ff.Add(s)
End If
End If
Next
If ff.Size = 0 Then
pbRow.Progress = 1
la.Text = "Nessun file trovato."
Globals.SetNodeImage(la,File.DirAssets,"warning.png",16,16,"LEFT")
o(13) = la
lg.add(MakeLogMap("W",la.Text,o(2),o(3),o(28)))
Else
' devo zippare il file
If Globals.IntegerToBoolean(o(27)) Then
Globals.Zippo(o(20),ff,o(3)&".zip")
End If
' se ho richiesto la storicizzazione e lo zip
If Globals.IntegerToBoolean(o(27)) Then
If o(19) <> "" Then
Dim hpath As String = o(19)&GetSystemProperty("file.separator","NF")&o(2)&GetSystemProperty("file.separator","NF")&o(3)
File.MakeDir(o(20),hpath)
End If
For i = ff.Size-1 To 0 Step-1
Dim nf As String = ff.Get(i)
File.Copy(o(20),nf,o(20)&GetSystemProperty("file.separator","NF")&hpath,nf&"_"&DateTime.Date(DateTime.Now)&DateTime.Time(DateTime.Now))
File.Delete(o(20),nf)
ff.RemoveAt(i)
Next
ff.Initialize
ff.Add(o(3)&".zip")
End If
' richiesta fotografie
If Globals.IntegerToBoolean(o(29)) Then
' crea le foto del cliente o(2) cercandole nel path o(30) nel percorso locale o(19)
Dim photofile As String = Globals.AddPhoto(o(2),o(30),o(20))
If File.Exists(o(20),photofile) Then
ff.Add(photofile)
End If
End If
' invio i file in lista
Dim mftp As tmFTP
' inizilizzo
mftp.Initialize(o(22),o(23),o(24),o(25))
For n = 0 To ff.Size-1
Dim nf As String = ff.Get(n)
pbRow.Id = File.Size(o(20),nf)
mftp.FTPUpload(o(20),nf,o(21)&nf,pbRow)
wait for mftpupload_completed(success As String)
If success <> "" Then
la.Text = success
Globals.SetNodeImage(la,File.DirAssets,"cancel.png",16,16,"LEFT")
o(13) = la
lg.Add(MakeLogMap("E",la.Text,o(2),o(3),o(28)))
Else
la.Text = "Inviato con successo il file "&nf&"."
Globals.SetNodeImage(la,File.DirAssets,"accept.png",16,16,"LEFT")
o(13) = la
lg.Add(MakeLogMap("O",la.Text,o(2),o(3),o(28)))
End If
Next
mftp.Close
' se tutto ok passo alle opzioni successive
For n = ff.Size-1 To 0 Step-1
' devo storicizzare
If o(19) <> "" And Globals.IntegerToBoolean(o(27)) = False Then
Dim hpath As String = o(19)&GetSystemProperty("file.separator","NF")&o(2)&GetSystemProperty("file.separator","NF")&o(3)
File.MakeDir(o(20),hpath)
Dim nf As String = ff.Get(n)
File.Copy(o(20),nf,o(20)&GetSystemProperty("file.separator","NF")&hpath,nf&"_"&DateTime.Date(DateTime.Now)&DateTime.Time(DateTime.Now))
End If
' cancello
File.Delete(o(20),nf)
ff.RemoveAt(n)
Next
End If
Else
la.Text = "Path locale non accessibile."
Globals.SetNodeImage(la,File.DirAssets,"cancel.png",16,16,"LEFT")
o(13) = la
pbRow.Progress = 1
lg.Add(MakeLogMap("E",la.Text,o(2),o(3),o(28)))
End If
WriteLogs(lg)
Return True
End Sub