73 lines
2.4 KiB
VB.net

Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Base
Public Class ClassConfig
Public Class Config
Public Property PathError As String
Public Property PathAttachments As String
Public Property BodyFont As String
Public Property WindreamConnectionString As String
Public Property TimerInterval As Integer
Public Property WindreamDrive As String = "W"
End Class
Private ReadOnly Logger As Logger
Private ReadOnly Database As MSSQLServer
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
Logger = pLogConfig.GetLogger()
Database = pDatabase
End Sub
Private Function GetConfigTable() As DataTable
Dim oSQL As String = "SELECT * FROM TBEMLP_CONFIG"
Dim oTable As DataTable = Database.GetDatatable(oSQL)
Return oTable
End Function
Private Function GetBaseConfigTable() As DataTable
Dim oSQL As String = "SELECT * FROM TBDD_BASECONFIG"
Dim oTable As DataTable = Database.GetDatatable(oSQL)
Return oTable
End Function
Public Function GetConfig() As Config
Dim oConfigTable = GetConfigTable()
Dim oBaseTable = GetBaseConfigTable()
If oBaseTable Is Nothing Then
Logger.Warn("Config from TBDD_BASECONFIG could not be loaded!")
Return Nothing
End If
If oBaseTable.Rows.Count = 0 Then
Logger.Warn("Config from TBDD_BASECONFIG could not be loaded!")
Return Nothing
End If
If oConfigTable Is Nothing Then
Logger.Warn("Config from TBEMLP_CONFIG could not be loaded!")
Return Nothing
End If
If oConfigTable.Rows.Count = 0 Then
Logger.Warn("Config from TBEMLP_CONFIG is empty!")
Return Nothing
End If
Dim oRow As DataRow = oConfigTable.Rows.Item(0)
Dim oConfig As New Config With {
.PathAttachments = oRow.ItemEx("PATH_EMAIL_TEMP", ""),
.PathError = oRow.ItemEx("PATH_EMAIL_ERRORS", ""),
.BodyFont = oRow.ItemEx("FONT_BODY", "Arial"),
.TimerInterval = oRow.ItemEx("CHECK_INTERVALL_MINUTES", 5),
.WindreamConnectionString = oRow.ItemEx("WM_CON_STRING", ""),
.WindreamDrive = oRow.ItemEx("WM_DRIVE", "W")
}
Return oConfig
End Function
End Class