jj: zugferd
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
Imports System.Xml
|
||||
Imports System.Xml.Serialization
|
||||
Imports System.Xml.XPath
|
||||
Imports System.Xml.Xsl
|
||||
Imports DigitalData.Modules.Interfaces.Exceptions
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
@@ -25,7 +28,7 @@ Public Class ZUGFeRDInterface
|
||||
''' <param name="Path"></param>
|
||||
''' <exception cref="ZUGFeRDExecption"></exception>
|
||||
''' <returns></returns>
|
||||
Public Function ExtractXMLFile(Path As String) As XmlDocument
|
||||
Public Function ExtractXMLFile(Path As String) As XPathDocument
|
||||
Dim oException As New Exception
|
||||
Dim oXmlDocument = ExtractZugferd(Path)
|
||||
|
||||
@@ -36,10 +39,10 @@ Public Class ZUGFeRDInterface
|
||||
Return oXmlDocument
|
||||
End Function
|
||||
|
||||
Public Function ExtractZugferd(Path As String) As XmlDocument
|
||||
Public Function ExtractZugferd(Path As String) As XPathDocument
|
||||
Dim oProcessOutput, oProcessError, oFileContent As String
|
||||
Dim oXmlDocument As New XmlDocument()
|
||||
Dim oTempFile = IO.Path.GetTempFileName()
|
||||
Dim oXmlDocument As XPathDocument
|
||||
Dim oTempFile = System.IO.Path.GetTempFileName()
|
||||
|
||||
Dim oProcessStartInfo As New ProcessStartInfo() With {
|
||||
.FileName = ZUGFERD_CONVERTER_EXE,
|
||||
@@ -68,14 +71,8 @@ Public Class ZUGFeRDInterface
|
||||
End If
|
||||
|
||||
Try
|
||||
oFileContent = IO.File.ReadAllText(oTempFile)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
oXmlDocument = New XPath.XPathDocument(oTempFile)
|
||||
|
||||
Try
|
||||
oXmlDocument.LoadXml(oFileContent)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
@@ -84,31 +81,11 @@ Public Class ZUGFeRDInterface
|
||||
Return oXmlDocument
|
||||
End Function
|
||||
|
||||
Private Function CheckZugferd(Path As String) As Boolean
|
||||
Dim oProcessOutput, oProcessError As String
|
||||
Dim oProcessStartInfo As New ProcessStartInfo() With {
|
||||
.FileName = ZUGFERD_CONVERTER_EXE,
|
||||
.RedirectStandardError = True,
|
||||
.RedirectStandardOutput = True,
|
||||
.UseShellExecute = False,
|
||||
.Arguments = $"-i {Path}"
|
||||
}
|
||||
Dim oProcess As New Process() With {
|
||||
.StartInfo = oProcessStartInfo
|
||||
}
|
||||
Public Function ParseXMLDocument(doc As XPathDocument)
|
||||
Dim nav As XPathNavigator = doc.CreateNavigator()
|
||||
Dim reader = nav.ReadSubtree()
|
||||
|
||||
Try
|
||||
oProcess.Start()
|
||||
oProcessOutput = oProcess.StandardOutput.ReadToEnd()
|
||||
oProcessError = oProcess.StandardError.ReadToEnd()
|
||||
oProcess.WaitForExit()
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
Return True
|
||||
Dim serializer As New XmlSerializer(GetType(CrossIndustryDocumentType))
|
||||
Dim cross As CrossIndustryDocumentType = serializer.Deserialize(reader)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user