spedbuch auswert; ReadT1ATEZ,Greenpulse API
This commit is contained in:
@@ -4072,10 +4072,13 @@ Class cSpeditionsbuchReport
|
||||
datei = exclApp.Workbooks.Open(path)
|
||||
blatt = datei.Worksheets(1)
|
||||
|
||||
|
||||
CreateDetailReport(blatt, dt, KDNR)
|
||||
Dim errorTmp = ""
|
||||
CreateDetailReport(blatt, dt, KDNR, errorTmp)
|
||||
' CreateGeneralReport(blatt, dt, KDNR, AbfVon, AbfBis)
|
||||
|
||||
If errorTmp <> "" Then
|
||||
MsgBox("Fehlende Datensätze des Detailberichtes (SpedBuch vorhanden): " & vbCrLf & errorTmp.Trim)
|
||||
End If
|
||||
|
||||
datei.Save()
|
||||
|
||||
@@ -4181,7 +4184,7 @@ Class cSpeditionsbuchReport
|
||||
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
||||
|
||||
Dim sqlText As String =
|
||||
"SELECT CAST([FilialenNr] as varchar) + '/' + CAST([AbfertigungsNr] as varchar) Abfertigungsnummer, " &
|
||||
"Select CAST([FilialenNr] As varchar) + '/' + CAST([AbfertigungsNr] as varchar) Abfertigungsnummer, " &
|
||||
" CAST([Abfertigungsdatum] as date) Abfertigungsdatum, " &
|
||||
" Absender, Empfänger, " &
|
||||
" Rechnungsbetrag Betrag, " &
|
||||
@@ -4237,7 +4240,7 @@ Class cSpeditionsbuchReport
|
||||
Return cd
|
||||
End Function
|
||||
|
||||
Private Sub CreateDetailReport(blatt As Object, dt As DataTable, kdnr As Integer)
|
||||
Private Sub CreateDetailReport(blatt As Object, dt As DataTable, kdnr As Integer, ByRef errorTmp As String)
|
||||
Dim cnt As Integer = 2
|
||||
|
||||
For Each r As DataRow In dt.Rows
|
||||
@@ -4245,14 +4248,14 @@ Class cSpeditionsbuchReport
|
||||
Dim cd As cVERAG_CustomsDeclarations = LoadCustomsDeclaration(r)
|
||||
|
||||
If Not cd.hasEntry Then
|
||||
MsgBox("ERROR: Nicht gefunden: " &
|
||||
If(r("BelegNr"), "").ToString() & " " &
|
||||
errorTmp &= If(r("BelegNr"), "").ToString() & " " &
|
||||
If(r("FilialenNr"), "").ToString() & "/" &
|
||||
If(r("AbfertigungsNr"), "").ToString())
|
||||
End If
|
||||
's
|
||||
WriteDetailReportRow(blatt, r, cd, cnt, kdnr)
|
||||
If(r("AbfertigungsNr"), "").ToString() & vbNewLine
|
||||
Else 'Durch else wird nur Zeile geschrieben, wenn auch eine Zolldeklaration gefunden wurde. Sonst wird nur eine Fehlermeldung ausgegeben.
|
||||
|
||||
WriteDetailReportRow(blatt, r, cd, cnt, kdnr)
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & vbCrLf & ex.StackTrace)
|
||||
End Try
|
||||
|
||||
@@ -249,5 +249,9 @@ Public Class usrCntlMessenger_ListNewChats
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
End Sub
|
||||
Public Sub initFontSizeSmaller()
|
||||
dgvChats.RowsDefaultCellStyle.Font = New Font(dgvChats.Font.FontFamily, 8, dgvChats.Font.Style)
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -37,28 +37,214 @@ Public Class cATEZ_Read_T1
|
||||
' ==========================
|
||||
' Zentrale Konfiguration
|
||||
' ==========================
|
||||
Private Const BaseUrl As String = "https://t1.declarant.ai/"
|
||||
|
||||
' lt. API-Dokumentation
|
||||
Private Const Username As String = "verag"
|
||||
Private Const Password As String = "verag_password123"
|
||||
Private Const ClientId As String = "client3"
|
||||
Private Const TokenUrl As String =
|
||||
"https://login.singlewindow.io/auth/realms/agsw/protocol/openid-connect/token"
|
||||
|
||||
Private Const ApiUrl As String =
|
||||
"https://declaranthub.singlewindow.io/api/v1-0/ai-ingestion/base64"
|
||||
|
||||
Private Const Username As String = "dhub@verag.ag"
|
||||
|
||||
' Gleiches Passwort wie für den Declaranthub-Login
|
||||
Private Const Password As String = "Dhub1234*"
|
||||
|
||||
Private Const ClientId As String = "agsw-admin"
|
||||
Private Const GrantType As String = "password"
|
||||
|
||||
Private Shared ReadOnly client As HttpClient = New HttpClient With {
|
||||
.BaseAddress = New Uri(BaseUrl)
|
||||
}
|
||||
Private Shared ReadOnly client As New HttpClient()
|
||||
|
||||
|
||||
' ==========================
|
||||
' TOKEN
|
||||
' ==========================
|
||||
Private Async Function GetTokenAsync() As Task(Of String)
|
||||
|
||||
Dim data = New Dictionary(Of String, String) From {
|
||||
{"grant_type", GrantType},
|
||||
{"username", Username},
|
||||
{"password", Password},
|
||||
{"client_id", ClientId}
|
||||
}
|
||||
|
||||
Using content As New FormUrlEncodedContent(data)
|
||||
|
||||
Dim response As HttpResponseMessage
|
||||
|
||||
Try
|
||||
response = Await client.PostAsync(TokenUrl, content)
|
||||
|
||||
Catch ex As TaskCanceledException
|
||||
Throw New T1ApiException(
|
||||
0,
|
||||
"Zeitüberschreitung beim Abrufen des Access Tokens.",
|
||||
Nothing,
|
||||
Nothing,
|
||||
ex)
|
||||
|
||||
Catch ex As Exception
|
||||
Throw New T1ApiException(
|
||||
0,
|
||||
"Fehler beim Abrufen des Access Tokens.",
|
||||
Nothing,
|
||||
Nothing,
|
||||
ex)
|
||||
End Try
|
||||
|
||||
If Not response.IsSuccessStatusCode Then
|
||||
Await CreateAndThrowApiExceptionAsync(response, "Token-Anforderung")
|
||||
End If
|
||||
|
||||
Dim json = Await response.Content.ReadAsStringAsync()
|
||||
|
||||
Dim tokenObj As JObject
|
||||
|
||||
Try
|
||||
tokenObj = JObject.Parse(json)
|
||||
Catch ex As Exception
|
||||
Throw New T1ApiException(
|
||||
response.StatusCode,
|
||||
"Token-Response enthält kein gültiges JSON.",
|
||||
Nothing,
|
||||
json,
|
||||
ex)
|
||||
End Try
|
||||
|
||||
Dim token = tokenObj.Value(Of String)("access_token")
|
||||
|
||||
If String.IsNullOrWhiteSpace(token) Then
|
||||
Throw New T1ApiException(
|
||||
response.StatusCode,
|
||||
"Kein access_token im Token-Response gefunden.",
|
||||
Nothing,
|
||||
json)
|
||||
End If
|
||||
|
||||
Return token
|
||||
|
||||
End Using
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
' ==========================
|
||||
' PROCESS PDF
|
||||
' ==========================
|
||||
Public Async Function ProcessPdfAsync(pdfPath As String) As Task(Of T1ProcessResult)
|
||||
|
||||
If Not File.Exists(pdfPath) Then
|
||||
Throw New FileNotFoundException(
|
||||
"PDF-Datei nicht gefunden.",
|
||||
pdfPath)
|
||||
End If
|
||||
|
||||
' 1. Access Token holen
|
||||
Dim token As String = Await GetTokenAsync()
|
||||
|
||||
' 2. PDF → Base64
|
||||
Dim pdfBytes As Byte() = File.ReadAllBytes(pdfPath)
|
||||
Dim base64 As String = Convert.ToBase64String(pdfBytes)
|
||||
|
||||
' 3. Payload gemäß neuer API
|
||||
Dim payload = New With {
|
||||
.documentType = "transit_declaration",
|
||||
.mode = "direct",
|
||||
.outputApplicationId = "dakosy/sftp/verg",
|
||||
.base64String = base64
|
||||
}
|
||||
|
||||
Dim jsonBody As String =
|
||||
JsonConvert.SerializeObject(payload)
|
||||
|
||||
Using content As New StringContent(
|
||||
jsonBody,
|
||||
Encoding.UTF8,
|
||||
"application/json")
|
||||
|
||||
Using request As New HttpRequestMessage(
|
||||
HttpMethod.Post,
|
||||
ApiUrl)
|
||||
|
||||
request.Headers.Authorization =
|
||||
New AuthenticationHeaderValue("Bearer", token)
|
||||
|
||||
request.Content = content
|
||||
|
||||
Dim response As HttpResponseMessage
|
||||
|
||||
Try
|
||||
response = Await client.SendAsync(request)
|
||||
|
||||
Catch ex As TaskCanceledException
|
||||
Throw New T1ApiException(
|
||||
0,
|
||||
"Zeitüberschreitung beim Aufruf der Declaranthub API.",
|
||||
Nothing,
|
||||
Nothing,
|
||||
ex)
|
||||
|
||||
Catch ex As Exception
|
||||
Throw New T1ApiException(
|
||||
0,
|
||||
"Fehler beim Aufruf der Declaranthub API.",
|
||||
Nothing,
|
||||
Nothing,
|
||||
ex)
|
||||
End Try
|
||||
|
||||
If Not response.IsSuccessStatusCode Then
|
||||
Await CreateAndThrowApiExceptionAsync(
|
||||
response,
|
||||
"Declaranthub AI Ingestion")
|
||||
End If
|
||||
|
||||
Dim resultJson As String =
|
||||
Await response.Content.ReadAsStringAsync()
|
||||
|
||||
Dim result As T1ProcessResult
|
||||
|
||||
Try
|
||||
result =
|
||||
JsonConvert.DeserializeObject(Of T1ProcessResult)(
|
||||
resultJson)
|
||||
|
||||
Catch ex As Exception
|
||||
Throw New T1ApiException(
|
||||
response.StatusCode,
|
||||
"Konnte API-Response nicht in T1ProcessResult deserialisieren.",
|
||||
Nothing,
|
||||
resultJson,
|
||||
ex)
|
||||
End Try
|
||||
|
||||
If result Is Nothing Then
|
||||
Throw New T1ApiException(
|
||||
response.StatusCode,
|
||||
"Leeres API-Ergebnis nach Deserialisierung.",
|
||||
Nothing,
|
||||
resultJson)
|
||||
End If
|
||||
|
||||
Return result
|
||||
|
||||
End Using
|
||||
End Using
|
||||
|
||||
End Function
|
||||
|
||||
' ==========================
|
||||
' Zentrale Error-Auswertung
|
||||
' ==========================
|
||||
Private Async Function CreateAndThrowApiExceptionAsync(response As HttpResponseMessage,
|
||||
context As String) As Task
|
||||
Private Async Function CreateAndThrowApiExceptionAsync(
|
||||
response As HttpResponseMessage,
|
||||
context As String) As Task
|
||||
|
||||
Dim raw As String = String.Empty
|
||||
|
||||
Try
|
||||
raw = Await response.Content.ReadAsStringAsync()
|
||||
Catch
|
||||
' Ignorieren, wenn Lesen des Inhalts fehlschlägt
|
||||
' Ignorieren, falls Response nicht gelesen werden kann
|
||||
End Try
|
||||
|
||||
Dim errorKey As String = Nothing
|
||||
@@ -66,14 +252,16 @@ Public Class cATEZ_Read_T1
|
||||
|
||||
If Not String.IsNullOrWhiteSpace(raw) Then
|
||||
Try
|
||||
Dim jo = JObject.Parse(raw)
|
||||
Dim jo As JObject = JObject.Parse(raw)
|
||||
|
||||
errorKey = jo.Value(Of String)("error_key")
|
||||
|
||||
If String.IsNullOrEmpty(errorKey) Then
|
||||
errorKey = jo.Value(Of String)("error")
|
||||
End If
|
||||
|
||||
message = jo.Value(Of String)("message")
|
||||
|
||||
If String.IsNullOrEmpty(message) Then
|
||||
message = jo.Value(Of String)("detail")
|
||||
End If
|
||||
@@ -83,216 +271,220 @@ Public Class cATEZ_Read_T1
|
||||
End If
|
||||
|
||||
Catch
|
||||
' Inhalt war kein gültiges JSON – unten als Text verwenden
|
||||
' Response ist kein JSON -> Raw Response verwenden
|
||||
message = raw
|
||||
End Try
|
||||
End If
|
||||
|
||||
If String.IsNullOrWhiteSpace(message) Then
|
||||
message = $"API-Fehler {CInt(response.StatusCode)} in {context}."
|
||||
If Not String.IsNullOrWhiteSpace(raw) Then
|
||||
message &= " Response: " & raw
|
||||
End If
|
||||
message =
|
||||
$"API-Fehler {CInt(response.StatusCode)} ({response.ReasonPhrase}) in {context}."
|
||||
Else
|
||||
message = $"API-Fehler in {context}: " & message
|
||||
message =
|
||||
$"API-Fehler {CInt(response.StatusCode)} ({response.ReasonPhrase}) in {context}: {message}"
|
||||
End If
|
||||
|
||||
Throw New T1ApiException(response.StatusCode, message, errorKey, raw)
|
||||
End Function
|
||||
Throw New T1ApiException(
|
||||
response.StatusCode,
|
||||
message,
|
||||
errorKey,
|
||||
raw)
|
||||
|
||||
' ==========================
|
||||
' TOKEN
|
||||
' ==========================
|
||||
Private Async Function GetTokenAsync() As Task(Of String)
|
||||
|
||||
Dim data = New Dictionary(Of String, String) From {
|
||||
{"username", Username},
|
||||
{"password", Password},
|
||||
{"client_id", ClientId},
|
||||
{"grant_type", GrantType}
|
||||
}
|
||||
|
||||
Dim content = New FormUrlEncodedContent(data)
|
||||
|
||||
Dim response As HttpResponseMessage
|
||||
Try
|
||||
response = Await client.PostAsync("token", content)
|
||||
Catch ex As TaskCanceledException
|
||||
Throw New T1ApiException(0, "Zeitüberschreitung beim Aufruf von /token.", Nothing, Nothing, ex)
|
||||
Catch ex As Exception
|
||||
Throw New T1ApiException(0, "Fehler beim Aufruf von /token.", Nothing, Nothing, ex)
|
||||
End Try
|
||||
|
||||
If Not response.IsSuccessStatusCode Then
|
||||
Await CreateAndThrowApiExceptionAsync(response, "/token")
|
||||
End If
|
||||
|
||||
Dim json = Await response.Content.ReadAsStringAsync()
|
||||
Dim tokenObj = JObject.Parse(json)
|
||||
|
||||
Dim token = tokenObj.Value(Of String)("access_token")
|
||||
If String.IsNullOrEmpty(token) Then
|
||||
Throw New T1ApiException(response.StatusCode,
|
||||
"Kein access_token im /token-Response gefunden.",
|
||||
Nothing,
|
||||
json)
|
||||
End If
|
||||
|
||||
Return token
|
||||
End Function
|
||||
|
||||
' ==========================
|
||||
' PROCESS PDF
|
||||
' ==========================
|
||||
Public Async Function ProcessPdfAsync(pdfPath As String) As Task(Of T1ProcessResult)
|
||||
|
||||
If Not File.Exists(pdfPath) Then
|
||||
Throw New FileNotFoundException("PDF-Datei nicht gefunden.", pdfPath)
|
||||
End If
|
||||
|
||||
' Token holen
|
||||
Dim token = Await GetTokenAsync()
|
||||
|
||||
' PDF → Base64
|
||||
Dim base64 = Convert.ToBase64String(File.ReadAllBytes(pdfPath))
|
||||
|
||||
Dim payload = New With {
|
||||
.document_base64 = base64
|
||||
}
|
||||
|
||||
Dim jsonBody = JsonConvert.SerializeObject(payload)
|
||||
Dim content = New StringContent(jsonBody, Encoding.UTF8, "application/json")
|
||||
|
||||
Dim request = New HttpRequestMessage(HttpMethod.Post, "process")
|
||||
request.Headers.Authorization = New AuthenticationHeaderValue("Bearer", token)
|
||||
request.Content = content
|
||||
|
||||
Dim response As HttpResponseMessage
|
||||
Try
|
||||
response = Await client.SendAsync(request)
|
||||
Catch ex As TaskCanceledException
|
||||
Throw New T1ApiException(0, "Zeitüberschreitung beim Aufruf von /process.", Nothing, Nothing, ex)
|
||||
Catch ex As Exception
|
||||
Throw New T1ApiException(0, "Fehler beim Aufruf von /process.", Nothing, Nothing, ex)
|
||||
End Try
|
||||
|
||||
If Not response.IsSuccessStatusCode Then
|
||||
Await CreateAndThrowApiExceptionAsync(response, "/process")
|
||||
End If
|
||||
|
||||
Dim resultJson = Await response.Content.ReadAsStringAsync()
|
||||
|
||||
' JSON → Klasse
|
||||
Dim result As T1ProcessResult
|
||||
Try
|
||||
result = JsonConvert.DeserializeObject(Of T1ProcessResult)(resultJson)
|
||||
Catch ex As Exception
|
||||
Throw New T1ApiException(response.StatusCode,
|
||||
"Konnte /process-Response nicht in T1ProcessResult deserialisieren.",
|
||||
Nothing,
|
||||
resultJson,
|
||||
ex)
|
||||
End Try
|
||||
|
||||
If result Is Nothing Then
|
||||
Throw New T1ApiException(response.StatusCode,
|
||||
"Leeres /process-Ergebnis nach Deserialisierung.",
|
||||
Nothing,
|
||||
resultJson)
|
||||
End If
|
||||
|
||||
Return result
|
||||
End Function
|
||||
|
||||
|
||||
' Sync Wrapper falls du ihn brauchst
|
||||
Public Function ProcessPdf(pdfPath As String) As T1ProcessResult
|
||||
Return ProcessPdfAsync(pdfPath).GetAwaiter().GetResult()
|
||||
End Function
|
||||
'' Sync Wrapper falls du ihn brauchst
|
||||
'Public Function ProcessPdf(pdfPath As String) As T1ProcessResult
|
||||
' Return ProcessPdfAsync(pdfPath).GetAwaiter().GetResult()
|
||||
'End Function
|
||||
|
||||
|
||||
' ==========================
|
||||
' TEST-Methode – ruft ProcessPdfAsync auf und gibt ALLES aus
|
||||
' ==========================
|
||||
Public Async Sub TEST(pdfPath As String)
|
||||
|
||||
Try
|
||||
' dieselbe Instanz verwenden
|
||||
Cursor.Current = Cursors.WaitCursor
|
||||
|
||||
Dim result As T1ProcessResult = Await Me.ProcessPdfAsync(pdfPath)
|
||||
|
||||
Dim sb As New 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("=== DECLARANTHUB RESPONSE ===")
|
||||
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
|
||||
If result Is Nothing Then
|
||||
sb.AppendLine("Keine Daten von der API erhalten.")
|
||||
Else
|
||||
sb.AppendLine("Keine Items vorhanden.")
|
||||
|
||||
' ==========================================
|
||||
' Grunddaten
|
||||
' ==========================================
|
||||
sb.AppendLine("=== Grunddaten ===")
|
||||
sb.AppendLine("Status: " & If(result.Status, ""))
|
||||
sb.AppendLine("Document Count: " & result.DocumentCount.ToString())
|
||||
sb.AppendLine("Document Type: " & If(result.DocumentType, ""))
|
||||
sb.AppendLine("Processing Time (s): " & result.ProcessingTimeSeconds.ToString())
|
||||
|
||||
' ==========================================
|
||||
' T1 Kopfdaten
|
||||
' ==========================================
|
||||
sb.AppendLine()
|
||||
sb.AppendLine("=== 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, ""))
|
||||
|
||||
|
||||
' ==========================================
|
||||
' Items
|
||||
' ==========================================
|
||||
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 As T1ProcessItem = result.Items(i)
|
||||
|
||||
sb.AppendLine($"Item #{i + 1}")
|
||||
sb.AppendLine($" Export ID: {If(it.ExportId, "")}")
|
||||
sb.AppendLine($" Invoice No: {If(it.InvoiceNo, "")}")
|
||||
sb.AppendLine($" Item Index: {it.ItemIndex}")
|
||||
sb.AppendLine($" Sender: {If(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
|
||||
|
||||
|
||||
' ==========================================
|
||||
' Noch nicht gemappte Felder
|
||||
' ==========================================
|
||||
sb.AppendLine()
|
||||
sb.AppendLine("=== Additional Data ===")
|
||||
|
||||
If result.AdditionalData IsNot Nothing AndAlso
|
||||
result.AdditionalData.Count > 0 Then
|
||||
|
||||
For Each kvp In result.AdditionalData
|
||||
|
||||
sb.AppendLine(
|
||||
$"{kvp.Key}: {kvp.Value.ToString(Formatting.Indented)}"
|
||||
)
|
||||
|
||||
Next
|
||||
|
||||
Else
|
||||
sb.AppendLine("Keine zusätzlichen Felder vorhanden.")
|
||||
End If
|
||||
|
||||
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)
|
||||
MessageBox.Show(
|
||||
sb.ToString(),
|
||||
"Declaranthub – T1 verarbeitet",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information
|
||||
)
|
||||
|
||||
|
||||
Catch apiEx As T1ApiException
|
||||
|
||||
Dim sbErr As New 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)
|
||||
|
||||
sbErr.AppendLine("DECLARANTHUB API FEHLER")
|
||||
sbErr.AppendLine()
|
||||
|
||||
If CInt(apiEx.StatusCode) > 0 Then
|
||||
sbErr.AppendLine(
|
||||
"HTTP-Status: " & CInt(apiEx.StatusCode).ToString()
|
||||
)
|
||||
Else
|
||||
sbErr.AppendLine(
|
||||
"HTTP-Status: keine HTTP-Antwort"
|
||||
)
|
||||
End If
|
||||
|
||||
MessageBox.Show(sbErr.ToString(), "T1 API Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
If Not String.IsNullOrWhiteSpace(apiEx.ErrorKey) Then
|
||||
sbErr.AppendLine(
|
||||
"Error Key: " & apiEx.ErrorKey
|
||||
)
|
||||
End If
|
||||
|
||||
sbErr.AppendLine()
|
||||
sbErr.AppendLine("Nachricht:")
|
||||
sbErr.AppendLine(apiEx.Message)
|
||||
|
||||
|
||||
' Besonders wichtig beim ersten Test der neuen API
|
||||
If Not String.IsNullOrWhiteSpace(apiEx.RawResponse) Then
|
||||
|
||||
sbErr.AppendLine()
|
||||
sbErr.AppendLine("=== RAW RESPONSE ===")
|
||||
sbErr.AppendLine(apiEx.RawResponse)
|
||||
|
||||
End If
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
sbErr.ToString(),
|
||||
"Declaranthub API Fehler",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
)
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
MessageBox.Show(ex.ToString(), "Allgemeiner Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
|
||||
MessageBox.Show(
|
||||
ex.ToString(),
|
||||
"Allgemeiner Fehler",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error
|
||||
)
|
||||
|
||||
Finally
|
||||
|
||||
Cursor.Current = Cursors.Default
|
||||
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
Public Class T1ProcessItem
|
||||
<JsonProperty("export_id")>
|
||||
Public Property ExportId As String
|
||||
|
||||
@@ -441,6 +441,7 @@
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Schnittstellen\ATEZ\GREENPULSE\cATEZ_Greenpulse_CBAM_CostCalculation.vb" />
|
||||
<Compile Include="Schnittstellen\ATEZ\GREENPULSE\cATEZ_Greenpulse_CBAM_CostCalculation_NEU.vb" />
|
||||
<Compile Include="Schnittstellen\ATEZ\GREENPULSE\cATEZ_Greenpulse_KafkaDecs.vb" />
|
||||
<Compile Include="Schnittstellen\ATEZ\GREENPULSE\cATEZ_Greenpulse_KafkaInvoices.vb" />
|
||||
<Compile Include="Schnittstellen\ATEZ\Read_T1\cATEZ_Read_T1.vb" />
|
||||
|
||||
Reference in New Issue
Block a user