You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
193 lines
6.1 KiB
193 lines
6.1 KiB
Imports System.ServiceProcess
|
|
Imports System.Threading
|
|
Imports System.IO
|
|
Imports System.Reflection
|
|
Imports System.IO.File
|
|
Imports System.Data.SqlClient
|
|
Imports System.Data.SqlTypes
|
|
Imports System.ComponentModel
|
|
Imports System
|
|
Imports System.SystemException
|
|
Imports System.Web.Mail
|
|
Imports System.Timers
|
|
|
|
'''<summary></summary>
|
|
Public Class Service1
|
|
Inherits System.ServiceProcess.ServiceBase
|
|
|
|
#Region " Vom Component Designer generierter Code "
|
|
|
|
Public Sub New()
|
|
MyBase.New()
|
|
|
|
' Dieser Aufruf wird vom Komponenten-Designer benötigt.
|
|
InitializeComponent()
|
|
|
|
' Fügen Sie Initialisierungscode hinter dem InitializeComponent()-Aufruf ein
|
|
|
|
End Sub
|
|
|
|
'UserService überschreibt den Löschvorgang zum Bereinigen der Komponentenliste.
|
|
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
|
|
|
|
' Der Haupteinstiegspunkt für den Vorgang
|
|
<MTAThread()>
|
|
Shared Sub Main()
|
|
|
|
#If CONFIG = "Release" Then
|
|
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
|
ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1()}
|
|
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
|
|
#Else
|
|
Dim myServ As New Service1
|
|
myServ.OnStart({""})
|
|
While (True)
|
|
System.Threading.Thread.Sleep(2000)
|
|
End While
|
|
#End If
|
|
'#If DEBUG Then
|
|
' Dim myServ As New Service1()
|
|
' myServ.OnStart({""})
|
|
' While (True)
|
|
' System.Threading.Thread.Sleep(2000)
|
|
' End While
|
|
|
|
'#Else
|
|
' Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
|
' ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1()}
|
|
' System.ServiceProcess.ServiceBase.Run(ServicesToRun)
|
|
'#End If
|
|
|
|
'Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
|
|
|
'ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1()}
|
|
|
|
'System.ServiceProcess.ServiceBase.Run(ServicesToRun)
|
|
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
' Für Komponenten-Designer erforderlich
|
|
Private components As System.ComponentModel.IContainer
|
|
|
|
' HINWEIS: Die folgende Prozedur wird vom Komponenten-Designer benötigt.
|
|
' Sie kann mit dem Komponenten-Designer modifiziert werden. Verwenden Sie nicht
|
|
' den Code-Editor zur Bearbeitung.
|
|
'Friend WithEvents ServiceIcon As System.Windows.Forms.NotifyIcon
|
|
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
|
|
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
|
Me.components = New System.ComponentModel.Container()
|
|
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Service1))
|
|
'Me.ServiceIcon = New System.Windows.Forms.NotifyIcon(Me.components)
|
|
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
|
|
'
|
|
'ServiceIcon
|
|
'
|
|
'Me.ServiceIcon.Icon = CType(resources.GetObject("ServiceIcon.Icon"), System.Drawing.Icon)
|
|
'Me.ServiceIcon.Text = "EDKB08WS"
|
|
'Me.ServiceIcon.Visible = True
|
|
'
|
|
'ImageList1
|
|
'
|
|
Me.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
|
|
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
|
|
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
|
|
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
|
|
'
|
|
'Service1
|
|
'
|
|
Me.ServiceName = "Service1"
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "Deklarationen"
|
|
Dim WithEvents StartTimer As New Timers.Timer()
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "Hauptverarbeitung"
|
|
|
|
'''<summary>Start des Dienstes EDKB08WS</summary>
|
|
'''<remarks>Beim Start des Dienstes werden neben dem Einlesen der Parameter der
|
|
'''Journaltimer sowie der Systemfilewatcher zur Verzeichnisüberwachung
|
|
'''initialisiert.</remarks>
|
|
'''<param name="args"></param>
|
|
Protected Overrides Sub OnStart(ByVal args() As String)
|
|
Try
|
|
PrintOut("Start EDKB21")
|
|
|
|
'Parameter auslesen
|
|
StartTimer.Interval = My.Settings.Timer * 1000
|
|
#If CONFIG = "Release" Then
|
|
Starttimer.Enabled = True
|
|
|
|
#Else
|
|
Dim a As Integer = 1
|
|
StartTimer.Enabled = True
|
|
#End If
|
|
|
|
Catch ex As Exception
|
|
Printout("Fehler beim Start von EDKB21" + ex.Message, EventLogEntryType.Error)
|
|
End Try
|
|
End Sub
|
|
|
|
Protected Overrides Sub OnStop()
|
|
' Dim bmp1 As New Bitmap(Me.ImageList1.Images(2))
|
|
'ServiceIcon.Icon = Icon.FromHandle(bmp1.GetHicon())
|
|
'ServiceIcon.Text = "Stopping..."
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
Sub StartJob() Handles StartTimer.Elapsed
|
|
Shell(My.Settings.Startapp, AppWinStyle.NormalFocus)
|
|
End Sub
|
|
|
|
Public Sub PrintOut(ByVal s As String)
|
|
'Console.WriteLine(Format(Now, "yyyyMMddHHmmss") + ": " + s)
|
|
PrintLog(Format(Now, "yyyyMMddHHmmss") + ": " + s, EventLogEntryType.Information)
|
|
End Sub
|
|
|
|
Public Sub Printout(ByVal s As String, ByVal LogEntryType As EventLogEntryType)
|
|
PrintLog(Format(Now, "yyyyMMddHHmmss") + ": " + s, LogEntryType)
|
|
End Sub
|
|
|
|
Dim EVLog As New EventLog("Log_EDKB21")
|
|
|
|
'''<summary>Eintrag ins EventLog von EDKB08 schreiben</summary>
|
|
'''<param name="message"></param>
|
|
'''<param name="eventmessage"></param>
|
|
Public Sub PrintLog(ByVal message As String, Optional ByVal eventmessage As EventLogEntryType = EventLogEntryType.Information)
|
|
#If CONFIG = "Release" Then 'Release
|
|
If Not EventLog.SourceExists("EDKB21") Then
|
|
EventLog.CreateEventSource("EDKB21", "EDKB08 Log")
|
|
End If
|
|
EVLog.Source = "EDKB08 Log"
|
|
|
|
EventLog.WriteEntry(EVLog.Source, message, eventmessage)
|
|
#Else
|
|
Debug.Print(message)
|
|
|
|
|
|
|
|
#End If
|
|
|
|
End Sub
|
|
|
|
End Class
|