SPChangeCollection.LastChangeToken 属性

获取对应于上次更改集合中的更改令牌。

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public ReadOnly Property LastChangeToken As SPChangeToken
    Get
用法
Dim instance As SPChangeCollection
Dim value As SPChangeToken

value = instance.LastChangeToken
public SPChangeToken LastChangeToken { get; }

属性值

类型:Microsoft.SharePoint.SPChangeToken
一个SPChangeToken对象,表示上次更改令牌。

备注

返回的更改令牌是索引为更改集合中的Count – 1SPChange对象的ChangeToken属性的值。何时获取批次中的更改,您可用作此标记的起始点的下一个批次。

示例

下面的示例是一个简单的控制台应用程序演示如何从当前更改日志中检索所有更改。

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

另请参阅

引用

SPChangeCollection 类

SPChangeCollection 成员

Microsoft.SharePoint 命名空间

FetchLimit

其他资源

Using the Change Log