SPHealthAnalysisRule Class

An abstract base class that provides a definition for a SharePoint Maintenance Manager rule. This class is used by the upgrade tool.

Inheritance Hierarchy

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

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

Syntax

<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public MustInherit Class SPHealthAnalysisRule _
    Implements ISPHealthAnalysisRule

Dim instance As SPHealthAnalysisRule
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public abstract class SPHealthAnalysisRule : ISPHealthAnalysisRule

Remarks

A SharePoint Maintenance Manager rule is a class that inherits from this class or from the SPRepairableHealthAnalysisRule class (which inherits from the SPHealthAnalysisRule class). The only difference between these two classes is that while both have a Check() method to detect a problem, the SPRepairableHealthAnalysisRule class also has a Repair() method to correct the problem found by the Check method.

When you create a subclass of the SPHealthAnalysisRule class, you must override and implement the Summary, Explanation, Remedy, and ErrorLevel properties as well as the Check() method. Implementation of the remaining members of the class is optional.

Examples

The following example creates a rule that checks whether the local server is joined to the server farm.

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;
        }
    }

}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPHealthAnalysisRule Members

Microsoft.SharePoint.Administration.Health Namespace

SPRepairableHealthAnalysisRule