コード スニペット: 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 つのサブスクリプション
この例を使用するには
クライアント コンピューターで Visual Studio を開始し、次に新しい C# Microsoft Office アプリケーション アドイン プロジェクトを作成します。プロジェクトを作成するときに、[.NET Framework 3.5] を選択します。
[表示] メニューから、[プロパティ ページ] を選択してプロジェクト プロパティを表示します。
[ビルド] タブから、[プラットフォーム ターゲット] で、[Any CPU] を選択します。
プロジェクト プロパティ ウィンドウを閉じます。
[ソリューション エクスプローラー] の [参照設定] で、[System] と [System.Core] を除いて、すべてのプロジェクト参照を削除します。
プロジェクトに以下の参照を追加します。
Microsoft.Office.BusinessApplications.Runtime
Microsoft.BusinessData
System.Windows.Forms
以下のステートメントで既存の using ステートメントを置換します。
using System; using Microsoft.BusinessData.Offlining; using Microsoft.Office.BusinessData.Offlining; using System.Windows.Forms; using System.Collections.Generic; using Microsoft.BusinessData.Runtime;
この手順の最後に示すコードで、アドインの起動イベントのコードを置換します。
有効な値で <entityNamespace>、<entityName>、<viewName>、および <subscriptionName> のプレースホルダー値を置換します。
プロジェクトを保存します。
プロジェクトをコンパイルして、実行します。
これにより 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()