为什么在背景任务中使用QueueBackgroundWorkitem开始使用Crystal Reports引擎的行为会有所不同?
在Web应用程序中,我有代码可以使用Crystal Reports以及ReportDocument.exportTodisk和reportDocument.exportToStream方法生成PDF文件。我正在使用64位晶体运行时V13 SP31。使用SetDataSource方法将所有数据库数据直接推向每个报告。
当我从网页的代码范围内调用代码时,它可以完美地执行并生成可用的PDF。
对于应用程序中的某些(不是全部)报告时,当我从使用QueueBackgroundWorkitem产生的背景任务中调用完全相同的代码时,它的行为不同并生成异常。到目前为止,我得到的异常类型是与报告中的公式字段有关的虚假“在这里需要一个字符串”,或者是与所有子报告参数有关的“缺失参数”异常(尽管所有子报告参数都在链接到等效的主报告参数)。
对于单个报告,这些问题似乎是一致的(即每次在后台运行报告时都会发生相同的错误) - 但并非应用程序中的每个报告都受到影响。在到目前为止确定的每种情况下,如果从代码范围内或在报告设计器中预览的情况下,报告都可以正常工作,但仅在后台环境中生成报告时才失败。
公式字段异常似乎仅影响包含使用条件语句的公式字段的报告(“如果”或“ iif”),其中该条件涉及数字字段,但结果是字符串 - 类似于“ iif({numericfield}) = 0,'Zero','non-Zero')
“例如”。调整公式以包装数字条件(例如“ iif(totext({numericfield})='0','Zero','non-Zero')
“)无法解决问题。
同样,我尝试添加额外的代码来直接设置子报告参数(而不是允许它们从链接的主报告参数过滤下来),但是无论我使用什么技术,也会生成异常(似乎Crystal似乎不喜欢您试图绕过参数链接)。
据我所知,Crystal Reports引擎在背景环境中的行为不同。与正常的代码范围相比,是否有人知道背景任务环境中存在的物理差异,这可以解释这些行为差异,并且有人对补救措施有任何建议吗?
In a web application I have code to generate a PDF file using crystal reports and both the ReportDocument.ExportToDisk and ReportDocument.ExportToStream methods. I am using the 64bit crystal runtime v13 SP31. All database data is pushed directly to each report using the SetDataSource method.
When I call the code from the code-behind of a web page, it executes perfectly and a useable pdf is generated.
For some (not all) reports in the application, when I call exactly the same code from a background task spawned using QueueBackgroundWorkItem, it behaves differently and generates exceptions. So far the kinds of exceptions I get are either a spurious "A string is required here" exception relating to a formula field in the report or a "Missing Parameters" exception relating to ALL sub-report parameters (despite all sub-report parameters being linked to equivalent main report parameters).
The problems seem to be consistent for individual reports (i.e. the same error occurs every time that report is run in the background) - but not every report in the application is affected. In each case identified so far, the report works perfectly if run from code-behind or if previewed in the report designer, but only fails when the report is generated in the background environment.
The formula field exception seems only to affect reports containing formulas fields that use conditional statements ("if" or "iif") where the condition involves a numeric field but the result is a string - something like "IIF ({NumericField} = 0, 'Zero', 'Non-Zero')
" for example. Tweaking the formula to wrap the numeric condition (e.g. "IIF (TOTEXT({NumericField}) = '0', 'Zero', 'Non-Zero')
") does NOT cure the problem.
Similarly, I have tried adding extra code to set the sub-report parameters directly (instead of allowing them to filter down from the linked main report parameters), but whatever technique I use, that also generates exceptions (it seems crystal doesn't like you trying to bypass parameter links).
As far as I can see, the crystal reports engine is behaving differently in a background setting. Is anyone aware of the physical differences there are in the environment of a background task compared to normal code-behind that could explain these behavioral differences and does anyone have any suggestions as to a remedy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能与提供数据的过程有关。
要测试该理论,请使用静态数据源测试(或简单地使用保存的数据)。
This might be related to the process used to supply the data.
To test that theory, please test with a static data source (or simply use Saved Data).