yafes Posted December 23, 2004 Posted December 23, 2004 Where is the Error? Imports System.ServiceProcess Public Class msnService Inherits System.ServiceProcess.ServiceBase Private msnObj As MessengerAPI.Messenger Dim nextStatus As Integer Dim previousStatus As Integer #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 <MTAThread()> _ Shared Sub Main() Dim ServicesToRun() As System.ServiceProcess.ServiceBase ' More than one NT Service may run within the same process. To add ' another service to this process, change the following line to ' create a second service object. For example, ' ' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService} ' ServicesToRun = New System.ServiceProcess.ServiceBase() {New msnService} 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 eventLogMSN As System.Diagnostics.EventLog Friend WithEvents eventTimer As System.Timers.Timer <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.eventLogMSN = New System.Diagnostics.EventLog Me.eventTimer = New System.Timers.Timer CType(Me.eventLogMSN, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.eventTimer, System.ComponentModel.ISupportInitialize).BeginInit() ' 'eventTimer ' Me.eventTimer.Enabled = True Me.eventTimer.Interval = 60000 ' 'msnService ' Me.CanShutdown = True Me.ServiceName = "MSN Messenger Status" CType(Me.eventLogMSN, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.eventTimer, System.ComponentModel.ISupportInitialize).EndInit() End Sub #End Region Protected Overrides Sub OnStart(ByVal args() As String) eventTimer.Enabled = True eventTimer.Start() previousStatus = GetMyStatus(msnObj.MyStatus) End Sub Protected Overrides Sub OnStop() eventTimer.Enabled = False End Sub Public Function GetMyStatus(ByVal intStatus As Integer) As Integer Select Case intStatus Case 1 Return 1 'OffLine Case 2 Return 2 'OnLine Case 6 Return 3 'InVisible Case 10 Return 4 'Busy Case 14 Return 5 'Be Right Back Case 18 Return 6 'Idle Case 34 Return 7 'Away Case 50 Return 8 'On The Phone Case 66 Return 9 'Out To Lunch Case Else Return 10 'Unkown End Select End Function Private Sub eventTimer_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles eventTimer.Elapsed Dim log As New EventLog Dim myEmail As String Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source = C:\inetpub\wwwroot\messenger\db.mdb" Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(connString) Dim updateString As String myEmail = msnObj.MySigninName Try If Not log.SourceExists("msnService") Then log.CreateEventSource("msnService", "msnService Log") End If log.Source = "msnService" nextStatus = GetMyStatus(msnObj.MyStatus) If nextStatus <> previousStatus Then previousStatus = nextStatus End If conn.Open() updateString = "UPDATE ODH_CLIENT SET DURUM='" & nextStatus & "' WHERE EMAIL='" & myEmail & "'" conn.Close() log.WriteEntry("msnService Log", "This is log on" & CStr(TimeOfDay), EventLogEntryType.Information) Catch ex As Exception log.WriteEntry(ex.Message, CStr(TimeOfDay), EventLogEntryType.Information) End Try End Sub End Class Quote
Administrators PlausiblyDamp Posted December 24, 2004 Administrators Posted December 24, 2004 What is the problem? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
yafes Posted December 25, 2004 Author Posted December 25, 2004 i speak some english. Error Timer Component. you The Code packed and run. Quote
Leaders Iceplug Posted December 28, 2004 Leaders Posted December 28, 2004 Do you get a window that gives you the error? Is there a button with "Details" on it? That should show you where the error is... or if you are in the IDE, the line should be highlighted in yellow. Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.