zugpferd prüfungstool
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
Imports System.Reflection
|
||||
Imports System.Globalization
|
||||
Imports System.IO
|
||||
Imports VERAG_PROG_ALLGEMEIN
|
||||
|
||||
Public Class frmKundenUebersichtZollRgDetails
|
||||
Dim RK_ID As Integer = -1
|
||||
@@ -140,7 +141,11 @@ Public Class frmKundenUebersichtZollRgDetails
|
||||
Console.WriteLine(output)
|
||||
Console.WriteLine(err)
|
||||
|
||||
If err <> "" Then MsgBox(err)
|
||||
If err <> "" Then
|
||||
Dim tmpPath_Report = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath("MUSTANG-REPORT", ".pdf", , False)
|
||||
CreateValidationPdf(err, Path_temp, RK_ID, tmpPath_Report)
|
||||
If tmpPath_Report <> "" Then Process.Start(tmpPath_Report)
|
||||
End If
|
||||
|
||||
End Using
|
||||
|
||||
@@ -151,4 +156,57 @@ Public Class frmKundenUebersichtZollRgDetails
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function ExtractMustangResult(log As String, Invoice_file As String, RK_ID As Integer) As String
|
||||
|
||||
Dim pdfStatus = If(log.Contains("Parsed PDF:invalid"), "INVALID", "VALID")
|
||||
Dim xmlStatus = If(log.Contains("XML:valid"), "VALID", "INVALID")
|
||||
Dim FileInfo As New FileInfo(Invoice_file)
|
||||
Dim Invoice As New cRechnungsausgang(RK_ID)
|
||||
|
||||
Dim profile As String = "EN16931"
|
||||
If log.Contains("EN16931") Then profile = "EN16931"
|
||||
|
||||
Dim took As String = ""
|
||||
Dim m = System.Text.RegularExpressions.Regex.Match(log, "Took:(\d+)ms")
|
||||
If m.Success Then took = m.Groups(1).Value & " ms"
|
||||
|
||||
Return $"ZUGFeRD VALIDATION RESULT" & vbCrLf &
|
||||
$"--------------------------------" & vbCrLf &
|
||||
$"PDF File : {FileInfo.Name}" & vbCrLf &
|
||||
$"Invoice No : {Invoice.RechnungsNr}" & vbCrLf &
|
||||
$"PDF Status : {pdfStatus}" & vbCrLf &
|
||||
$"XML Status : {xmlStatus}" & vbCrLf &
|
||||
$"Profile : {profile}" & vbCrLf &
|
||||
$"Duration : {took}"
|
||||
|
||||
End Function
|
||||
|
||||
Public Sub CreateValidationPdf(log As String, Invoice_file As String, RK_ID As Integer, outputPath As String)
|
||||
|
||||
Dim resultText = ExtractMustangResult(log, Invoice_file, RK_ID)
|
||||
|
||||
Using fs As New FileStream(outputPath, FileMode.Create)
|
||||
Using doc As New itextsharp.text.Document()
|
||||
Dim writer = itextsharp.text.pdf.PdfWriter.GetInstance(doc, fs)
|
||||
|
||||
doc.Open()
|
||||
|
||||
Dim titleFont = itextsharp.text.FontFactory.GetFont("Arial", 14, itextsharp.text.Font.BOLD)
|
||||
Dim bodyFont = itextsharp.text.FontFactory.GetFont("Arial", 10)
|
||||
|
||||
doc.Add(New itextsharp.text.Paragraph("ZUGFeRD VALIDATION REPORT", titleFont))
|
||||
doc.Add(New itextsharp.text.Paragraph(" "))
|
||||
|
||||
Dim lines = resultText.Split(vbCrLf)
|
||||
|
||||
For Each line In lines
|
||||
doc.Add(New itextsharp.text.Paragraph(line, bodyFont))
|
||||
Next
|
||||
doc.Close()
|
||||
End Using
|
||||
End Using
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user