SPChangeQuery.Site - Propriété
Obtient ou définit une valeur Boolean qui indique si les modifications apportées aux objets SPSite sont incluses dans la requête.
Espace de noms : Microsoft.SharePoint
Assembly : Microsoft.SharePoint (dans Microsoft.SharePoint.dll)
Syntaxe
'Déclaration
Public Property Site As Boolean
Get
Set
'Utilisation
Dim instance As SPChangeQuery
Dim value As Boolean
value = instance.Site
instance.Site = value
public bool Site { get; set; }
Valeur de propriété
Type : System.Boolean
true pour inclure les modifications apportées aux objets SPSite ; dans le cas contraire, false. La valeur par défaut est false.
Exemples
L'exemple suivant est une application console qui interroge la base de données de contenu pour toutes les modifications apportées aux objets de SPSite .
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite host = new SPSite("https://localhost"))
{
SPChangeQuery query = new SPChangeQuery(false, true);
// object type
query.Site = true;
// Get the SPSite collection.
SPSiteCollection sites = host.ContentDatabase.Sites;
int total = 0;
// Loop until we reach the end of the log.
while (true)
{
SPChangeCollection changes = host.ContentDatabase.GetChanges(query);
total += changes.Count;
// Print info about each change to the console.
foreach (SPChange change in changes)
{
// Get the URL for the changed SPSite.
string url = String.Empty;
foreach (SPSite site in sites)
{
if (site.ID == change.SiteId)
{
url = site.Url;
break;
}
}
Console.WriteLine("\nDate: {0}", change.Time.ToString());
Console.WriteLine("Change: {0} site collection", change.ChangeType.ToString());
Console.WriteLine("Url: {0}", url);
}
// 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
Imports Microsoft.SharePoint.Administration
Module ConsoleApp
Sub Main()
Using host As SPSite = New SPSite("https://localhost")
Dim query As New SPChangeQuery(False, True)
' object type
query.Site = True
' Get the SPSite collection.
Dim sites As SPSiteCollection = host.ContentDatabase.Sites
Dim total As Integer = 0
' Loop until we reach the end of the log.
While True
Dim changes As SPChangeCollection = host.ContentDatabase.GetChanges(query)
total += changes.Count
' Print info about each change to the console.
For Each change As SPChange In changes
' Get the URL for the changed SPSite.
Dim url As String = String.Empty
For Each site As SPSite In sites
If site.ID = change.SiteId Then
url = site.Url
Exit For
End If
Next site
Console.WriteLine(ControlChars.Lf + "Date: {0}", change.Time.ToString())
Console.WriteLine("Change: {0} site collection", change.ChangeType.ToString())
Console.WriteLine("Url: {0}", url)
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
Console.Write(vbCrLf + "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module