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..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 @@ -606,9 +605,9 @@ Public Class cATEZ_NCTS_IN 'DEBUG-Mode -> no request will be sent! 'rest.DebugMode = True - rest.PercentDoneOnSend = True - rest.IdleTimeoutMs = 60000 - + 'rest.PercentDoneOnSend = True + rest.IdleTimeoutMs = 5000 * 16 + rest.VerboseLogging = True success = rest.SendReqSb("POST", "/api/integrations/verag", sbRequestBody) @@ -617,13 +616,17 @@ 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 If rest.ResponseStatusCode <> 200 Then + If responseStatusCode = -1 Then + Return responseStatusCode + End If MsgBox(rest.LastErrorText) - Return False + failureDesc = responseStatusCode & "-" & rest.ResponseStatusText + Return failureDesc End If End If @@ -642,7 +645,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 @@ -692,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..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,7 +491,7 @@ Public Class cDigicustAPI rest.SetMultipartBodyString(dig.reference) counter += 1 - ' createUserinput(rest, counter, dig) + createUserinput(rest, counter, dig) rest.PartSelector = "0" @@ -493,12 +499,18 @@ Public Class cDigicustAPI 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") + + + Dim responseStatusCode = rest.ReadResponseHeader() If (responseStatusCode < 0) Then For i = 0 To 15 'Versuche den Header 16x abzufragen (funktioniert ab und zu nicht). @@ -508,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 @@ -553,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 @@ -619,23 +641,40 @@ 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 + 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 json As New Chilkat.JsonObject - If sendung.licencePlate <> "" Then - json.UpdateString("truckLicensePlate", sendung.licencePlate) + 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) + + 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