procedures

This commit is contained in:
2025-11-26 09:03:21 +01:00
parent 7918b0d0b8
commit 99bb7d39de
6 changed files with 489 additions and 26 deletions

View File

@@ -4304,6 +4304,119 @@ OPTION (MAXRECURSION 1000);", "AVISO") '
End Sub
Private Sub btnImportTrStat_Click(sender As Object, e As EventArgs) Handles btnImportTrStat.Click
' SQL Connection String (ggf. anpassen)
Dim connectionString As String = "Data Source=DEVELOPER\DEVSQL;Initial Catalog=TRCustStat;Integrated Security=false;User ID=sa;Password=BmWr501956;"
' FileDialog vorbereiten
Using ofd As New OpenFileDialog()
ofd.Title = "Select one or more Customs Excel files"
ofd.Filter = "Excel Files (*.xlsx;*.xls;*.xlsm)|*.xlsx;*.xls;*.xlsm|All Files (*.*)|*.*"
ofd.Multiselect = True
ofd.InitialDirectory = "D:\CustomsUploads" ' optionaler Startordner
If ofd.ShowDialog() = DialogResult.OK Then
Dim selectedFiles = ofd.FileNames
Try
Dim importer As New cTRCustStat(connectionString)
importer.ImportFiles(selectedFiles)
MessageBox.Show($"✅ Import completed successfully." & vbCrLf &
$"Files imported: {selectedFiles.Length}",
"Import Finished", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("❌ Error during import:" & vbCrLf & ex.Message,
"Import Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Using
End Sub
Private Sub Button53_Click(sender As Object, e As EventArgs) Handles Button53.Click
TESTs("D:\Andreas\TMP\TESTT1.pdf")
End Sub
Private Async Sub TESTs(pdfPath As String)
Try
Dim READ As New VERAG_PROG_ALLGEMEIN.cATEZ_Read_T1
' dieselbe Instanz verwenden
Dim result As T1ProcessResult = Await READ.ProcessPdfAsync(pdfPath)
Dim sb As New System.Text.StringBuilder()
sb.AppendLine("=== Grunddaten ===")
sb.AppendLine("Status: " & If(result.Status, ""))
sb.AppendLine("Document Count: " & result.DocumentCount)
sb.AppendLine("Document Type: " & If(result.DocumentType, ""))
sb.AppendLine("Processing Time (s): " & result.ProcessingTimeSeconds)
sb.AppendLine()
sb.AppendLine("=== Kopf-T1-Daten ===")
sb.AppendLine("Date: " & If(result.DateField, ""))
sb.AppendLine("Dispatch Country: " & If(result.DispatchCountry, ""))
sb.AppendLine("Dispatch Place: " & If(result.DispatchPlace, ""))
sb.AppendLine("Loading Place: " & If(result.LoadingPlace, ""))
sb.AppendLine("Destination Country: " & If(result.DestinationCountry, ""))
sb.AppendLine("Destination Customs Authority: " & If(result.DestinationCustomsAuthority, ""))
sb.AppendLine("Mode of Transport: " & If(result.ModeOfTransport, ""))
sb.AppendLine("Type of Transport: " & If(result.TypeOfTransport, ""))
sb.AppendLine("Transit ID: " & If(result.TransitId, ""))
sb.AppendLine("Truck ID Border: " & If(result.TruckIdBorder, ""))
sb.AppendLine("Truck ID Transit: " & If(result.TruckIdTransit, ""))
sb.AppendLine()
sb.AppendLine("=== Items ===")
If result.Items IsNot Nothing AndAlso result.Items.Count > 0 Then
For i As Integer = 0 To result.Items.Count - 1
Dim it = result.Items(i)
sb.AppendLine($"Item #{i + 1}")
sb.AppendLine($" Export ID: {it.ExportId}")
sb.AppendLine($" Invoice No: {it.InvoiceNo}")
sb.AppendLine($" Item Index: {it.ItemIndex}")
sb.AppendLine($" Sender: {it.Sender}")
sb.AppendLine($" Total Package: {it.TotalPackage}")
sb.AppendLine($" Total Weight: {it.TotalWeight}")
sb.AppendLine()
Next
Else
sb.AppendLine("Keine Items vorhanden.")
End If
sb.AppendLine("=== Additional Data (ungeparst) ===")
If result.AdditionalData IsNot Nothing AndAlso result.AdditionalData.Count > 0 Then
For Each kvp In result.AdditionalData
sb.AppendLine($" {kvp.Key}: {kvp.Value.ToString()}")
Next
Else
sb.AppendLine("Keine zusätzlichen Felder.")
End If
MessageBox.Show(sb.ToString(), "T1 Dokument verarbeitet", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch apiEx As T1ApiException
Dim sbErr As New System.Text.StringBuilder()
sbErr.AppendLine("T1 API Fehler")
sbErr.AppendLine("HTTP-Status: " & CInt(apiEx.StatusCode))
If Not String.IsNullOrEmpty(apiEx.ErrorKey) Then
sbErr.AppendLine("Error Key: " & apiEx.ErrorKey)
End If
sbErr.AppendLine("Nachricht: " & apiEx.Message)
If Not String.IsNullOrEmpty(apiEx.RawResponse) Then
sbErr.AppendLine()
sbErr.AppendLine("Raw Response:")
sbErr.AppendLine(apiEx.RawResponse)
End If
MessageBox.Show(sbErr.ToString(), "T1 API Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch ex As Exception
MessageBox.Show(ex.ToString(), "Allgemeiner Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
'Private Sub Button26_Click(sender As Object, e As EventArgs)