1
我們有一個SSRS集成的Sharepoint服務器。我試圖從它導出PDF格式的報告。XMLHTTP的responsebody是否在VB6中異步工作?
(我不得不做這樣的,因爲我的網址太長,我寧願用shell命令做這樣的,雖然這看起來像一個更好的解決方案。)
Here'is我的代碼:
Dim request as New XMLHTTP
Dim oStream as New Stream
Dim aBunchOfMiliseconds as Long
Dim fileLocation as String
Dim reportUrl as String
aBunchOfMiliseconds = 500
reportUrl = "http://www.mySharepointDomain.com/_vti_bin/ReportServer?http://www.mySharepointDomain.com/sites/AFolderHere/OOAnotherFolder/BlaBlaReportFolder/FolderFolder/AhTheLastOne/AtLeastMyReportFile.rdl&rs:Command=Render&rc:Toolbar=true&rs:Format=PDF&Parameter1=ABC &Parameter2=1&Parameter3=1&TheLastParameter=IllBeDamned&rs%3aParameterLanguage=ln-LN"
request.Open "GET", reportUrl
request.setRequestHeader "WWW-Authenticate", "NTLM" 'For impersonation
request.Send 'Go get it Bruce
If request.Status = 200 Then 'Are you successful?
oStream.Type = adTypeBinary
oStream.Open
oStream.Write request.responseBody 'Here's the problematic part
Sleep(aBunchOfMiliseconds) 'If I don't do this, file will be corrupted
oStream.SaveToFile fileLocation, adSaveCreateOverWrite
oStream.Close
End If
Set oStream = Nothing
Set request = Nothing
如果我註釋掉「睡眠」這一行,我將有一個無法打開的損壞文件。此代碼工作正常,但我發現它在那裏使用「睡眠」嘲笑。
有什麼辦法讓我理解數據複製操作已完成?