uso FileZilla Server a otro PC de la red local
- Code: Select all Expand view RUN
#include "FiveTouch.ch"
function Main()
LOCAL oDlg
LOCAL oBtnCon, oBtnPar, OBtnEnd
LOCAL cFile, cDir := "",;
xPath := HB_DIRBASE() + "SOLVING/"
cDir := xPath + "DATI"
cFile := cDir + "/_PAR_FTP.DBF"
* --- Verifica se Non Esiste la Directory
* viene creata
IF !lIsDir( cDir )
MakeDir( cDir )
ENDIF
* --- Crea File
Crea_Dbf( cFile )
CLOSE ALL
DEFINE DIALOG oDlg TITLE "FTP SAMPLE" ;
SIZE 300, 200
@ 010, 50 BUTTON oBtnCon PROMPT "Connetti" OF oDlg ;
ACTION Connetti( cFile, xPath )
@ 050, 50 BUTTON oBtnPar PROMPT "Parametri" OF oDlg ;
ACTION Parametri( cFile )
@ 090, 50 BUTTON oBtnEnd PROMPT "Abbandona" OF oDlg ;
ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
RETURN
// ----------------------- PARAMETRI
FUNCTION Parametri( cFile )
LOCAL oDlg
LOCAL oIp, cIp := SPACE(15) ,;
oPorta, cPorta := SPACE(6),;
oUser, cUser := SPACE(25) ,;
oPsw, cPsw := SPACE(10) ,;
oDirD, cDirD := SPACE(30)
LOCAL oBtnEnd, oBtnOk
* --- Apre File
USE( cFile ) ALIAS Dati NEW
* --- Leggo Dati da Dbf
Dati->( DBGOTOP() )
cIp := Dati->PAR_IP
cPorta := Dati->PAR_POR
cUser := Dati->PAR_USR
cPsw := Dati->PAR_PSW
cDirD := Dati->PAR_DIRD
DEFINE DIALOG oDlg TITLE "Paramatri FTP" ;
SIZE 300, 220
@ 180, 25 BUTTON oBtnEnd PROMPT "Abbandona" OF oDlg ;
ACTION oDlg:End()
@ 180, 150 BUTTON oBtnOk PROMPT "Conferma" OF oDlg ;
ACTION (Salva( cIp, cPorta, cUser, cPsw, cDirD ), oDlg:End())
@ 20, 020 SAY oSay PROMPT "Indirizzo IP" OF oDlg
@ 50, 020 SAY oSay PROMPT "Porta" OF oDlg
@ 80, 020 SAY oSay PROMPT "User" OF oDlg
@ 110,020 SAY oSay PROMPT "PassWord" OF oDlg
@ 140,020 SAY oSay PROMPT "Dir DownLoad" OF oDlg
@ 15, 090 GET oIp VAR cIp OF oDlg
oIp:setFixedSize(100,25)
oIp:setInputMask("000.000.000.000")
@ 45, 090 GET oPorta VAR cPorta OF oDlg
oPorta:setFixedSize(50,25)
oPorta:setInputMask("000000")
@ 75, 090 GET oUser VAR cUser OF oDlg
oUser:setFixedSize(160,25)
oUser:SetMaxLength(25)
@ 105, 090 GET oPsw VAR cPsw OF oDlg
oPsw:setFixedSize(100,25)
oPsw:SetMaxLength(10)
@ 135, 090 GET oDirD VAR cDirD OF oDlg
oDirD:setFixedSize(170,25)
oDirD:SetMaxLength(30)
oIp:setFocus()
ACTIVATE DIALOG oDlg CENTERED
Dati->( DBCLOSEAREA() )
RETURN NIL
// ------------------------------- SALVA
FUNCTION Salva( cIp,cPorta,cUser,cPsw,cDirD )
Dati->( DBGOTOP() )
Dati->PAR_IP := cIp
Dati->PAR_POR := cPorta
Dati->PAR_USR := cUser
Dati->PAR_PSW := cPsw
Dati->PAR_DIRD := cDirD
Dati->( DBCOMMIT() )
RETURN NIL
// ----------------------- CREA_DBF
FUNCTION Crea_Dbf( cFile )
LOCAL aDbf := {}
IF !FILE( cFile )
AADD(aDbf,{"PAR_IP", "C",15,0})
AADD(aDbf,{"PAR_POR", "C",6,0})
AADD(aDbf,{"PAR_USR", "C",25,0})
AADD(aDbf,{"PAR_PSW", "C",10,0})
AADD(aDbf,{"PAR_DIRD","C",30,0})
DBCREATE(cFile,aDbf)
* --- Crea 1 Record
USE( cFile ) ALIAS Dati NEW
Dati->( dbAppend() )
Dati->( DBCLOSEAREA() )
ENDIF
RETURN NIL
// ----------------------- CONNETTI
FUNCTION Connetti( cFile, xPath )
LOCAL cIp, cUser, cPsw, cPorta, cDirD
LOCAL oUrl, cUrl, oFtp
LOCAL aFiles := {}, i, c_Tx := ""
* --- Apre File
USE( cFile ) ALIAS Dati NEW
* --- Leggo Dati da Dbf
Dati->( DBGOTOP() )
cIp := Dati->PAR_IP
cPorta := ALLTRIM( Dati->PAR_POR )
cUser := ALLTRIM( Dati->PAR_USR )
cPsw := ALLTRIM( Dati->PAR_PSW )
cDirD := ALLTRIM( Dati->PAR_DIRD )
Dati->( DBCLOSEAREA() )
* --- Imposta Url
cUrl := "ftp://" + cUser + ":" + cPsw + "@" + cIp
IF !EMPTY( cPorta )
cUrl += ":" + cPorta
ENDIF
** MsgInfo(cUrl )
oUrl := TUrl():New( cUrl )
oFtp := TIpClientFtp():New( oUrl, .F. )
oFtp:nConnTimeout := 2000
oFtp:bUsePasv := .T.
IF oFTP:Open( cUrl )
MsgInfo( "Collegato con FTP", cIp )
* --- Test DownLoad
* --- Set DownLoad Path
*IF !EMPTY( cDirD )
* c_Tx := cDirD + "\"
*ENDIF
*MsgInfo( oFTP:DownloadFile( c_Tx + "BUFF2.OBJ", "BUFF.OBJ") )
* --- Test UpLoad
*MsgInfo( oFTP:UploadFile( "LIST00.PRG", "LIST1.PRG") )
* --- Test Show Files
aFiles := oFTP:ListFiles( "*.*")
*FOR i= 1 TO LEN( aFiles )
* MsgInfo(aFiles[i,1])
* MsgInfo(aFiles[i,2])
* MsgInfo(aFiles[i,3])
* MsgInfo(aFiles[i,4])
*NEXT
Elenco( aFiles, xPath )
oFTP:Close()
ELSE
MsgInfo( "Collegamento Non Possibile con FTP", cIp )
ENDIF
RETURN NIL
// ------------------------ ELENCO
FUNCTION Elenco( aFiles, xPath )
local oDlg := QDialog()
local oBrw := QTableView( oDlg )
local oModel := QStandardItemModel( 3, 4, oDlg )
LOCAL nNumRecord := 0, x, y, cApp, oIcon
LOCAL oBtnEnd, oBtnTp, oBtnBt
nNumRecord := LEN( aFiles )
* --- Dichiaro Button
@ 260, 25 BUTTON oBtnEnd PROMPT "Abbandona" OF oDlg ;
ACTION oDlg:End()
@ 260, 150 BUTTON oBtnTp PROMPT "Inizio" OF oDlg ;
ACTION Inizio( oBrw )
@ 260, 250 BUTTON oBtnBt PROMPT "Fine" OF oDlg ;
ACTION Fine( oBrw )
* --- Imposto Icone nei Pulsanti
oBtnTp:SetIcon( QIcon(xPath + "go-top.png") )
oBtnBt:SetIcon( QIcon(xPath + "go-bottom.png") )
* --- Imposto Intestazione
oModel:SetHorizontalHeaderItem( 0, QStandardItem( "Nome" ) )
oModel:SetHorizontalHeaderItem( 1, QStandardItem( "LEN" ) )
oModel:SetHorizontalHeaderItem( 2, QStandardItem( "DATA" ) )
oModel:SetHorizontalHeaderItem( 3, QStandardItem( "ORA" ) )
* --- Carico Dati
FOR x = 1 to nNumRecord
FOR y = 1 TO 4
cApp := aFiles[x,y]
DO CASE
CASE VALTYPE( cApp ) == "N"
cApp := STR( cApp )
CASE VALTYPE( cApp ) == "D"
cApp := DTOC( cApp )
ENDCASE
oModel:SetItem( x-1, y-1, QStandardItem( cApp ) )
NEXT
NEXT
* --- Imposto Form Principale
oDlg:SetWindowTitle( "Elenco" )
oDlg:Resize( 415, 300 )
oDlg:Center()
* --- Imposto Form Browse
oBrw:SetModel( oModel )
oBrw:Resize( 410, 240 )
* --- Imposto Larghezza Colonne della Browse
oBrw:setColumnWidth(0, 200)
oBrw:setColumnWidth(1, 60)
oBrw:setColumnWidth(2, 55)
oBrw:setColumnWidth(3, 40)
* --- Esecuzione
oBrw:show()
oDlg:Exec()
RETURN NIL
* --- Posizione Top del Browse
FUNCTION Inizio( oBrw )
oBrw:scrollToTop()
oBrw:setFocus()
RETURN NIL
* --- Posizione Bottom del Browse
FUNCTION Fine( oBrw )
oBrw:scrollToBottom()
oBrw:setFocus()
RETURN NIL
Esto es lo que encontré en el foro
01
02 CREATE CLASS TIPClientFTP FROM TIPClient
03
04 VAR nDataPort
05 VAR cDataServer
06 VAR bUsePasv INIT .T.
07 VAR RegBytes
08 VAR RegPasv
09 // Socket opened in response to a port command
10 VAR SocketControl
11 VAR SocketPortServer
12
13 METHOD New( oUrl, xTrace, oCredentials )
14 METHOD Open( cUrl )
15 METHOD Close()
16 METHOD GetReply()
17 METHOD Commit()
18 METHOD ScanLength()
19 METHOD TransferStart()
20
21 METHOD Pasv()
22 METHOD Quit()
23 METHOD TypeI()
24 METHOD TypeA()
25 METHOD NoOp()
26 METHOD Rest( nPos )
27 METHOD Pwd()
28 METHOD Cwd( cPath )
29 METHOD Dele( cPath )
30 METHOD LS( cSpec )
31 METHOD Rename( cFrom, cTo )
32 METHOD MKD( cPath )
33 METHOD RMD( cPath )
34 METHOD Retr( cFile )
35 METHOD Stor( cFile )
36 METHOD List( cSpec )
37 METHOD UserCommand( cCommand, lPasv, lReadPort, lGetReply )
38
39 METHOD Port()
40 METHOD SendPort()
41 METHOD ReadAuxPort()
42 METHOD Read( nLen )
43 METHOD Write( cData, nLen )
44 METHOD MGet( cSpec, cLocalPath )
45 METHOD MPut( cFileSpec, cAttr )
46 METHOD UploadFile( cLocalFile, cRemoteFile )
47 METHOD DownloadFile( cLocalFile, cRemoteFile )
48 METHOD ListFiles( cFileSpec )
49 METHOD FileSize( cFileSpec )
50
51 ENDCLASS
algunos métodos no son claras puedo obtener más información?
ejemplo: 16,18,19, 22,23,24,25 existe una explicación para todos ?
gracias
saludos