Compartir a través de


de la propiedad SPHealthReportsList.Local

Obtiene un objeto SPHealthReportsList que representa la lista de informes de Analizador de mantenimiento de SharePoint para la granja de servidores.

Espacio de nombres:  Microsoft.SharePoint.Administration.Health
Ensamblado:  Microsoft.SharePoint (en Microsoft.SharePoint.dll)

Sintaxis

'Declaración
Public Shared ReadOnly Property Local As SPHealthReportsList
    Get
'Uso
Dim value As SPHealthReportsList

value = SPHealthReportsList.Local
public static SPHealthReportsList Local { get; }

Valor de propiedad

Tipo: Microsoft.SharePoint.Administration.Health.SPHealthReportsList
Objeto SPHealthReportsList que representa la lista de informes de Analizador de mantenimiento de SharePoint para la granja de servidores.

Excepciones

Excepción Condición
InvalidOperationException

El servidor local no está unido a la granja de servidores.

Comentarios

El objeto SPHealthReportsList devuelto por la propiedad Local utiliza recursos no administrados. Usted es responsable de liberar esos recursos. Una forma de hacerlo es que se llama al método Dispose() cuando ya no necesita el objeto SPHealthReportsList .

Ejemplos

En el siguiente ejemplo es una aplicación de consola que consulta la lista de informes de estado para obtener información acerca de las comprobaciones de mantenimiento que se ha producido un error.

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

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPHealthReportsList reportsList = SPHealthReportsList.Local)
            {
                if (reportsList != null)
                {
                    // Write a query against the list.
                    SPQuery query = new SPQuery();
                    query.Query = string.Concat(
                                    "<GroupBy>",
                                        "<FieldRef Name=\"HealthReportCategory\" Ascending=\"FALSE\"/>",
                                    "</GroupBy>",
                                    "<OrderBy>",
                                        "<FieldRef Name=\"HealthReportSeverity\" />",
                                    "</OrderBy>",
                                    "<Where>",
                                        "<Neq>",
                                            "<FieldRef Name=\"HealthReportSeverity\" />",
                                            "<Value Type=\"Text\">4 - Success</Value>",
                                        "</Neq>",
                                    "</Where>"
                                    );
                   
                    // Retrieve list items that satisfy the query.
                    SPListItemCollection reports = reportsList.GetItems(query);

                    // Print information from each item.
                    string category = string.Empty;
                    foreach (SPListItem report in reports)
                    {
                        string thisCategory = report[SPBuiltInFieldId.HealthReportCategory].ToString();
                        if (thisCategory != category)
                        {
                            category = thisCategory;
                            Console.WriteLine("\nCategory: {0}", category);
                        } 
                        
                        string title = report[SPBuiltInFieldId.LinkTitleNoMenu].ToString();
                        string errorLevel = report[SPBuiltInFieldId.HealthReportSeverity].ToString();
                            
                        Console.WriteLine("\n- {0}", title);
                        Console.WriteLine("  Severity: {0}", errorLevel);

                        object failingServers = report[SPBuiltInFieldId.HealthReportServers];
                        object failingServices = report[SPBuiltInFieldId.HealthReportServices];

                        if (failingServers != null)
                            Console.WriteLine("  Failing servers: {0}", failingServers.ToString());
                        if (failingServices != null)
                            Console.WriteLine("  Failing services: {0}", failingServices.ToString());
                    }
                }
            }
            Console.Write("\nPress ENTER to continue...");
            Console.Read();
        }
    }
}
Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Administration.Health

Module Test

    Sub Main()

        Using reportsList As SPHealthReportsList = SPHealthReportsList.Local

            If Not reportsList Is Nothing Then

                ' Write a query against the list.
                Dim query As SPQuery = New SPQuery()
                query.Query = "<GroupBy>" + _
                                    "<FieldRef Name='HealthReportCategory' Ascending='FALSE'/>" + _
                                "</GroupBy>" + _
                                "<OrderBy>" + _
                                    "<FieldRef Name='HealthReportSeverity' />" + _
                                "</OrderBy>" + _
                                "<Where>" + _
                                    "<Neq>" + _
                                        "<FieldRef Name='HealthReportSeverity' />" + _
                                        "<Value Type='Text'>4 - Success</Value>" + _
                                    "</Neq>" + _
                                "</Where>"

                ' Retrieve list items that satisfy the query.
                Dim reports As SPListItemCollection = reportsList.GetItems(query)

                ' Print information from each item.
                Dim category As String = String.Empty
                Dim report As SPListItem
                For Each report In reports

                    Dim thisCategory As String = report(SPBuiltInFieldId.HealthReportCategory).ToString()
                    If thisCategory <> category Then
                        category = thisCategory
                        Console.WriteLine(vbCrLf + "Category: {0}", category)
                    End If

                    Dim title As String = report(SPBuiltInFieldId.LinkTitleNoMenu).ToString()
                    Dim errorLevel As String = report(SPBuiltInFieldId.HealthReportSeverity).ToString()

                    Console.WriteLine(vbCrLf + "- {0}", title)
                    Console.WriteLine("  Severity: {0}", errorLevel)

                    Dim failingServers As Object = report(SPBuiltInFieldId.HealthReportServers)
                    Dim failingServices As Object = report(SPBuiltInFieldId.HealthReportServices)

                    If Not failingServers Is Nothing Then
                        Console.WriteLine("  Failing servers: {0}", failingServers.ToString())
                    End If
                    If Not failingServices Is Nothing Then
                        Console.WriteLine("  Failing services: {0}", failingServices.ToString())
                    End If

                Next
            End If

        End Using
        Console.Write(vbCrLf + "Press ENTER to continue...")
        Console.Read()
    End Sub

End Module

Vea también

Referencia

clase SPHealthReportsList

Miembros SPHealthReportsList

Espacio de nombres Microsoft.SharePoint.Administration.Health