我们有一个SSRS集成的sharepoint服务器。我正在尝试从中导出PDF格式的报告。
(我必须这样做,因为我的网址太长了。我宁愿使用Shell命令这样做,虽然这看起来更好。但
这是我的代码:
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
如果我注释掉“睡眠”行,我将会有一个无法打开的损坏文件。这段代码工作正常,但我发现在那里使用“Sleep”是荒谬的。
我有什么方法可以理解数据复制操作已经完成了吗?
答案 0 :(得分:1)
哦,我明白了。
我错过了说"这不是异步电话"。
request.Open "GET", reportUrl, False