Compartir a través de


de la propiedad SPChangeQuery.ContentType

Obtiene o establece un valor de Boolean que especifica si los cambios realizados en los objetos SPContentType se incluyen en la consulta.

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

Sintaxis

'Declaración
Public Property ContentType As Boolean
    Get
    Set
'Uso
Dim instance As SPChangeQuery
Dim value As Boolean

value = instance.ContentType

instance.ContentType = value
public bool ContentType { get; set; }

Valor de propiedad

Tipo: System.Boolean
true para incluir los cambios realizados en los tipos de contenido; en caso contrario, false. El valor predeterminado es false.

Ejemplos

En el siguiente ejemplo es una aplicación de consola que consulta el registro de cambios de todos los cambios en los tipos de contenido en una colección de sitios.

Imports System
Imports Microsoft.SharePoint

Module ConsoleApp
   Sub Main()
      Using siteCollection As SPSite = New SPSite("https://localhost")
         Using webSite As SPWeb = siteCollection.RootWeb

            ' Construct a query.
            Dim query As New SPChangeQuery(False, True)

            ' Set a limit on the number of changes returned on a single trip.
            query.FetchLimit = 500

            ' object type
            query.ContentType = True

            Dim total As Long = 0
            While True
               Dim changes As SPChangeCollection = siteCollection.GetChanges(query)

               total += changes.Count

               For Each change As SPChangeContentType In changes

                  ' Get the content type (if it still exists).
                  Dim contentType As SPContentType = _
                      webSite.AvailableContentTypes(change.Id)

                  ' The change might have been to delete the content type.
                  Dim contentTypeName As String
                  If contentType Is Nothing Then
                     contentTypeName = "Unknown"
                  Else
                     contentTypeName = contentType.Name
                  End If

                  Console.WriteLine(vbCrLf + "{0} content type was changed on {1}.", _
                                    contentTypeName, change.Time.ToShortDateString())
                  Console.WriteLine("Type of change: {0}", change.ChangeType.ToString())

               Next change

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

               ' Go get another batch of changes starting where we left off.
               query.ChangeTokenStart = changes.LastChangeToken

            End While

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

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub
End Module
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.RootWeb)
            {
               
               // Set a limit on the number of changes returned on a single trip.
               query.FetchLimit = 500;
.
               SPChangeQuery query = new SPChangeQuery(false, true);

               // object type 
               query.ContentType = true;

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

                  total += changes.Count;

                  foreach (SPChangeContentType change in changes)
                  {
                     // Get the content type (if it still exists).
                     SPContentType contentType = 
                         webSite.AvailableContentTypes[change.Id];

                     // The change might have been to delete the content type.
                     string contentTypeName;
                     if (contentType == null)
                        contentTypeName = "Unknown";
                     else
                        contentTypeName = contentType.Name;

                     Console.WriteLine("\n{0} content type was changed on {1}.", 
                                       contentTypeName, change.Time.ToShortDateString());
                     Console.WriteLine("Type of change: {0}", change.ChangeType.ToString());
                  }

                  // Break out of 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();
      }
   }
}

Vea también

Referencia

clase SPChangeQuery

Miembros SPChangeQuery

Espacio de nombres Microsoft.SharePoint

SPChangeContentType