EDMI: Load Object Store Paths

This commit is contained in:
Jonathan Jenne
2020-04-17 11:57:18 +02:00
parent 88dfb3fab1
commit 14194248ad
12 changed files with 183 additions and 121 deletions

View File

@@ -8,19 +8,18 @@ Imports System.ServiceModel.Description
Public Class WindowsService
Inherits ServiceBase
Private _serviceHost As ServiceHost = Nothing
Private _edmService As IEDMIService = Nothing
Private _ServiceHost As ServiceHost
Private _LogConfig As LogConfig
Private _Logger As Logger
Private _logConfig As LogConfig
Private _logger As Logger
Private _Firebird As Firebird
Private _MSSQL As MSSQLServer
Private _firebird As Firebird
Private _mssql As MSSQLServer
Private _config As AppConfig
Private _Config As AppConfig
Private _Path As EDMI.File.Path
Private _Archive As EDMI.File.Archive
Private _filesystem As Filesystem.File
Private _Filesystem As Filesystem.File
Private _Global As GlobalState
Public Sub New()
ServiceName = SERVICE_NAME
@@ -32,78 +31,84 @@ Public Class WindowsService
Protected Overrides Sub OnStart(ByVal args As String())
Try
AppConfig.Load()
_logConfig = New LogConfig(LogConfig.PathType.CustomPath, "E:\EDMService") With {
_Config = New AppConfig()
_LogConfig = New LogConfig(LogConfig.PathType.CustomPath, "E:\EDMService") With {
.Debug = True
}
_Logger = _LogConfig.GetLogger()
_Logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME)
_logger = _logConfig.GetLogger()
MaybeStartFirebird()
MaybeStartMSSQL()
_logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME)
_Logger.Debug("Initializing EDMI Functions")
If AppConfig.IsFirebirdConfigured() Then
_logger.Debug("Connecting to Firebird...")
_firebird = New Firebird(
_logConfig,
AppConfig.FirebirdDataSource,
AppConfig.FirebirdDatabase,
AppConfig.FirebirdUser,
AppConfig.FirebirdPassword
)
_logger.Info("Database connection established.")
Else
_logger.Info("Firebird is not configured, will not be used!")
End If
_Archive = New EDMI.File.Archive(_LogConfig)
_Filesystem = New Filesystem.File(_LogConfig)
_Global = New GlobalState(_LogConfig, _MSSQL)
If AppConfig.IsMSSQLConfigured() Then
_logger.Debug("Connecting to MSSQL...")
_mssql = New MSSQLServer(_logConfig, AppConfig.MSSQLConnectionString)
_logger.Info("Database connection established.")
Else
_logger.Info("MSSQL is not configured, will not be used!")
End If
_Global.LoadObjectStores()
_logger.Debug("Initializing EDMI Functions")
_Logger.Info("EDMI Functions initialized.")
_Path = New EDMI.File.Path(_logConfig, AppConfig.DatastorePath)
_Archive = New EDMI.File.Archive(_logConfig)
_filesystem = New Filesystem.File(_logConfig)
_logger.Info("EDMI Functions initialized.")
EDMIService.MSSQL = _mssql
EDMIService.Firebird = _firebird
EDMIService.LogConfig = _logConfig
EDMIService.AppConfig = _config
EDMIService.MSSQL = _MSSQL
EDMIService.Firebird = _Firebird
EDMIService.LogConfig = _LogConfig
EDMIService.AppConfig = _Config
EDMIService.EDMIArchive = _Archive
EDMIService.EDMIPath = _Path
EDMIService.Filesystem = _filesystem
EDMIService.Filesystem = _Filesystem
EDMIService.GlobalState = _Global
_logger.Debug("Starting WCF ServiceHost...")
_Logger.Debug("Starting WCF ServiceHost...")
_serviceHost = New ServiceHost(GetType(EDMIService))
_serviceHost.Open()
_ServiceHost = New ServiceHost(GetType(EDMIService))
_ServiceHost.Open()
_logger.Info("WCF ServiceHost started.")
_Logger.Info("WCF ServiceHost started.")
_logger.Info("Service {0} successfully started.", SERVICE_DISPLAY_NAME)
_Logger.Info("Service {0} successfully started.", SERVICE_DISPLAY_NAME)
Catch ex As Exception
_logger.Error(ex, "Failed to start the service host!")
_Logger.Error(ex, "Failed to start the service host!")
GracefullyStop()
End Try
End Sub
Private Sub MaybeStartFirebird()
If _Config.IsFirebirdConfigured() Then
_Logger.Debug("Connecting to Firebird")
_Firebird = New Firebird(
_LogConfig,
_Config.FirebirdDataSource,
_Config.FirebirdDatabase,
_Config.FirebirdUser,
_Config.FirebirdPassword
)
_Logger.Info("Database connection established.")
Else
_Logger.Info("Firebird is not configured, will not be used!")
End If
End Sub
Private Sub MaybeStartMSSQL()
If _Config.IsMSSQLConfigured() Then
_Logger.Debug("Connecting to MSSQL")
_MSSQL = New MSSQLServer(_LogConfig, _Config.MSSQLConnectionString)
_Logger.Info("Database connection established.")
Else
_Logger.Info("MSSQL is not configured, will not be used!")
End If
End Sub
Protected Overrides Sub OnStop()
GracefullyStop()
End Sub
Private Sub GracefullyStop()
If _serviceHost IsNot Nothing Then
_serviceHost.Close()
_serviceHost = Nothing
If _ServiceHost IsNot Nothing Then
_ServiceHost.Close()
_ServiceHost = Nothing
End If
_logger.Info("Service {0} is stopping!", SERVICE_DISPLAY_NAME)
_Logger.Info("Service {0} is stopping!", SERVICE_DISPLAY_NAME)
End Sub
End Class