#include #include AutoItSetOption("GUIOnEventMode", 1) $GUITitle = "Ažuriranje baze" $GUIWidth = 300 $GUIHeight = 65 Dim $iDloadFinalSize = "" Dim $iDloadCurrentSize = "" Dim $iPercentage2 Dim $tajmer $GUI = GUICreate($GUITitle, $GUIWidth, $GUIHeight, (@DesktopWidth - $GUIWidth) / 2, (@DesktopHeight - $GUIHeight) / 2) ;$buttonDownload = GUICtrlCreateButton("Ažuriranje Baze", 100, 40, 100, 20) $progressDownloadStatus = GUICtrlCreateProgress(5, 10, $GUIWidth - 10, 20) GUISetState() #Region Events list GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitIt") ;GUICtrlSetOnEvent($buttonDownload,"_DownloadFF") #EndRegion Events list $tajmer = 0 _DownloadFF() While 1 Sleep(10) If $iPercentage2 = 0 Then $tajmer = $tajmer + 1 EndIf If $iDloadFinalSize <> "" Then _CheckActiveDownload() If $tajmer = 10000 Then MsgBox(16, "Greška", "Ažuriranje baze neuspešno!") Exit EndIf WEnd Func _ExitIt() Exit EndFunc ;==>_ExitIt Func _CheckActiveDownload() If @InetGetBytesRead <> "-1" Then $iDloadCurrentSize = @InetGetBytesRead $iPercentage = Int(($iDloadCurrentSize / $iDloadFinalSize) * 100) $iPercentage2 = ($iDloadCurrentSize / $iDloadFinalSize) * 100 GUICtrlSetData($progressDownloadStatus, $iPercentage) Else $iDloadFinalSize = "" GUICtrlSetData($progressDownloadStatus, "0") MsgBox(16, "Greška", "Ažuriranje baze neuspešno!.") Exit EndIf If $iDloadCurrentSize = $iDloadFinalSize Then $iDloadFinalSize = "" ;FileDelete("D:\Trebovanje\magdb.zip") ;AKO HOCES BACKUP PRETHODNE BAZE FileCopy("D:\Trebovanje\saz.dbf", "D:\Trebovanje\saz.bak") FileDelete("D:\Trebovanje\saz.dbf") ;BRISANJE PRETHODNE BAZE _Zip_UnzipAll("D:\Trebovanje\magdb.zip", "D:\Trebovanje\", 1) ;UNZIPOVANJE PROMENI FAJL KOJI SE SKIDA I DESTINATION RunWait(@ComSpec & " /c " & '"rd /S /Q %TEMP%"',"",@SW_HIDE) ;BRISE SVE PRIVREMENE FOLDERE IZ TEMP-a! MsgBox(64, "Završeno", "Ažuriranje baze uspešno!") Exit EndIf EndFunc ;==>_CheckActiveDownload Func _DownloadFF() If @InetGetActive Then InetGet("abort") GUICtrlSetData($progressDownloadStatus, "0") Else $sFileURL = "ftp://USERNAME:PASSWORD@IPADRESS/magdb.zip" ;FAJL NA SERVERU $sFileDest = "D:\Trebovanje\magdb.zip" ;FAJL U LOKALU (ISTO KAO I UNZIP) $iDloadFinalSize = InetGetSize($sFileURL) $iDloadCurrentSize = "0" InetGet($sFileURL, $sFileDest, 1, 1) EndIf EndFunc ;==>_DownloadFF