ICachedReport Interface

This interface identifies an implementing class as cacheable into the ASP.NET Cache object using the Crystal Reports SDK.

Namespace CrystalDecisions.ReportSource Assembly CrystalDecisions.ReportSource (CrystalDecisions.ReportSource.dll)

Syntax

'Declaration
Public MustInherit Interface ICachedReport
public abstract interface ICachedReport

Remarks

To use the pre-built caching mechanism, implement this interface on your own class. The methods and properties you implement will get called by the ReportDocument object model to retrieve the information necessary to cache your reports. Set an instance of your class to the ReportSource property of the CrystalReportViewer control to enable caching.

Example

The following example creates a class that implements the ICachedReport interface.

'Declaration

      Imports System
      Imports System.ComponentModel
      Imports CrystalDecisions.CrystalReports.Engine
      Imports CrystalDecisions.ReportSource
      Imports CrystalDecisions.Shared
      
      Public Class CachedReport
         Inherits Component
         Implements ICachedReport
      
         Private blIsCacheable As Boolean
         Private blShareDBLogonInfo As Boolean
         Private tsCacheTimeOut As TimeSpan
         Private Report As New ReportDocument()
         Private reportName As String
      
         Public Sub New(ByVal s As String)
            reportName = s
         End Sub
      
         Public Overridable Property IsCacheable() As [Boolean] _
            Implements CrystalDecisions.ReportSource.ICachedReport.IsCacheable
            Get
                Return blIsCacheable
            End Get
            Set(ByVal Value As [Boolean])
                blIsCacheable = Value
            End Set
         End Property
      
         Public Overridable Property ShareDBLogonInfo() _
            As [Boolean] Implements _
            CrystalDecisions.ReportSource.ICachedReport.ShareDBLogonInfo
            Get
              Return blShareDBLogonInfo
            End Get
            Set(ByVal Value As [Boolean])
               blShareDBLogonInfo = Value
            End Set
         End Property
      
         Public Overridable Property CacheTimeOut() _
            As TimeSpan Implements _
            CrystalDecisions.ReportSource.ICachedReport.CacheTimeOut
            Get
               Return tsCacheTimeOut
            End Get
            Set(ByVal Value As TimeSpan)
               tsCacheTimeOut = Value
            End Set
         End Property
      
      
         Public Overridable Function CreateReport() _
            As ReportDocument Implements _
            CrystalDecisions.ReportSource.ICachedReport.CreateReport
            Report.Load _
               (reportName, OpenReportMethod.OpenReportByTempCopy)
            Report.Site = Me.Site
            Return Report
         End Function
      
         Public Overridable Function GetCustomizedCacheKey _
            (ByVal request As RequestContext)
            As [String] Implements _
            CrystalDecisions.ReportSource. _
            ICachedReport.GetCustomizedCacheKey
      
            Dim key As [String] = Nothing
   
            key = RequestContext.BuildCompleteCacheKey _
               (request, reportName, Me.GetType(), Me.ShareDBLogonInfo)
            Return key
         End Function
      End Class
      using System;
      using System.ComponentModel;
      using CrystalDecisions.CrystalReports.Engine;
      using CrystalDecisions.ReportSource;
      using CrystalDecisions.Shared;
      
      public class CachedReport : Component, ICachedReport
      {
         protected ReportDocument reportDocument = new ReportDocument();
         protected bool isCacheable;
         protected bool shareDBLogonInfo;
         protected string reportName;
         protected TimeSpan cacheTimeOut;
      
         public CachedReport(string s)
         {
            reportName = s;
         }
      
         public virtual Boolean IsCacheable
         {
            get
            {
               return isCacheable;
            }
            set
            {
               isCacheable = value;
            }
         }
         public virtual Boolean ShareDBLogonInfo
         {
            get
            {
               return shareDBLogonInfo;
            }
            set
            {
               shareDBLogonInfo = value;
            }
         }
      
         public virtual TimeSpan CacheTimeOut
         {
            get
            {
               return cacheTimeOut;
            }
            set
            {
               cacheTimeOut = value;
            }
         }
      
         public virtual ReportDocument CreateReport()
         {
            reportDocument.Load
               (reportName, OpenReportMethod.OpenReportByTempCopy);
            reportDocument.Site = this.Site;
            return reportDocument;
         }
      
         public virtual String GetCustomizedCacheKey
            (RequestContext request)
         {
            String key = null;
      
            key = RequestContext.BuildCompleteCacheKey(
                request,
                reportName,
                this.GetType(),
                this.ShareDBLogonInfo);
             return key;
         }
      }

Inheritance Hierarchy

ICachedReport

Version Information

Crystal Reports Basic for Visual Studio 2008

Supported since: Crystal Reports for Visual Studio .NET 2002

See Also

Reference

ICachedReport Members
CrystalDecisions.ReportSource Namespace