2

I have a report that needs to process the data that it get from SQL before show it. For that, I have a custom code, and a Dictionary where I push all the processed data. My problem is that if I save the dictionary in a report variable when I export the report to Word that variable seems to be cleaned. What is the lifecycle of the reports variables? What is the most convenient way of saving an object during the report life.

Thanks!

4

1 回答 1

2

我已经玩了大约 6 周的自定义代码,所以我可以回答 SSRS 2008 R2 中变量生命周期问题的某些部分。

我有使用字典来存储总计的报告,允许我为财务提供一些专业的小计。我有一些你可以检查的东西(因为我还不能评论)。

您是否将变量声明为“共享”,这是一个自定义代码特定关键字,不会转换为 VB.net。它确保变量存在到下一页,我在 Excel 中对此进行了测试,word 似乎可以很好地传输变量的数据。

但是在 SSRS“按需报告”引擎(在 Web 上,而不是在 BIDS 上)下,需要权衡取舍,它保存变量并且在缓存本身被清除之前不会进行垃圾收集。我编写了更多自定义代码来指示我的参数何时更改并清除变量。

代码;

Public Shared Dim Totals As New System.Collections.Generic.Dictionary(Of String, Decimal)

Public Function WipeKeys() as Decimal 'Clear Data from Dictionary (this will clear the cached object as well)
  Totals.Clear()
  Return 0D
End Function

我还将建议尽可能覆盖密钥以确保减少添加循环。

问候,

于 2013-05-15T13:45:00.877 回答