39 lines
1.3 KiB
VB.net
39 lines
1.3 KiB
VB.net
Imports System.IO
|
|
Imports DigitalData.Modules.Database
|
|
Imports DigitalData.Modules.Logging
|
|
Imports DigitalData.Modules.Logging.LogConfig
|
|
|
|
Public Class WindowsService
|
|
Private _logConfig As LogConfig
|
|
Private _logger As Logger
|
|
Private _firebird As Firebird
|
|
|
|
Private _jobRunner As JobRunner
|
|
|
|
Protected Overrides Sub OnStart(ByVal args() As String)
|
|
_logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
|
|
_logConfig.Debug = True
|
|
_logger = _logConfig.GetLogger()
|
|
_logger.Info($"{My.Settings.SERVICE_NAME} is starting.")
|
|
|
|
Dim oDataSource As String = My.Settings.DB_DATASOURCE
|
|
Dim oDatabase As String = My.Settings.DB_DATABASE
|
|
Dim oUser As String = My.Settings.DB_USER
|
|
Dim oPassword As String = My.Settings.DB_PASSWORD
|
|
Dim oInterval As Long = My.Settings.JOB_INTERVAL
|
|
|
|
_firebird = New Firebird(_logConfig, oDataSource, oDatabase, oUser, oPassword)
|
|
|
|
Try
|
|
_jobRunner = New JobRunner(_logConfig, _firebird, oInterval)
|
|
_jobRunner.Start()
|
|
Catch ex As Exception
|
|
_logger.Error(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Protected Overrides Sub OnStop()
|
|
_logger.Info($"{My.Settings.SERVICE_NAME} is stopping.")
|
|
End Sub
|
|
End Class
|