Public Sub SMB_TRASMETTI As ResumableSub
Dim cFileTrasf As String
Dim cPathFileOut As String
Dim credentials As SMBCred
credentials.Initialize
credentials.Domain = ""
credentials.Username =B4XPages.MainPage.MappaParametri.Get("USERSMB")
credentials.Password =B4XPages.MainPage.MappaParametri.Get("PSWSMB")
cFileTrasf=Nomefile
cPathFileOut=File.DirDefaultExternal
' cPathFileOut=File.DirDefaultExternal ' & "/download/"
' cPathOut= "ORDINE.OUT"
AttesaShow("Trasferimento ... ",$"Attendere ${CRLF}${Modo} ${Nomefile} ${CRLF} SMB://${B4XPages.MainPage.MappaParametri.Get("SERVERSMB")}"$)
Try
If Modo.ToUpperCase="INVIA" Then ' questo e' ok
credentials.Share = "smb://" & B4XPages.MainPage.MappaParametri.Get("SERVERSMB") & B4XPages.MainPage.MappaParametri.Get("PTHDATIOUTSMB") ' & "/" & "c-drive/FTP/"
smbClient.Initialize("smbClient_Copy", credentials.Domain, credentials.Username,credentials.Password, credentials.Share)
Wait For smbClient_Copy_Resource(success As Boolean, smbobjres As Object,smbobj As Object, info As String)
If success = False Then
AttesaHide
Return False
End If
If smbobjres <> Null And smbobj <> Null And info = "OK" Then
Dim smbResource As SMBResource = smbobjres
smbClient.Copy2(cPathFileOut,cFileTrasf,smbResource, cFileTrasf)
'Wait For smbclient_copy_copyresult(success As Boolean, path As String, filename As String)
Wait For smbClient_Copy_Copy2Result(success As Boolean, path As String, filename As String)
If success = False Then
'bB = False
Log("ERRORE COPIA")
Else
Log("copia ok")
End If
Sleep(0)
End If
Else 'RICEVI non va
' PTHDATIINSMB
credentials.Share = "smb://" & B4XPages.MainPage.MappaParametri.Get("SERVERSMB") & B4XPages.MainPage.MappaParametri.Get("PTHDATIOUTSMB")
smbClient.Initialize("smbClient_Copy", credentials.Domain, credentials.Username,credentials.Password, credentials.Share)
Wait For smbClient_Copy_Resource(success As Boolean, smbobjres As Object,smbobj As Object, info As String)
If smbobjres <> Null And smbobj <> Null And info = "OK" Then
Dim smbResource As SMBResource = smbobjres
' smbClient.Copy2(cPathFileOut,cFileTrasf,smbResource, cFileTrasf)
'provato anche cosi
'smbClient.copy(cPathFileOut,cFileTrasf,smbResource, cFileTrasf)
' e cosi
smbClient.copy(cFileTrasf,smbResource,cPathFileOut, cFileTrasf)
Wait For smbClient_Copy_CopyResult(success As Boolean, path As String, filename As String)
'Wait For smbClient_Copy_Copy2Result(success As Boolean, path As String, filename As String)
If success = False Then
'bB = False
Log("ERRORE COPIA")
Else
Log("copia ok")
End If
Sleep(0)
End If
End If
Catch
AttesaHide
Return False
End Try
AttesaHide
Return success