;
Imports System.ServiceProcess
Imports System
Imports Microsoft.Data.Odbc
Public Class AreWeDown
Inherits System.ServiceProcess.ServiceBase
#Region " Component Designer generated code "
Public Sub New()
MyBase.New()
' This call is required by the Component Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call
End Sub
'UserService overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
' The main entry point for the process
_
Shared Sub Main()
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
ServicesToRun = New System.ServiceProcess.ServiceBase() {New AreWeDown}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
End Sub
'Required by the Component Designer
Private components As System.ComponentModel.IContainer
' NOTE: The following procedure is required by the Component Designer
' It can be modified using the Component Designer.
' Do not modify it using the code editor.
Friend WithEvents Timer1 As System.Timers.Timer
Private Sub InitializeComponent()
Me.Timer1 = New System.Timers.Timer
CType(Me.Timer1, System.ComponentModel.ISupportInitialize).BeginInit()
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 30000
Me.ServiceName = "AreWeDown.com"
CType(Me.Timer1, System.ComponentModel.ISupportInitialize).EndInit()
End Sub
#End Region
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Timer1.Enabled = True
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
Timer1.Enabled = False
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As _
System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Dim MyConString As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=arewedownhost;" & _
"DATABASE=arewedown;" & _
"UID=are;" & _
"PASSWORD=arepass;" & _
"OPTION=3;"
Dim MyConnection As New OdbcConnection(MyConString)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "INSERT INTO stats VALUES(CURRENT_TIMESTAMP,USER(),100)"
MyCommand.ExecuteNonQuery()
MyCommand.CommandText = "INSERT INTO stats VALUES(CURRENT_TIMESTAMP,USER(),101)"
MyCommand.ExecuteNonQuery()
MyConnection.Close()
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class
|