Android Question FTP issues.

Jairo Lizotti

Member
Licensed User
Longtime User
I'm having a recent problem that's giving me a headache and I can not figure it out,what the hell is going on, I beg your help for your kindness the problem is that when my b4aAPP (sales force) sends requests, some arrive to the FTP folder, and others do not arrive. but the sent parameter that I have in the system shows as sent. any idea what might be happening?
 

Jairo Lizotti

Member
Licensed User
Longtime User
Here is the revelent sub, sometimes upload, sometimes not....


I was reviewing my lybraries and found the Net library in V1.20, in the forum I found a recent version 1.80 maybe that is causing the problem? what do you think? I will do some tests with the new version of the library!


B4X:
Sub UploadPedidos
    Dim curP As Cursor
    Dim i As Int
    Dim nped As String

    myFTP2.Initialize("myFTP2", General.FtpEndereco, 21, General.FtpUsuario, General.FtpSenha)
    myFTP2.PassiveMode = True
    If myFTP2.IsInitialized Then
            NaoGeraNovoLote = False
            curP = QueryMain.ExecQuery("SELECT ID, case when bkl then 'true' else 'false' end as BKL, enviado FROM PEDIDOS WHERE enviado<>1 and lote is null")
            If curP.RowCount > 0 Then
                FtpTrace = 0
                FinalTrace = curP.RowCount
'                ProgressDialogShow("Enviando Pedidos...")
            
                If Not (NaoGeraNovoLote) Then
                    Dim ultimoLote As Int = General.ObterUltimoLote
                    QueryMain.ExecNonQuery2("INSERT INTO LOTES (ID) VALUES (?)",Array As String(ultimoLote))
                End If
                For i = 0 To curP.RowCount -1
                    curP.Position = i
                    nped = "ped" & "_" &Login_edtUsuario.text&"_"& curP.GetString("ID") & ".xml"
                    If (Not (File.Exists(File.DirDefaultExternal, nped))) Then
                        General.GravarPedido (curP.GetString("ID"), curP.GetString("BKL"))
                    End If
                    If IsConnected=True Then
                        myFTP2.UploadFileResume(File.DirDefaultExternal, nped, False, General.FtpPastaUploadUsuario & "/" & nped, 0)
                        QueryMain.ExecNonQuery2("UPDATE PEDIDOS SET ENVIADO = 1, ENVIADO_QUANDO = ?, ENVIADO_STATUS='OK', LOTE = ? WHERE LOTE IS NULL",Array As String(DateTime.Date(DateTime.Now),ultimoLote))
'                     
                    Else
                        QueryMain.ExecNonQuery2("UPDATE PEDIDOS SET ENVIADO = 0, ENVIADO_QUANDO = ?, ENVIADO_STATUS='false', LOTE = ? WHERE LOTE IS NULL",Array As String(DateTime.Date(DateTime.Now),ultimoLote))
'                     
                    End If
                
                Next
            
                If IsConnected=True Then
                    Msgbox("PEDIDO(S) ENVIADO(S)","OBA")
                End If
            Else
                Msgbox ("Não existe nenhum pedido para enviar ou todos os pedidos já foram enviados", "")
            End If
            CardView_hoje
        End If
    End If
    curP.Close
    ''------------------------------------------------------------------------

End Sub
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Try to close the FTP connection after you finish your upload. Sometimes I've problems if I try to upload several times and there was an open connection.
Try to Log(LastException) in order to have more information

B4X:
Log("LastException FTP: " & LastException)
myFTP2.Close
 
Upvote 0

Jairo Lizotti

Member
Licensed User
Longtime User
before making this change, I am trying to check if with network 4g, with the update of the library, all are coming, if continue in the same I places this change and give a return. thank you

Try to close the FTP connection after you finish your upload. Sometimes I've problems if I try to upload several times and there was an open connection.
Try to Log(LastException) in order to have more information

B4X:
Log("LastException FTP: " & LastException)
myFTP2.Close
 
Upvote 0
Top