当数据库日志记录信息应用于每个 Crystal Reports 部分时,应用程序运行缓慢

2024-01-09

目前,我使用以下方法将连接信息分配给所有报告部分。但由于报告中有很多部分,因此报告会在大约 10 秒后显示。这看起来真的很慢。当安装在客户端时,是否有其他方法可以一次性为每个 CR 设置登录信息。

JFYI:所有 CR 使用相同的登录凭据连接到同一数据库。先感谢您。

   readDiamondBillReport = new RealDiamondBill();
                        crConnectionInfo.ServerName = db.Connection.DataSource;
                        crConnectionInfo.DatabaseName = db.Connection.Database;
                        crConnectionInfo.UserID = "client";
                        crConnectionInfo.Password = "client";
                        crConnectionInfo.IntegratedSecurity = false;

                        CrTables = readDiamondBillReport.Database.Tables;
                        foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
                        {
                            crtableLogoninfo = CrTable.LogOnInfo;
                            crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                            CrTable.ApplyLogOnInfo(crtableLogoninfo);
                        }

                        Sections crSections2 = readDiamondBillReport.ReportDefinition.Sections;
                        // loop through all the sections to find all the report objects 
                        foreach (Section crSection in crSections2)
                        {
                            ReportObjects crReportObjects = crSection.ReportObjects;
                            //loop through all the report objects in there to find all subreports 
                            foreach (ReportObject crReportObject in crReportObjects)
                            {
                                if (crReportObject.Kind == ReportObjectKind.SubreportObject)
                                {
                                    SubreportObject crSubreportObject = (SubreportObject)crReportObject;
                                    //open the subreport object and logon as for the general report 
                                    ReportDocument crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName);

                                    Tables SubCrTables = crSubreportDocument.Database.Tables;
                                    foreach (CrystalDecisions.CrystalReports.Engine.Table SubCrTable in SubCrTables)
                                    {
                                        crtableLogoninfo = SubCrTable.LogOnInfo;
                                        crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                                        SubCrTable.ApplyLogOnInfo(crtableLogoninfo);

                                    }
                                }
                            }
                        }

                        readDiamondBillReport.Refresh();

我终于发现,应用登录信息和刷新报告都不是问题。但这是我用来在水晶报告中设置水印的大图片对象。

我有 10 份报告使用此图像作为水印。我删除了带水印的图像,现在解决了以下问题:

  1. 项目构建得非常非常快。之前构建需要大约 1 分钟,现在已大幅缩短至 8-10 秒。

  2. 对项目的任何更改,尤其是对报告的更改都会更快地保存。

  3. 我曾经得到过“没有足够的存储空间来完成此操作” https://stackoverflow.com/questions/6626056/not-enough-storage-is-available-to-complete-this-operation经过一两次构建后。我必须重新启动 VS,并为每个构建祈祷。

  4. Crystal Reports 在 CrystalReportViewer 上显示得更快,而且objrpt.PrintToPrinter工作速度快 500 倍。

希望这些观点能够对各位程序员有所帮助。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

当数据库日志记录信息应用于每个 Crystal Reports 部分时,应用程序运行缓慢 的相关文章