|
|
|
|
@@ -1,17 +1,15 @@
|
|
|
|
|
Imports System.Collections.Generic
|
|
|
|
|
Imports System.Data
|
|
|
|
|
Imports System.Data.SqlClient
|
|
|
|
|
Imports System.IO
|
|
|
|
|
Imports System.Linq
|
|
|
|
|
Imports System.Security.Cryptography
|
|
|
|
|
Imports DigitalData.Modules.Base
|
|
|
|
|
Imports DigitalData.Modules.Database
|
|
|
|
|
Imports DigitalData.Modules.Interfaces
|
|
|
|
|
Imports DigitalData.Modules.Interfaces.Exceptions
|
|
|
|
|
Imports DigitalData.Modules.Interfaces.PropertyValues
|
|
|
|
|
Imports DigitalData.Modules.Jobs.Exceptions
|
|
|
|
|
Imports DigitalData.Modules.Logging
|
|
|
|
|
Imports System.Data.SqlClient
|
|
|
|
|
Imports Newtonsoft.Json.Linq
|
|
|
|
|
Imports System.Xml.Linq
|
|
|
|
|
|
|
|
|
|
Public Class ImportZUGFeRDFiles
|
|
|
|
|
Implements IJob
|
|
|
|
|
@@ -85,7 +83,7 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
|
|
|
|
|
Public Sub Start(Arguments As Object) Implements IJob.Start
|
|
|
|
|
Dim oArgs As WorkerArgs = Arguments
|
|
|
|
|
Dim oPropertyExtractor = New PropertyValues(_logConfig)
|
|
|
|
|
'Dim oPropertyExtractor = New PropertyValues(_logConfig)
|
|
|
|
|
Dim oAttachmentExtractor = New PDFEmbeds(_logConfig)
|
|
|
|
|
|
|
|
|
|
_EmailOutAccountId = oArgs.EmailOutProfileId
|
|
|
|
|
@@ -219,10 +217,12 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
Catch ex As ValidationException
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
Dim oErrors = ex.ValidationErrors
|
|
|
|
|
Dim oMessage = "REJECTED - ZUGFeRD yes but formal validation failed!"
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage)
|
|
|
|
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.ValidationException)
|
|
|
|
|
|
|
|
|
|
'Dim oMessage = "REJECTED - ZUGFeRD yes but formal validation failed!"
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
|
|
|
|
|
|
|
|
|
Dim oErrors = ex.ValidationErrors
|
|
|
|
|
Dim oErrorList As String = ""
|
|
|
|
|
Dim oErrorListDE As String = ""
|
|
|
|
|
For Each oError In oErrors
|
|
|
|
|
@@ -233,107 +233,115 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
Dim oBody = String.Format(EmailStrings.EMAIL_VALIDATION_ERROR, oErrorList)
|
|
|
|
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "ValidationException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.ValidationException, oErrorListDE, oErrorList)
|
|
|
|
|
AddRejectedState(oMessageId, "ValidationException", "Die Rechnungsvalidierung ist fehlgeschlagen!", "", oSQLTransaction)
|
|
|
|
|
AddRejectedState(oMessageId, oRejectionCodeString, "Die Rechnungsvalidierung ist fehlgeschlagen!", "", oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
Catch ex As MD5HashException
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.MD5HashException)
|
|
|
|
|
|
|
|
|
|
' When MD5HashException is thrown, we don't have a MD5Hash yet.
|
|
|
|
|
' That 's why we set it to String.Empty here.
|
|
|
|
|
Dim oMessage = "REJECTED - Already processed (MD5Hash)"
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oMessage)
|
|
|
|
|
' Thats why we set it to String.Empty here.
|
|
|
|
|
'Dim oMessage = "REJECTED - Already processed (MD5Hash)"
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oRejectionCodeString)
|
|
|
|
|
|
|
|
|
|
Dim oBody = String.Format(EmailStrings.EMAIL_MD5_ERROR, ex.FileName)
|
|
|
|
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MD5HashException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MD5HashException, ex.FileName, "")
|
|
|
|
|
AddRejectedState(oMessageId, "MD5HashException", "Die gesendete Rechnung wurde bereits verarbeitet!", "", oSQLTransaction)
|
|
|
|
|
AddRejectedState(oMessageId, oRejectionCodeString, "Die gesendete Rechnung wurde bereits verarbeitet!", "", oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
Catch ex As UnsupportedFerdException
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.UnsupportedFerdException)
|
|
|
|
|
|
|
|
|
|
' When UnsupportedFerdException is thrown, we don't have a MD5Hash yet.
|
|
|
|
|
' That 's why we set it to String.Empty here.
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, String.Empty, "REJECTED - ZUGFeRD yes but unsupported format")
|
|
|
|
|
' Thats why we set it to String.Empty here.
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oRejectionCodeString)
|
|
|
|
|
|
|
|
|
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
|
|
|
|
Dim oBody As String = String.Format(EmailStrings.EMAIL_UNSUPPORTED_DOCUMENT, oEmailData.Subject, ex.XmlFile)
|
|
|
|
|
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "UnsupportedFerdException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnsupportedFerdException, ex.XmlFile, "")
|
|
|
|
|
AddRejectedState(oMessageId, "UnsupportedFerdException", "Nicht unterstütztes Datenformat", "", oSQLTransaction)
|
|
|
|
|
AddRejectedState(oMessageId, oRejectionCodeString, "Nicht unterstütztes Datenformat", "", oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
Catch ex As InvalidFerdException
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.InvalidFerdException)
|
|
|
|
|
|
|
|
|
|
' When InvalidFerdException is thrown, we don't have a MD5Hash yet.
|
|
|
|
|
' That 's why we set it to String.Empty here.
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, String.Empty, "REJECTED - ZUGFeRD yes but incorrect format")
|
|
|
|
|
' Thats why we set it to String.Empty here.
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, String.Empty, oRejectionCodeString)
|
|
|
|
|
|
|
|
|
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
|
|
|
|
Dim oBody = String.Format(EmailStrings.EMAIL_INVALID_DOCUMENT, oEmailData.Subject)
|
|
|
|
|
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "InvalidFerdException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.InvalidFerdException, "", "")
|
|
|
|
|
AddRejectedState(oMessageId, "InvalidFerdException", "Inkorrekte Formate", "", oSQLTransaction)
|
|
|
|
|
AddRejectedState(oMessageId, oRejectionCodeString, "Inkorrektes Format", "", oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
Catch ex As TooMuchFerdsException
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - More than one ZUGFeRD-document in email")
|
|
|
|
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.TooMuchFerdsException)
|
|
|
|
|
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
|
|
|
|
|
|
|
|
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
|
|
|
|
Dim oBody = String.Format(EmailStrings.EMAIL_TOO_MUCH_FERDS, oEmailData.Subject)
|
|
|
|
|
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "TooMuchFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.TooMuchFerdsException, "", "")
|
|
|
|
|
AddRejectedState(oMessageId, "TooMuchFerdsException", "Email enthielt mehr als ein ZUGFeRD-Dokument", "", oSQLTransaction)
|
|
|
|
|
AddRejectedState(oMessageId, oRejectionCodeString, "Email enthielt mehr als ein ZUGFeRD-Dokument", "", oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
Catch ex As NoFerdsException
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - no ZUGFeRD-Document in email")
|
|
|
|
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.NoFerdsException)
|
|
|
|
|
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
|
|
|
|
|
|
|
|
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
|
|
|
|
Dim oBody = String.Format(EmailStrings.EMAIL_NO_FERDS, oEmailData.Subject)
|
|
|
|
|
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "NoFerdsException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.NoFerdsException, "", "")
|
|
|
|
|
AddRejectedState(oMessageId, "NoFerdsException", " Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction)
|
|
|
|
|
AddRejectedState(oMessageId, oRejectionCodeString, "Email enthielt keine ZUGFeRD-Dokumente", "", oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
Catch ex As MissingValueException
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
Dim oMessage As String = ""
|
|
|
|
|
For Each prop In ex.MissingProperties
|
|
|
|
|
oMessage &= $"- {prop}"
|
|
|
|
|
Next
|
|
|
|
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.MissingValueException)
|
|
|
|
|
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, $"REJECTED - Missing Required Properties: [{oMessage}]")
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
|
|
|
|
|
|
|
|
|
Dim oMissingFieldList As String = ""
|
|
|
|
|
For Each oMissingFieldDescription In ex.MissingProperties
|
|
|
|
|
oMissingFieldList += $"<li>{oMissingFieldDescription}</li>"
|
|
|
|
|
oMissingFieldList += $"<li>{oMissingFieldDescription.Description}<br/><em>{oMissingFieldDescription.XMLPath}</em></li>"
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
Dim oOrgFilename = _hash.GetOriginalFilename(ex.File.Name)
|
|
|
|
|
Dim oBody = _email.CreateBodyForMissingProperties(ex.File.Name, ex.MissingProperties)
|
|
|
|
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MissingValueException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MissingValueException, ex.File.Name, oMissingFieldList)
|
|
|
|
|
AddRejectedState(oMessageId, "MissingValueException", "Es fehlten ZugferdSpezifikationen", oMessage, oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "MissingValueException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.MissingValueException, oOrgFilename, oMissingFieldList)
|
|
|
|
|
AddRejectedState(oMessageId, oRejectionCodeString, "Es fehlten ZugferdSpezifikationen", "", oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
Catch ex As FileSizeLimitReachedException
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - File size limit reached")
|
|
|
|
|
Dim oRejectionCodeString = GetRejectionCodeString(oMessageId, ErrorCode.FileSizeLimitReachedException)
|
|
|
|
|
|
|
|
|
|
_history.Update_HistoryEntry(oMessageId, oMD5CheckSum, oRejectionCodeString)
|
|
|
|
|
|
|
|
|
|
Dim oEmailData = _file.MoveAndRenameEmailToRejected(oArgs, oMessageId)
|
|
|
|
|
|
|
|
|
|
Dim oKey = FileSizeLimitReachedException.KEY_FILENAME
|
|
|
|
|
Dim oFileExceedingThreshold As String = IIf(ex.Data.Contains(oKey), ex.Data.Item(oKey), "")
|
|
|
|
|
Dim oFileWithoutMessageId = oFileExceedingThreshold.
|
|
|
|
|
Replace(oMessageId, "").
|
|
|
|
|
Replace("~", "")
|
|
|
|
|
Dim oOrgFilename = _hash.GetOriginalFilename(oFileExceedingThreshold)
|
|
|
|
|
|
|
|
|
|
Dim oBody = String.Format(EmailStrings.EMAIL_FILE_SIZE_REACHED, oArgs.MaxAttachmentSizeInMegaBytes, oFileWithoutMessageId)
|
|
|
|
|
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "FileSizeLimitReachedException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.FileSizeLimitReachedException, oArgs.MaxAttachmentSizeInMegaBytes, oFileWithoutMessageId)
|
|
|
|
|
AddRejectedState(oMessageId, "FileSizeLimitReachedException", "Erlaubte Dateigröße überschritten", "", oSQLTransaction)
|
|
|
|
|
Dim oBody = String.Format(EmailStrings.EMAIL_FILE_SIZE_REACHED, oArgs.MaxAttachmentSizeInMegaBytes, oOrgFilename)
|
|
|
|
|
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "FileSizeLimitReachedException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.FileSizeLimitReachedException, oArgs.MaxAttachmentSizeInMegaBytes, oOrgFilename)
|
|
|
|
|
AddRejectedState(oMessageId, oRejectionCodeString, "Erlaubte Dateigröße überschritten", "", oSQLTransaction)
|
|
|
|
|
|
|
|
|
|
Catch ex As NoFerdsAlternateException
|
|
|
|
|
' TODO: Maybe dont even log this 'error', since it's not really an error and it might happen *A LOT*
|
|
|
|
|
@@ -363,21 +371,22 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
_logger.Warn("Unknown Error occurred: {0}", ex.Message)
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
|
|
|
|
|
' Send Email to Digital Data
|
|
|
|
|
Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex)
|
|
|
|
|
Dim oEmailData As New EmailData With {
|
|
|
|
|
.From = oArgs.ExceptionEmailAddress,
|
|
|
|
|
.Subject = $"UnhandledException im ZUGFeRD-Parser @ {oMessageId}"
|
|
|
|
|
}
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "UnhandledException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnhandledException, ex.Message, ex.StackTrace)
|
|
|
|
|
|
|
|
|
|
' Rollback Transaction
|
|
|
|
|
oSQLTransaction.Rollback()
|
|
|
|
|
|
|
|
|
|
oMoveDirectory = DIRECTORY_DONT_MOVE
|
|
|
|
|
|
|
|
|
|
oExpectedError = False
|
|
|
|
|
|
|
|
|
|
If oSQLConnection IsNot Nothing And oSQLTransaction IsNot Nothing Then
|
|
|
|
|
' Send Email to Digital Data
|
|
|
|
|
Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex)
|
|
|
|
|
Dim oEmailData As New EmailData With {
|
|
|
|
|
.From = oArgs.ExceptionEmailAddress,
|
|
|
|
|
.Subject = $"UnhandledException im ZUGFeRD-Parser @ {oMessageId}"
|
|
|
|
|
}
|
|
|
|
|
_email.AddToEmailQueueMSSQL(oMessageId, oSQLTransaction, oBody, oEmailData, "UnhandledException", _EmailOutAccountId, oArgs.NamePortal, oArgs.RejectionTemplateId, ErrorCode.UnhandledException, ex.Message, ex.StackTrace)
|
|
|
|
|
|
|
|
|
|
' Rollback Transaction
|
|
|
|
|
oSQLTransaction.Rollback()
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Finally
|
|
|
|
|
Try
|
|
|
|
|
' If an application error occurred, dont move files so they will be processed again later
|
|
|
|
|
@@ -407,8 +416,10 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
' finally commit all changes To the Database
|
|
|
|
|
' ==================================================================
|
|
|
|
|
If oIsSuccess Or oExpectedError Then
|
|
|
|
|
' Commit Transaction
|
|
|
|
|
oSQLTransaction.Commit()
|
|
|
|
|
If oSQLTransaction IsNot Nothing Then
|
|
|
|
|
' Commit Transaction
|
|
|
|
|
oSQLTransaction.Commit()
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
@@ -416,7 +427,9 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
End Try
|
|
|
|
|
|
|
|
|
|
Try
|
|
|
|
|
oSQLConnection.Close()
|
|
|
|
|
If oSQLConnection IsNot Nothing Then
|
|
|
|
|
oSQLConnection.Close()
|
|
|
|
|
End If
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
_logger.Error(ex)
|
|
|
|
|
_logger.Warn("Database Connections were not closed successfully.")
|
|
|
|
|
@@ -432,10 +445,21 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
End Try
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Function GetRejectionCodeString(pMessageId As String, pRejectionCode As ErrorCode) As String
|
|
|
|
|
|
|
|
|
|
Dim intCode As Integer = DirectCast(pRejectionCode, Integer)
|
|
|
|
|
Dim oRejectionCodeString = $"{EmailStrings.ErrorCodePraefix}{intCode}"
|
|
|
|
|
|
|
|
|
|
' Wir wollen im error-Log den Code und die MessageID haben, um die es geht
|
|
|
|
|
Dim oInfoMessage = $"Rejection {oRejectionCodeString} triggered for '{pMessageId}'"
|
|
|
|
|
_logger.Error(oInfoMessage)
|
|
|
|
|
|
|
|
|
|
Return oRejectionCodeString
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Private Function ProcessFile(pMessageId As String, pEmailData As EmailData, pZugferdFiles As Integer, oFile As FileInfo, oConnections As DatabaseConnections, pArgs As WorkerArgs) As ProcessFileResult
|
|
|
|
|
Dim oDocument As ZUGFeRDInterface.ZugferdResult
|
|
|
|
|
Dim oResult As New ProcessFileResult()
|
|
|
|
|
Dim oMissingProperties As New List(Of String)
|
|
|
|
|
|
|
|
|
|
' Only pdf files are allowed from here on
|
|
|
|
|
If Not oFile.Name.ToUpper.EndsWith(".PDF") Then
|
|
|
|
|
@@ -520,7 +544,6 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
|
|
|
|
|
If oCheckResult.MissingProperties.Count > 0 Then
|
|
|
|
|
_logger.Warn("[{0}] missing properties found. Exiting.", oCheckResult.MissingProperties.Count)
|
|
|
|
|
oMissingProperties = oCheckResult.MissingProperties
|
|
|
|
|
Throw New MissingValueException(oFile, oCheckResult.MissingProperties)
|
|
|
|
|
Else
|
|
|
|
|
_logger.Debug("No missing properties found. Continuing.")
|
|
|
|
|
@@ -548,7 +571,7 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
'Next
|
|
|
|
|
|
|
|
|
|
' DataTable vorbereiten
|
|
|
|
|
Dim oDataTable As DataTable = FillDataTable(pMessageId, oCheckResult, oDocument.Specification)
|
|
|
|
|
Dim oDataTable As DataTable = FillDataTable(pMessageId, oCheckResult, oDocument.Specification, oDocument.UsedXMLSchema)
|
|
|
|
|
|
|
|
|
|
' ColumnList initialisieren
|
|
|
|
|
Dim oColumnNames As List(Of String) = New List(Of String) From {
|
|
|
|
|
@@ -578,7 +601,7 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Private Function FillDataTable(pMessageId As String, pCheckResult As PropertyValues.CheckPropertyValuesResult, pSpecification As String) As DataTable
|
|
|
|
|
Private Function FillDataTable(pMessageId As String, pCheckResult As PropertyValues.CheckPropertyValuesResult, pSpecification As String, pUsedXMLSchema As String) As DataTable
|
|
|
|
|
|
|
|
|
|
Dim oDataTable As DataTable = New DataTable()
|
|
|
|
|
oDataTable.Columns.Add(New DataColumn("REFERENCE_GUID", GetType(String)))
|
|
|
|
|
@@ -600,6 +623,17 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
_logger.Debug("Mapping Property [ZUGFERD_SPECIFICATION] with value [{0}]", pSpecification)
|
|
|
|
|
oDataTable.Rows.Add(oFirstRow)
|
|
|
|
|
|
|
|
|
|
' Zweite Zeile enthält das verwendete XML Schema
|
|
|
|
|
Dim oSecondRow As DataRow = oDataTable.NewRow()
|
|
|
|
|
oSecondRow("REFERENCE_GUID") = pMessageId
|
|
|
|
|
oSecondRow("ITEM_DESCRIPTION") = "ZUGFeRDXMLSchema"
|
|
|
|
|
oSecondRow("ITEM_VALUE") = pUsedXMLSchema
|
|
|
|
|
oSecondRow("GROUP_COUNTER") = 0
|
|
|
|
|
oSecondRow("SPEC_NAME") = "ZUGFERD_XML_SCHEMA"
|
|
|
|
|
oSecondRow("IS_REQUIRED") = False
|
|
|
|
|
|
|
|
|
|
_logger.Debug("Mapping Property [ZUGFERD_XML_SCHEMA] with value [{0}]", pUsedXMLSchema)
|
|
|
|
|
oDataTable.Rows.Add(oSecondRow)
|
|
|
|
|
|
|
|
|
|
For Each oProperty In pCheckResult.ValidProperties
|
|
|
|
|
|
|
|
|
|
@@ -610,10 +644,14 @@ Public Class ImportZUGFeRDFiles
|
|
|
|
|
oGroupCounterValue = 0
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
If oProperty.Value.Length > 900 Then
|
|
|
|
|
_logger.Warn("Value for field [{0}] is longer than 900 characters, will be truncated!", oProperty.TableColumn)
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Dim oNewRow As DataRow = oDataTable.NewRow()
|
|
|
|
|
oNewRow("REFERENCE_GUID") = pMessageId
|
|
|
|
|
oNewRow("ITEM_DESCRIPTION") = oProperty.Description
|
|
|
|
|
oNewRow("ITEM_VALUE") = oProperty.Value.Replace("'", "''")
|
|
|
|
|
oNewRow("ITEM_VALUE") = oProperty.Value.Truncate(900).Replace("'", "''")
|
|
|
|
|
oNewRow("GROUP_COUNTER") = oGroupCounterValue
|
|
|
|
|
oNewRow("SPEC_NAME") = oProperty.TableColumn
|
|
|
|
|
oNewRow("IS_REQUIRED") = oProperty.IsRequired
|
|
|
|
|
|