SPBackupRestoreLogSeverity 枚举

指定的备份或还原操作过程中发生,并记录一条消息的问题的严重性。

命名空间:  Microsoft.SharePoint.Administration.Backup
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Enumeration SPBackupRestoreLogSeverity
用法
Dim instance As SPBackupRestoreLogSeverity
public enum SPBackupRestoreLogSeverity

成员

成员名称 说明
Important 信息日志条目是重要但不是问题。
None 没有日志项。
Error 致命错误导致无法完成该操作。
Warning 问题,需要一个警告,但不是致命。
Verbose 并不是问题不太重要信息的日志条目。
WorkItem 日志条目标识某些后期的备份或还原后需要做的工作。

备注

这些值主要用作Log方法的参数。

示例

下面的示例演示如何使用枚举中的OnRestore方法的实现。

[C#]

public Boolean OnRestore(Object sender, SPRestoreInformation args)
{
    if (args == null)
    {
        throw new ArgumentNullException("args");
    }

    // If the CriticalFiles object was deleted from the farm after it was
    // backed up, restore it to the configuration database.
    CriticalFiles cf = SPFarm.Local.GetChild<CriticalFiles>(this.Name);
    if (cf == null)
    {
        this.Update();
        args.Log(SPBackupRestoreLogSeverity.Verbose, this.Name + " added back to configuration database.");
    }

    Boolean successSignal = true;

    // TODO: The following loop restores files to the local server. If there are 
    //       multiple front end servers, your code must iterate through all of 
    //       SPFarm.Local.Servers and restore the same files to every server whose
    //       Role property is SPServerRole.WebFrontEnd

    foreach (String path in FrontEndFilePaths)
    {
        FileInfo backupCopy = new FileInfo(path);
        FileInfo file = new FileInfo(args.Location + @"\" + backupCopy.Name);
        try
        {
            file.CopyTo(path, true);
            args.Log(SPBackupRestoreLogSeverity.Verbose, "Restored " + file.Name);
        }
        catch (Exception e)
        {
            args.Log(SPBackupRestoreLogSeverity.Verbose, file.Name + " not restored: " + e.Message);
            successSignal = false;
        }
    }
    
    args.CurrentProgress = 50;
    return successSignal;
}

另请参阅

引用

Microsoft.SharePoint.Administration.Backup 命名空间