Crystal Reports Export Takes Longer After Inactivity in Web API 2 Application

12 Views Asked by At

I have a Web API 2 application deployed on IIS, where I utilize Crystal Reports to export .rpt files to PDF format. In my production environment, I'm encountering an issue where the export operation takes significantly longer (around 2 minutes) for the first request after a period of inactivity, even when the report contains only a few records. Subsequent requests, however, are much faster and typically complete within 12 seconds.

This issue seems to occur specifically when there is a gap between requests, such as 1 hour or more. I'm struggling to understand why there's such a drastic difference in export times between the first request and subsequent requests.

The .rpt file used for export contains queries that select data from functions in another schema. structured as SELECT * FROM table(x.fn_y(param)).

Here's a simplified version of the code snippet responsible for the export operation:


public class ReportExporter
{
    public void ExportReport(string reportFilePath, string exportFilePath)
    {
        // Load the report document
        ReportDocument reportDocument = new ReportDocument();
        reportDocument.Load(reportFilePath);

        // Set export options
        ExportOptions exportOpts = new ExportOptions();
        exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat;
        exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
        exportOpts.ExportDestinationOptions = new DiskFileDestinationOptions { DiskFileName = exportFilePath };

        // Perform export operation
        reportDocument.Export(exportOpts);

        // Report export completed
        Console.WriteLine("Report export completed.");
    }
}

I'm struggling to identify the root cause of this delay and how to address it effectively. Any insights or suggestions on how to diagnose and resolve this issue would be greatly appreciated.

0

There are 0 best solutions below