我们有一个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
如果我注释掉"睡眠"行,我将有一个无法打开的损坏文件。这段代码工作正常,但我发现在那里使用"睡眠"很荒谬。
有什么方法可以了解数据复制操作已完成吗?
哦,
我明白了。
我错过了说"这不是异步调用"。
request.Open "GET", reportUrl, False