次の方法で共有


変更ログの範囲

変更ログでは、コンテンツ データベース、サイト コレクション、Web サイト、リスト範囲という 4 つの異なる範囲で変更を照会できます。クライアントが関心を持つアプリケーションおよび範囲に応じて、どの範囲を使用する必要があるかを判断できます。たとえば、クライアントが Web サイト内の特定のリストに対する変更にのみ関心を持つ場合は、リスト範囲で変更を照会できます。一方、データベース全体にわたって変更を監視する必要がある場合は、コンテンツ データベース範囲で変更ログを照会できます。

一般に、クライアントが特定のオブジェクトに対する変更を監視する必要がある場合は、親オブジェクトの範囲で変更を照会できます。たとえば、Microsoft Office Outlook 2007 は SharePoint リスト内のアイテムに対する変更に関心があるため、複数のリストのリスト範囲で変更を照会します。また、SharePoint 検索は、データベース内のすべての変更を探す必要があるため、コンテンツ データベース範囲で変更を照会します。GetChanges メソッドを使用して、変更を照会できます。

次の例では、GetChanges メソッドを使用してサイト コレクションの変更を返すさまざまな方法を説明します。

Dim mySite As New SPSite("http://siteUrl")

' Initial snapshot of the Change Log at site collection scope.
Dim initToken As SPChangeToken = mySite.CurrentChangeToken

' After a certain time, once the site collection has changed, the 
' client can query for changes that occurred since the initial snapshot ' (in other words, since initToken). 

' Return all changes to the site collection.
Dim changes As SPChangeCollection = mySite.GetChanges()

' Return all changes since initToken.
Dim changes1 As SPChangeCollection = mySite.GetChanges(initToken)

' Final snapshot of the change log at the site collection scope.
Dim finalToken As SPChangeToken = mySite.CurrentChangeToken

' Return all changes from initToken to finalToken.
Dim changes2 As SPChangeCollection = mySite.GetChanges(initToken, finalToken)

' Query for specific types of changes.
Dim query As New SPChangeQuery(True, True)
Dim changes3 As SPChangeCollection = mySite.GetChanges(query)
SPSite mySite = new SPSite("http://siteUrl");
/* Initial snapshot of the Change Log at the site collection scope.*/
SPChangeToken initToken = mySite.CurrentChangeToken; 

/* After a certain time, once the site collection has changed, the client can query for changes that occurred since the initial snapshot (in other words, since initToken). */

/* Return all changes to the site collection.*/
SPChangeCollection changes = mySite.GetChanges();

/* Return all changes since initToken.*/
SPChangeCollection changes1 = mySite.GetChanges(initToken); 

/* Final snapshot of the change log at the site collection scope.*/
SPChangeToken finalToken = mySite.CurrentChangeToken; 

/* Return all changes from initToken to finalToken.*/
SPChangeCollection changes2 = mySite.GetChanges(initToken,finalToken); 

/* Query for specific types of changes.*/
SPChangeQuery query = new SPChangeQuery(true, true);
SPChangeCollection changes3 = mySite.GetChanges(query);