42 lines
1.3 KiB
VB.net
42 lines
1.3 KiB
VB.net
Imports System.IO
|
|
Imports DigitalData.Modules.Logging
|
|
Imports DigitalData.Modules.Logging.LogConfig
|
|
Imports DigitalData.Modules.Database
|
|
Imports DigitalData.Modules.Config
|
|
|
|
Public Class JobRunnerService
|
|
Private _logConfig As LogConfig
|
|
Private _logger As Logger
|
|
Private _config As ConfigManager(Of Config)
|
|
Private _mssql As MSSQLServer
|
|
Private _jobrunner As JobRunner
|
|
|
|
Protected Overrides Sub OnStart(ByVal args() As String)
|
|
_logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log")) With {.Debug = True}
|
|
_logger = _logConfig.GetLogger()
|
|
|
|
Try
|
|
|
|
_logger.Info("Starting Service {0}", ServiceName)
|
|
_config = New ConfigManager(Of Config)(_logConfig, My.Application.Info.DirectoryPath)
|
|
_logConfig.Debug = _config.Config.Debug
|
|
|
|
_logger.Debug("Connecting to Database..")
|
|
|
|
_mssql = New MSSQLServer(_logConfig, _config.Config.SQLConnectionString)
|
|
|
|
_logger.Debug("Starting Jobrunner..")
|
|
|
|
_jobrunner = New JobRunner(_logConfig, _config.Config, _mssql)
|
|
_jobrunner.Start()
|
|
Catch ex As Exception
|
|
_logger.Error(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Protected Overrides Sub OnStop()
|
|
_jobrunner.Stop()
|
|
_logger.Info("Stopping Service {0}", ServiceName)
|
|
End Sub
|
|
End Class
|