Interfaces: Remove obsolete pdf_zugferd_test.exe

This commit is contained in:
Jonathan Jenne 2021-07-13 13:52:45 +02:00
parent 757a8616dc
commit aa873d501c
5 changed files with 12 additions and 66 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

@ -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"}