Add MSSQL Functions to ZUGFeRD Service

This commit is contained in:
Jonathan Jenne
2019-04-05 15:51:42 +02:00
parent caad7eda42
commit 720618f29b
10 changed files with 122 additions and 43 deletions

View File

@@ -24,13 +24,15 @@ Public Class ImportZUGFeRDFiles
Private _zugferd As ZUGFeRDInterface
Private _firebird As Firebird
Private _filesystem As Filesystem.File
Private _mssql As MSSQLServer
Public Sub New(LogConfig As LogConfig, Firebird As Firebird)
Public Sub New(LogConfig As LogConfig, Firebird As Firebird, Optional MSSQL As MSSQLServer = Nothing)
_logConfig = LogConfig
_logger = LogConfig.GetLogger()
_firebird = Firebird
_filesystem = New Filesystem.File(_logConfig)
_zugferd = New ZUGFeRDInterface(_logConfig)
_mssql = MSSQL
End Sub
Private Function RandomValue(lowerBound As Integer, upperBound As Integer) As Integer
@@ -182,7 +184,7 @@ Public Class ImportZUGFeRDFiles
Public Sub Start(Arguments As Object) Implements IJob.Start
Dim args As WorkerArgs = Arguments
_logger.Info("Starting Job {0}", Me.GetType.Name)
_logger.Info("Starting Job {0}", [GetType].Name)
Try
For Each oPath As String In args.WatchDirectories
@@ -276,9 +278,17 @@ Public Class ImportZUGFeRDFiles
Dim oTableName = Item.Value.TableName
Dim oCommand = $"INSERT INTO {oTableName} (REFERENCE_GUID, ITEM_DESCRIPTION, ITEM_VALUE) VALUES ('{oFileGroupId}', '{propertyDescripton}', '{propertyValue}')"
_logger.Debug("Mapping Property {0} to value {1}. Will be inserted into table {2}", propertyDescripton, propertyValue, oTableName)
' Insert into SQL Server
If args.InsertIntoSQLServer = True Then
Dim oResult = _mssql.NewExecutenonQuery(oCommand)
If oResult = False Then
_logger.Warn("SQL Command was not successful. Check the log.")
End If
End If
' Insert into Firebird
_firebird.ExecuteNonQueryWithConnection(oCommand, oConnection, Firebird.TransactionMode.ExternalTransaction, oTransaction)
Next

View File

@@ -7,6 +7,7 @@ Public Class WorkerArgs
Public OriginalEmailDirectory As String
Public RejectedEmailDirectory As String
Public PropertyMap As Dictionary(Of String, XmlItemProperty)
Public InsertIntoSQLServer As Boolean
Public Sub New()
WatchDirectories = New List(Of String)
@@ -15,5 +16,6 @@ Public Class WorkerArgs
OriginalEmailDirectory = Nothing
RejectedEmailDirectory = Nothing
PropertyMap = New Dictionary(Of String, XmlItemProperty)
InsertIntoSQLServer = False
End Sub
End Class