Peppol 3017 / UBL Logik
This commit is contained in:
@@ -8,6 +8,7 @@ Imports DigitalData.Modules.Config
|
||||
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
|
||||
|
||||
@@ -686,12 +687,54 @@ Public Class ImportZUGFeRDFiles
|
||||
_logger.Debug("No missing properties found. Continuing.")
|
||||
End If
|
||||
|
||||
' Daten in die Datenbank speichern
|
||||
If BulkInsertDataToDatabase(pMessageId, pDocument, pConnections, oCheckResult) = False Then
|
||||
_logger.Error("Bulk Insert for MessageId [{0}] failed!", pMessageId)
|
||||
Throw New Exception("Bulk Insert failed! Exiting.")
|
||||
End If
|
||||
|
||||
' TODO hier BAUSTELLE
|
||||
' Eingebettete Dateien speichern
|
||||
'If CreateEmbeddedFilesOnDisk(pMessageId, pDocument, pConnections, oCheckResult) = False Then
|
||||
' _logger.Debug("Files saving for MessageId [{0}] failed!", pMessageId)
|
||||
'End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function CreateEmbeddedFilesOnDisk(pMessageId As String, pDocument As ZUGFeRDInterface.ZugferdResult, pConnections As DatabaseConnections, pCheckResult As CheckPropertyValuesResult) As Boolean
|
||||
|
||||
' Finde alle Eintraege in pCheckResult mit Item_Type=3
|
||||
' Finde Dateinamen (Index nach ~attm) und Dateityp. Wir speichern nur PDF.
|
||||
' TODO Funktion aufrufen
|
||||
'SaveBase64ToDisk("", "") = False Then
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function SaveBase64ToDisk(pExportFilePath As String, pBase64String As String) As Boolean
|
||||
Try
|
||||
Dim base64BinaryDataString As String = pBase64String ' Hier Base64-String einfügen
|
||||
Dim binaryDataString As Byte() = System.Convert.FromBase64String(base64BinaryDataString)
|
||||
Dim oFilename As String = pExportFilePath
|
||||
Dim Stream As System.IO.FileStream = New System.IO.FileStream(oFilename, System.IO.FileMode.Create)
|
||||
Stream.Write(binaryDataString, 0, binaryDataString.Length)
|
||||
Stream.Close()
|
||||
Catch ex As Exception
|
||||
_logger.Error("Could NOT save File to Disk for MessageId [{0}] !", pExportFilePath)
|
||||
|
||||
End Try
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function BulkInsertDataToDatabase(pMessageId As String, pDocument As ZUGFeRDInterface.ZugferdResult, pConnections As DatabaseConnections, pCheckResults As CheckPropertyValuesResult) As Boolean
|
||||
If DeleteExistingPropertyValues(pMessageId, pConnections) = False Then
|
||||
Throw New Exception("Could not cleanup data. Exiting.")
|
||||
End If
|
||||
|
||||
' DataTable vorbereiten
|
||||
Dim oDataTable As DataTable = FillDataTable(pMessageId, oCheckResult, pDocument)
|
||||
Dim oDataTable As DataTable = FillDataTable(pMessageId, pCheckResults, pDocument)
|
||||
|
||||
' ColumnList initialisieren
|
||||
Dim oColumnNames As List(Of String) = New List(Of String) From {
|
||||
@@ -714,6 +757,7 @@ Public Class ImportZUGFeRDFiles
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
Private Function FillDataTable(pMessageId As String, pCheckResult As PropertyValues.CheckPropertyValuesResult, pDocument As ZUGFeRDInterface.ZugferdResult) As DataTable
|
||||
|
||||
Dim oDataTable As DataTable = New DataTable()
|
||||
@@ -762,6 +806,11 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
For Each oProperty In pCheckResult.ValidProperties
|
||||
|
||||
' ItemType = 3 => eingebettete Datei, nicht den base64 speichern
|
||||
If oProperty.ItemType = 3 Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
' If GroupCounter is -1, it means this is a default property that can only occur once.
|
||||
' Set the actual inserted value to 0
|
||||
Dim oGroupCounterValue As Integer = oProperty.GroupCounter
|
||||
|
||||
Reference in New Issue
Block a user