简体   繁体   English

为什么 Crystal Reports 引擎在使用 QueueBackgroundWorkItem 启动的后台任务中使用时表现不同?

[英]Why does the crystal reports engine appear to behave differently when used in a background task started using QueueBackgroundWorkItem?

In a web application I have code to generate a PDF file using crystal reports and both the ReportDocument.ExportToDisk and ReportDocument.ExportToStream methods.在 web 应用程序中,我有代码使用水晶报表以及 ReportDocument.ExportToDisk 和 ReportDocument.ExportToStream 方法生成 PDF 文件。 I am using the 64bit crystal runtime v13 SP31.我正在使用 64 位 crystal runtime v13 SP31。 All database data is pushed directly to each report using the SetDataSource method.使用 SetDataSource 方法将所有数据库数据直接推送到每个报表。

When I call the code from the code-behind of a web page, it executes perfectly and a useable pdf is generated.当我从 web 页面的代码隐藏调用代码时,它完美执行并生成了可用的 pdf。

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.对于应用程序中的某些(不是全部)报告,当我从使用 QueueBackgroundWorkItem 生成的后台任务中调用完全相同的代码时,它的行为会有所不同并生成异常。 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 (ie 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.公式字段异常似乎只影响包含使用条件语句(“if”或“iif”)的公式字段的报告,其中条件涉及数字字段但结果是字符串 - 类似于“ IIF ({NumericField} = 0, 'Zero', 'Non-Zero') ”例如。 Tweaking the formula to wrap the numeric condition (eg " IIF (TOTEXT({NumericField}) = '0', 'Zero', 'Non-Zero') ") does NOT cure the problem.调整公式以包含数字条件(例如“ IIF (TOTEXT({NumericField}) = '0', 'Zero', 'Non-Zero') ”)并不能解决问题。

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?有没有人知道后台任务环境中的物理差异与可以解释这些行为差异的正常代码隐藏相比,有没有人对补救措施有任何建议?

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).要测试该理论,请使用 static 数据源(或仅使用保存的数据)进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM