on 04-10-2013 7:59 PM
using (ReportDocument repDoc1 = new ReportDocument())
{
DateTime dteStart = DateTime.Now;
dteDoneFlag = dteStart;
repDoc1.Load(strFileName);
DateTime dteEnd = DateTime.Now;
storeDelay(fcnDelayed( dteStart,dteEnd));
...
}
public static string fcnDelayed( DateTime dteStart, DateTime dteEnd)
{
TimeSpan strDiff = (dteEnd - dteStart);
string strMinutes = strDiff.Minutes.ToString();
string strSeconds = strDiff.Seconds.ToString();
string strMilSeconds = strDiff.Milliseconds.ToString();
return strMinutes + "Min" + strSeconds + "Sec" + strMilSeconds + "MS since: " + dteStart;
}
1Min32Sec141MS since: 4/10/2013 10:27:36 AM
0Min2Sec125MS since: 4/10/2013 10:27:35 AM
0Min0Sec984MS since: 4/10/2013 10:14:37 AM
1Min38Sec516MS since: 4/10/2013 10:07:23 AM
1Min39Sec672MS since: 4/10/2013 10:07:22 AM
0Min0Sec312MS since: 4/10/2013 9:45:08 AM
0Min0Sec187MS since: 4/10/2013 9:45:07 AM
0Min0Sec296MS since: 4/10/2013 9:45:03 AM
0Min0Sec171MS since: 4/10/2013 9:43:00 AM
1Min4Sec219MS since: 4/10/2013 9:36:41 AM
1Min5Sec187MS since: 4/10/2013 9:36:40 AM
1Min36Sec875MS since: 4/10/2013 9:34:42 AM
1Min38Sec578MS since: 4/10/2013 9:34:41 AM
1Min37Sec906MS since: 4/10/2013 9:34:41 AM
1Min39Sec735MS since: 4/10/2013 9:34:39 AM
1Min36Sec31MS since: 4/10/2013 9:06:46 AM
1Min37Sec172MS since: 4/10/2013 9:06:45 AM
0Min1Sec265MS since: 4/10/2013 9:00:55 AM
0Min1Sec328MS since: 4/10/2013 9:00:54 AM
1Min25Sec781MS since: 4/10/2013 9:00:19 AM
1Min26Sec891MS since: 4/10/2013 9:00:18 AM
I tried every solution I could find, to include subreport, printer, and running a throw away report, but no consistant solution was found. Threading one report first seems to help the latter most of the time but still undependable.
Your help will be greatly appreciated.
Hugh
Hello Hugh
First, make sure you are using Service Pack 5:
http://scn.sap.com/docs/DOC-7824
Next. I am not sure what the load process is. E.g.; on 1st load of a report, you will notice a that there is a longer delay as opposed to refreshing or loading a 2nd report.
So, I suppose the question is which of the following scenarios are you testing;
A)
Start the exe that loads the report
Close the report
View the report again without restarting the app
B)
Start the exe that loads the report
Close the app
Restart the app
In A, you'd have an initial slow report load. Subsequent loads would be faster.
In B, all report loads would be slow (equivalent to first load in A).
Oh. Also, don't test in the VS IDE. Test a compiled exe (it was my assumption that you are using compiled exe, but...)
- Ludek
Follow us on Twitter
Got Enhancement ideas? Try the SAP Idea Place
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for (int Index_I = 0; Index_I < intParams; Index_I++)
{
repDoc.SetParameterValue(repDoc.ParameterFields[Index_I].Name, "SomeValue");
}
// Logon to the database
repDoc.SetDatabaseLogon(strDBUserName, strPwd);
// display the report
this.crViewer.ReportSource = rdRtnVal;
<br>You wrote:>First, make sure you are using Service Pack 5
On April 1st I installed CRforVS_13_0_5.exe on my workstation where I run Visual Studio 2012.
and on the server I installed the contents of :
http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_redist_install_64bit_13_0_5.zip
Well, all I can say is; the Universe works in weird ways - not sure about the wonderful part.
Anyhow, I am just in the process of "writing" an article on how this threading actually works. It's a bit counterintuitive, but threading will produce just the results you are seeing. I am attaching a beat of the article. The issue was actually investigated by someone with more gray mater than me. And he penned his results in this article. All I'm going to do is rewrite is so it's nice looking and then publish it.
Download the attachment. Unzip it, rename the unzipped file to *.DOC and have a read.
- Ludek
Thank you for your assistance.
It appears that our problem was solved by:
Phase 1:
- Installed the latest Crystal Reports
- Used a thread to start loading the report and another to run the report for display (this fixed 80 percent of our noticable slow down)
- Revising the thread process to verify the first thread not only stared but has 5000 milleseconds head start before alowing the second thread to start loading.
- Capturing the load times for each report to use in phase 2
Phase 2: Looked closely at each report that continued to have long load times identified in phase 1 :
- Fixed printer issues (see below)
- Removed replaced if statements in queries with case statements
- Stopped reports from storing data
- Fixed subreports
Phase 3: Once problem reports showed significant improvment, we made the same changes as in Phase 2 to all of our Crystal Reports report files bringing our time to load into the milliseconds.
Load times example:
0Min0Sec640MS since: 4/11/2013 3:35:22 PM
0Min0Sec578MS since: 4/11/2013 3:28:07 PM
0Min0Sec406MS since: 4/11/2013 3:26:58 PM
0Min0Sec453MS since: 4/11/2013 3:26:49 PM
0Min0Sec859MS since: 4/11/2013 3:23:42 PM
0Min0Sec499MS since: 4/11/2013 3:00:29 PM
0Min0Sec93MS since: 4/11/2013 2:43:30 PM
0Min0Sec250MS since: 4/11/2013 2:42:39 PM
0Min0Sec359MS since: 4/11/2013 2:42:32 PM
0Min0Sec359MS since: 4/11/2013 2:41:02 PM
0Min0Sec93MS since: 4/11/2013 2:37:20 PM
0Min0Sec109MS since: 4/11/2013 2:35:27 PM
0Min0Sec281MS since: 4/11/2013 2:27:15 PM
0Min0Sec437MS since: 4/11/2013 2:23:41 PM
0Min0Sec546MS since: 4/11/2013 2:13:54 PM
0Min0Sec640MS since: 4/11/2013 2:11:47 PM
0Min0Sec468MS since: 4/11/2013 1:59:54 PM
0Min0Sec500MS since: 4/11/2013 1:58:38 PM
0Min0Sec390MS since: 4/11/2013 1:56:20 PM
0Min0Sec468MS since: 4/11/2013 1:53:15 PM
0Min0Sec671MS since: 4/11/2013 1:45:20 PM
0Min0Sec656MS since: 4/11/2013 1:40:57 PM
Here is the research that brought me to this point:
Could be the Report is looking for the default printer when the report was loaded or it may be trying to connect to the original datasource again when the report was created if you have any of the Verify Database Options enabled in the report.
Thank you
Don
Don Williams
http://support.resortdata.com/Customers/Knowledge/KB-RDPWin/KWin0007.htm
Some Crystal Reports were loading very slowly in both RDPWin and in the Crystal Designer. The problem usually only manifests itself when there are subreports in the report. The more subreports, the longer the load time. The owner statement report was taking almost a minute to load.
The real problem is that Crystal Reports use the printer driver to format the report. This printer driver is stored as part of the report. Some printer drivers cause the formatting to take a long time. By defining "No Printer" as part of the main report and ALL subreports, a generic driver is used, which is much faster for formatting. This does not effect the format of the report, when it is finally printed since the driver for the printer chosen at this time is used. With the owner statement reconfigured, it now takes less than a second to load.
Subreports that are an external file have one copy on the disk in the report file and another copy in the main report. The two subreports are not the same. If changes are made to the external file, the copy in the main report is not changed. The subreport must be re-imported in order to get the new changes. So, all the subreport external files must be changed to No Printer and then re-imported into the main report. The steps below outline this procedure.
Reports that don't have and subreports seem to load quickly with or without the "No Printer" being checked, so changing those reports is optional. All RDP standard Crystal Reports will be changed to the "No Printer" setting.
Main Report:
Modify All Subreports:
Continue with Main Report:
http://support.resortdata.com/Customers/Knowledge/KB-RDPWin/KWin0007.htm
Re: Crystal Reports slow loading/formatting
Ludek Uher Dec 19, 2008 3:58 PM (in response to DARRYL SMITH)
There is a number of great posts on this forum regarding load times for a report. Typically, these are the places to start to troubleshoot the issue:
1) disable verify on first refresh option (File | Report Options)
2) disable verify stored procedure on first refresh option (File | Report Options)
3) ole object not where the report expects it to be
4) subreport option "Re-import when opening" is enabled (right click the subreport(s), choose format subreport, look at the subreport tab)
5) Specific printer is set for the report and the printer does not exist. Try the "No printer" option (File | Page setup)
For your situation, I'd start with investigating at point #5.
Other places to look for ideas:
Better user experience for slow reports (loading in background, progressbar
Loss of Performance (Start delay 2min.) after Migrating to CR2008
If none of the above helps, confirm that you are using [the latest version of crystal]. Also, is this a web or a win app?
Ludek
http://scn.sap.com/thread/1173036
Here is an example of the code I used to do the thread and syncronize them so it was consistently loading the first (throw away report) one first:
I hope this helps the next guy or gal fighting VS and Crystal Reports delays
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web;
using System.Threading;
public partial class threadCRpt : System.Web.UI.Page
{
public static string strFileName = string.Empty;
public static DateTime dteDoneFlag = DateTime.Now.AddDays(1);
public static int intDelay = 6000;
protected void Page_Load(object sender, EventArgs e)
{
Response.Buffer = true;
...
strFileName = MapPath(strReportURL);
// Start the throw away report load
Thread td1;
ThreadStart start = new ThreadStart(RptThread1);
td1 = new Thread(start);
td1.Start();
// Call as a function the second, no new thread needed.
RptThread2();
}
}
// Threads can not accept parameters... so passing variable as globals
protected void RptThread1()
{
using (ReportDocument repDoc1 = new ReportDocument())
{
DateTime dteStart = DateTime.Now;
// Set date flag so RptThread2 knows I am starting the first load
dteDoneFlag = dteStart;
repDoc1.Load(strFileName);
DateTime dteEnd = DateTime.Now;
// nothing follows as this is used to load a report and nothing else
}
}
protected void RptThread2()
{
DateTime dteStart = DateTime.Now;
try
{
using (ReportDocument repDoc = new ReportDocument())
{
int intCnt = 0;
// Waiting on first thread to begin.
// Wait intdelay time extra (1000 ms was not enough so using 6000ms)
// Without enough delay both reports load slow
while (!(dteDoneFlag.AddMilliseconds(intDelay) < dteStart))
{
intCnt++;
Master.lblNoticeText += ".";
Thread.Sleep(intDelay);
dteStart = DateTime.Now;
if (intCnt > 10)
break;
}
repDoc.Load(strFileName);
DateTime dteEnd = DateTime.Now;
...
}
}
...
}
Followup: All of our reports are running consistently under 10 seconds and most are running in less then 1 second.
As we discussed the problem we had a point that should be noted came out. Even though I had fixed all the suggested issues with one report that report as well as most others remained mostly slow until we implemented the threading and identified the 6 reports that were causing all to run slow. Once we fixed those 6, all reports began running fast.
This is a hard concept to get my head around, so I thought it worth sharing. Why would the sins of a few cause all to be slow?
Also, I do not think I need the threading construct anymore but encourage anyone with slow reports to use it to help identify the few that are causing the problem.
Hugh
Followup: Shortly after I posted the last Followup we began having issues with the Application Pool. The wierd thing was the .Net application would run just fine but Crystal would hang or stall and the quickest way to get it producing reports again was to Recycle the Application Pool that the site was in.
I tried adjusting the recycling and that seemed to lengthen the duration between hangs but then IIS got so bound up I had to do an iisreset because the app pool would not recycle and when stopped you could not restart the app pool. Rebooting the server also worked to get things working.
Then after much searching I found a side comment "change the managed pipeline mode of App pool used by app to Classic", so I searched on application pool and found someone say that Crystal has a know problem with application pools running in integrated mode. I searched on why but could not find anything.
Hopefully we are fixed now...
Hugh
Today we also noticed that if you go back into reports that you fix the printer in and preview that report, the "No Printer" checkbox gets de-selected and has to be re-selected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.