de la propiedad SPChangeQuery.Item
Obtiene o establece un valor de Boolean que especifica si los cambios realizados en los objetos SPListItem se incluyen en la consulta.
Espacio de nombres: Microsoft.SharePoint
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
Public Property Item As Boolean
Get
Set
'Uso
Dim instance As SPChangeQuery
Dim value As Boolean
value = instance.Item
instance.Item = value
public bool Item { get; set; }
Valor de propiedad
Tipo: System.Boolean
true para incluir los cambios realizados en elementos de lista; 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 los cambios realizados en los elementos en todas las listas en una colección de sitios. Después de recuperar los cambios, la aplicación examina cada cambio e imprime la fecha del cambio, la dirección URL del sitio Web, el título de la lista, el nombre para mostrar del elemento y el tipo de cambio.
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.Item = True
' Convert to local time.
Dim timeZone As SPTimeZone = webSite.RegionalSettings.TimeZone
' total changes
Dim total As Integer = 0
' Loop until we reach the end of the log.
While True
Dim changes As SPChangeCollection = siteCollection.GetChanges(query)
total += changes.Count ' running total
For Each change As SPChangeItem In changes
' Get information we want.
Dim webUrl As String = String.Empty
Dim listTitle As String = String.Empty
Dim itemDisplayName As String = String.Empty
' Get the web site where the change was made.
Using web As SPWeb = siteCollection.AllWebs(change.WebId)
' Url of the web site
webUrl = web.Url
' Get title of the list.
Dim list As SPList = Nothing
Try
list = web.Lists(change.ListId)
listTitle = list.Title
Catch ex As SPException
listTitle = "Unknown"
itemDisplayName = "Unknown"
End Try
' Get display name of the item.
If list IsNot Nothing Then
Try ' Is it an item?
itemDisplayName = _
list.GetItemByUniqueId(change.UniqueId).DisplayName
Catch noItem As ArgumentException
Try ' Is it a folder?
itemDisplayName = _
list.Folders(change.UniqueId).DisplayName
Catch noFolder As ArgumentException ' Must have been deleted
itemDisplayName = "No longer exists"
End Try
End Try
End If
End Using
' Write to the console.
Console.WriteLine(vbCrLf + "Date: {0}", _
timeZone.UTCToLocalTime(change.Time).ToString())
Console.WriteLine("Web site: {0}", webUrl)
Console.WriteLine("List: {0}", listTitle)
Console.WriteLine("Item: {0}", itemDisplayName)
Console.WriteLine("Change: {0}", change.ChangeType)
Next change
' Break out of the 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 of {0:#,#} changes", 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)
{
// Construct a query.
SPChangeQuery query = new SPChangeQuery(false, true);
// Set a limit on the number of changes returned on a single trip.
query.FetchLimit = 500;
// object type
query.Item = true;
// Convert to local time.
SPTimeZone timeZone = webSite.RegionalSettings.TimeZone;
// total changes
int total = 0;
// Loop until we reach the end of the log.
while (true)
{
SPChangeCollection changes = siteCollection.GetChanges(query);
total += changes.Count; // running total
foreach (SPChangeItem change in changes)
{
// Get information we want.
string webUrl = String.Empty;
string listTitle = String.Empty;
string itemDisplayName = String.Empty;
// Get the web site where the change was made.
using (SPWeb web = siteCollection.AllWebs[change.WebId])
{
// Get url of the web site.
webUrl = web.Url;
// Get title of the list.
SPList list = null;
try
{
list = web.Lists[change.ListId];
listTitle = list.Title;
}
catch (SPException)
{
listTitle = "Unknown";
itemDisplayName = "Unknown";
}
// Get display name of the item.
if (list != null)
{
try // Is it an item?
{
itemDisplayName =
list.GetItemByUniqueId(change.UniqueId).DisplayName;
}
catch (ArgumentException)
{
try // Is it a folder?
{
itemDisplayName =
list.Folders[change.UniqueId].DisplayName;
}
catch (ArgumentException) // Must have been deleted.
{
itemDisplayName = "No longer exists";
}
}
}
}
// Write to the console.
Console.WriteLine("\nDate: {0}",
timeZone.UTCToLocalTime(change.Time).ToString());
Console.WriteLine("Web site: {0}", webUrl);
Console.WriteLine("List: {0}", listTitle);
Console.WriteLine("Item: {0}", itemDisplayName);
Console.WriteLine("Change: {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();
}
}
}