通过网站生成SSRS,很好——通过代码,内存不足

发布于 2024-11-04 18:11:48 字数 1187 浏览 0 评论 0原文

我有一份 68,000 页以上的报告需要生成 PDF 格式。 (我加了逗号,这样你就知道这不是一个错字:) 如果我通过 SSRS 的 Website/WebService 生成它,这实际上工作得很好。 需要一分多钟的时间才能生成第一页。在此期间,服务器 CPU 达到 100%,内存达到 2GB。生成第一页后,CPU 和内存都会下降到报告前的状态。现在如果我选择导出为 PDF。服务器上的 CPU 达到 100,但在生成 pdf 时内存不会显着跳跃,可能为 0.05GB (50 MB)。这大约需要 10-15 分钟。

现在,如果我在代码中使用 Render 方法,

rs.Render(Me.ReportName, Me.ContentType, Nothing, Nothing, ....

我将 rs.Timeout 设置为 1800000 //(30 分钟)。服务器上的 CPU 和内存出现峰值,大约 10 分钟后我收到内存不足异常。我相信来自服务器而不是具有调用代码(网络服务)的主机。

现在我确实注意到,当 PDF 通过 SSRS 网站渲染时,它会创建一个带有参数的新 URL。

ReportSession=gvrjxt4504wtpkiydu0o51fo
ControlID=5754f0889fb34bea80e7b5e97c120cfd
Culture=1033
UICulture=9
ReportStack=1
OpType=Export
FileName=Invoice+Session+Register+Batch
ContentDisposition=OnlyHtmlInline
Format=PDF

现在我相信正是这个 ReportSession 或 ControlId 使 PDF 生成不占用那么多内存。

不管怎样,我的问题是如何通过代码模仿网站显示的行为?

我即将研究 LoadReport 方法,并且 NULL 是可以传递给渲染方法的内容类型之一。但我找不到它的例子和解释。

因此,在我深入这些兔子洞之前,是否还有其他人做过类似的事情或遇到过这样的项目?

背景:如果我一次生成一页报告,则需要 9.5 小时才能运行并生成所有 PDF。当我可以在 10 分钟内生成整个报告并使用 PDFSharp 拆分报告时,我感到非常兴奋。现在我很可能一次可以生成 10,000 或 20,000 个,但是当一个方法有效但我无法在代码中复制它时,这真的让我很沮丧。

I have a report that is 68,000 pages plus that needs to be generated in PDF. (I put the comma in so you knew it wasn’t a typo :)
And this actually works fine if I generate it through the Website/WebService of SSRS.
It takes a little over a minute and generates the first page. During this time Server CPU goes to 100% and Memory to 2GB. After the first page is generated both CPU and Memory drop down to their pre-report state. Now if I choose to export to PDF. CPU on the Server goes to 100 but Memory does not jump significantly maybe .05GB (50 MB) as the pdf is being generated. This takes about 10-15 Minutes.

Now if I use the Render method in code

rs.Render(Me.ReportName, Me.ContentType, Nothing, Nothing, ....

I set the rs.Timeout to 1800000 //(30 minutes). CPU and Memory on the server spikes and about after 10 Minutes I get a out of Memory Exception. I believe from the server and not the host machine with the calling code (a web service).

Now I did notice when the PDF gets render through the SSRS website it creates a new URL with the parameters

ReportSession=gvrjxt4504wtpkiydu0o51fo
ControlID=5754f0889fb34bea80e7b5e97c120cfd
Culture=1033
UICulture=9
ReportStack=1
OpType=Export
FileName=Invoice+Session+Register+Batch
ContentDisposition=OnlyHtmlInline
Format=PDF

Now it is my belief that it is this ReportSession or ControlId that makes the PDF generation not take up so much memory.

Either way my question is how can I mimic through code the behavior that the Website is showing?

I about to look into LoadReport method and also NULL is one of the content types you can pass to the render method. But I cannot find an example nor and explanation of what it does.

So before I go down all these rabbit holes, has anyone else done something like this or encounter a project like this?

Background:If I generate the report one page at a time it took 9.5 hours to run and generate all the PDFs. I was really excited when I could generate the whole report in 10 minutes and use PDFSharp to split the report. Now I most likely can generate 10,000 or 20,000 at a time but it really fustrates me when a method works but I cannot duplicate it in code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文