ZUGFeRDService: Load ExceptionEmailAddress from Config
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
Public Property JobInterval As Integer = 10
|
||||
Public Property GDPictureKey As String = "1234567890_EXAMPLE_KEY"
|
||||
Public Property ExceptionEmailAddress As String = "wisag-flow@digitaldata.works"
|
||||
|
||||
Public Property Debug As Boolean = False
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Public Class ThreadRunner
|
||||
Private WithEvents _workerThread As BackgroundWorker
|
||||
Private WithEvents _workerTimer As Timer
|
||||
|
||||
Private _config As Config
|
||||
Private _config As ConfigManager(Of Config)
|
||||
Private _logConfig As LogConfig
|
||||
Private _logger As Logger
|
||||
Private _firebird As Firebird
|
||||
@@ -27,11 +27,11 @@ Public Class ThreadRunner
|
||||
Private _jobArguments As WorkerArgs
|
||||
Private _mssql As MSSQLServer
|
||||
|
||||
Public Sub New(LogConfig As LogConfig, Config As ConfigManager(Of Config), Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing)
|
||||
Public Sub New(LogConfig As LogConfig, ConfigManager As ConfigManager(Of Config), Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing)
|
||||
_logConfig = LogConfig
|
||||
_logger = _logConfig.GetLogger()
|
||||
_firebird = Firebird
|
||||
_config = Config
|
||||
_config = ConfigManager
|
||||
_mssql = MSSQL
|
||||
Try
|
||||
Dim directory As New IO.DirectoryInfo(_logConfig.LogDirectory)
|
||||
@@ -48,39 +48,47 @@ Public Class ThreadRunner
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
Dim args As New WorkerArgs()
|
||||
args = LoadFolderConfig(args)
|
||||
args = LoadPropertyMapFor(args, "DEFAULT")
|
||||
|
||||
Dim oArgs As New WorkerArgs With {
|
||||
.ExceptionEmailAddress = _config.Config.ExceptionEmailAddress
|
||||
}
|
||||
oArgs = LoadFolderConfig(oArgs)
|
||||
oArgs = LoadPropertyMapFor(oArgs, "DEFAULT")
|
||||
|
||||
' Use MSSQL Server if available
|
||||
If Not IsNothing(_mssql) Then
|
||||
_logger.Debug("Data will also be inserted into MSSQL Server.")
|
||||
args.InsertIntoSQLServer = True
|
||||
oArgs.InsertIntoSQLServer = True
|
||||
End If
|
||||
|
||||
_jobArguments = args
|
||||
_jobArguments = oArgs
|
||||
|
||||
_logger.Debug("Checking SuccessDirectory {0}", args.SuccessDirectory)
|
||||
If Not Directory.Exists(args.SuccessDirectory) Then
|
||||
_logger.Warn("SuccessDirectory {0} does not exist!", args.SuccessDirectory)
|
||||
_logger.Debug("Checking SuccessDirectory {0}", oArgs.SuccessDirectory)
|
||||
If Not Directory.Exists(oArgs.SuccessDirectory) Then
|
||||
_logger.Warn("SuccessDirectory {0} does not exist!", oArgs.SuccessDirectory)
|
||||
End If
|
||||
|
||||
_logger.Debug("Checking ErrorDirectory {0}", args.ErrorDirectory)
|
||||
If Not Directory.Exists(args.ErrorDirectory) Then
|
||||
_logger.Warn("ErrorDirectory {0} does not exist!", args.ErrorDirectory)
|
||||
_logger.Debug("Checking ErrorDirectory {0}", oArgs.ErrorDirectory)
|
||||
If Not Directory.Exists(oArgs.ErrorDirectory) Then
|
||||
_logger.Warn("ErrorDirectory {0} does not exist!", oArgs.ErrorDirectory)
|
||||
End If
|
||||
|
||||
_logger.Debug("Checking Original Email Directory {0}", args.OriginalEmailDirectory)
|
||||
If Not Directory.Exists(args.OriginalEmailDirectory) Then
|
||||
_logger.Warn("OriginalEmailDirectory {0} does not exist!", args.OriginalEmailDirectory)
|
||||
_logger.Debug("Checking Original Email Directory {0}", oArgs.OriginalEmailDirectory)
|
||||
If Not Directory.Exists(oArgs.OriginalEmailDirectory) Then
|
||||
_logger.Warn("OriginalEmailDirectory {0} does not exist!", oArgs.OriginalEmailDirectory)
|
||||
End If
|
||||
|
||||
_logger.Debug("Checking Rejected Email Directory {0}", args.RejectedEmailDirectory)
|
||||
If Not Directory.Exists(args.RejectedEmailDirectory) Then
|
||||
_logger.Warn("RejectedEmailDirectory {0} does not exist!", args.RejectedEmailDirectory)
|
||||
_logger.Debug("Checking Rejected Email Directory {0}", oArgs.RejectedEmailDirectory)
|
||||
If Not Directory.Exists(oArgs.RejectedEmailDirectory) Then
|
||||
_logger.Warn("RejectedEmailDirectory {0} does not exist!", oArgs.RejectedEmailDirectory)
|
||||
End If
|
||||
|
||||
For Each oDirectory In args.WatchDirectories
|
||||
_logger.Debug("Checking Exception Email Adress {0}", oArgs.ExceptionEmailAddress)
|
||||
If oArgs.ExceptionEmailAddress = String.Empty Then
|
||||
_logger.Warn("ExceptionEmailAddress {0} is not set!", oArgs.ExceptionEmailAddress)
|
||||
End If
|
||||
|
||||
For Each oDirectory In oArgs.WatchDirectories
|
||||
_logger.Debug("Checking WatchDirectory {0}", oDirectory)
|
||||
If Not Directory.Exists(oDirectory) Then
|
||||
_logger.Warn("WatchDirectory {0} does not exist!", oDirectory)
|
||||
@@ -140,7 +148,7 @@ Public Class ThreadRunner
|
||||
Dim args As WorkerArgs = e.Argument
|
||||
_logger.Debug("Background worker running..")
|
||||
|
||||
Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, _config.MSSQLEmailOutAccountID, _mssql)
|
||||
Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, _config.Config.MSSQLEmailOutAccountID, _mssql)
|
||||
job.Start(args)
|
||||
Catch ex As Exception
|
||||
_logger.Warn("Background worker failed!")
|
||||
@@ -152,7 +160,7 @@ Public Class ThreadRunner
|
||||
_logger.Debug("Background worker completed!")
|
||||
End Sub
|
||||
|
||||
Private Function LoadFolderConfig(args As WorkerArgs)
|
||||
Private Function LoadFolderConfig(pArgs As WorkerArgs) As WorkerArgs
|
||||
Dim oSQL As String = "SELECT T1.FOLDER_TYPE, T.FOLDER_PATH FROM TBEDM_FOLDER T, TBEDM_FOLDER_TYPE T1 WHERE T.FOLDER_TYPE_ID = T1.GUID AND T1.""ACTIVE"" = True AND T.""ACTIVE"" = True"
|
||||
Dim oResult As DataTable = _firebird.GetDatatable(oSQL)
|
||||
|
||||
@@ -161,31 +169,31 @@ Public Class ThreadRunner
|
||||
|
||||
Select Case oFolderType
|
||||
Case ZUGFERD_IN
|
||||
args.WatchDirectories.Add(row.Item("FOLDER_PATH"))
|
||||
pArgs.WatchDirectories.Add(row.Item("FOLDER_PATH"))
|
||||
|
||||
Case ZUGFERD_SUCCESS
|
||||
args.SuccessDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.SuccessDirectory = row.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_ERROR
|
||||
args.ErrorDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.ErrorDirectory = row.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_EML
|
||||
args.OriginalEmailDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.OriginalEmailDirectory = row.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_REJECTED_EML
|
||||
args.RejectedEmailDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.RejectedEmailDirectory = row.Item("FOLDER_PATH")
|
||||
|
||||
Case ZUGFERD_ATTACHMENTS
|
||||
args.AttachmentsSubDirectory = row.Item("FOLDER_PATH")
|
||||
pArgs.AttachmentsSubDirectory = row.Item("FOLDER_PATH")
|
||||
|
||||
End Select
|
||||
Next
|
||||
|
||||
Return args
|
||||
Return pArgs
|
||||
End Function
|
||||
|
||||
Private Function LoadPropertyMapFor(args As WorkerArgs, specification As String)
|
||||
Dim oSQL As String = $"SELECT * FROM TBEDM_XML_ITEMS WHERE SPECIFICATION = '{specification}' AND ACTIVE = True ORDER BY XML_PATH"
|
||||
Private Function LoadPropertyMapFor(pArgs As WorkerArgs, pSpecification As String) As WorkerArgs
|
||||
Dim oSQL As String = $"SELECT * FROM TBEDM_XML_ITEMS WHERE SPECIFICATION = '{pSpecification}' AND ACTIVE = True ORDER BY XML_PATH"
|
||||
Dim oResult As DataTable = _firebird.GetDatatable(oSQL)
|
||||
|
||||
For Each row As DataRow In oResult.Rows
|
||||
@@ -197,7 +205,7 @@ Public Class ThreadRunner
|
||||
Dim oIsGrouped = row.Item("IS_GROUPED")
|
||||
Dim oGroupScope = row.Item("GROUP_SCOPE")
|
||||
|
||||
args.PropertyMap.Add(oXmlPath, New XmlItemProperty() With {
|
||||
pArgs.PropertyMap.Add(oXmlPath, New XmlItemProperty() With {
|
||||
.Description = oDescription,
|
||||
.TableName = oTableName,
|
||||
.TableColumn = oTableColumn,
|
||||
@@ -207,6 +215,6 @@ Public Class ThreadRunner
|
||||
})
|
||||
Next
|
||||
|
||||
Return args
|
||||
Return pArgs
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user