Share via


(SPChangeToken) del método SPList.GetChanges

Devuelve una colección de cambios desde un punto determinado en el registro de cambios.

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

Sintaxis

'Declaración
Public Function GetChanges ( _
    changeToken As SPChangeToken _
) As SPChangeCollection
'Uso
Dim instance As SPList
Dim changeToken As SPChangeToken
Dim returnValue As SPChangeCollection

returnValue = instance.GetChanges(changeToken)
public SPChangeCollection GetChanges(
    SPChangeToken changeToken
)

Parámetros

  • changeToken
    Tipo: Microsoft.SharePoint.SPChangeToken

    La fecha y hora de inicio. Para comenzar al principio del registro de cambios, establezca este valor en una referencia null (Nothing en Visual Basic).

Valor devuelto

Tipo: Microsoft.SharePoint.SPChangeCollection
Los cambios que se han producido en la lista con respecto a la fecha y hora especificado por changeToken.

Excepciones

Excepción Condición
SPException

changeToken hace referencia a una hora antes del inicio del actual registro de cambios.

Comentarios

Puede obtener un objeto SPChangeToken a pasar como un argumento a este método mediante la extracción de uno de la propiedad ChangeToken del último cambio devuelto por una llamada anterior al método GetChanges . O bien, puede usar el constructor SPChangeToken para crear un nuevo token de cambio.

Nota

De forma predeterminada, el registro de cambios conserva los datos durante 60 días. Puede configurar el período de retención estableciendo la propiedad ChangeLogRetentionPeriod .

Ejemplos

En el siguiente ejemplo es una aplicación de consola que muestra cómo obtener todos los cambios realizados en el registro. El sistema realiza un bucle al obtener los cambios en lotes y se interrumpe el bucle cuando recupera una colección con cero miembros, lo que significa que ha alcanzado el final de la lista.

using System;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite siteCollection = new SPSite("https://localhost"))
         {
            using (SPWeb webSite = siteCollection.OpenWeb())
            {
               // Get a list.
               SPList list = webSite.Lists[0];

               int total = 0;
               SPChangeToken token = null;

               // Get the first batch of changes.
               SPChangeCollection changes = list.GetChanges(token);

               // Loop until we reach the end of the log.
               while (changes.Count > 0)
               {
                  total += changes.Count;

                  // Go get another batch.
                  token = changes.LastChangeToken;
                  changes = list.GetChanges(token);
               }

               Console.WriteLine("Total of {0:#,#} changes to {1} list", total, list.Title);
            }
         }
         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")
         Using webSite As SPWeb = siteCollection.OpenWeb()

            ' Get a list.
            Dim list As SPList = webSite.Lists(0)

            Dim total As Integer = 0
            Dim token As SPChangeToken = Nothing

            ' Get the first batch of changes.
            Dim changes As SPChangeCollection = list.GetChanges(token)

            ' Loop until we reach the end of the log.
            While changes.Count > 0

               total += changes.Count

               ' Go get another batch of changes starting where we left off.
               token = changes.LastChangeToken
               changes = list.GetChanges(token)

            End While

            Console.WriteLine("Total of {0:#,#} changes to {1} list", total, List.Title)

         End Using
      End Using

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

   End Sub
End Module

Vea también

Referencia

clase SPList

Miembros SPList

Sobrecarga GetChanges

Espacio de nombres Microsoft.SharePoint

Otros recursos

Using the Change Log