コード スニペット: BCS キャッシュ サブスクリプションのメンバーを取得する 2

最終更新日: 2010年5月13日

適用対象: SharePoint Server 2010

この記事の内容
説明
前提条件
この例を使用するには

説明

以下の例では、クライアント上にある Business Connectivity Services のキャッシュ サブスクリプションのメンバーを取得する方法を説明します。

前提条件

  • サーバーにインストールされた Microsoft SharePoint Server 2010 あるいは Microsoft SharePoint Foundation 2010

  • クライアント コンピューターにインストールされた Microsoft Office Professional Plus 2010 と Microsoft .NET Framework 3.5

  • Microsoft Visual Studio

  • Business Connectivity Services クライアント キャッシュでの少なくとも 1 つのサブスクリプション

この例を使用するには

  1. クライアント コンピューターで Visual Studio を開始し、次に新しい C# Microsoft Office アプリケーション アドイン プロジェクトを作成します。プロジェクトを作成するときに、[.NET Framework 3.5] を選択します。

  2. [表示] メニューから、[プロパティ ページ] を選択してプロジェクト プロパティを表示します。

  3. [ビルド] タブから、[プラットフォーム ターゲット] で、[Any CPU] を選択します。

  4. プロジェクト プロパティ ウィンドウを閉じます。

  5. [ソリューション エクスプローラー] の [参照設定] で、[System] と [System.Core] を除いて、すべてのプロジェクト参照を削除します。

  6. プロジェクトに以下の参照を追加します。

    1. Microsoft.Office.BusinessApplications.Runtime

    2. Microsoft.BusinessData

    3. System.Windows.Forms

  7. 以下のステートメントで既存の using ステートメントを置換します。

    using System;
    using Microsoft.BusinessData.Offlining;
    using Microsoft.Office.BusinessData.Offlining;
    using System.Windows.Forms;
    using System.Collections.Generic;
    using Microsoft.BusinessData.Runtime;
    
  8. この手順の最後に示すコードで、アドインの起動イベントのコードを置換します。

  9. 有効な値で <entityNamespace>、<entityName>、<viewName>、および <subscriptionName> のプレースホルダー値を置換します。

  10. プロジェクトを保存します。

  11. プロジェクトをコンパイルして、実行します。

    これにより Office アプリケーションが開始し、このコードから出力されたメッセージが表示されます。

RemoteOfflineRuntime remoteOfflineRuntime = new RemoteOfflineRuntime();

// Read the subscription.
ISubscription sub = 
    remoteOfflineRuntime.GetSubscriptionManager().GetSubscription(
    "<entityNamespace>", "<entityName>", "<viewName>", "<subscriptionName>");

//Get subscription members.
using (IEnumerator<IEntityInstance> subMembers = sub.GetMembers())
{
    while (subMembers.MoveNext())
    {
        //Get the Synchronization Status of each member.
        MessageBox.Show((((IOfflineEntityInstance)subMembers.Current).SynchronizationStatus).ToString());
    }
}

関連項目

参照

RemoteOfflineRuntime

GetSubscriptionManager()

ISubscription

GetSubscription(String, String, String, String)

GetMembers()