Urgent Information Required For reporting
Dear forum members .........
I am using crystal Report 10 for my reporting process.This reports contains multitple detail
sections and multiple subreports which are link with each other.My task is to make such an application which automatically hit a table in SQL server database in a particular time interval, as it get the record then it generate crystal report and then export it into Pdf format. All of this work is done through Windows Service.
The problem i am facing is that when my method load the report its taking 100% CPU usage.
How i can reduce this amount of CPU usage?
Method for loding report is a follows:
public static ReportDocument prepareReport(string ID)
{
ReportDocument crReportDocument,crSubreportDocument;
Sections crSections;
SubreportObject crSubreportObject;
ReportObjects crReportObjects;
ConnectionInfo crConnectionInfo;
Database crDatabase;
Tables crTables;
TableLogOnInfo crTableLogOnInfo;
crReportDocument = new ReportDocument();
crReportDocument.Load(ConfigurationSettings.AppSet tings["PathMainReport"].ToString(),CrystalDecisions.Shared.OpenReportMeth od.OpenReportByTempCopy);
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;
crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "FURQAN";
crConnectionInfo.DatabaseName = "flyingeagles";
crConnectionInfo.UserID ="crystal";
crConnectionInfo.Password = "cr";
foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
{
crTableLogOnInfo = aTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
aTable.ApplyLogOnInfo(crTableLogOnInfo); }
// THIS STUFF HERE IS FOR REPORTS HAVING SUBREPORTS
// set the sections object to the current report's section
crSections = crReportDocument.ReportDefinition.Sections;
// loop through all the sections to find all the report objects
foreach (Section crSection in crSections)
{
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)
{
crSubreportObject = (SubreportObject) crReportObject;
//open the subreport object and logon as for the general report
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject. SubreportName);
crDatabase = crSubreportDocument.Database;
crTables = crDatabase.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table aTable in crTables)
{
crTableLogOnInfo = aTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
aTable.ApplyLogOnInfo(crTableLogOnInfo);
}
}
}
}
crReportDocument.SetParameterValue("customer",1);
crReportDocument.SetParameterValue("@BookingID",ID );
//crReportDocument.SetParameterValue("ID",ID);
//crReportDocument.SaveAs(ConfigurationSettings.AppS ettings["PathAdminReport"].ToString()+"//Invoice_"+ID+".rpt");
CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new DiskFileDestinationOptions();
CrystalDecisions.Shared.DiskFileDestinationOptions crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crReportDocument.ExportOptions.ExportDestinationTy pe=CrystalDecisions.Shared.ExportDestinationType.D iskFile;
crReportDocument.ExportOptions.ExportFormatType=Cr ystalDecisions.Shared.ExportFormatType.PortableDoc Format;
DiskOpts.DiskFileName = ConfigurationSettings.AppSettings["PathAdminReport"].ToString()+"//Invoice_"+ID+".pdf";
crReportDocument.ExportOptions.DestinationOptions= DiskOpts;
crReportDocument.Export();
return crReportDocument;
}
Please reply soon..
Abdus Subhan
Abdus Subhan
|