Compare commits

...

7 Commits

10 changed files with 146 additions and 76 deletions

View File

@ -226,6 +226,7 @@
<Compile Include="GrapQLInterface\LoginData.vb" /> <Compile Include="GrapQLInterface\LoginData.vb" />
<Compile Include="GrapQLInterface\LogoutData.vb" /> <Compile Include="GrapQLInterface\LogoutData.vb" />
<Compile Include="GrapQLInterface\QueryData.vb" /> <Compile Include="GrapQLInterface\QueryData.vb" />
<Compile Include="ZUGFeRDInterface\Enums\ErrorCodes.vb" />
<Compile Include="ZUGFeRDInterface\Enums\Item_Types.vb" /> <Compile Include="ZUGFeRDInterface\Enums\Item_Types.vb" />
<Compile Include="ZUGFeRDInterface\Exceptions.vb" /> <Compile Include="ZUGFeRDInterface\Exceptions.vb" />
<Compile Include="My Project\AssemblyInfo.vb" /> <Compile Include="My Project\AssemblyInfo.vb" />
@ -247,6 +248,7 @@
<Compile Include="ZUGFeRDInterface\PDFConverter.vb" /> <Compile Include="ZUGFeRDInterface\PDFConverter.vb" />
<Compile Include="ZUGFeRDInterface\Peppol_UBL2.1\CreditNoteType.vb" /> <Compile Include="ZUGFeRDInterface\Peppol_UBL2.1\CreditNoteType.vb" />
<Compile Include="ZUGFeRDInterface\Peppol_UBL2.1\InvoiceType.vb" /> <Compile Include="ZUGFeRDInterface\Peppol_UBL2.1\InvoiceType.vb" />
<Compile Include="ZUGFeRDInterface\RejectionStringRow.vb" />
<Compile Include="ZUGFeRDInterface\Validator.vb" /> <Compile Include="ZUGFeRDInterface\Validator.vb" />
<Compile Include="ZUGFeRDInterface\Version1.0\CrossIndustryDocumentType.vb" /> <Compile Include="ZUGFeRDInterface\Version1.0\CrossIndustryDocumentType.vb" />
<Compile Include="ZUGFeRDInterface.vb" /> <Compile Include="ZUGFeRDInterface.vb" />

View File

@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Interfaces")> <Assembly: AssemblyProduct("Modules.Interfaces")>
<Assembly: AssemblyCopyright("Copyright © 2025")> <Assembly: AssemblyCopyright("Copyright © 2025")>
<Assembly: AssemblyTrademark("2.3.5.0")> <Assembly: AssemblyTrademark("2.3.6.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.3.5.0")> <Assembly: AssemblyVersion("2.3.6.0")>
<Assembly: AssemblyFileVersion("2.3.5.0")> <Assembly: AssemblyFileVersion("2.3.6.0")>

View File

@ -43,7 +43,7 @@ Public Class ZUGFeRDInterface
Private AllowedFilenames As New List(Of String) Private AllowedFilenames As New List(Of String)
Public Enum ErrorType Public Enum ErrorType1
NoValidFile NoValidFile
NoZugferd NoZugferd
NoValidZugferd NoValidZugferd
@ -51,6 +51,7 @@ Public Class ZUGFeRDInterface
UnsupportedFormat UnsupportedFormat
FileTooBig FileTooBig
UnknownError UnknownError
NotInUse
End Enum End Enum
Public ReadOnly Property FileGroup As FileGroups Public ReadOnly Property FileGroup As FileGroups
@ -171,6 +172,7 @@ Public Class ZUGFeRDInterface
Public Function GetSerializedXMLContentFromFile(oFileInfo As FileInfo) As ZugferdResult Public Function GetSerializedXMLContentFromFile(oFileInfo As FileInfo) As ZugferdResult
Dim oResult = New ZugferdResult() Dim oResult = New ZugferdResult()
Dim oMessage As String = String.Empty
Try Try
Dim oFileSize As Integer = oFileInfo.Length Dim oFileSize As Integer = oFileInfo.Length
@ -195,7 +197,7 @@ Public Class ZUGFeRDInterface
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, "Datei ist eine ungültige XML Datei.") Throw New ZUGFeRDExecption(ErrorCodes.UnsupportedFerdException, "Datei ist eine ungültige XML Datei.")
End Try End Try
If oResult.ValidationErrors.Any() Then If oResult.ValidationErrors.Any() Then
@ -211,7 +213,6 @@ Public Class ZUGFeRDInterface
''' Validates a ZUGFeRD File and extracts the XML Document from it ''' Validates a ZUGFeRD File and extracts the XML Document from it
''' </summary> ''' </summary>
''' <param name="Path"></param> ''' <param name="Path"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
Public Function ExtractZUGFeRDFileWithGDPicture(Path As String) As ZugferdResult Public Function ExtractZUGFeRDFileWithGDPicture(Path As String) As ZugferdResult
Dim oResult = ValidateZUGFeRDFileWithGDPicture(Path) Dim oResult = ValidateZUGFeRDFileWithGDPicture(Path)
oResult = ValidateZUGFeRDDocument(oResult) oResult = ValidateZUGFeRDDocument(oResult)
@ -229,7 +230,6 @@ Public Class ZUGFeRDInterface
''' Validates a ZUGFeRD File and extracts the XML Document from it ''' Validates a ZUGFeRD File and extracts the XML Document from it
''' </summary> ''' </summary>
''' <param name="Stream"></param> ''' <param name="Stream"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
Public Function ExtractZUGFeRDFileWithGDPicture(Stream As Stream) As ZugferdResult Public Function ExtractZUGFeRDFileWithGDPicture(Stream As Stream) As ZugferdResult
Dim oResult = ValidateZUGFeRDFileWithGDPicture(Stream) Dim oResult = ValidateZUGFeRDFileWithGDPicture(Stream)
oResult = ValidateZUGFeRDDocument(oResult) oResult = ValidateZUGFeRDDocument(oResult)
@ -252,7 +252,6 @@ Public Class ZUGFeRDInterface
''' Validates a ZUGFeRD File and extracts the XML Document from it ''' Validates a ZUGFeRD File and extracts the XML Document from it
''' </summary> ''' </summary>
''' <param name="pStream"></param> ''' <param name="pStream"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
''' <returns>The embedded xml data as an XPath document</returns> ''' <returns>The embedded xml data as an XPath document</returns>
Public Function ValidateZUGFeRDFileWithGDPicture(pStream As Stream) As ZugferdResult Public Function ValidateZUGFeRDFileWithGDPicture(pStream As Stream) As ZugferdResult
Dim oEmbedExtractor = New PDFEmbeds(_logConfig) Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
@ -281,7 +280,6 @@ Public Class ZUGFeRDInterface
''' Validates a ZUGFeRD File and extracts the XML Document from it ''' Validates a ZUGFeRD File and extracts the XML Document from it
''' </summary> ''' </summary>
''' <param name="pPath"></param> ''' <param name="pPath"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
''' <returns>The embedded xml data as an XPath document</returns> ''' <returns>The embedded xml data as an XPath document</returns>
Public Function ValidateZUGFeRDFileWithGDPicture(pPath As String) As ZugferdResult Public Function ValidateZUGFeRDFileWithGDPicture(pPath As String) As ZugferdResult
Dim oEmbedExtractor = New PDFEmbeds(_logConfig) Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
@ -307,12 +305,8 @@ Public Class ZUGFeRDInterface
End Function End Function
Private Function HandleEmbeddedFiles(pResults As List(Of PDFEmbeds.EmbeddedFile)) As ZugferdResult Private Function HandleEmbeddedFiles(pResults As List(Of PDFEmbeds.EmbeddedFile)) As ZugferdResult
If pResults Is Nothing Then If pResults Is Nothing OrElse pResults.Count = 0 Then
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil die Attachments nicht gelesen werden konnten.") Throw New ZUGFeRDExecption(ErrorCodes.InvalidFerdNoXMLAttachmentFound, "Die Datei ist keine gültige ZUGFeRD-Datei, es wurde kein passender XML-Anhang gefunden.")
End If
If pResults.Count = 0 Then
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil sie keine Attachments enthält.")
End If End If
' Find the first file which filename matches the valid filenames for embedded invoice files ' Find the first file which filename matches the valid filenames for embedded invoice files
@ -321,7 +315,7 @@ Public Class ZUGFeRDInterface
FirstOrDefault() FirstOrDefault()
If oValidResult Is Nothing Then If oValidResult Is Nothing Then
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei, weil keine entsprechende XML-Datei gefunden wurde.") Throw New ZUGFeRDExecption(ErrorCodes.InvalidFerdNoXMLAttachmentFound, "Die Datei ist keine ZUGFeRD Datei, weil keine passende XML-Datei gefunden wurde.")
End If End If
' Search the embedded files for the ones which are allowed as per the configuration. ' Search the embedded files for the ones which are allowed as per the configuration.
@ -331,7 +325,7 @@ Public Class ZUGFeRDInterface
FirstOrDefault() FirstOrDefault()
If oAllowedResult Is Nothing Then If oAllowedResult Is Nothing Then
Throw New ZUGFeRDExecption(ErrorType.UnsupportedFormat, "Datei ist eine ZUGFeRD Datei, aber das Format wird nicht unterstützt.", oAllowedResult.FileName) Throw New ZUGFeRDExecption(ErrorCodes.InvalidFerdNoXMLAttachmentFound, "Datei enthält einen XML-Anhang mit einem ungültigen Dateinamen.", oAllowedResult.FileName)
End If End If
Try Try
@ -349,7 +343,7 @@ Public Class ZUGFeRDInterface
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, "Datei ist eine ungültige ZUGFeRD Datei.") Throw New ZUGFeRDExecption(ErrorCodes.InvalidFerdException, "XML-Datei konnte nicht gelesen werden.")
End Try End Try
End Function End Function
@ -456,8 +450,7 @@ Public Class ZUGFeRDInterface
Next Next
If oObject Is Nothing Then If oObject Is Nothing Then
'Throw New ApplicationException("No Types matched the given document. Document could not be serialized.") Throw New ZUGFeRDExecption(ErrorCodes.UnsupportedFerdException, "Unsupported Format")
Throw New ZUGFeRDExecption(ErrorType.UnsupportedFormat, "Unsupported Format")
End If End If
pResult.Specification = oSpecification pResult.Specification = oSpecification
@ -472,8 +465,8 @@ Public Class ZUGFeRDInterface
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
Dim oMessage = "Datei ist eine ungültige eInvoice Datei oder das Format wird nicht unterstüzt, oder das Format ist deaktiviert." Dim oMessage = "Datei ist eine ungültige Datei oder das Format wird nicht unterstüzt, oder das Format ist deaktiviert."
Throw New ZUGFeRDExecption(ErrorType.NoValidZugferd, oMessage) Throw New ZUGFeRDExecption(ErrorCodes.UnsupportedFerdException, oMessage)
End Try End Try
End Function End Function
End Class End Class

View File

@ -0,0 +1,14 @@
Public Enum ErrorCodes
NotInUse = 0
ValidationException = 20001
MD5HashException = 20002
UnsupportedFerdException = 20003
InvalidFerdException = 20004
TooMuchFerdsException = 20005
InvalidFerdNoXMLAttachmentFound = 20006
MissingValueException = 20007
FileSizeLimitReachedException = 20008
OutOfMemoryException = 20009
UnhandledException = 20010
FileMoveException = 200011
End Enum

View File

@ -4,7 +4,11 @@ Public Class Exceptions
Public Class ZUGFeRDExecption Public Class ZUGFeRDExecption
Inherits ApplicationException Inherits ApplicationException
Public ReadOnly Property ErrorType() As ZUGFeRDInterface.ErrorType Public ReadOnly Property ErrorCode() As ErrorCodes
Public ReadOnly Property Param1 As String = String.Empty
Public ReadOnly Property Param2 As String = String.Empty
''' <summary> ''' <summary>
''' Contains the name of the extracted xml file if already extracted. ''' Contains the name of the extracted xml file if already extracted.
@ -12,18 +16,37 @@ Public Class Exceptions
''' <returns>A filename like zugferd-invoice.xml</returns> ''' <returns>A filename like zugferd-invoice.xml</returns>
Public ReadOnly Property XmlFile As String = String.Empty Public ReadOnly Property XmlFile As String = String.Empty
Public Sub New(ErrorType As ZUGFeRDInterface.ErrorType, Message As String) Public Sub New(pErrorCode As ErrorCodes, Message As String)
MyBase.New(Message) MyBase.New(Message)
_ErrorType = ErrorType _ErrorCode = pErrorCode
End Sub End Sub
Public Sub New(ErrorType As ZUGFeRDInterface.ErrorType, Message As String, pXmlFileName As String) Public Sub New(pErrorCode As ErrorCodes, Message As String, pXmlFileName As String)
MyBase.New(Message) MyBase.New(Message)
_ErrorType = ErrorType _ErrorCode = pErrorCode
_XmlFile = pXmlFileName _XmlFile = pXmlFileName
End Sub End Sub
Public Sub New(pErrorCode As ErrorCodes, Param1 As String, Param2 As String, Message As String)
MyBase.New(Message)
_ErrorCode = pErrorCode
_Param1 = Param1
_Param2 = Param2
End Sub
Public Sub New(pErrorCode As ErrorCodes, Param1 As String, Param2 As String, Message As String, pXmlFileName As String)
MyBase.New(Message)
_ErrorCode = pErrorCode
_Param1 = Param1
_Param2 = Param2
_XmlFile = pXmlFileName
End Sub
End Class End Class
Public Class ValidationException Public Class ValidationException
@ -31,8 +54,13 @@ Public Class Exceptions
Public ValidationErrors As List(Of ZugferdValidationError) Public ValidationErrors As List(Of ZugferdValidationError)
Public ReadOnly Property ErrorCode() As ErrorCodes
Public Sub New() Public Sub New()
MyBase.New("ZUGFeRD document found but validation failed!") MyBase.New("ZUGFeRD document found but validation failed!")
_ErrorCode = ErrorCodes.ValidationException
End Sub End Sub
End Class End Class
End Class End Class

View File

@ -0,0 +1,8 @@
Public Class RejectionStringRow
Public ModuleName As String
Public Title As String
Public Caption As String
Public Language As String
Public String1 As String
End Class

View File

@ -30,7 +30,7 @@ Public Class Validator
.ElementName = oNode.Name.LocalName, .ElementName = oNode.Name.LocalName,
.ElementValue = oNode.Value, .ElementValue = oNode.Value,
.ErrorMessage = "Value could not be parsed as Decimal.", .ErrorMessage = "Value could not be parsed as Decimal.",
.ErrorMessageDE = "Der Wert konnte nicht in eine Dezimalzahl umgewandelt werden." .ErrorMessageDE = "Der Wert ist keine Dezimalzahl."
}) })
End If End If
Next Next

View File

@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Jobs")> <Assembly: AssemblyProduct("Modules.Jobs")>
<Assembly: AssemblyCopyright("Copyright © 2025")> <Assembly: AssemblyCopyright("Copyright © 2025")>
<Assembly: AssemblyTrademark("2.9.9.0")> <Assembly: AssemblyTrademark("3.0.1.0")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern ' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
<Assembly: AssemblyVersion("2.9.9.0")> <Assembly: AssemblyVersion("3.0.1.0")>
<Assembly: AssemblyFileVersion("2.9.9.0")> <Assembly: AssemblyFileVersion("3.0.1.0")>

View File

@ -439,7 +439,8 @@ Public Class ImportZUGFeRDFiles
If oMoveDirectory = DIRECTORY_DONT_MOVE Then If oMoveDirectory = DIRECTORY_DONT_MOVE Then
_logger.Info("Application Error occurred. Files for message Id {0} will not be moved.", oMessageId) _logger.Info("Application Error occurred. Files for message Id {0} will not be moved.", oMessageId)
ElseIf oArgs.AllowXRechnung And oIsSuccess And oEInvoiceFileGroup.Item(0).Extension = ".xml" Then ElseIf oArgs.AllowXRechnung And oIsSuccess And
oEInvoiceFileGroup.Item(0).Extension.Equals(".xml", StringComparison.OrdinalIgnoreCase) = True Then
_logger.Debug("Before Creating the PDF-File from XML data / Before Commit") _logger.Debug("Before Creating the PDF-File from XML data / Before Commit")
oxRechnungHandle = True oxRechnungHandle = True
@ -558,36 +559,46 @@ Public Class ImportZUGFeRDFiles
Try Try
oDocument = _zugferd.GetSerializedXMLContentFromFile(pFile) oDocument = _zugferd.GetSerializedXMLContentFromFile(pFile)
oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_XML
Catch ex As ValidationException Catch ex As ValidationException
Throw ex Throw ex
Catch ex As ZUGFeRDExecption Catch ex As ZUGFeRDExecption
Select Case ex.ErrorType
Case ZUGFeRDInterface.ErrorType.NoZugferd If ex.ErrorCode > 0 Then
_logger.Info("New Rejection Logik")
Select Case ex.ErrorCode
Case ErrorCode.NoFerdsException
_logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name) _logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
oResult.EmailAttachmentFiles.Add(pFile) oResult.EmailAttachmentFiles.Add(pFile)
Return oResult Return oResult
Case ZUGFeRDInterface.ErrorType.UnsupportedFormat Case ErrorCode.UnsupportedFerdException
_logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile) _logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
Throw New UnsupportedFerdException(ex.XmlFile) Throw New UnsupportedFerdException(ex.XmlFile)
Case ZUGFeRDInterface.ErrorType.NoValidZugferd Case ErrorCode.InvalidFerdException
_logger.Info("File [{0}] is an Incorrectly formatted eInvoice document!", pFile.Name) _logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
Throw New InvalidFerdException() Throw New InvalidFerdException()
Case Else Case Else
_logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name) _logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
Throw ex Throw ex
End Select
End Select
End If
End Try End Try
Try Try
oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_XML Dim sqlResult As Boolean = False
Dim sqlResult As Boolean = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
If oDocument IsNot Nothing Then
sqlResult = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
End If
Catch ex As Exception Catch ex As Exception
Throw ex Throw ex
End Try End Try
@ -630,30 +641,37 @@ Public Class ImportZUGFeRDFiles
Try Try
oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(pFile.FullName) oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(pFile.FullName)
oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_PDF
Catch ex As ValidationException Catch ex As ValidationException
Throw ex Throw ex
Catch ex As ZUGFeRDExecption Catch ex As ZUGFeRDExecption
Select Case ex.ErrorType If ex.ErrorCode > 0 Then
Case ZUGFeRDInterface.ErrorType.NoZugferd _logger.Info("New Rejection Logik")
Select Case ex.ErrorCode
Case ErrorCode.NoFerdsException
_logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name) _logger.Info("File [{0}] is not a valid eInvoice document. Skipping.", pFile.Name)
oResult.EmailAttachmentFiles.Add(pFile) oResult.EmailAttachmentFiles.Add(pFile)
Return oResult Return oResult
Case ZUGFeRDInterface.ErrorType.UnsupportedFormat Case ErrorCode.UnsupportedFerdException
_logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile) _logger.Info("File [{0}/{1}] is an unsupported eInvoice document format!", pFile.Name, ex.XmlFile)
Throw New UnsupportedFerdException(ex.XmlFile) Throw New UnsupportedFerdException(ex.XmlFile)
Case ZUGFeRDInterface.ErrorType.NoValidZugferd Case ErrorCode.InvalidFerdException
_logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name) _logger.Info("File [{0}] is an incorrectly formatted eInvoice document!", pFile.Name)
Throw New InvalidFerdException() Throw New InvalidFerdException()
Case Else Case Else
_logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name) _logger.Warn("Unexpected Error occurred while extracting eInvoice Information from file {0}", pFile.Name)
Throw ex Throw ex
End Select End Select
End If
End Try End Try
' Check if there are more than one ZUGFeRD files ' Check if there are more than one ZUGFeRD files
@ -676,7 +694,6 @@ Public Class ImportZUGFeRDFiles
End If End If
Try Try
oDocument.ReceiptFileType = ZUGFeRDInterface.RECEIPT_TYPE_PDF
Dim sqlResult As Boolean = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult) Dim sqlResult As Boolean = StoreXMLItemsInDatabase(pMessageId, oDocument, pFile, pConnections, pArgs, oResult)
Catch ex As Exception Catch ex As Exception
Throw ex Throw ex

View File

@ -7,6 +7,7 @@ Imports DigitalData.Modules.Logging
Imports GdPicture14 Imports GdPicture14
Imports System.Drawing Imports System.Drawing
Imports System.Linq Imports System.Linq
Imports System.Text.RegularExpressions
Public Class XRechnungViewDocument Public Class XRechnungViewDocument
Private ReadOnly _logger As Logger Private ReadOnly _logger As Logger
Private ReadOnly _logConfig As LogConfig Private ReadOnly _logConfig As LogConfig
@ -25,28 +26,35 @@ Public Class XRechnungViewDocument
_file = New ZUGFeRD.FileFunctions(LogConfig, MSSQL) _file = New ZUGFeRD.FileFunctions(LogConfig, MSSQL)
_gdpictureLicenseKey = GDPictureLicenseKey _gdpictureLicenseKey = GDPictureLicenseKey
End Sub End Sub
Public Function Create_PDFfromXML(oxmlFile As FileInfo, pDTItemValues As DataTable) As FileInfo Public Function Create_PDFfromXML(pXmlFile As FileInfo, pDTItemValues As DataTable) As FileInfo
_logger.Debug("Create_PDFfromXML() Start") _logger.Debug("Create_PDFfromXML() Start")
Try Try
Dim oXRechnungFile = oxmlFile.FullName Dim oXRechnungFile = pXmlFile.FullName
Dim oNewFileinfo As FileInfo Dim oNewFileinfo As FileInfo
Dim oxmlFilePath = oxmlFile.FullName Dim oXmlFilePath = pXmlFile.FullName
Dim oViewRecieptFilename = oxmlFile.Name Dim oViewRecieptFilename = pXmlFile.Name
Dim oTempFilePath = Path.GetDirectoryName(oxmlFilePath) + "\Temp" Dim oTempFilePath = Path.Combine(Path.GetDirectoryName(oXmlFilePath), "temp")
If Not Directory.Exists(oTempFilePath) Then If Not Directory.Exists(oTempFilePath) Then
Directory.CreateDirectory(oTempFilePath) Directory.CreateDirectory(oTempFilePath)
End If End If
oTempFilePath = oTempFilePath + "\xrechnung.xml" oTempFilePath = Path.Combine(oTempFilePath, "xrechnung.xml")
If File.Exists(oTempFilePath) Then If File.Exists(oTempFilePath) Then
File.Delete(oTempFilePath) File.Delete(oTempFilePath)
End If End If
File.Move(oxmlFilePath, oTempFilePath)
oxmlFile = New FileInfo(oTempFilePath) _logger.Debug("Vor MOVE... oxmlFilePath: [{0}] / oTempFilePath: [{1}]", oXmlFilePath, oTempFilePath)
oViewRecieptFilename = oViewRecieptFilename.Replace("xml", "pdf")
Dim oOutputPath = Path.GetDirectoryName(oxmlFilePath) + "\" + oViewRecieptFilename File.Move(oXmlFilePath, oTempFilePath)
pXmlFile = New FileInfo(oTempFilePath)
'oViewRecieptFilename = oViewRecieptFilename.Replace(".xml", ".pdf")
oViewRecieptFilename = Regex.Replace(oViewRecieptFilename, ".xml", ".pdf", RegexOptions.IgnoreCase)
Dim oOutputPath = Path.Combine(Path.GetDirectoryName(oXmlFilePath), oViewRecieptFilename)
_logger.Debug("Create_PDFfromXML() Resulting PDF Filepath: [{0}]", oOutputPath)
If File.Exists(oOutputPath) Then If File.Exists(oOutputPath) Then
File.Delete(oOutputPath) File.Delete(oOutputPath)
End If End If
@ -417,7 +425,7 @@ Public Class XRechnungViewDocument
File.Delete(oXRechnungFile) File.Delete(oXRechnungFile)
oNewFileinfo = New FileInfo(oOutputPath) oNewFileinfo = New FileInfo(oOutputPath)
_logger.Debug("Create_PDFfromXML() End successfully") _logger.Debug("Create_PDFfromXML() End successfully. File [{0}] written.", oNewFileinfo.FullName)
Return oNewFileinfo Return oNewFileinfo
Else Else
_logger.Debug("Create_PDFfromXML() Ends with nothing") _logger.Debug("Create_PDFfromXML() Ends with nothing")