- Сообщения
- 7,790
- Репутация
- 2,322
logos,
Еще один вариант с логированием.
Еще один вариант с логированием.
Код:
#NoTrayIcon
#include <Date.au3>
Opt('MustDeclareVars', 1)
Global $iSound = 48, $sMess = 'Download completed successfully', $iIcon = 1, $sTitle = 'Finam download'
ToolTip('I''m working now :)', @DesktopWidth, 0, $sTitle, $iIcon, 4)
DllCall('user32.dll', 'bool', 'MessageBeep', 'uint', 0)
If Not _GetFiles() Then
$sMess = 'One or more errors downloaded'
$iSound = 16
$iIcon = 3
EndIf
DllCall('user32.dll', 'bool', 'MessageBeep', 'uint', $iSound)
ToolTip($sMess, @DesktopWidth, 0, $sTitle, $iIcon, 4)
Sleep(3000)
Exit
Func _GetFiles($f_Log = True)
Local $a_M[12] = ['http://195.128.78.52/', '.txt?market=5&em=8', '&code=', '&df=', '&mf=', '&yf=', '&dt=', '&mt=', '&yt=', '&p=8&f=', _
'&e=.txt&cn=', '&dtf=1&tmf=1&MSOR=0&mstime=on&mstimever=1&sep=1&sep2=1&datf=2&at=1'], $s_Minus7, $a_Min, $s_Year, _
$a_Work[9][5] = [[8],['EURUSD', 3, '', 'EURUSD'],['EURUSD', 3, '-', 'E-D'],['GBPUSD', 6, '', 'GBPUSD'],['GBPUSD', 6, '-', 'GBP'], _
['USDCHF', 5, '', 'USDCHF'],['USDCHF', 5, '-', 'CHF'],['USDJPY', 7, '', 'USDJPY'],['USDJPY', 7, '-', 'JPY']], _
$s_Dir = @ScriptDir & '\Закачки\';поменяйте на свою папку закачки
$s_Year = StringRight(@YEAR, 2)
$s_Minus7 = _DateAdd('D', -7, @YEAR & '/' & @MON & '/' & @MDAY)
$a_Min = StringSplit($s_Minus7, '/')
If Not FileExists($s_Dir) Then DirCreate($s_Dir)
$a_Work[0][3] = TimerInit()
For $i = 1 To $a_Work[0][0]
$a_Work[$i][4] = $a_Work[$i][0] & '_' & StringRight($a_Min[1], 2) & $a_Min[2] & $a_Min[3] & '_' & $s_Year & @MON & @MDAY & $a_Work[$i][2]
$a_Work[$i][3] = $a_M[0] & $a_Work[$i][4] & $a_M[1] & $a_Work[$i][1] & $a_M[2] & $a_Work[$i][0] & $a_M[3] & $a_Min[3] & $a_M[4] & $a_Min[2] - 1 & _
$a_M[5] & $a_Min[1] & $a_M[6] & @MDAY & $a_M[7] & @MON - 1 & $a_M[8] & @YEAR & $a_M[9] & $a_Work[$i][4] & $a_M[10] & $a_Work[$i][3] & $a_M[11]
For $j = 0 To 2
$a_Work[$i][$j] = 0
Next
$a_Work[$i][4] &= '.txt'
$a_Work[$i][0] = InetGet($a_Work[$i][3], $s_Dir & $a_Work[$i][4], 17, 1)
If $a_Work[$i][0] Then
Do
Sleep(20)
Until InetGetInfo($a_Work[$i][0], 2)
If InetGetInfo($a_Work[$i][0], 4) Then
$a_Work[$i][2] = 'Error'
Else
$a_Work[$i][2] = 'Success'
$a_Work[$i][1] = InetGetInfo($a_Work[$i][0], 0)
$a_Work[0][1] += $a_Work[$i][1]
$a_Work[0][2] += 1
EndIf
InetClose($a_Work[$i][0])
Else
$a_Work[$i][2] = 'Error'
EndIf
Next
$a_Work[0][4] = StringFormat('Time: %.2f sec', TimerDiff($a_Work[0][3]) / 1000)
$a_Work[0][3] = ''
If $f_Log Then
_Log($a_Work)
EndIf
Return ($a_Work[0][0] = $a_Work[0][2])
EndFunc ;==>_GetFiles
Func _Log($a_Work)
Local $s_Log = @ScriptDir & '\LogFinam.txt', $s_Text = StringFormat('Finam downloaded: %s.%s.%s %s:%s:%s\r\n', @MDAY, @MON, @YEAR, @HOUR, @MIN, @SEC)
If FileGetSize($s_Log) > 10240 Then FileDelete($s_Log);10 kb если много или мало, поменяйте размер
For $i = 1 To $a_Work[0][0]
$s_Text &= StringFormat('%d. %s\tSize: %d b\t%s\r\n', $i, $a_Work[$i][4], $a_Work[$i][1], $a_Work[$i][2])
Next
$s_Text &= '----------------------------------------------------------------' & @CRLF
$s_Text &= StringFormat('Files downloaded: %d\tAll size: %d b\t%s\tErrors: %d\r\n', $a_Work[0][2], $a_Work[0][1], $a_Work[0][4], _
$a_Work[0][0] - $a_Work[0][2])
$s_Text &= '================================================================' & @CRLF & @CRLF
FileWrite($s_Log, $s_Text)
EndFunc ;==>_Log