Library code snippets

Health Monitoring in ASP.NET 2

WebEvents Class

Imports DeveloperMeeting
Imports DeveloperMeeting.DataProvider

Namespace EventLog
    Public NotInheritable Class WebEvents #Region " Constructor "
        Public Sub New(ByVal ConnectionString As String)             _ConnectionString = ConnectionString             DSEventLog = SqlDataProvider.FillDataSet(ConnectionString, _             "DM_WebEvent_GetLogEvent", _ CommandType.StoredProcedure, Nothing)         End Sub #End Region

#Region " Declarations "
        Dim DSEventLog As New DataSet
        Dim _ConnectionString As String
#End Region
#Region " Propreties "
        Public ReadOnly Property Count() As Integer
            Get
                Return DSEventLog.Tables(0).Rows.Count
            End Get
        End Property
#End Region #Region " GetEventLog Method "
        Public Function GetEventLog(ByVal Index As Integer) As [Event]
            Dim Return_Value As New [Event]
            With Return_Value
                .EventID = DSEventLog.Tables(0).Rows(Index)("EventId")
                .EventTimeUtc = DSEventLog.Tables(0).Rows(Index)("EventTimeUtc")
                .EventTime = DSEventLog.Tables(0).Rows(Index)("EventTime")
                .EventType = DSEventLog.Tables(0).Rows(Index)("EventType")
                .EventSequence = DSEventLog.Tables(0).Rows(Index)("EventSequence")
                .EventOccurrence = DSEventLog.Tables(0).Rows(Index)("EventOccurrence")
                .EventCode = DSEventLog.Tables(0).Rows(Index)("EventCode")
                .EventDetailCode = DSEventLog.Tables(0).Rows(Index)("EventDetailCode")
                .Message = IIf(DSEventLog.Tables(0).Rows(Index)("Message") Is DBNull.Value, _
vbNullString, DSEventLog.Tables(0).Rows(Index)("Message"))
                .ApplicationPath = IIf(DSEventLog.Tables(0).Rows(Index)("ApplicationPath") _
Is DBNull.Value, vbNullString, DSEventLog.Tables(0).Rows(Index)
("ApplicationPath"))
                .ApplicationVirtualPath = IIf(DSEventLog.Tables(0).Rows(Index) _
("ApplicationVirtualPath") Is DBNull.Value, vbNullString, _
DSEventLog.Tables(0).Rows(Index)("ApplicationVirtualPath"))
                .MachineName = DSEventLog.Tables(0).Rows(Index)("MachineName")
                .RequestUrl = IIf(DSEventLog.Tables(0).Rows(Index)("RequestUrl") _
Is DBNull.Value, vbNullString, DSEventLog.Tables(0).Rows(Index)("RequestUrl"))
                .ExceptionType = IIf(DSEventLog.Tables(0).Rows(Index)("ExceptionType") _
Is DBNull.Value, vbNullString, DSEventLog.Tables(0).Rows(Index) _
("ExceptionType"))
                .Details = IIf(DSEventLog.Tables(0).Rows(Index)("Details") Is DBNull.Value, _
vbNullString, DSEventLog.Tables(0).Rows(Index)("Details"))
            End With
            Return Return_Value
        End Function

        Public Function GetEventLog() As DataSet
            Return DSEventLog
        End Function
#End Region #Region " ClearAllEvent Method "
        Public Sub ClearAllEvent()
            SqlDataProvider.ExecuteQuery(_ConnectionString, "DM_WebEvent_ClearAllEvent", _
CommandType.StoredProcedure, Nothing)
        End Sub
#End Region
    End Class End Namespace

Comments

  1. 22 May 2006 at 06:53

    Hi Mehdi Golchin,

    Thanks for you guide. I have successed to configure the aspnet_regsql.

     

    regard,
    Jason

  2. 21 May 2006 at 18:39

    Hi Jason,
    Health monitoring uses SQL Server for storing web events. so you must add health monitoring's tables and stored procedures. for that you have tow solutions. you can use aspnet_regsql command in visual studio command prompt or if you like to create a installation page for your project you can use
    that code which generates health monitoring's tables and stored procedures as run-time.

  3. 21 May 2006 at 15:48

    Dear Mehdi Golchin,

    With regard to your Step 1, can you please explain more in details "run-time mode". As i do not know where to install it Many thanks...

    Step 1 : Installing Web Event
    You can do this easily in run-time mode with this code below:

    Management.SqlServices.Install("Computer Name", "SQL user name",_
    "SQL password", "Database name", Management.SqlFeatures._
    SqlWebEventProvider)

     
    Regard,
    Jason
  4. 01 Jan 1999 at 00:00

    This thread is for discussions of Health Monitoring in ASP.NET 2.

Leave a comment

Sign in or Join us (it's free).

Related podcasts

Events coming up

  • Mar 15

    DevWeek 2010

    London, United Kingdom

    DevWeek is Europe’s leading independent conference for software developers, database professionals and IT architects, and features expert speakers on a wide range of topics, including .NET 4.0, Silverlight 3, WCF 4, Visual Studio 2010, REST, Windows Workflow 4, Thread Synchronization, ASP.NET 4.0, SQL Server 2008 R2, LINQ, Unit Testing, CLR & C# 4.0, .NET Patterns, WPF 4, F#, Windows Azure, ADO.NET, Entity Framework, Debugging, T-SQL Tips & Tricks, and more.

We'd love to hear what you think! Submit ideas or give us feedback