此介面會將實作類別視為能夠存入使用 Crystal Reports SDK 之 ASP.NET Cache 物件的類別。
如需這個類型的成員清單,請參閱 ICachedReport 成員。
ICachedReport
[Visual Basic]
Public Interface ICachedReport
Inherits System.Object
[C#]
public interface ICachedReport : System.Object
註解
若要使用預先建立的快取機制,請在您的類別上實作這個介面。ReportDocument 物件模型將會呼叫您實作的方法和屬性,以擷取快取報表所需的資訊。請將您類別的執行個體設為 CrystalReportViewer 控制項的 ReportSource 屬性以啟用快取。
範例
下列範例會建立實作 ICachedReport 介面的類別。
[Visual Basic]
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
[C#]
using System;
using System.ComponentModel;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
public class CachedReport : Component, ICachedReport
{
protected ReportDocument Report = 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()
{
Report.Load
(reportName, OpenReportMethod.OpenReportByTempCopy);
Report.Site = this.Site;
return Report;
}
public virtual String GetCustomizedCacheKey
(RequestContext request)
{
String key = null;
key = RequestContext.BuildCompleteCacheKey(
request,
reportName,
this.GetType(),
this.ShareDBLogonInfo);
return key;
}
}
需求
命名空間 CrystalDecisions.ReportSource
組件 CrystalDecisions.ReportSource (CrystalDecisions.ReportSource.dll)
請參閱
ICachedReport 成員 | CrystalDecisions.ReportSource 命名空間
©2005 Business Objects SA All rights reserved
| Business Objects SA http://www.china.businessobjects.com/ 支援的服務 http://www.china.businessobjects.com/BOindex/support/ |