From 2b85d4ee8cbcd9576f2680aae7e69f9f9c13608c Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Tue, 12 Sep 2023 22:19:17 +0200 Subject: [PATCH 1/4] atez --- .../Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb index ab291b66..be2fcebc 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb @@ -606,10 +606,9 @@ Public Class cATEZ_NCTS_IN 'DEBUG-Mode -> no request will be sent! 'rest.DebugMode = True - rest.PercentDoneOnSend = True + 'rest.PercentDoneOnSend = True rest.IdleTimeoutMs = 60000 - success = rest.SendReqSb("POST", "/api/integrations/verag", sbRequestBody) Dim responseStatusCode = rest.ReadResponseHeader() @@ -617,7 +616,7 @@ Public Class cATEZ_NCTS_IN For i = 0 To 15 'Versuche den Header 16x abzufragen (funktioniert ab und zu nicht). responseStatusCode = rest.ReadResponseHeader() If responseStatusCode > 0 Then Exit For - Thread.Sleep(3000) + Thread.Sleep(5000) i = i + 1 Next From 093931e9faa0dc90b42c1588b84a7ff7e5938cca Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Tue, 12 Sep 2023 22:19:37 +0200 Subject: [PATCH 2/4] atez --- .../Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb index be2fcebc..5c742601 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb @@ -607,7 +607,7 @@ Public Class cATEZ_NCTS_IN 'rest.DebugMode = True 'rest.PercentDoneOnSend = True - rest.IdleTimeoutMs = 60000 + rest.IdleTimeoutMs = 5000 * 16 success = rest.SendReqSb("POST", "/api/integrations/verag", sbRequestBody) @@ -622,7 +622,7 @@ Public Class cATEZ_NCTS_IN If rest.ResponseStatusCode <> 200 Then MsgBox(rest.LastErrorText) - Return False + Return responseStatusCode & "-" & rest.ResponseStatusText End If End If @@ -641,7 +641,7 @@ Public Class cATEZ_NCTS_IN Dim jsonResultFailure As New Chilkat.JsonObject jsonResultFailure.LoadSb(sbResponseBody) jsonResultFailure.Emit() - failureDesc = jsonResultFailure.StringOf("code") & "-" & jsonResultFailure.StringOf("message") + failureDesc = "ATEZ: " & jsonResultFailure.StringOf("code") & "-" & jsonResultFailure.StringOf("message") Return failureDesc Else From b5ffd4433d97180145efc87ca1b3274b27f88c10 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Wed, 13 Sep 2023 10:38:20 +0200 Subject: [PATCH 3/4] Fehlerhandling ATEZ bei not receivedResponseHeader verbessert., Digicust API erweitert. --- .../ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb | 9 ++++++--- .../Schnittstellen/Digicast/cDigicustAPI.vb | 12 +++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb index 5c742601..6c8c67ea 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb @@ -581,7 +581,6 @@ Public Class cATEZ_NCTS_IN Dim rest As New Chilkat.Rest Dim success As Boolean - Dim bTls As Boolean = True Dim port As Integer = 443 Dim bAutoReconnect As Boolean = True @@ -608,6 +607,7 @@ Public Class cATEZ_NCTS_IN 'rest.PercentDoneOnSend = True rest.IdleTimeoutMs = 5000 * 16 + rest.VerboseLogging = True success = rest.SendReqSb("POST", "/api/integrations/verag", sbRequestBody) @@ -621,8 +621,12 @@ Public Class cATEZ_NCTS_IN Next If rest.ResponseStatusCode <> 200 Then + If responseStatusCode = -1 Then + Return responseStatusCode + End If MsgBox(rest.LastErrorText) - Return responseStatusCode & "-" & rest.ResponseStatusText + failureDesc = responseStatusCode & "-" & rest.ResponseStatusText + Return failureDesc End If End If @@ -691,7 +695,6 @@ Public Class cATEZ_NCTS_IN success = jsonData.UpdateString("Guarantee.GRN", ncts.Guarantee_GRN) - Dim Route_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen) VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen.LOAD_LIST_ByNCTS(Route_LIST, ncts.Id) diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb index 5d8c078f..2f7469ff 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb @@ -487,7 +487,7 @@ Public Class cDigicustAPI ' createUserinput(rest, counter, dig) - rest.PartSelector = "0" + rest.AddHeader("Content-Type", "multipart/form-data") rest.AddHeader("Authorization", "Bearer " & token) @@ -499,6 +499,11 @@ Public Class cDigicustAPI rest.SendReqMultipart("POST", "/upload/api/" & settings.customerId & "/" & settings.projectId & "/new") + rest.PartSelector = "0" + rest.ClearAllHeaders() + rest.ClearAllParts() + rest.PartSelector = "" + Dim responseStatusCode = rest.ReadResponseHeader() If (responseStatusCode < 0) Then For i = 0 To 15 'Versuche den Header 16x abzufragen (funktioniert ab und zu nicht). @@ -619,10 +624,15 @@ Public Class cDigicustAPI Shared Function createUserinput(ByRef rest As Chilkat.Rest, ByRef counter As Integer, ByVal sendung As cDigicustSendungen) + 'zusätzliche Informationen aus dem AVISO 'beforeNormalization(fallback -> falls Daten nicht gelesen werden können, wird ergänzt) 'afterNormalization(overwrite -> werden mit mitgeschickten Infos überschrieben). + Dim jsonArray As New Chilkat.JsonArray() + + + Dim json As New Chilkat.JsonObject If sendung.licencePlate <> "" Then json.UpdateString("truckLicensePlate", sendung.licencePlate) From 80cdbe2c630eb5cfb26489de5f6c6b85fbd928c1 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Wed, 13 Sep 2023 13:34:24 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Digicust-erg=C3=A4nzende=20Daten=20werden?= =?UTF-8?q?=20mitgeschickt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Schnittstellen/Digicast/cDigicustAPI.vb | 67 +++++++++++++------ 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb index 2f7469ff..1a5ca24b 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb @@ -439,6 +439,12 @@ Public Class cDigicustAPI rest.VerboseLogging = True + + rest.ClearAllHeaders() + rest.ClearAllParts() + rest.PartSelector = "" + + Dim counter As Integer = 1 Dim jsonFileArray = New Chilkat.JsonArray() @@ -485,24 +491,25 @@ Public Class cDigicustAPI rest.SetMultipartBodyString(dig.reference) counter += 1 - ' createUserinput(rest, counter, dig) - + createUserinput(rest, counter, dig) + rest.PartSelector = "0" rest.AddHeader("Content-Type", "multipart/form-data") rest.AddHeader("Authorization", "Bearer " & token) rest.AddHeader("Expect", "100-continue") + + Debug.WriteLine(rest) + 'Debuging 'rest.DebugMode = True rest.IdleTimeoutMs = 60000 rest.SendReqMultipart("POST", "/upload/api/" & settings.customerId & "/" & settings.projectId & "/new") - rest.PartSelector = "0" - rest.ClearAllHeaders() - rest.ClearAllParts() - rest.PartSelector = "" + + Dim responseStatusCode = rest.ReadResponseHeader() If (responseStatusCode < 0) Then @@ -513,13 +520,18 @@ Public Class cDigicustAPI i = i + 1 Next - If rest.ResponseStatusCode <> 200 Then - MsgBox(rest.LastErrorText) - Return False - End If - End If + If Not (rest.ResponseStatusCode = 200 Or rest.ResponseStatusCode = 201) Then + MsgBox(rest.LastErrorText) + If rest.ResponseStatusCode = -1 Then + Return True + End If + Return False + End If + + + If (rest.LastMethodSuccess <> True) Then MsgBox(rest.LastErrorText) Return False @@ -558,6 +570,11 @@ Public Class cDigicustAPI dig.projectId = jsonResp.StringOf("result.projectId") dig.companyId = jsonResp.StringOf("result.customerId") + rest.ClearAllHeaders() + rest.ClearAllParts() + rest.PartSelector = "" + + Return True End Function @@ -626,26 +643,38 @@ Public Class cDigicustAPI 'zusätzliche Informationen aus dem AVISO + Dim jarr As New Chilkat.JsonArray + + jarr.AddObjectAt(-1) + Dim json As Chilkat.JsonObject = jarr.ObjectAt(jarr.Size - 1) 'beforeNormalization(fallback -> falls Daten nicht gelesen werden können, wird ergänzt) 'afterNormalization(overwrite -> werden mit mitgeschickten Infos überschrieben). + json.UpdateString("priority", "afterNormalization") + json.UpdateString("documentStatus", "finished") - Dim jsonArray As New Chilkat.JsonArray() + If sendung.consignee_name <> "" Then json.UpdateString("annotatedAggregated.consignee.name.input", sendung.consignee_name) + If sendung.consignee_address <> "" Then json.UpdateString("annotatedAggregated.consignee.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, "")) + If sendung.consignee_eori <> "" Then json.UpdateString("annotatedAggregated.consignee.EORI.input", sendung.consignee_eori) - Dim json As New Chilkat.JsonObject - If sendung.licencePlate <> "" Then - json.UpdateString("truckLicensePlate", sendung.licencePlate) + If sendung.licencePlate <> "" AndAlso sendung.lkwCountryId <> "" Then + json.UpdateString("annotatedAggregated.meansOfTransportation[0].type", "Inland") + json.UpdateString("annotatedAggregated.meansOfTransportation[0].value", "Road") + json.UpdateString("annotatedAggregated.meansOfTransportation[0].licensePlate", sendung.licencePlate) + json.UpdateString("annotatedAggregated.meansOfTransportation[0].countryCode", sendung.lkwCountryId) End If - If sendung.lkwCountryId <> "" Then - json.UpdateString("truckNationality", sendung.lkwCountryId) - End If + 'json.UpdateString("annotatedAggregated.consignee.email.input", "") + 'json.UpdateString("annotatedAggregated.consignee.contactPerson.input", "Herr Berger") + 'json.UpdateString("annotatedAggregated.consignee.VAT.input", "") rest.PartSelector = counter rest.AddHeader("Content-Disposition", "form-data; name=""documents""") - rest.SetMultipartBodyString("[{""priority"":""afterNormalization"",""annotatedAggregated"":{" & json.Emit & "}}]") + rest.SetMultipartBodyString(jarr.Emit) + + counter += 1 End Function