开发者

Is there any way to speed up crystal reports generation?

We are running a reporting web application that allows the user to select a few fields and a crystal report is generated based off of the fields selected. The SQL that is generated for the most complex report will return the data in < 5 seconds, however it takes the report and average of 3 minutes to run, sometimes longer causing a time out. We are running VS2010. The reports are basically set up out of the box with no real manipulations or computations being done, just displaying th开发者_StackOverflow中文版e data in a nice format. Is there anything we can try to speed it up, pre-loading a dummy report to load the dlls, some hack to make crystal run faster, anything?

EDIT: Code Added to show the databinding

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        string strFile = Server.MapPath(@"AwardStatus.rpt");
        CrystalReportSource1.Report.FileName = strFile;
        DataTable main = Main();
        CrystalReportSource1.ReportDocument.SetDataSource(main);

        CrystalReportViewer1.HasCrystalLogo = false;

        CrystalReportSource1.ReportDocument.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, false, "pmperformance");

    }
}

private DataTable Main()
{
    Guid guidOffice = Office;
    CMS.Model.ReportsTableAdapters.ViewACTableAdapter rptAdapter = new CMS.Model.ReportsTableAdapters.ViewACTableAdapter();

    Reports.ViewAwardedContractsDataTable main = new Reports.ViewAwardedContractsDataTable();

    if (Office == new Guid())
    {
        IEnumerable<DataRow> data = rptAdapter.GetData().Where(d => UserPermissions.HasAccessToOrg(d.guidFromId, AuthenticatedUser.PersonID)).Select(d => d);
        foreach (var row in data)
        {
            main.ImportRow(row);
        }
    }
    else if (guidOffice != new Guid())
    {
        main = rptAdapter.GetDataByOffice(guidOffice);
    }
    else
    {
        main = new Reports.ViewACDataTable();
    }


    return main;
}

private Guid Office
{
    get
    {
        string strOffice = Request.QueryString["Office"];
        Guid guidOffice = BaseControl.ParseGuid(strOffice);

        if (!UserPermissions.HasAccessToOrg(guidOffice, AuthenticatedUser.PersonID))
        {
            return Guid.Empty;
        }
        else
        {

            return guidOffice;
        }
    }
}



protected void CrystalReportSource1_DataBinding(object sender, EventArgs e)
{
   //TODO
}


This may be a bit flippant, but possibly consider not using crystal reports... We had a fair bit of trouble with them recently (out of memory errors being one), and we've moved off to other options and are quite happy...


Here's what I would do:

Put clocks from the time you get the field choices from the user, all the way to when you display the report. See where your processing time is going up.

When you look at the clocks, there can be various situations:

  1. If Crystal Reports is taking time to fill the report, check how you're filling it. If you're linking the report fields directly to your data table, CR is probably taking time looking up the data. I suggest creating a new table (t_rpt) with dynamic columns (Field1, Field2,..FieldN) and pointing your report template to that table. I don't know if you're already doing this.

  2. If it's taking time for you to lookup the data itself, I suggest creating a view of your table. Even though a memory hog, this will make your lookup quick and you can delete the view once you're done.

If it's none of the above, let us know what your clocks show.


In terms of loading any large amount of data, you'll always want to use a stored procedure.

Outside of that, you WILL see a delay in the report running the first time the Crystal DLLs load. Yes, you can preload them as you mentioned and that will help some.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜