Func _GetFile()
TrayTip("准备工作", "下载所需文件~", 30, 1)
_GUICtrlTab_ClickTab($Tab, 0)
Local $sUser = GUICtrlRead($Tab1_Input1)
Local $sPassword = GUICtrlRead($Tab1_Input2)
If DirGetSize(GUICtrlRead($Tab1_Input3)) = -1 Then DirCreate(GUICtrlRead($Tab1_Input3))
Local $sFile = GUICtrlRead($Tab1_Input3) & '\全部应用系统的报表' & @YEAR & @MON & @MDAY & '.xls'
_GUICtrlEdit_InsertText($iexport, '======================' & @LF)
_GUICtrlEdit_InsertText($iexport, '正在登录站点.' & _Gettime() & @LF)
_IENavigate($oIE, 'http://10.238.1.29:7001/TMS/')
Local $oForm = _IEFormGetObjByName($oIE, "loginForm")
Local $oPrNo = _IEFormElementGetObjByName($oForm, "oprNo")
Local $oPassWord = _IEFormElementGetObjByName($oForm, "passWord")
_IEFormElementSetValue($oPrNo, $sUser)
_IEFormElementSetValue($oPassWord, $sPassword)
_IEFormSubmit($oForm)
If @error Then
_GUICtrlEdit_InsertText($iexport, '无法导航至指定地址,提交表单失败.' & _Gettime() & @LF)
FileWriteLine($LOG, _Gettime() & '无法导航至指定地址,提交表单失败.')
Return SetError(1, 0, 0)
EndIf
$sHTML = _IEDocReadHTML($oIE)
;~ FileWrite('2.txt', $sHTML)
If Not StringInStr($sHTML, 'welcome.jsp') Then
_GUICtrlEdit_InsertText($iexport, '登录站点失败.' & _Gettime() & @LF)
FileWriteLine($LOG, _Gettime() & '登录站点失败.')
Return SetError(1, 0, 0)
Else
_GUICtrlEdit_InsertText($iexport, '登录站点成功.' & _Gettime() & @LF)
EndIf
_GUICtrlEdit_InsertText($iexport, '进入指定页面.' & _Gettime() & @LF)
_IENavigate($oIE, 'http://10.238.1.29:7001/TMS/fpages/report/ftl/reportTml.ftl?_cds_=0')
If @error Then
_GUICtrlEdit_InsertText($iexport, '请求失败,请重试.' & _Gettime() & @LF)
FileWriteLine($LOG, _Gettime() & '地址打开失败.')
Return SetError(1, 0, 0)
EndIf
_GUICtrlEdit_InsertText($iexport, '请求所需文件.' & _Gettime() & @LF)
$oIE.document.getElementById('Report_ReportTml_interface_dataset_btnSubmit' ).click()
_IELoadWait($oIE)
If @error Then
_GUICtrlEdit_InsertText($iexport, '请求失败,请重试.' & _Gettime() & @LF)
FileWriteLine($LOG, _Gettime() & '地址打开失败.')
Return SetError(1, 0, 0)
EndIf
_GUICtrlEdit_InsertText($iexport, '得到下载链接.' & _Gettime() & @LF)
_GUICtrlEdit_InsertText($iexport, '下载文件到"' & $sFile & '"' & _Gettime() & @LF)
Local $hDownload = InetGet('http://10.238.1.29:7001/TMS/filedownload/FileDownloadAction.do?param=tml', $sFile, 1 + 4, 1)
Do
Sleep(250)
Until InetGetInfo($hDownload, 2) ; 检查完成的下载.
Local $aData = InetGetInfo($hDownload) ; 获取全部信息.
InetClose($hDownload) ; 关闭句柄以释放资源.
_GUICtrlEdit_InsertText($iexport, '读取字节:' & $aData[0] & @LF)
If $aData[3] Then
_GUICtrlEdit_InsertText($iexport, '文件下载成功' & _Gettime() & @LF)
Else
_GUICtrlEdit_InsertText($iexport, '文件下载失败,请手动下载' & _Gettime() & @LF)
FileWriteLine($LOG, _Gettime() & '文件下载失败.')
Return SetError(2, 0, 0)
EndIf
Return $sFile
EndFunc ;==>_GetFile