2 Commits

Author SHA1 Message Date
Jonathan Jenne
fd22b6a3bf Interfaces: Version 1.5.4 2021-07-13 13:53:01 +02:00
Jonathan Jenne
aa873d501c Interfaces: Remove obsolete pdf_zugferd_test.exe 2021-07-13 13:52:45 +02:00
6 changed files with 14 additions and 68 deletions

View File

@@ -136,9 +136,6 @@
<LastGenOutput>Settings.Designer.vb</LastGenOutput> <LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None> </None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="ZUGFeRDInterface\pdf_zugferd_lib\pdf_zugferd_lib.lib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Modules.Database\Database.vbproj"> <ProjectReference Include="..\Modules.Database\Database.vbproj">
@@ -150,14 +147,6 @@
<Name>Logging</Name> <Name>Logging</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="ZUGFeRDInterface\pdf_zugferd_lib\pdf_zugferd_lib.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="ZUGFeRDInterface\pdf_zugferd_lib\pdf_zugferd_test.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project> </Project>

View File

@@ -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("1.5.3.0")> <Assembly: AssemblyVersion("1.5.4.0")>
<Assembly: AssemblyFileVersion("1.5.3.0")> <Assembly: AssemblyFileVersion("1.5.4.0")>

View File

@@ -40,23 +40,12 @@ Public Class ZUGFeRDInterface
End Try End Try
End Sub End Sub
''' <summary> ''' <summary>
''' 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> ''' <exception cref="ZUGFeRDExecption"></exception>
''' <returns></returns> ''' <returns></returns>
Public Function ExtractZUGFeRDFile(Path As String) As CrossIndustryDocumentType
Dim oXmlDocument = ValidateZUGFeRDFile(Path)
If IsNothing(oXmlDocument) Then
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei.")
End If
Return SerializeZUGFeRDDocument(oXmlDocument)
End Function
Public Function ExtractZUGFeRDFileWithGDPicture(Path As String) As CrossIndustryDocumentType Public Function ExtractZUGFeRDFileWithGDPicture(Path As String) As CrossIndustryDocumentType
Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Path) Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Path)
@@ -67,6 +56,12 @@ Public Class ZUGFeRDInterface
Return SerializeZUGFeRDDocument(oXmlDocument) Return SerializeZUGFeRDDocument(oXmlDocument)
End Function End Function
''' <summary>
''' Validates a ZUGFeRD File and extracts the XML Document from it
''' </summary>
''' <param name="Stream"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
''' <returns></returns>
Public Function ExtractZUGFeRDFileWithGDPicture(Stream As Stream) As CrossIndustryDocumentType Public Function ExtractZUGFeRDFileWithGDPicture(Stream As Stream) As CrossIndustryDocumentType
Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Stream) Dim oXmlDocument = ValidateZUGFeRDFileWithGDPicture(Stream)
@@ -77,50 +72,12 @@ Public Class ZUGFeRDInterface
Return SerializeZUGFeRDDocument(oXmlDocument) Return SerializeZUGFeRDDocument(oXmlDocument)
End Function End Function
Public Function ValidateZUGFeRDFile(Path As String) As XPathDocument ''' <summary>
Dim oProcessOutput, oProcessError As String ''' Validates a ZUGFeRD File and extracts the XML Document from it
Dim oXmlDocument As XPathDocument ''' </summary>
Dim oTempFile = IO.Path.GetTempFileName() ''' <param name="Stream"></param>
''' <exception cref="ZUGFeRDExecption"></exception>
Dim oProcess As New Process() With { ''' <returns></returns>
.StartInfo = New ProcessStartInfo() With {
.FileName = ZUGFERD_CONVERTER_EXE,
.RedirectStandardError = True,
.RedirectStandardOutput = True,
.UseShellExecute = False,
.Arguments = $"-i ""{Path}"" -o ""{oTempFile}"""
}
}
Try
oProcess.Start()
oProcessOutput = oProcess.StandardOutput.ReadToEnd()
oProcessError = oProcess.StandardError.ReadToEnd()
oProcess.WaitForExit()
_logger.Debug("Process Output:")
_logger.Debug(oProcessOutput)
Catch ex As Exception
_logger.Error(ex)
Throw ex
End Try
If Not oProcessOutput.ToLower.Contains(ZUGFERD_CONVERTER_SUCCESS_MESSAGE.ToLower) Then
_logger.Warn("File {0} is not a valid ZUGFeRD File!", Path)
Throw New ZUGFeRDExecption(ErrorType.NoZugferd, "Datei ist keine ZUGFeRD Datei.")
End If
Try
oXmlDocument = New XPathDocument(oTempFile)
Catch ex As Exception
_logger.Error(ex)
Throw ex
End Try
Return oXmlDocument
End Function
Public Function ValidateZUGFeRDFileWithGDPicture(Stream As Stream) As XPathDocument Public Function ValidateZUGFeRDFileWithGDPicture(Stream As Stream) As XPathDocument
Dim oEmbedExtractor = New PDFEmbeds(_logConfig) Dim oEmbedExtractor = New PDFEmbeds(_logConfig)
Dim oAllowedExtensions = New List(Of String) From {"xml"} Dim oAllowedExtensions = New List(Of String) From {"xml"}