WebProcessInformation Klas

Definitie

Biedt informatie over het werkproces dat als host fungeert voor ASP.NET.

public ref class WebProcessInformation sealed
public sealed class WebProcessInformation
type WebProcessInformation = class
Public NotInheritable Class WebProcessInformation
Overname
WebProcessInformation

Voorbeelden

Het volgende voorbeeld heeft twee delen. Het eerste is een fragment van een configuratiebestand waarmee ASP.NET een aangepaste gebeurtenis kan gebruiken die gebruikmaakt van het type WebProcessInformation.

In de tweede sectie ziet u hoe u de aangepaste gebeurtenis implementeert.

Zorg ervoor dat uw aangepaste gebeurtenis op het juiste moment wordt gegenereerd, dat wil gezegd, wanneer de equivalente systeemstatus gebeurtenis die wordt vervangen, wordt gegenereerd.

<healthMonitoring
  enabled="true" heartBeatInterval="0">

    <eventMappings>
      <add
        name="SampleProcessInformation"
        type="SamplesAspNet.SampleWebProcessInformation, webprocessinformation, Version=1.0.1585.27289, Culture=neutral, PublicKeyToken=3648e5c763a8239f, processorArchitecture=MSIL"/>
    </eventMappings>

    <rules>
      <add
        name="Custom Process Information"
        eventName="SampleProcessInformation"
        provider="EventLogProvider"
        profile="Default"/>
    </rules>

</healthMonitoring>

In het volgende voorbeeld ziet u hoe u een aangepaste gebeurtenis implementeert die gebruikmaakt van het WebProcessInformation type.


using System;
using System.Text;
using System.Web;
using System.Web.Management;

namespace SamplesAspNet
{
    // Implements a custom WebBaseEvent type that 
    // uses WebProcessInformation.
    public class SampleWebProcessInformation: 
        WebManagementEvent
    {
        private StringBuilder eventInfo;
        // Instantiate SampleWebProcessInformation.    
        public SampleWebProcessInformation(string msg, 
            object eventSource, int eventCode) : 
        base(msg, eventSource, eventCode)
        {
            // Perform custom initialization.
            eventInfo = new StringBuilder();
            eventInfo.Append(string.Format(
            "Event created at: {0}", 
            EventTime.ToString()));
        }   

        // Raises the event.
        public override void Raise()
        {
            // Perform custom processing. 
            eventInfo.Append(string.Format(
            "Event raised at: {0}", 
            EventTime.ToString()));

            // Raise the event.
            base.Raise();
        }

        public string GetAccountName()
        {
            // Get the name of the account.
            return (string.Format(
                "Account name: {0}", 
                ProcessInformation.AccountName));
        }

        public string GetProcessId()
        {
            // Get the process identifier.
            return (string.Format(
                "Process Id: {0}", 
                ProcessInformation.ProcessID.ToString()));
        }

        public string GetProcessName()
        {
            // Get the requests in execution.
            return (string.Format(
                "Process name: {0}", 
                ProcessInformation.ProcessName));
        }

        //Formats Web request event information.
        public override void FormatCustomEventDetails(
            WebEventFormatter formatter)
        {
            base.FormatCustomEventDetails(formatter);

            // Add custom data.
            formatter.AppendLine("Custom Process Information:");
            formatter.IndentationLevel += 1;

            // Display the process information.
            formatter.AppendLine(GetAccountName());
            formatter.AppendLine(GetProcessId());
            formatter.AppendLine(GetProcessName());
            formatter.IndentationLevel -= 1;
            formatter.AppendLine(eventInfo.ToString());
        }
    }
}
Imports System.Text
Imports System.Web
Imports System.Web.Management


' Implements a custom WebBaseEvent type that 
' uses WebProcessInformation.

Public Class SampleWebProcessInformation
   Inherits WebBaseEvent
   Private eventInfo As StringBuilder
    Private Shared processInformation _
    As WebProcessInformation
   
   ' Instantiate SampleWebProcessInformation.    
    Public Sub New(ByVal msg As String, _
    ByVal eventSource As Object, ByVal eventCode As Integer)
        MyBase.New(msg, eventSource, eventCode)
        ' Perform custom initialization.
        eventInfo = New StringBuilder
        eventInfo.Append(String.Format( _
        "Event created at: {0}", _
        EventTime.ToString()))

    End Sub
   
   ' Raises the event.
   Public Overrides Sub Raise()
      ' Perform custom processing. 
        eventInfo.Append(String.Format( _
        "Event raised at: {0}", _
        EventTime.ToString()))
      
      ' Raise the event.
      MyBase.Raise()
   End Sub
   
   Public Function GetAccountName() As String
      ' Get the name of the account.
        Return String.Format("Account name: {0}", _
        processInformation.AccountName)
   End Function 'GetAccountName
   
   Public Function GetProcessId() As String
      ' Get the process identifier.
        Return String.Format("Process Id: {0}", _
        processInformation.ProcessID.ToString())
   End Function 'GetProcessId
   
   Public Function GetProcessName() As String
      ' Get the requests in execution.
        Return String.Format("Process name: {0}", _
        ProcessInformation.ProcessName)
   End Function 'GetProcessName
   
    'Formats Web request event information.
    Public Overrides Sub FormatCustomEventDetails( _
    ByVal formatter _
    As System.Web.Management.WebEventFormatter)
        MyBase.FormatCustomEventDetails(formatter)
   
        ' Add custom data.
        formatter.AppendLine("")
        formatter.AppendLine( _
        "Custom Process Information:")
        formatter.IndentationLevel += 1

        ' Display the process information.
        formatter.AppendLine(GetAccountName())
        formatter.AppendLine(GetProcessId())
        formatter.AppendLine(GetProcessName())
        formatter.IndentationLevel -= 1
        formatter.AppendLine(eventInfo.ToString())
    End Sub

End Class

Opmerkingen

ASP.NET statuscontrole maakt het productie- en operationele personeel mogelijk om geïmplementeerde webtoepassingen te beheren. De System.Web.Management naamruimte bevat de statusgebeurtenistypen die verantwoordelijk zijn voor het verpakken van statusgegevens van toepassingen en de providertypen die verantwoordelijk zijn voor het verwerken van deze gegevens. Het bevat ook ondersteunende typen die u helpen tijdens het beheer van statusevenementen.

Exemplaren van de WebProcessInformation klasse bevatten informatie die wordt verkregen met behulp van een van de typen die zijn afgeleid van het WebManagementEvent type.

Uw toepassing heeft de juiste machtigingen nodig voor toegang tot beveiligde gegevens die door dit type worden verstrekt.

Het volgende voorbeeld is een fragment van het configuratiebestand dat u kunt gebruiken om ASP.NET in staat te stellen fouten te registreren die procesinformatie bevatten.

<healthMonitoring
  enabled="true" heartBeatInterval="0">

    <rules>
     <add
       name="All Errors Default"
       eventName="All Errors"
       provider="EventLogProvider"
       profile="Default"
       minInterval="00:01:00" />
    </rules>

</healthMonitoring>

Note

In de meeste gevallen kunt u de ASP.NET statuscontroletypen gebruiken zoals geïmplementeerd en u kunt het systeem voor statusbewaking beheren door waarden op te geven in de sectie healthMonitoring configuratie. U kunt ook afleiden van de statuscontroletypen om uw eigen aangepaste gebeurtenissen en providers te maken. Zie de sectie Voorbeeld voor een voorbeeld van het maken van een aangepaste gebeurtenisklasse.

Eigenschappen

Name Description
AccountName

Hiermee haalt u de accountnaam voor het werkproces op.

ProcessID

Hiermee haalt u de proces-id op.

ProcessName

Hiermee haalt u de naam van het proces op.

Methoden

Name Description
Equals(Object)

Bepaalt of het opgegeven object gelijk is aan het huidige object.

(Overgenomen van Object)
FormatToString(WebEventFormatter)

Hiermee wordt de toepassingsgegevens opgemaakt.

GetHashCode()

Fungeert als de standaardhashfunctie.

(Overgenomen van Object)
GetType()

Hiermee haalt u de Type huidige instantie op.

(Overgenomen van Object)
MemberwiseClone()

Hiermee maakt u een ondiepe kopie van de huidige Object.

(Overgenomen van Object)
ToString()

Retourneert een tekenreeks die het huidige object vertegenwoordigt.

(Overgenomen van Object)

Van toepassing op

Zie ook