Import initial din SVN ROAAUTO/Trunk @HEAD
This commit is contained in:
209
COMUN/programe/filebringer.prg
Normal file
209
COMUN/programe/filebringer.prg
Normal file
@@ -0,0 +1,209 @@
|
||||
Function BringFile
|
||||
Lparameters cFilePath,lcprogram,tcLocalFile
|
||||
*!* modificare ROARESTAURANT v 1.0.0
|
||||
LOCAL lnTransferTotal
|
||||
lnTransferTotal = -1
|
||||
*!* modificare ROARESTAURANT v 1.0.0 ^
|
||||
If !Empty(tcLocalFile)
|
||||
lcLocalFile=tcLocalFile
|
||||
Else
|
||||
If At("_",lcprogram)#0
|
||||
lccurrentUR=Substr(lcprogram,At("_",lcprogram)+1)
|
||||
* MESSAGEBOX(lccurrentUR)
|
||||
Else
|
||||
lccurrentUR=lcprogram
|
||||
Endif
|
||||
mypath=GetIniPath()
|
||||
mypath=Substr(mypath,1,Rat("\",mypath,1))
|
||||
|
||||
Try
|
||||
Md mypath+lccurrentUR+"\"
|
||||
Catch To loex
|
||||
Endtry
|
||||
lcLocalFile=Alltrim(GetCurrentTempPath(lcprogram))
|
||||
Endif
|
||||
* Do Form waitwindow Name frmwait
|
||||
polog.Log("Fisierul care trebuie descarcat este "+cFilePath,Program())
|
||||
If (Occurs('/', cFilePath)>0)
|
||||
*WAIT WINDOW AT 10,10 NOWAIT "Se downloadeaza fisierul..."
|
||||
polog.Log([Createobject("wwCodeUpdate")],Program())
|
||||
|
||||
loUpdate=Createobject("wwCodeUpdate")
|
||||
*!* loUpdate.cExeFile = lcprogram+".exe"
|
||||
|
||||
If Isnull(loUpdate.oHTTP)
|
||||
loIP = loUpdate.CreateHTTPClient()
|
||||
Else
|
||||
loIP = loUpdate.oHTTP
|
||||
Endif
|
||||
|
||||
loIP.lShowDialog = .T.
|
||||
|
||||
loUrl = loIP.InternetCrackUrl(cFilePath)
|
||||
|
||||
If Isnull(loUrl)
|
||||
Return .F.
|
||||
Endif
|
||||
|
||||
myinihandler=Createobject("iniaccess")
|
||||
loIP.nhttpport=Val(loUrl.cPort)
|
||||
If loIP.HTTPConnect(loUrl.cServer,myinihandler.getUsername(),myinihandler.getPassword(),;
|
||||
IIF(Lower(loUrl.cProtocol)="https",.T.,.F.)) # 0
|
||||
loUpdate.SetError(loIP.cErrorMsg)
|
||||
Release myinihandler
|
||||
polog.Log([loIP.HTTPConnect(] + loUrl.cServer + [)#0],Program())
|
||||
Return .F.
|
||||
Else
|
||||
Release myinihandler
|
||||
|
||||
lcTFile = lcLocalFile
|
||||
lcData = ""
|
||||
lnSize = 0
|
||||
polog.Log([loIP.HTTPGetEx(] + Trim(loUrl.cPath) + [)],Program())
|
||||
If(loIP.HTTPGetEx( Trim(loUrl.cPath),@lcData,@lnSize,,lcTFile)=0)
|
||||
|
||||
polog.Log([lnSize=] + alltrim(transform(m.lnSize)),Program())
|
||||
TransferHandlerResult=lnSize
|
||||
else
|
||||
polog.Log([loIp.cerrormsg=] + alltrim(transf(loIp.nerror)) + ' ' + alltrim(transform(nvl(loIp.cerrormsg,''))),Program())
|
||||
TransferHandlerResult=0
|
||||
endif
|
||||
polog.Log([lnSize=] + alltrim(transform(m.lnSize)),Program())
|
||||
polog.Log([loIP.nContentSize=] + alltrim(transform(loIP.nContentSize)),Program())
|
||||
If lnSize#loIP.nContentSize
|
||||
TransferHandlerResult=0
|
||||
Endif
|
||||
|
||||
|
||||
Endif
|
||||
|
||||
|
||||
|
||||
* TransferHandlerResult= DownLoadURL(cFilePath,cLocalFile,"FeedBack",1000,.T.)
|
||||
polog.Log("TransferHandlerResult = "+Alltrim(Transform(TransferHandlerResult)),Program())
|
||||
Else
|
||||
*WAIT WINDOW NOWAIT "Se copiaza fisierul..."
|
||||
*!* If Left(cFilePath,1)="\"
|
||||
*!* cFilePath=Right(cFilePath,Len(cFilePath)-1)
|
||||
*!* Endif
|
||||
*!* cFilePath=lcNetworkPath+cFilePath
|
||||
If(PathFileExists(cFilePath)=1)
|
||||
scomp=Set('comp')
|
||||
Set Compatible On
|
||||
nsize=Fsize(cFilePath)
|
||||
Set Compatible &scomp
|
||||
loProgressForm = Createobject("wwProgressForm")
|
||||
loProgressForm.SetCaption("Se descarc<72> actualizarea...")
|
||||
*!* loProgressForm.ShowCancelButton()
|
||||
loProgressForm.Show()
|
||||
*!* IF loProgressForm.lCancelled
|
||||
loProgressForm.SetDescription("S-au primit de la "+Justpath(cFilePath)+":" +Chr(13)+;
|
||||
"0 din "+Ltrim(Transform(nsize,"999,999,999"))+ " bytes")
|
||||
*!* THIS.oProgressForm.SetDescription("Received from " + THIS.cServer + ":" +CHR(13) +;
|
||||
*!* LTRIM( TRANSFORM(lnbytes,"999,999,999") ) + " of " +;
|
||||
*!* LTRIM(TRANSFORM(THIS.nContentSize,"999,999,999"))+ " bytes")
|
||||
*!* THIS.oProgressForm.SetProgress(lnbytes/THIS.nContentSize * 100)
|
||||
loProgressForm.SetProgress(0)
|
||||
loProgressForm.SetDescription("S-au primit de la "+Justpath(cFilePath)+":" +Chr(13)+;
|
||||
LTRIM(Transform(nsize*0.05,"999,999,999"))+" din "+Ltrim(Transform(nsize,"999,999,999"))+ " bytes")
|
||||
loProgressForm.SetProgress(5)
|
||||
TransferHandlerResult= CopyFile(cFilePath, lcLocalFile, .F.)
|
||||
loProgressForm.SetDescription("S-au primit de la "+Justpath(cFilePath)+":" +Chr(13)+;
|
||||
LTRIM(Transform(nsize,"999,999,999"))+" din "+Ltrim(Transform(nsize,"999,999,999"))+ " bytes")
|
||||
loProgressForm.SetProgress(100)
|
||||
loProgressForm = .F.
|
||||
Else
|
||||
*MESSAGEBOX("Update-ul nu a fost gasit la locatia XML-ului")
|
||||
polog.Log("A incercat cu CopyFile si nu a mers = ",Program())
|
||||
TransferHandlerResult=0
|
||||
Endif
|
||||
|
||||
Endif
|
||||
* frmwait.Release()
|
||||
*WAIT CLEAR
|
||||
If (TransferHandlerResult!=0 And TransferHandlerResult!=-1)
|
||||
*!* modificare ROARESTAURANT v 1.0.0
|
||||
*!* If gTransferTotal!=-1
|
||||
IF lnTransferTotal != -1
|
||||
If TransferHandlerResult=gTransferTotal
|
||||
lnTransferTotal = -1
|
||||
*!* gTransferTotal=-1
|
||||
Return .T.
|
||||
Else
|
||||
lnTransferTotal = -1
|
||||
*!* gTransferTotal=-1
|
||||
polog.Log("TransferHandlerresult != TransferTotal ",Program())
|
||||
Return .F.
|
||||
Endif
|
||||
Endif
|
||||
*!* modificare ROARESTAURANT v 1.0.0 ^
|
||||
|
||||
Return .T.
|
||||
Else
|
||||
If TransferHandlerResult=0
|
||||
polog.Log("TransferHandlerresult = 0",Program())
|
||||
Endif
|
||||
If TransferHandlerResult=-1
|
||||
polog.Log("TransferHandlerresult = -1",Program())
|
||||
Endif
|
||||
|
||||
|
||||
Return .F.
|
||||
Endif
|
||||
Endfunc
|
||||
|
||||
Function StripXmlFile
|
||||
Lparameters cXmlString
|
||||
Return Strextract(Alltrim(cXmlString),"(",")",1)
|
||||
Endfunc
|
||||
|
||||
|
||||
Function FeedBack
|
||||
* if this function returned with .f., downloading would terminate
|
||||
* it is called after each 100 byte downloaded. (You can alter this value!)
|
||||
Lparameters tiAll, tiCount
|
||||
gTransferTotal=tiAll
|
||||
frmwait.label1.Caption = "Desc<73>rcare " + Alltrim(Str(tiCount/1000)) + " kb din " + Alltrim(Str(tiAll/1000)) + " kb"
|
||||
procent = (tiCount*100)/tiAll
|
||||
frmwait._progressbar1.Update(procent)
|
||||
|
||||
If !gcmdCancelDownload
|
||||
Return .T.
|
||||
Else
|
||||
gcmdCancelDownload= .F.
|
||||
Return .F.
|
||||
Endif
|
||||
Endfunc
|
||||
|
||||
Function CheckProcess
|
||||
Lparameters ProgramCheck
|
||||
|
||||
ProgramtoCheck=Addbs(gcDirMare) + ProgramCheck + "\"+ProgramCheck + ".exe"
|
||||
ProgramProba= Addbs(gcDirMare) + ProgramCheck + "\" + ProgramCheck + "Proba.exe"
|
||||
|
||||
Local loex As Exception
|
||||
err=.F.
|
||||
If File("&ProgramtoCheck")
|
||||
Copy File &ProgramtoCheck To &ProgramProba
|
||||
Else
|
||||
Return .F.
|
||||
Endif
|
||||
|
||||
|
||||
Try
|
||||
Delete File &ProgramtoCheck
|
||||
Catch To loex
|
||||
If loex.ErrorNo=1705
|
||||
err= .T.
|
||||
Endif
|
||||
Endtry
|
||||
|
||||
If err=.F.
|
||||
Copy File &ProgramProba To &ProgramtoCheck
|
||||
Delete File &ProgramProba
|
||||
Endif
|
||||
|
||||
|
||||
|
||||
Return err
|
||||
Endfunc
|
||||
Reference in New Issue
Block a user