jj: oh my god /o\
This commit is contained in:
@@ -88,7 +88,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="ZUGFeRD1p0.vb" />
|
||||
<Compile Include="CrossIndustryDocumentType.vb" />
|
||||
<Compile Include="ZUGFeRDInterface.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -28,31 +28,31 @@ Public Class ZUGFeRDInterface
|
||||
''' <param name="Path"></param>
|
||||
''' <exception cref="ZUGFeRDExecption"></exception>
|
||||
''' <returns></returns>
|
||||
Public Function ExtractXMLFile(Path As String) As XPathDocument
|
||||
Public Function ExtractZUGFeRDFile(Path As String) As CrossIndustryDocumentType
|
||||
Dim oException As New Exception
|
||||
Dim oXmlDocument = ExtractZugferd(Path)
|
||||
Dim oXmlDocument = ValidateZUGFeRDFile(Path)
|
||||
|
||||
If IsNothing(oXmlDocument) Then
|
||||
Throw New ZUGFeRDExecption(ErrorType.ExtractionFailed, "Datei ist kein gültiges ZUGFeRD Format.")
|
||||
End If
|
||||
|
||||
Return oXmlDocument
|
||||
Return SerializeZUGFeRDDocument(oXmlDocument)
|
||||
End Function
|
||||
|
||||
Public Function ExtractZugferd(Path As String) As XPathDocument
|
||||
Dim oProcessOutput, oProcessError, oFileContent As String
|
||||
Dim oXmlDocument As XPathDocument
|
||||
Dim oTempFile = System.IO.Path.GetTempFileName()
|
||||
|
||||
Dim oProcessStartInfo As New ProcessStartInfo() With {
|
||||
.FileName = ZUGFERD_CONVERTER_EXE,
|
||||
.RedirectStandardError = True,
|
||||
.RedirectStandardOutput = True,
|
||||
.UseShellExecute = False,
|
||||
.Arguments = $"-i ""{Path}"" -o ""{oTempFile}"""
|
||||
}
|
||||
Public Function ValidateZUGFeRDFile(Path As String) As XPathDocument
|
||||
Dim oProcessOutput, oProcessError As String
|
||||
Dim oXmlDocument As XPathDocument
|
||||
Dim oTempFile = IO.Path.GetTempFileName()
|
||||
|
||||
Dim oProcess As New Process() With {
|
||||
.StartInfo = oProcessStartInfo
|
||||
.StartInfo = New ProcessStartInfo() With {
|
||||
.FileName = ZUGFERD_CONVERTER_EXE,
|
||||
.RedirectStandardError = True,
|
||||
.RedirectStandardOutput = True,
|
||||
.UseShellExecute = False,
|
||||
.Arguments = $"-i ""{Path}"" -o ""{oTempFile}"""
|
||||
}
|
||||
}
|
||||
|
||||
Try
|
||||
@@ -62,30 +62,35 @@ Public Class ZUGFeRDInterface
|
||||
oProcess.WaitForExit()
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
Throw ex
|
||||
End Try
|
||||
|
||||
If Not oProcessOutput.Contains(ZUGFERD_CONVERTER_SUCCESS_MESSAGE) Then
|
||||
_logger.Warn("File {0} is not a valid ZUGFeRD File!", Path)
|
||||
Return Nothing
|
||||
Throw New ZUGFeRDExecption(ErrorType.NoValidFile, "Datei ist kein gültiges ZUGFeRD Format.")
|
||||
End If
|
||||
|
||||
Try
|
||||
oXmlDocument = New XPath.XPathDocument(oTempFile)
|
||||
oXmlDocument = New XPathDocument(oTempFile)
|
||||
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
Throw ex
|
||||
End Try
|
||||
|
||||
Return oXmlDocument
|
||||
End Function
|
||||
|
||||
Public Function ParseXMLDocument(doc As XPathDocument)
|
||||
Dim nav As XPathNavigator = doc.CreateNavigator()
|
||||
Dim reader = nav.ReadSubtree()
|
||||
Public Function SerializeZUGFeRDDocument(Document As XPathDocument) As CrossIndustryDocumentType
|
||||
Try
|
||||
Dim oNavigator As XPathNavigator = Document.CreateNavigator()
|
||||
Dim oReader = oNavigator.ReadSubtree()
|
||||
Dim oSerializer As New XmlSerializer(GetType(CrossIndustryDocumentType))
|
||||
|
||||
Dim serializer As New XmlSerializer(GetType(CrossIndustryDocumentType))
|
||||
Dim cross As CrossIndustryDocumentType = serializer.Deserialize(reader)
|
||||
Return oSerializer.Deserialize(oReader)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user