Compartir a través de


de la propiedad SPChangeQuery.View

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

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

Sintaxis

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

value = instance.View

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

Valor de propiedad

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

Ejemplos

En el siguiente ejemplo es una aplicación de consola que recupera todos los cambios en las vistas de lista en una colección de sitios. La aplicación examina cada cambio y se intenta determinar a qué vista en la que se cambió lista, imprimir los resultados de la consola.

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)
            {
               SPChangeQuery query = new SPChangeQuery(false, true);

               // object type
               query.View = true;

               // Get the list collection
               SPListCollection lists = webSite.Lists;

               int total = 0;

               // Loop until we reach the end of the log.
               while (true)
               {
                  SPChangeCollection changes = webSite.GetChanges(query);

                  total += changes.Count;

                  // Print info about each change to the console.
                  foreach (SPChange change in changes)
                  {
                     SPChangeView changedView = (SPChangeView)change;
                     string listTitle = "Unknown";
                     string viewTitle = "Unknown";

                     // Try to get the title of the list.
                     try
                     {
                        SPList list = lists.GetList(changedView.ListId, false);
                        listTitle = list.Title;

                        // Try to get the title of the view.
                        try
                        {
                           SPView view = list.Views[changedView.Id];
                           viewTitle = view.Title;
                        }
                        catch (SPException) // View not found
                        {
                           viewTitle = "No longer exists";
                        }

                     }
                     catch (SPException) // List not found
                     {
                        listTitle = "No longer exists";
                     }

                     Console.WriteLine("\nDate: {0}", change.Time.ToString());
                     Console.WriteLine("Change: {0} ", change.ChangeType.ToString());
                     Console.WriteLine("List: {0}", listTitle);
                     Console.WriteLine("View: {0}", viewTitle);
                  }

                  // 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 of {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")
         Using webSite As SPWeb = siteCollection.RootWeb

            Dim query As New SPChangeQuery(False, True)

            ' object type
            query.View = True

            ' Get the list collection.
            Dim lists As SPListCollection = webSite.Lists

            Dim total As Integer = 0

            ' Loop until we reach the end of the log.
            While True
               Dim changes As SPChangeCollection = webSite.GetChanges(query)

               total += changes.Count

               ' Print info about each change to the console.
               For Each change As SPChange In changes

                  Dim changedView As SPChangeView = CType(change, SPChangeView)

                  Dim listTitle As String = "Unknown"
                  Dim viewTitle As String = "Unknown"
                  ' Try to get the title of the list.
                  Try
                     Dim list As SPList = lists.GetList(changedView.ListId, False)
                     listTitle = list.Title

                     ' Try to get the title of the view.
                     Try
                        Dim view As SPView = list.Views(changedView.Id)
                        viewTitle = view.Title
                     Catch ex As SPException ' View not found
                        viewTitle = "No longer exists"
                     End Try

                  Catch ex As SPException 'List not found
                     listTitle = "No longer exists"
                  End Try

                  Console.WriteLine(ControlChars.Lf + "Date: {0}", change.Time.ToString())
                  Console.WriteLine("Change: {0} ", change.ChangeType.ToString())
                  Console.WriteLine("List: {0}", listTitle)
                  Console.WriteLine("View: {0}", viewTitle)

               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(ControlChars.Lf + "Total of {0} changes", total)

         End Using
      End Using

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

   End Sub
End Module

Vea también

Referencia

clase SPChangeQuery

Miembros SPChangeQuery

Espacio de nombres Microsoft.SharePoint

SPChangeView