Clase SPHealthAnalysisRule
Clase base abstracta que proporciona una definición para una regla de Analizador de mantenimiento de SharePoint .
Jerarquía de la herencia
System.Object
Microsoft.SharePoint.Administration.Health.SPHealthAnalysisRule
Microsoft.SharePoint.Administration.Health.SPRepairableHealthAnalysisRule
Espacio de nombres: Microsoft.SharePoint.Administration.Health
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public MustInherit Class SPHealthAnalysisRule
'Uso
Dim instance As SPHealthAnalysisRule
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public abstract class SPHealthAnalysisRule
Comentarios
Una regla de Analizador de mantenimiento de SharePoint es un una subclase concreta que hereda de una de las dos clases abstractas: SPHealthAnalysisRule o SPRepairableHealthAnalysisRule. La única diferencia entre estas dos clases es que, aunque ambas tienen un método Check() para detectar un problema, la clase SPRepairableHealthAnalysisRule tiene también un método Repair() para corregir el problema que se encuentra en el método Check .
Cuando se crea una subclase de la clase SPHealthAnalysisRule , debe invalide e implemente el Summary, Explanation, Remedy, Categoryy las propiedades de ErrorLevel así como el método Check() . Si desea que la regla que se ejecute automáticamente en un trabajo del temporizador, debe invalide e implemente así como la propiedad AutomaticExecutionParameters . Implementación de los miembros restantes de la clase es opcional.
Ejemplos
En el siguiente ejemplo se crea una regla que comprueba si el servidor local está unido a la granja de servidores.
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
Seguridad para subprocesos
Los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para subprocesos. No se garantiza que los miembros de instancias sean seguros para los subprocesos.
Vea también
Referencia
Espacio de nombres Microsoft.SharePoint.Administration.Health
SPRepairableHealthAnalysisRule