SPHealthAnalysisRule-Klasse

Eine abstrakte Basisklasse, die eine Definition für eine Regel SharePoint-Integritätsanalyse bereitstellt.

Vererbungshierarchie

System.Object
  Microsoft.SharePoint.Administration.Health.SPHealthAnalysisRule
    Microsoft.SharePoint.Administration.Health.SPRepairableHealthAnalysisRule

Namespace:  Microsoft.SharePoint.Administration.Health
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public MustInherit Class SPHealthAnalysisRule
'Usage
Dim instance As SPHealthAnalysisRule
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public abstract class SPHealthAnalysisRule

Hinweise

Eine Regel SharePoint-Integritätsanalyse ist eine konkrete Unterklasse, die über einen dieser zwei abstrakten Klassen erbt: SPHealthAnalysisRule oder SPRepairableHealthAnalysisRule. Der einzige Unterschied zwischen diesen beiden Klassen ist, dass zwar sowohl eine Check() -Methode, um ein Problem zu erkennen, die SPRepairableHealthAnalysisRule -Klasse auch eine Repair() -Methode zur Behebung des Problems, das von der Check -Methode gefunden hat.

Wenn Sie eine Unterklasse der SPHealthAnalysisRule -Klasse erstellen, müssen Sie überschreiben und Implementieren der Summary, Explanation, Remedy, Category, und ErrorLevel Eigenschaften als auch die Check() -Methode. Wenn Sie die Regel automatisch unter einen Zeitgeberauftrag ausgeführt werden soll, sollten Sie überschreiben und implementieren die AutomaticExecutionParameters -Eigenschaft. Implementierung der restlichen Elemente der Klasse ist optional.

Beispiele

Das folgende Beispiel erstellt eine Regel, die überprüft, ob der lokale Server der Serverfarm zugeordnet ist.

using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Administration.Health;

namespace Sample.HealthRules
{
    public sealed class LocalJoinedToFarm : SPHealthAnalysisRule
    {
        
        public override string Summary
        {
            get { return "The local server is not joined to a SharePoint server farm."; }
        }

        public override string Explanation
        {
            get { return "SharePoint is installed on this server, but the installation will not function until the server has been joined to a SharePoint server farm."; }
        }

        public override string Remedy
        {
            get { return "Run the SharePoint Products and Technologies Configuration Wizard and follow the prompts to create a new farm or to join this server to an existing farm."; }
        }

        public override SPHealthCategory Category
        {
            get { return SPHealthCategory.Configuration; }
        }

        public override SPHealthCheckErrorLevel ErrorLevel
        {
            get { return SPHealthCheckErrorLevel.Error; }
        }

        public override SPHealthAnalysisRuleAutomaticExecutionParameters AutomaticExecutionParameters
        {
            get
            {
                SPHealthAnalysisRuleAutomaticExecutionParameters retval = new SPHealthAnalysisRuleAutomaticExecutionParameters();
                retval.Schedule = SPHealthCheckSchedule.Hourly;
                retval.Scope = SPHealthCheckScope.All;
                retval.ServiceType = typeof(SPTimerService);
                retval.RepairAutomatically = false;
                return retval;
            }
        }        
        
        public override SPHealthCheckStatus Check()
        {
            return SPFarm.Joined ? SPHealthCheckStatus.Passed : SPHealthCheckStatus.Failed;
        }
    }

}
Imports Microsoft.SharePoint.Administration
Imports Microsoft.SharePoint.Administration.Health

Namespace Sample.HealthRules
    Public NotInheritable Class LocalJoinedToFarm
        Inherits SPHealthAnalysisRule

        Public Overrides ReadOnly Property Summary() As String
            Get
                Return "The local server is not joined to a SharePoint server farm."
            End Get
        End Property

        Public Overrides ReadOnly Property Explanation() As String
            Get
                Return "SharePoint is installed on this server, but the installation will not function until the server has been joined to a SharePoint server farm."
            End Get
        End Property

        Public Overrides ReadOnly Property Remedy() As String
            Get
                Return "Run the SharePoint Products and Technologies Configuration Wizard and follow the prompts to create a new farm or to join this server to an existing farm."
            End Get
        End Property

        Public Overrides ReadOnly Property Category() As SPHealthCategory
            Get
                Return SPHealthCategory.Configuration
            End Get
        End Property

        Public Overrides ReadOnly Property ErrorLevel() As SPHealthCheckErrorLevel
            Get
                Return SPHealthCheckErrorLevel.Error
            End Get
        End Property

        Public Overrides ReadOnly Property AutomaticExecutionParameters() As SPHealthAnalysisRuleAutomaticExecutionParameters
            Get
                Dim retval As New SPHealthAnalysisRuleAutomaticExecutionParameters()
                retval.Schedule = SPHealthCheckSchedule.Hourly
                retval.Scope = SPHealthCheckScope.All
                retval.ServiceType = GetType(SPTimerService)
                retval.RepairAutomatically = False
                Return retval
            End Get
        End Property

        Public Overrides Function Check() As SPHealthCheckStatus
            Return If(SPFarm.Joined, SPHealthCheckStatus.Passed, SPHealthCheckStatus.Failed)
        End Function
    End Class

End Namespace

Threadsicherheit

Alle öffentlichen static (Shared in Visual Basic) Member dieses Typs sind threadsicher. Die Threadsicherheit von Instanzmembern ist nicht gewährleistet.

Siehe auch

Referenz

SPHealthAnalysisRule-Member

Microsoft.SharePoint.Administration.Health-Namespace

SPRepairableHealthAnalysisRule

Weitere Ressourcen

SharePoint Maintenance Manager

How to: Create a Health Rule