(SPChangeCollection.CollectionScope, Guid, DateTime) del constructor SPChangeToken

Inicializa una nueva instancia de la clase SPChangeToken con un ámbito de colección de cambio especificada, el identificador de objeto correspondiente (ID.) y el tiempo de cambio.

Espacio de nombres:  Microsoft.SharePoint
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

'Declaración
Public Sub New ( _
    scope As SPChangeCollection.CollectionScope, _
    scopeId As Guid, _
    changeTime As DateTime _
)
'Uso
Dim scope As SPChangeCollection.CollectionScope
Dim scopeId As Guid
Dim changeTime As DateTime

Dim instance As New SPChangeToken(scope, scopeId, _
    changeTime)
public SPChangeToken(
    SPChangeCollection.CollectionScope scope,
    Guid scopeId,
    DateTime changeTime
)

Parámetros

  • changeTime
    Tipo: System.DateTime

    La fecha y la hora de un cambio. Veces en el registro de cambios se especifican en formato de hora Universal coordinada (UTC).

Comentarios

Tokens de cambio son específicos de una lista determinada, el sitio Web, la colección de sitios o la base de datos de contenido. Al construir un token de cambio, los valores que usan en los dos primeros parámetros del constructor deben coincidir con el objeto que está programando contra. Por ejemplo, si desea pasar el token de cambio al método GetChanges de un objeto SPList , debe especificar SPChangeCollection.CollectionScope.List como la scope y el valor de la propiedad ID de la lista como el scopeId.

Ejemplos

En el siguiente ejemplo es una aplicación de consola que crea dos tokens de cambio, de manera que puede consultar el registro de cambios de los cambios realizados en una colección de sitios durante un período de siete días.

using System;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite siteCollection = new SPSite("https://localhost"))
         {
            // Create a query.
            SPChangeQuery query = new SPChangeQuery(true, true);

            // Create a change token for the start.
            DateTime startTime = new DateTime(2009, 6, 1);
            query.ChangeTokenStart = new SPChangeToken(SPChangeCollection.CollectionScope.Site,
                                                       siteCollection.ID,
                                                       startTime);
            // Create a change token for the end.
            query.ChangeTokenEnd = new SPChangeToken(SPChangeCollection.CollectionScope.Site,
                                                     siteCollection.ID,
                                                     startTime.AddDays(6));

            // Specify the number of changes per round trip.
            query.FetchLimit = 1000;
            // Keep a running total.
            long total = 0;

            while (true)
            {
               SPChangeCollection changes = siteCollection.GetChanges(query);

               total += changes.Count;

               foreach (SPChange change in changes)
               {
                  Console.WriteLine("\nDate: {0}", change.Time.ToShortDateString());
                  Console.WriteLine("Change subclass: {0}", change.GetType().ToString());
                  Console.WriteLine("Change type: {0}", change.ChangeType);
               }

               // Break out of the loop if we have the last batch.
               if (changes.Count < query.FetchLimit)
                  break;
               // Otherwise, go get another batch.
               query.ChangeTokenStart = changes.LastChangeToken;
            }

            Console.WriteLine("\nTotal changes = {0:#,#}", 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")

         ' Create a query
         Dim query As New SPChangeQuery(True, True)

         ' Create a change token for the start.
         Dim startTime As New DateTime(2009, 6, 1)
         query.ChangeTokenStart = New SPChangeToken(SPChangeCollection.CollectionScope.Site, _
                                                    siteCollection.ID, _
                                                    startTime)
         ' Create a change token for the end.
         query.ChangeTokenEnd = New SPChangeToken(SPChangeCollection.CollectionScope.Site, _
                                                  siteCollection.ID, _
                                                  startTime.AddDays(6))

         ' Specify the number of changes per round trip.
         query.FetchLimit = 1000

         ' Keep a running total.
         Dim total As Long = 0


         While True

            Dim changes As SPChangeCollection = siteCollection.GetChanges(query)

            total += changes.Count

            For Each change As SPChange In changes

               Console.WriteLine(vbCrLf + "Date: {0}", change.Time.ToShortDateString())
               Console.WriteLine("Change subclass: {0}", change.GetType().ToString())
               Console.WriteLine("Change type: {0}", change.ChangeType)

            Next change

            ' Break out of loop if we have the last batch.
            If changes.Count < query.FetchLimit Then
               Exit While
            End If

            ' Otherwise, go get another batch.
            query.ChangeTokenStart = changes.LastChangeToken

         End While

         Console.WriteLine(vbCrLf + "Total changes = {0:#,#}", total)

      End Using

      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()

   End Sub
End Module

Vea también

Referencia

clase SPChangeToken

Miembros SPChangeToken

Sobrecarga SPChangeToken

Espacio de nombres Microsoft.SharePoint