spedbuch auswert; ReadT1ATEZ,Greenpulse API
This commit is contained in:
@@ -4072,10 +4072,13 @@ Class cSpeditionsbuchReport
|
|||||||
datei = exclApp.Workbooks.Open(path)
|
datei = exclApp.Workbooks.Open(path)
|
||||||
blatt = datei.Worksheets(1)
|
blatt = datei.Worksheets(1)
|
||||||
|
|
||||||
|
Dim errorTmp = ""
|
||||||
CreateDetailReport(blatt, dt, KDNR)
|
CreateDetailReport(blatt, dt, KDNR, errorTmp)
|
||||||
' CreateGeneralReport(blatt, dt, KDNR, AbfVon, AbfBis)
|
' CreateGeneralReport(blatt, dt, KDNR, AbfVon, AbfBis)
|
||||||
|
|
||||||
|
If errorTmp <> "" Then
|
||||||
|
MsgBox("Fehlende Datensätze des Detailberichtes (SpedBuch vorhanden): " & vbCrLf & errorTmp.Trim)
|
||||||
|
End If
|
||||||
|
|
||||||
datei.Save()
|
datei.Save()
|
||||||
|
|
||||||
@@ -4181,7 +4184,7 @@ Class cSpeditionsbuchReport
|
|||||||
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
||||||
|
|
||||||
Dim sqlText As String =
|
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, " &
|
" CAST([Abfertigungsdatum] as date) Abfertigungsdatum, " &
|
||||||
" Absender, Empfänger, " &
|
" Absender, Empfänger, " &
|
||||||
" Rechnungsbetrag Betrag, " &
|
" Rechnungsbetrag Betrag, " &
|
||||||
@@ -4237,7 +4240,7 @@ Class cSpeditionsbuchReport
|
|||||||
Return cd
|
Return cd
|
||||||
End Function
|
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
|
Dim cnt As Integer = 2
|
||||||
|
|
||||||
For Each r As DataRow In dt.Rows
|
For Each r As DataRow In dt.Rows
|
||||||
@@ -4245,14 +4248,14 @@ Class cSpeditionsbuchReport
|
|||||||
Dim cd As cVERAG_CustomsDeclarations = LoadCustomsDeclaration(r)
|
Dim cd As cVERAG_CustomsDeclarations = LoadCustomsDeclaration(r)
|
||||||
|
|
||||||
If Not cd.hasEntry Then
|
If Not cd.hasEntry Then
|
||||||
MsgBox("ERROR: Nicht gefunden: " &
|
errorTmp &= If(r("BelegNr"), "").ToString() & " " &
|
||||||
If(r("BelegNr"), "").ToString() & " " &
|
|
||||||
If(r("FilialenNr"), "").ToString() & "/" &
|
If(r("FilialenNr"), "").ToString() & "/" &
|
||||||
If(r("AbfertigungsNr"), "").ToString())
|
If(r("AbfertigungsNr"), "").ToString() & vbNewLine
|
||||||
End If
|
Else 'Durch else wird nur Zeile geschrieben, wenn auch eine Zolldeklaration gefunden wurde. Sonst wird nur eine Fehlermeldung ausgegeben.
|
||||||
's
|
|
||||||
WriteDetailReportRow(blatt, r, cd, cnt, kdnr)
|
|
||||||
|
|
||||||
|
WriteDetailReportRow(blatt, r, cd, cnt, kdnr)
|
||||||
|
|
||||||
|
End If
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
MsgBox(ex.Message & vbCrLf & ex.StackTrace)
|
MsgBox(ex.Message & vbCrLf & ex.StackTrace)
|
||||||
End Try
|
End Try
|
||||||
|
|||||||
@@ -249,5 +249,9 @@ Public Class usrCntlMessenger_ListNewChats
|
|||||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
Public Sub initFontSizeSmaller()
|
||||||
|
dgvChats.RowsDefaultCellStyle.Font = New Font(dgvChats.Font.FontFamily, 8, dgvChats.Font.Style)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
End Class
|
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
|
' Zentrale Konfiguration
|
||||||
' ==========================
|
' ==========================
|
||||||
Private Const BaseUrl As String = "https://t1.declarant.ai/"
|
|
||||||
|
|
||||||
' lt. API-Dokumentation
|
Private Const TokenUrl As String =
|
||||||
Private Const Username As String = "verag"
|
"https://login.singlewindow.io/auth/realms/agsw/protocol/openid-connect/token"
|
||||||
Private Const Password As String = "verag_password123"
|
|
||||||
Private Const ClientId As String = "client3"
|
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 Const GrantType As String = "password"
|
||||||
|
|
||||||
Private Shared ReadOnly client As HttpClient = New HttpClient With {
|
Private Shared ReadOnly client As New HttpClient()
|
||||||
.BaseAddress = New Uri(BaseUrl)
|
|
||||||
}
|
|
||||||
|
' ==========================
|
||||||
|
' 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
|
' Zentrale Error-Auswertung
|
||||||
' ==========================
|
' ==========================
|
||||||
Private Async Function CreateAndThrowApiExceptionAsync(response As HttpResponseMessage,
|
Private Async Function CreateAndThrowApiExceptionAsync(
|
||||||
context As String) As Task
|
response As HttpResponseMessage,
|
||||||
|
context As String) As Task
|
||||||
|
|
||||||
Dim raw As String = String.Empty
|
Dim raw As String = String.Empty
|
||||||
|
|
||||||
Try
|
Try
|
||||||
raw = Await response.Content.ReadAsStringAsync()
|
raw = Await response.Content.ReadAsStringAsync()
|
||||||
Catch
|
Catch
|
||||||
' Ignorieren, wenn Lesen des Inhalts fehlschlägt
|
' Ignorieren, falls Response nicht gelesen werden kann
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
Dim errorKey As String = Nothing
|
Dim errorKey As String = Nothing
|
||||||
@@ -66,14 +252,16 @@ Public Class cATEZ_Read_T1
|
|||||||
|
|
||||||
If Not String.IsNullOrWhiteSpace(raw) Then
|
If Not String.IsNullOrWhiteSpace(raw) Then
|
||||||
Try
|
Try
|
||||||
Dim jo = JObject.Parse(raw)
|
Dim jo As JObject = JObject.Parse(raw)
|
||||||
|
|
||||||
errorKey = jo.Value(Of String)("error_key")
|
errorKey = jo.Value(Of String)("error_key")
|
||||||
|
|
||||||
If String.IsNullOrEmpty(errorKey) Then
|
If String.IsNullOrEmpty(errorKey) Then
|
||||||
errorKey = jo.Value(Of String)("error")
|
errorKey = jo.Value(Of String)("error")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
message = jo.Value(Of String)("message")
|
message = jo.Value(Of String)("message")
|
||||||
|
|
||||||
If String.IsNullOrEmpty(message) Then
|
If String.IsNullOrEmpty(message) Then
|
||||||
message = jo.Value(Of String)("detail")
|
message = jo.Value(Of String)("detail")
|
||||||
End If
|
End If
|
||||||
@@ -83,216 +271,220 @@ Public Class cATEZ_Read_T1
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Catch
|
Catch
|
||||||
' Inhalt war kein gültiges JSON – unten als Text verwenden
|
' Response ist kein JSON -> Raw Response verwenden
|
||||||
|
message = raw
|
||||||
End Try
|
End Try
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If String.IsNullOrWhiteSpace(message) Then
|
If String.IsNullOrWhiteSpace(message) Then
|
||||||
message = $"API-Fehler {CInt(response.StatusCode)} in {context}."
|
message =
|
||||||
If Not String.IsNullOrWhiteSpace(raw) Then
|
$"API-Fehler {CInt(response.StatusCode)} ({response.ReasonPhrase}) in {context}."
|
||||||
message &= " Response: " & raw
|
|
||||||
End If
|
|
||||||
Else
|
Else
|
||||||
message = $"API-Fehler in {context}: " & message
|
message =
|
||||||
|
$"API-Fehler {CInt(response.StatusCode)} ({response.ReasonPhrase}) in {context}: {message}"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Throw New T1ApiException(response.StatusCode, message, errorKey, raw)
|
Throw New T1ApiException(
|
||||||
End Function
|
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
|
End Function
|
||||||
|
|
||||||
|
|
||||||
' Sync Wrapper falls du ihn brauchst
|
'' Sync Wrapper falls du ihn brauchst
|
||||||
Public Function ProcessPdf(pdfPath As String) As T1ProcessResult
|
'Public Function ProcessPdf(pdfPath As String) As T1ProcessResult
|
||||||
Return ProcessPdfAsync(pdfPath).GetAwaiter().GetResult()
|
' Return ProcessPdfAsync(pdfPath).GetAwaiter().GetResult()
|
||||||
End Function
|
'End Function
|
||||||
|
|
||||||
|
|
||||||
' ==========================
|
' ==========================
|
||||||
' TEST-Methode – ruft ProcessPdfAsync auf und gibt ALLES aus
|
' TEST-Methode – ruft ProcessPdfAsync auf und gibt ALLES aus
|
||||||
' ==========================
|
' ==========================
|
||||||
Public Async Sub TEST(pdfPath As String)
|
Public Async Sub TEST(pdfPath As String)
|
||||||
|
|
||||||
Try
|
Try
|
||||||
' dieselbe Instanz verwenden
|
Cursor.Current = Cursors.WaitCursor
|
||||||
|
|
||||||
Dim result As T1ProcessResult = Await Me.ProcessPdfAsync(pdfPath)
|
Dim result As T1ProcessResult = Await Me.ProcessPdfAsync(pdfPath)
|
||||||
|
|
||||||
Dim sb As New StringBuilder()
|
Dim sb As New StringBuilder()
|
||||||
|
|
||||||
sb.AppendLine("=== Grunddaten ===")
|
sb.AppendLine("=== DECLARANTHUB RESPONSE ===")
|
||||||
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()
|
||||||
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()
|
If result Is Nothing Then
|
||||||
sb.AppendLine("=== Items ===")
|
sb.AppendLine("Keine Daten von der API erhalten.")
|
||||||
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
|
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
|
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
|
Catch apiEx As T1ApiException
|
||||||
|
|
||||||
Dim sbErr As New StringBuilder()
|
Dim sbErr As New StringBuilder()
|
||||||
sbErr.AppendLine("T1 API Fehler")
|
|
||||||
sbErr.AppendLine("HTTP-Status: " & CInt(apiEx.StatusCode))
|
sbErr.AppendLine("DECLARANTHUB API FEHLER")
|
||||||
If Not String.IsNullOrEmpty(apiEx.ErrorKey) Then
|
sbErr.AppendLine()
|
||||||
sbErr.AppendLine("Error Key: " & apiEx.ErrorKey)
|
|
||||||
End If
|
If CInt(apiEx.StatusCode) > 0 Then
|
||||||
sbErr.AppendLine("Nachricht: " & apiEx.Message)
|
sbErr.AppendLine(
|
||||||
If Not String.IsNullOrEmpty(apiEx.RawResponse) Then
|
"HTTP-Status: " & CInt(apiEx.StatusCode).ToString()
|
||||||
sbErr.AppendLine()
|
)
|
||||||
sbErr.AppendLine("Raw Response:")
|
Else
|
||||||
sbErr.AppendLine(apiEx.RawResponse)
|
sbErr.AppendLine(
|
||||||
|
"HTTP-Status: keine HTTP-Antwort"
|
||||||
|
)
|
||||||
End If
|
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
|
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 Try
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|
||||||
Public Class T1ProcessItem
|
Public Class T1ProcessItem
|
||||||
<JsonProperty("export_id")>
|
<JsonProperty("export_id")>
|
||||||
Public Property ExportId As String
|
Public Property ExportId As String
|
||||||
|
|||||||
@@ -441,6 +441,7 @@
|
|||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Schnittstellen\ATEZ\GREENPULSE\cATEZ_Greenpulse_CBAM_CostCalculation.vb" />
|
<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_KafkaDecs.vb" />
|
||||||
<Compile Include="Schnittstellen\ATEZ\GREENPULSE\cATEZ_Greenpulse_KafkaInvoices.vb" />
|
<Compile Include="Schnittstellen\ATEZ\GREENPULSE\cATEZ_Greenpulse_KafkaInvoices.vb" />
|
||||||
<Compile Include="Schnittstellen\ATEZ\Read_T1\cATEZ_Read_T1.vb" />
|
<Compile Include="Schnittstellen\ATEZ\Read_T1\cATEZ_Read_T1.vb" />
|
||||||
|
|||||||
Reference in New Issue
Block a user