#include "FiveWin.ch"#include "TsButton.ch"#define FILE_ATTRIBUTE_READONLY
1#define FILE_ATTRIBUTE_HIDDEN
2#define FILE_ATTRIBUTE_SYSTEM
4#define FILE_ATTRIBUTE_DIRECTORY
16#define FILE_ATTRIBUTE_ARCHIVE
32#define FILE_ATTRIBUTE_NORMAL
128#define FILE_ATTRIBUTE_TEMPORARY
256#define INTERNET_OPEN_TYPE_PRECONFIG
0 // use registry configuration#define INTERNET_OPEN_TYPE_DIRECT
1 // direct to net#define INTERNET_OPEN_TYPE_PROXY
3 // via named proxy#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY
4 // prevent using java/script/INS#define INTERNET_INVALID_PORT_NUMBER
0 // use the protocol-specific default#define INTERNET_DEFAULT_FTP_PORT
21 // default for FTP servers#define INTERNET_DEFAULT_GOPHER_PORT
70 // " " gopher "#define INTERNET_DEFAULT_HTTP_PORT
80 // " " HTTP "#define INTERNET_DEFAULT_HTTPS_PORT
443 // " " HTTPS "#define INTERNET_DEFAULT_SOCKS_PORT
1080 // default for SOCKS firewall servers.#define INTERNET_SERVICE_FTP
1#define INTERNET_SERVICE_GOPHER
2#define INTERNET_SERVICE_HTTP
3#define INTERNET_FLAG_TRANSFER_ASCII
1#define INTERNET_FLAG_TRANSFER_BINARY
2Static oWnd
Static hBorland, User, hParaBNt
*..............................................................................................................................*
Function Main
()Local oDlg, oBar, oBmp, oIco, lOk, Local1:=GetWinDir
(), oFont
[1], FileName, oItem, oBsh, oTxt
Public Ubica:=CurDrive
()+
":\"+CurDir()
Public nClr:=aRGB( GetSysColor(15) ), CLR_SYSTEM
CLR_SYSTEM := RGB( nClr[1],nClr[2],nClr[3] )
hBorland:=LoadLibrary( ".\System\bwcc32.dll
" )
Set Date British
Set Century On
Set _3DLOOK On
DEFINE FONT oFont[1] NAME "Arial
" WEIGHT 12
DEFINE DIALOG oDlg RESOURCE "DIALOG_MAIN
" ICON oIco COLOR CLR_BLACK, CLR_WHITE BRUSH oBsh
REDEFINE SBUTTON ID 101 NAME "RUN2
" TEXT POSITION ON_BOTTOM OF oDlg ACTION ( GetFtp( oDlg ) ) BORDER CANCEL
REDEFINE SAY oTxt ID 102 OF oDlg
ACTIVATE DIALOG oDlg CENTERED;
VALID ( If( !GetKeyState( VK_ESCAPE ), .T., .F. ) )
Return ( Nil )
*..............................................................................................................................*
Static Function GetFtp(oDlg)
Local oInternet, usuario:="administrador@banks.com", password:="xxxxxx
" // estas se reemplazan con tu usuario y password
Local oFtp, lExito, False:=.F., True:=.T.
Local cLocalFile:="C:\Link\Mproduct.zip
", cRemoteFile:="/LTO/mproduct.zip
"
oInternet := TInternet():New()
oFTP := TFTP():New( "167.119.250.194", oInternet, usuario, password )
hLib = LOADLIBRARY( "wininet.dll
" )
hInternet = INETOPEN( "Anystring
", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
hConnect = INETCONNECT( hInternet, "167.119.250.194", 21, usuario, password,1, 0, 0 )
IF hConnect = 0
MsgAlert("Fallo la conección con el Servidor!
" + chr(13)+"Intente nuevamente.
")
FREELIBRARY( hLib )
INETCLOSEHANDLE( hConnect )
INETCLOSEHANDLE( hInternet )
FREELIBRARY( hLib )
Return ( Nil )
Else
MsgRun( "Descargando archivo
local MALL PLAZA, favor esperar.
","Conectando
")
lExito := FTPGETFILE( hConnect, cRemoteFile, cLocalFile, 0, FILE_ATTRIBUTE_ARCHIVE, 0, 0)
If !lExito
MsgAlert( "No se pudo realizar la descarga desde el servidor.
", "Error!
")
FREELIBRARY( hLib )
INETCLOSEHANDLE( hConnect )
INETCLOSEHANDLE( hInternet )
FREELIBRARY( hLib )
MsgRun("")
Else
aFiles := hb_GetFilesInZip(cLocalFile)
hb_unzipfile(cLocalFile,,.T.,,"C:\
", aFiles, NIL)
While .T.
If ( CopyFile("c:\Link\Fab\LTO\Mproduct.dat
", "c:\Ventas\Bases\Mproduct.dat
") = .F. )
If ( MsgYesNo("Es necesario que salga del sistema de ventas para realizar este proceso. Desea reintentar?
", "Error
") )
Loop
Else
Exit
EndIf
Else
Exit
EndIf
End While
EndIf
oDlg:End()
MsgRun("")
EndIf
Return ( Nil )
*...............................................................................................................................*
DLL32 FUNCTION INETOPEN( cAgent AS LPSTR, nAccessType AS DWORD, cProxyName AS LPSTR, cProxyBypass AS LPSTR, nFlags AS DWORD ) AS LONG;
PASCAL FROM "InternetOpenA
" LIB "wininet.dll
"
DLL32 FUNCTION INETCLOSEHANDLE( hInternet AS LONG ) AS BOOL;
PASCAL FROM "InternetCloseHandle
" LIB "wininet.dll
"
DLL32 FUNCTION INETCONNECT( hInternet AS LONG, cServerName AS LPSTR, nServerPort AS LONG, cUserName AS LPSTR, cPassword AS LPSTR, nService AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS LONG;
PASCAL FROM "InternetConnectA
" LIB "wininet.dll
"
DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpGetFileA
" LIB "wininet.dll
"
DLL32 FUNCTION FTPPUTFILE( hConnect AS LONG, cLocalFile AS LPSTR, cNewRemoteFile AS LPSTR, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpPutFileA
" LIB "wininet.dll
"
DLL FUNCTION COPYFILE( cExistingFileName AS LPSTR, cNewFileName AS LPSTR, lFailIfExists AS LONG ) AS BOOL;
PASCAL FROM "CopyFileA
" LIB "kernel32.dll
"
*...............................................................................................................................*