cancel
Showing results for 
Search instead for 
Did you mean: 

Combining push model with ICachedReport

Former Member
0 Kudos

I have an ASP.NET website project with many strongly-typed reports containing c-sharp classes deriving from ReportClass.  Each of these classes have a corresponding cache class like CachedMyReportName that implements the ICachedReport interface, which brings me to my question.

Most of the reports are utilizing the push model to be handed an ADO.NET datatable like this:

reportImplantHistoryPrint = new ReportImplantHistoryPrint();

DataSet reportData = history.GetHistoryData(Session["ImplantsToPrint"].ToString(), user.UserID);

reportImplantHistoryPrint.Database.Tables[0].SetDataSource(reportData.Tables[0]);

DataSet dsbarcode = history.LoadMultipleImpantBarcode(Session["ImplantsToPrint"].ToString());

reportImplantHistoryPrint.Subreports["ReportBarcodeImplant.rpt"].Database.Tables[0].SetDataSource(dsbarcode.Tables[0]);

....

This code is included in a method that gets called every single time any user clicks a button to view the report.

From reading documentation, I understand that if I want to use the built-in caching offered by the CS file, I should instead be instantiating CachedReportImplantHistoryPrint, which looks like this:

[System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.ExportOptions), "report.bmp")]

    public class CachedReportImplantHistoryPrint : Component, ICachedReport {

        public CachedReportImplantHistoryPrint()

        {

        }

      

        [Browsable(false)]

        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]

        public virtual bool IsCacheable {

            get {

                return true;

            }

            set {

                //

            }

        }

      

        [Browsable(false)]

        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]

        public virtual bool ShareDBLogonInfo {

            get {

                return false;

            }

            set {

                //

            }

        }

      

        [Browsable(false)]

        [DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]

        public virtual System.TimeSpan CacheTimeOut {

            get {

                return CachedReportConstants.DEFAULT_TIMEOUT;

            }

            set {

                //

            }

        }

      

        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() {

            ReportImplantHistoryPrint rpt = new ReportImplantHistoryPrint();

            rpt.Site = this.Site;

            return rpt;

        }

      

        public virtual string GetCustomizedCacheKey(RequestContext request) {

            String key = null;

           // // The following is the code used to generate the default

            // // cache key for caching report jobs in the ASP.NET Cache.

            // // Feel free to modify this code to suit your needs.

            // // Returning key == null causes the default cache key to

            // // be generated.

            //

            // key = RequestContext.BuildCompleteCacheKey(

            //     request,

            //     null,       // sReportFilename

            //     this.GetType(),

            //     this.ShareDBLogonInfo );

            return key;

        }

    }

My main question is if I want to use caching with ICachedReport, where should my calls to SetDataSource() on my main report and subreports go?  I don't want my database to continue resetting the datasrouce every time a user views a report.  That seems to defeat the purpose of caching.  Should I place these calls directly in the implementation of this interface, maybe in CreateReport()?  Or is this interface intended only for caching the ReportDocument object itself with the assumption that I've implemented my own caching/persistence mechanism for the report's data?  Finally, should CachedReportImplantHistoryPrint in my example be static since this report is reusable for any user without altering parameters or credentials?

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi John

Please see the following:

KBA 1218912 - How to use the 'ICachedReport' interface in a .NET application

KBA 1670041 - How to persist Crystal Reports using Cache in a custom .NET web application?

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow me on Twitter

Answers (0)