次の方法で共有


ICachedReport インターフェイス

キャッシュを使用すると、Web フォーム ビューアでレポートをさらに効率的に表示できます。Web プロジェクトに追加された厳密に型指定されたレポート、または ReportDocument コンポーネントをキャッシュすることができます。

[Visual Basic]

Public Interface ICachedReport

[C#]

public interface ICachedReport

[C++]

__gc public interface ICachedReport

[VJ#]

public interface ICachedReport

解説

あらかじめ組み込まれているキャッシュ メカニズムを使用するには、このインターフェイスを独自のクラスに実装します。実装したメソッドとプロパティは、レポートのキャッシュに必要な情報を取得するために、Report Engine に呼び出されます。キャッシュを有効にするには、ビューアの 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

' ICachedReport インターフェイスに定義されるプロパティを宣言します。

' レポートがキャッシュ可能かどうかを示す 
'  値を取得または設定します。 
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

   ' レポートが ASP.NET キャッシュにとどまる時間 
   '  を示す値を取得または設定します。
   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

   ' ICachedReport インターフェイスに定義されるメソッドを宣言します。

   ' レポートのインスタンスを作成して返します。
   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
      ' 次のコードは、レポート ジョブを ASP .NET キャッシュにキャッシュするための
      '  デフォルトのキャッシュ キーを生成します。
      ' このコードを必要に応じて自由に変更してください。
      ' 戻りキー ==  NULL を指定すると、デフォルトのキャッシュ キーが
      '  生成されます。

      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;
   }

   // ICachedReport インターフェイスに定義されるプロパティを宣言します。

   // レポートがキャッシュ可能かどうかを示す 
   //  値を取得または設定します。 
   public virtual Boolean IsCacheable 
   {
      get 
      {
         return isCacheable;
      }
      set 
      {
         isCacheable = value; 
      }
   }
   // レポート インスタンスが 
   //  個々のデータベース ログオンを区別するかどうかを 
   //  示す値を取得または設定します。
   public virtual Boolean ShareDBLogonInfo 
   {
      get 
      {
         return shareDBLogonInfo;
      }
      set 
      {
          shareDBLogonInfo = value;
      }
   }

   // レポートが ASP.NET キャッシュにとどまる時間 
   //  を示す値を取得または設定します。
   public virtual TimeSpan CacheTimeOut 
   {
      get 
      {
        return cacheTimeOut;
      }
      set 
      {
         cacheTimeOut = value; 
      }
   }

   // ICachedReport インターフェイスに定義されるメソッドを宣言します。

   // レポートのインスタンスを作成して返します。
   public virtual ReportDocument CreateReport() 
   {
      Report.Load
      (reportName, OpenReportMethod.OpenReportByTempCopy);
      Report.Site = this.Site;
      return Report;
   }

   // カスタマイズされたキャッシュ キーを作成して返します。
   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.
      // このコードを必要に応じて自由に変更してください。
      // 戻りキー ==  NULL を指定すると、デフォルトのキャッシュ キーが
      //  生成されます。

      key = RequestContext.BuildCompleteCacheKey(
          request,
          reportName,
          this.GetType(),
          this.ShareDBLogonInfo );
       return key;
   }
}

[C++]

// これはメイン ヘッダー ファイルです。
// MyWebReporting.h
#pragma once
#using <CrystalDecisions.CrystalReports.Engine.dll>
#using <CrystalDecisions.ReportSource.dll>
#using <CrystalDecisions.Shared.dll>
#using <CrystalDecisions.Web.dll>
#using <mscorlib.dll>
#using <System.dll>

using namespace CrystalDecisions::CrystalReports::Engine;
using namespace CrystalDecisions::ReportSource;
using namespace CrystalDecisions::Shared;
using namespace CrystalDecisions::Web;
using namespace System;
using namespace System::ComponentModel;

//CachedReport クラスを開始します。
public __gc class CachedReport: 
public Component, 
public ICachedReport 
{
public:

   virtual ~CachedReport();
   CachedReport(String* s);

   // ICachedReport インターフェイスに定義されるプロパティを宣言します。
   __property virtual Boolean get_IsCacheable()
   {return getIsCacheable();};
   __property virtual void set_IsCacheable(Boolean value) 
   {setIsCacheable(value);};
   
   __property virtual Boolean get_ShareDBLogonInfo() 
   {return getShareDBLogonInfo();};
   __property virtual void set_ShareDBLogonInfo(Boolean value) 
   {setShareDBLogonInfo(value);};

   __property virtual TimeSpan get_CacheTimeOut()
   {return getCacheTimeOut();};
   __property virtual void set_CacheTimeOut(TimeSpan value) 
   {setCacheTimeOut(value);};

   // ICachedReport インターフェイスに定義されるメソッドを宣言します。
   virtual String* GetCustomizedCacheKey
   (RequestContext* request);
   virtual ReportDocument* CreateReport();

private:
   // 変数を宣言します。
   ReportDocument * Report;
   Boolean isCacheable;
   Boolean shareDBLogonInfo;
   String* reportName;
   TimeSpan cacheTimeOut;
   
   // プロパティが使用する関数を 
   //  宣言します。
   Boolean getIsCacheable();
   void setIsCacheable(Boolean value);
   
   Boolean getShareDBLogonInfo();
   void setShareDBLogonInfo(Boolean value);

   TimeSpan getCacheTimeOut();
   void setCacheTimeOut(TimeSpan value);
   
}; //CachedReport クラスを終了します。

// これはメイン DLL ファイルです。
// WebReporting.cpp
#include "stdafx.h"
#include "MyWebReporting.h"

CachedReport::CachedReport(String* s)
{
   // レポートへのパスを設定します。
   reportName = s;
};

// 
CachedReport::~CachedReport()
{
   return;
};

// レポートがキャッシュ可能かどうかを示す 
//  値を取得または設定します。 
Boolean CachedReport::getIsCacheable()
{
   return isCacheable;
};
void CachedReport::setIsCacheable(Boolean value)
{
   isCacheable = value;
};

// レポート インスタンスが 
//  個々のデータベース ログオンを区別するかどうかを 
//  示す値を取得または設定します。
Boolean CachedReport::getShareDBLogonInfo()
{
   return shareDBLogonInfo;
};
void CachedReport::setShareDBLogonInfo(Boolean value)
{
   shareDBLogonInfo = value;
};

// レポートが ASP.NET キャッシュにとどまる時間 
//  を示す値を取得または設定します。
TimeSpan CachedReport::getCacheTimeOut()
{
   return cacheTimeOut;
};
void CachedReport::setCacheTimeOut(TimeSpan value)
{
   cacheTimeOut = value;
};

// レポートのインスタンスを作成して返します。
ReportDocument* CachedReport::CreateReport() 
{
   Report = new ReportDocument();
   Report->Load
   (reportName,OpenReportMethod::OpenReportByTempCopy);
   Report->Site = this->Site;
   return Report;
}
// カスタマイズされたキャッシュ キーを作成して返します。
String* CachedReport::GetCustomizedCacheKey
(RequestContext* request) 
{
   String* key = 0;
   // 次のコードは、レポート ジョブを ASP .NET キャッシュにキャッシュするための
   //  デフォルトのキャッシュ キーを生成します。
   // このコードを必要に応じて自由に変更してください。
   // 戻りキー ==  NULL を指定すると、デフォルトのキャッシュ キーが
   //  生成されます。
   key = RequestContext::BuildCompleteCacheKey
   (request, reportName,GetType(), false);

   return key;
};

[VJ#]

import System.*;
import System.ComponentModel.*;
import CrystalDecisions.CrystalReports.Engine.*;
import CrystalDecisions.ReportSource.*;
import CrystalDecisions.Shared.*;

public class CachedReport extends Component implements ICachedReport
{
   // 変数を宣言します。
   protected ReportDocument Report = new ReportDocument();
   protected boolean isCacheable;
   protected boolean shareDBLogonInfo;
   protected String reportName;
   protected System.TimeSpan cacheTimeOut;

   public CachedReport() 
   {
      // レポートへのパスを設定します。
   }

   // ICachedReport インターフェイスに定義されるプロパティを宣言します。

   // レポートがキャッシュ可能かどうかを示す 
   //  値を取得または設定します。 

   public boolean get_IsCacheable()
    {
        return true;
    }
   
   public void set_IsCacheable(boolean value)
    {

}   // レポート インスタンスが 
   //  個々のデータベース ログオンを区別するかどうかを 
   //  示す値を取得または設定します。

    public boolean get_ShareDBLogonInfo()
    {
        return false;
    }

    public void set_ShareDBLogonInfo(boolean value)
    {
        // 
    }

   // レポートが ASP.NET キャッシュにとどまる時間 
   //  を示す値を取得または設定します。

    public System.TimeSpan get_CacheTimeOut()
    {
        return CachedReportConstants.DEFAULT_TIMEOUT;
    }

    public void set_CacheTimeOut(System.TimeSpan value)
    {
        
    }

   // ICachedReport インターフェイスに定義されるメソッドを宣言します。
   // レポートのインスタンスを作成して返します。

   public CrystalDecisions.CrystalReports.Engine.ReportDocument 
   CreateReport() 
   {
      Report.Load
      (reportName, OpenReportMethod.OpenReportByTempCopy);
      Report.set_Site(this.get_Site());
      return Report;
   }

   // カスタマイズされたキャッシュ キーを作成して返します。
   public String GetCustomizedCacheKey
   (RequestContext request) 
   {
      String key = null;
   // 次のコードは、レポート ジョブを ASP .NET キャッシュにキャッシュするための
   //  デフォルトのキャッシュ キーを生成します。
   // このコードを必要に応じて自由に変更してください。
   // 戻りキー ==  NULL を指定すると、デフォルトのキャッシュ キーが
   //  生成されます。

      key = RequestContext.BuildCompleteCacheKey(
          request,
          reportName,
          this.GetType(),
          this.get_ShareDBLogonInfo());
       return key;
   }
}

要件

名前空間 :CrystalDecisions.ReportSource

プラットフォーム : Windows 98、Windows NT 4.0、Windows Millennium Edition、Windows 2000、Windows XP

アセンブリ : CrystalDecisions.Reportsource(CrystalDecisions.Reportsource.dll 内)

関連項目

ICachedReport のメンバ | CrystalDecisions.ReportSource 名前空間