lecojales Posted November 13, 2012 Report Share Posted November 13, 2012 Olá pessol, tenho uma pequena aplicação feita com fiveppc, e estou tentando migrar ela para fivewin versão free. Está com vários erros ao compilar, e boa parte deles é na rotinas que faz acesso ao ftp, no pocket roda redondinho, como fazer isso funcionar em windows //Inicio da Conexão hGprs:= GPRSCONNECT() hInternet := InternetOpen( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 ) IF hINTERNET = 0 *** desconectando GPRSRELEASE(hGprs) MSGINFO("Erro na conexão com a internet!") RETURN NIL ENDIF hCon = INTERNETCONNECT( hInternet, "189.189.189.189",0, "usuario_ftp","senha_ftp", INTERNET_SERVICE_FTP, 0,0 ) IF HCON = 0 *** desconectando GPRSRELEASE(hGprs) MSGSTOP("Erro na conexão FTP !") RETURN NIL ENDIF //TRANSMITIR PARA FTP if !FTPPUTFILE( hCon, CurDir()+"\setmp.dbf", varqped, 0, 0 ) MsgInfo("Problemas no envio do Pedido!!!") endif endif //BUSCAR DO FTP If !FTPGETFILE( hCon, varqpro1,varqpro2, 0, 0 ) else // apaga do ftp FtpDeleteFile(hCon,varqpro1) Endif INTERNETCLOSEHANDLE( hCon ) INTERNETCLOSEHANDLE( hInternet ) GPRSRELEASE(hGprs) /// termino da conexão id=code>id=code> Leco Jales FiveWin for xHarbour 6.12 - December 2006 Five PPC Harbour 1.0.1 - 1999-2008 Editado por - lecojales on 13/11/2012 22:23:01 Quote Link to comment Share on other sites More sharing options...
lecojales Posted November 13, 2012 Author Report Share Posted November 13, 2012 Olá pessol, tenho uma pequena aplicação feita com fiveppc, e estou tentando migrar ela para fivewin versão free. Está com vários erros ao compilar, e boa parte deles é na rotinas que faz acesso ao ftp, no pocket roda redondinho, como fazer isso funcionar em windows //Inicio da Conexão hGprs:= GPRSCONNECT() hInternet := InternetOpen( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 ) IF hINTERNET = 0 *** desconectando GPRSRELEASE(hGprs) MSGINFO("Erro na conexão com a internet!") RETURN NIL ENDIF hCon = INTERNETCONNECT( hInternet, "189.189.189.189",0, "usuario_ftp","senha_ftp", INTERNET_SERVICE_FTP, 0,0 ) IF HCON = 0 *** desconectando GPRSRELEASE(hGprs) MSGSTOP("Erro na conexão FTP !") RETURN NIL ENDIF //TRANSMITIR PARA FTP if !FTPPUTFILE( hCon, CurDir()+"\setmp.dbf", varqped, 0, 0 ) MsgInfo("Problemas no envio do Pedido!!!") endif endif //BUSCAR DO FTP If !FTPGETFILE( hCon, varqpro1,varqpro2, 0, 0 ) else // apaga do ftp FtpDeleteFile(hCon,varqpro1) Endif INTERNETCLOSEHANDLE( hCon ) INTERNETCLOSEHANDLE( hInternet ) GPRSRELEASE(hGprs) /// termino da conexão id=code>id=code> Leco Jales FiveWin for xHarbour 6.12 - December 2006 Five PPC Harbour 1.0.1 - 1999-2008 Editado por - lecojales on 13/11/2012 22:23:01 Quote Link to comment Share on other sites More sharing options...
atnsoft Posted November 14, 2012 Report Share Posted November 14, 2012 eu uso o FTPSendFiles( VnFtp, { (cPasta)+"\"+Lletil+"TRANSP.TRC" }, { cRecebeFtp }, VuFtp, VsFtp ) para enviar e FTPGetFiles( PnFtp, { cDirArq+lLetil+"*.Trc"}, { lLetil+"*.Trc" }, PuFtp, PsFtp, " ", "R") para pegar os arquivos Mais exemplos em FWH\SAMPLES\GALLERY\ICOPYFIL\ICOPYFIL.PRG AtnSoft(Antenor Rabello) - xHarbour 0.99.71 / FwH 7.05 / Verce C. Procópio - PR Quote Link to comment Share on other sites More sharing options...
sistem Posted November 15, 2012 Report Share Posted November 15, 2012 atnsoft RECEBER ARQUIVO Function recebeTxt() local oInternet := TInternet():New() local oFTP := TFTP():New( Alltrim(oApp:FtpServ), oInternet, Alltrim(oApp:FtpUsua), Alltrim(oApp:FtpSenh)) local aFiles, cDirName := Alltrim(oApp:FtpPath)+"/sendsmart/", aTarget:={}, aSource:={} If !Empty( oFTP:hFTP ) aFiles = oFTP:Directory( cDirName+"p?????????.*" ) If Empty(aFiles) MsgAlert( "Nenhum arquivo encontrado.", "Alerta!" ) Return nil Endif For nCount = 1 TO Len(aFiles) aAdd( aSource, Alltrim(oApp:FtpPath)+"/sendsmart/"+Alltrim(aFiles[nCount,1]) ) aAdd( aTarget, oApp:cDir_001+Alltrim(aFiles[nCount,1]) ) Next FtpGetFiles( aSource, aTarget, oFTP) Else MsgAlert( "Falha no Ftp.", "Alerta!" ) Return nil Endif *----------------------------------------- Function FtpGetFiles( aSource, aTarget, oFTP ) Local nBufSize:=4096, n, hTarget, cBuffer, nBytes, oFile, aFiles, aSizes:={} cBuffer:=Space( nBufSize ) For n = 1 to Len( aSource ) aFiles = oFTP:Directory( aSource[ n ] ) If Len( aFiles ) > 0 AAdd( aSizes, aFiles[ 1 ][ 2 ] ) Else AAdd( aSizes, 0 ) Endif Next For n = 1 to Len( aSource ) hTarget = FCreate( aTarget[ n ] ) oFile = TFtpFile():New( aSource[ n ], oFTP ) oFile:OpenRead() Do while ( nBytes := Len( cBuffer := oFile:Read( nBufSize ) ) ) > 0 FWrite( hTarget, cBuffer, nBytes ) Enddo FClose( hTarget ) oFtp:Deletefile(oFile:cFilename) oFile:End() Next Return nil id=code>id=code>ENVIAR ARQUIVO aFiles := Directory(oApp:cDir_Sit+"????"+cCod_Vend+".txt")// para todos arq.do diretorio ex: c:\arq If Empty(aFiles) MsgAlert( "Nenhum arquivo encontrado.", "Alerta!" ) Return nil Endif For nCount = 1 TO Len(aFiles) aAdd( aSource, oApp:cDir_Sit+Alltrim(aFiles[nCount,1]) ) aAdd( aTarget, Alltrim(oApp:FtpPath)+"/sendsistem/"+Alltrim(aFiles[nCount,1]) ) Next oInternet := TInternet():New() oFTP := TFTP():New( Alltrim(oApp:FtpServ), oInternet, Alltrim(oApp:FtpUsua), Alltrim(oApp:FtpSenh) ) If Empty( oFTP:hFTP ) MsgStop( "Não foi possivel conectar com FTP", "Aviso!" ) Return nil Endif FtpSendFiles( aSource, aTarget, oFTP ) oInternet:End() oFtp:End() *--------------------------------------------- Static Function FtpSendFiles( aSource, aTarget, oFTP ) Local n, hSource, cBuffer, nBufSize:=2000, nBytes, nFile:=0, oFile cBuffer=Space(nBufSize) For n = 1 to Len( aSource ) If !File( aSource[ n ] ) MsgStop( "Archivo No Encontrado: " + aSource[ n ] ) exit Endif hSource = FOpen( aSource[ n ] ) FClose( hSource ) next For n = 1 to Len( aSource ) hSource = FOpen( aSource[ n ] ) oFile = TFtpFile():New( aTarget[ n ], oFTP ) oFile:OpenWrite() FSeek( hSource, 0, 0 ) nFile := 0 do while ( nBytes := FRead( hSource, @cBuffer, nBufSize ) ) > 0 oFile:Write( SubStr( cBuffer, 1, nBytes ) ) enddo FClose( hSource ) oFile:End() Next Return nil id=code>id=code>Editado por - sistem on 15/11/2012 23:45:24 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.