SPBackupRestoreSettings.UpdateProgress-Eigenschaft
Dient zum Abrufen oder Festlegen eines Werts, das angibt, zu welchen Zeitpunkten des Vorgangs den Fortschritt melden soll.
Namespace: Microsoft.SharePoint.Administration.Backup
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Property UpdateProgress As Integer
Get
Set
'Usage
Dim instance As SPBackupRestoreSettings
Dim value As Integer
value = instance.UpdateProgress
instance.UpdateProgress = value
public int UpdateProgress { get; set; }
Eigenschaftswert
Typ: System.Int32
Eine Int32darstellt von 1 bis zu 100,, als Prozentsatz-Intervall des gesamten Vorgangs, wenn der Vorgang den Fortschritt melden sollte.
Ausnahmen
Ausnahme | Bedingung |
---|---|
SPException | Aufrufer hat versucht, die-Eigenschaft auf 0 festgelegt. |
ArgumentException | Aufrufer hat versucht, auf die Eigenschaft auf eine negative Zahl festgelegt. \endash oder \endash Aufrufer hat versucht, die-Eigenschaft auf einen Wert größer als 100 festgelegt. |
Hinweise
Beispielsweise führen, wenn UpdateProgress 5 ist, klicken Sie dann die Berichte Vorgang bei 5 % abgeschlossen, 10 % abgeschlossen, 15 % abgeschlossen ist, und so weiter, bis es 100 % ist.
Beispiele
Im folgenden Beispiel wird veranschaulicht, wie die UpdateProgress -Eigenschaft in einer Sicherungsanwendung verwendet. Das vollständige Beispiel und eine ausführliche Erläuterung des es finden Sie unter How to: Programmatically Back Up Content.
static void Main(string[] args)
{
// Identify the location for the backup storage.
Console.Write("Enter full UNC path to the directory where the backup will be stored:");
String backupLocation = Console.ReadLine();
// Create the backup settings.
SPBackupSettings settings = SPBackupRestoreSettings.GetBackupSettings(backupLocation, "Full");
// Identify the content component to backup.
Console.Write("Enter name of component to backup (default is whole farm):");
settings.IndividualItem = Console.ReadLine();
// Set optional operation parameters.
settings.IsVerbose = true;
settings.UpdateProgress = 10;
settings.BackupThreads = 10;
// Create the backup operation and return its ID.
Guid backup = SPBackupRestoreConsole.CreateBackupRestore(settings);
// Ensure that user has identified a valid and unique component.
SPBackupRestoreObject node = EnsureUniqueValidComponentName(settings, ref backup);
// Ensure that there is enough space.
Boolean targetHasEnoughSpace = false;
if (node != null)
{
targetHasEnoughSpace = EnsureEnoughDiskSpace(backupLocation, backup, node);
}
// If there is enough space, attempt to run the backup.
if (targetHasEnoughSpace)
{
// Set the backup as the active job and run it.
if (SPBackupRestoreConsole.SetActive(backup) == true)
{
if (SPBackupRestoreConsole.Run(backup, node) == false)
{
// Report "error" through your UI.
String error = SPBackupRestoreConsole.Get(backup).FailureMessage;
Console.WriteLine(error);
}
}
else
{
// Report through your UI that another backup
// or restore operation is underway.
Console.WriteLine("Another backup or restore operation is already underway. Try again when it ends.");
}
// Clean up the operation.
SPBackupRestoreConsole.Remove(backup);
Console.WriteLine("Backup attempt complete. Press Enter to continue.");
Console.ReadLine();
}
}// end Main
Shared Sub Main(ByVal args() As String)
' Identify the location for the backup storage.
Console.Write("Enter full UNC path to the directory where the backup will be stored:")
Dim backupLocation As String = Console.ReadLine()
' Create the backup settings.
Dim settings As SPBackupSettings = SPBackupRestoreSettings.GetBackupSettings(backupLocation, "Full")
' Identify the content component to backup.
Console.Write("Enter name of component to backup (default is whole farm):")
settings.IndividualItem = Console.ReadLine()
' Set optional operation parameters.
settings.IsVerbose = True
settings.UpdateProgress = 10
settings.BackupThreads = 10
' Create the backup operation and return its ID.
Dim backup As Guid = SPBackupRestoreConsole.CreateBackupRestore(settings)
' Ensure that user has identified a valid and unique component.
Dim node As SPBackupRestoreObject = EnsureUniqueValidComponentName(settings, backup)
' Ensure that there is enough space.
Dim targetHasEnoughSpace As Boolean = False
If node IsNot Nothing Then
targetHasEnoughSpace = EnsureEnoughDiskSpace(backupLocation, backup, node)
End If
' If there is enough space, attempt to run the backup.
If targetHasEnoughSpace Then
' Set the backup as the active job and run it.
If SPBackupRestoreConsole.SetActive(backup) = True Then
If SPBackupRestoreConsole.Run(backup, node) = False Then
' Report "error" through your UI.
Dim [error] As String = SPBackupRestoreConsole.Get(backup).FailureMessage
Console.WriteLine([error])
End If
Else
' Report through your UI that another backup
' or restore operation is underway.
Console.WriteLine("Another backup or restore operation is already underway. Try again when it ends.")
End If
' Clean up the operation.
SPBackupRestoreConsole.Remove(backup)
Console.WriteLine("Backup attempt complete. Press Enter to continue.")
Console.ReadLine()
End If
End Sub ' end Main
Siehe auch
Referenz
SPBackupRestoreSettings Klasse