SPChangeCollection.LastChangeToken property
取得對應至最後一個變更集合中的變更語彙基元。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public ReadOnly Property LastChangeToken As SPChangeToken
Get
'用途
Dim instance As SPChangeCollection
Dim value As SPChangeToken
value = instance.LastChangeToken
public SPChangeToken LastChangeToken { get; }
Property value
Type: Microsoft.SharePoint.SPChangeToken
SPChangeToken 物件,表示上次變更語彙基元。
備註
傳回的變更語彙基元是位於Count – 1變更集合中索引的SPChange物件的ChangeToken屬性值。當您擷取的批次中的變更時,您可以使用同於起始點這個語彙基元的下一個批次。
Examples
下列範例是示範如何擷取目前的變更記錄檔中的所有變更的簡單的主控台應用程式。
using System;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite siteCollection = new SPSite("https://localhost"))
{
long total = 0;
SPChangeToken token = null;
// Get the first batch of changes.
SPChangeCollection changes = siteCollection.ContentDatabase.GetChanges(token);
// Loop until the end of the log is reached.
while (changes.Count > 0)
{
total += changes.Count;
// Go get another batch.
token = changes.LastChangeToken;
changes = siteCollection.ContentDatabase.GetChanges(token);
}
Console.WriteLine("{0:#,#} changes", total);
}
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}
}
Imports System
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using siteCollection As SPSite = New SPSite("https://localhost")
Dim total As Long = 0
Dim token As SPChangeToken = Nothing
' Get the first batch of changes.
Dim changes As SPChangeCollection = siteCollection.ContentDatabase.GetChanges(token)
' Loop until the end of the log is reached.
While changes.Count > 0
total += changes.Count
' Go get another batch.
token = changes.LastChangeToken
changes = siteCollection.ContentDatabase.GetChanges(token)
End While
Console.WriteLine("{0:#,#} changes", total)
End Using
Console.Write(vbCrLf + "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
請參閱
參照
Microsoft.SharePoint namespace