ATEZ MRN API
This commit is contained in:
@@ -217,9 +217,8 @@ Public Class cATEZ_ncts_api
|
||||
|
||||
|
||||
|
||||
Public Shared Function updateStatusByMRN(MRN As String) As Boolean
|
||||
Public Shared Function updateStatusByMRN(MRN As String, Optional OverrideNCTSFin As Boolean = False) As Boolean
|
||||
Try
|
||||
Dim result = False
|
||||
' This example assumes the Chilkat API to have been previously unlocked.
|
||||
' See Global Unlock Sample for sample code.
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
@@ -227,54 +226,197 @@ Public Class cATEZ_ncts_api
|
||||
Dim http As New Chilkat.Http
|
||||
Dim success As Boolean
|
||||
|
||||
'http.SetRequestHeader("API-KEY", "{{API-KEY}}")
|
||||
Dim queryParams As New Chilkat.JsonObject
|
||||
|
||||
http.SetRequestHeader("API-KEY", API_KEY)
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
success = http.QuickGetSb("https://transcode.singlewindow.io/api/tds/integrations/verag/declarations/messages/ie015-by-mrn/" & MRN, sbResponseBody)
|
||||
If (success = False) Then
|
||||
|
||||
Dim resp As Chilkat.HttpResponse = http.QuickRequestParams("GET", "https://transcode.singlewindow.io/api/tds/integrations/verag/declarations/" & MRN, queryParams)
|
||||
If (http.LastMethodSuccess = False) Then
|
||||
Debug.WriteLine(http.LastErrorText)
|
||||
Return False
|
||||
End If
|
||||
|
||||
|
||||
Debug.WriteLine("Response status code = " & http.LastStatus)
|
||||
Dim responseString = (sbResponseBody.GetAsString())
|
||||
|
||||
If responseString <> "" Then
|
||||
MsgBox(responseString)
|
||||
Dim tempFilePath = saveStringToTmpXML(responseString)
|
||||
Dim NCTS_P5 = VERAG_PROG_ALLGEMEIN.NCTS_P5_CC015C.CC015CType.LoadFromFile(tempFilePath)
|
||||
Debug.WriteLine(resp.StatusCode)
|
||||
Debug.WriteLine(resp.BodyStr)
|
||||
|
||||
|
||||
' result = saveXMLtoNCTS_FREMD(NCTS_P5, MRN)
|
||||
Dim handler As New cATEZ_NCTS_declarations_ApiResponseHandler()
|
||||
Dim NCTS_TMP As cATEZ_NCTS_declarations_ApiResponseHandler.cATEZ_NCTS_declarations_Content = handler.ProcessJsonResponseContent(resp.BodyStr)
|
||||
|
||||
' Beispiel: Zugriff auf die Inhalte
|
||||
If NCTS_TMP IsNot Nothing Then
|
||||
|
||||
End If
|
||||
'Console.WriteLine("GRN: " & item.Grn)
|
||||
'Console.WriteLine("Guarantee Amount: " & item.GuaranteeAmount)
|
||||
|
||||
If Not checkDY_NCTS(NCTS_TMP.Mrn) Then
|
||||
|
||||
If checkDY_NCTSStatus60(NCTS_TMP.Mrn) And OverrideNCTSFin = False Then
|
||||
|
||||
'Wenn NCTS beretis Erledigt und kein Flag fürs überschreiben, mach nix....
|
||||
Else
|
||||
Dim NCTS_FREMD = VERAG_PROG_ALLGEMEIN.cNCTS_FREMD.LOADByMRN(NCTS_TMP.Mrn, True)
|
||||
If NCTS_FREMD Is Nothing Then NCTS_FREMD = New cNCTS_FREMD
|
||||
NCTS_FREMD.ncts_Partnersystem = "ATEZ"
|
||||
NCTS_FREMD.ncts_MRN = NCTS_TMP.Mrn
|
||||
|
||||
|
||||
' Dim NCTS_FREMD = VERAG_PROG_ALLGEMEIN.cNCTS_FREMD.LOADByMRN(NCTS_TMP.Mrn, True)
|
||||
'If NCTS_FREMD Is Nothing Then NCTS_FREMD = New cNCTS_FREMD
|
||||
'NCTS_FREMD.ncts_Partnersystem = "ATEZ"
|
||||
'NCTS_FREMD.ncts_MRN = NCTS_TMP.Mrn
|
||||
NCTS_FREMD.ncts_Eroeffnung = NCTS_TMP.MrnDate
|
||||
|
||||
If NCTS_TMP.MrnDate IsNot Nothing Then
|
||||
If If(NCTS_FREMD.ncts_LimitDate, "").ToString = "" Then NCTS_FREMD.ncts_LimitDate = CDate(NCTS_TMP.MrnDate).AddDays(10)
|
||||
End If
|
||||
|
||||
|
||||
'NCTS_FREMD.ncts_Eroeffnung = NCTS_TMP.MrnDate
|
||||
'RELEASED
|
||||
'IN_USE
|
||||
If NCTS_TMP.GuaranteeUsageStatus IsNot Nothing Then
|
||||
Select Case NCTS_TMP.GuaranteeUsageStatus
|
||||
Case "IN_USE"
|
||||
NCTS_FREMD.ncts_Eroeffnung = NCTS_TMP.MrnDate
|
||||
NCTS_FREMD.ncts_Status = 50
|
||||
Case "RELEASED"
|
||||
NCTS_FREMD.ncts_Eroeffnung = NCTS_TMP.MrnDate
|
||||
If If(NCTS_FREMD.ncts_Ankunft, "").ToString = "" Then NCTS_FREMD.ncts_Ankunft = NCTS_TMP.MrnDate
|
||||
If If(NCTS_FREMD.ncts_Erledigung, "").ToString = "" Then NCTS_FREMD.ncts_Erledigung = NCTS_TMP.MrnDate
|
||||
NCTS_FREMD.ncts_Status = 60
|
||||
End Select
|
||||
End If
|
||||
|
||||
'If NCTS_TMP.MrnDate IsNot Nothing Then
|
||||
' If If(NCTS_FREMD.ncts_LimitDate, "").ToString = "" Then NCTS_FREMD.ncts_LimitDate = CDate(NCTS_TMP.MrnDate).AddDays(10)
|
||||
'End If
|
||||
'WRT_NOT
|
||||
'MRN_NOTIFIED
|
||||
'GUAINF
|
||||
'CTR_DEC
|
||||
'CTRINFDEP
|
||||
'MRN_ALL
|
||||
'REL_TRA
|
||||
'TRANSIT_CLOSE
|
||||
'ARR_ADV
|
||||
If NCTS_TMP.Status IsNot Nothing Then
|
||||
Select Case NCTS_TMP.Status
|
||||
Case "ARR_ADV"
|
||||
If If(NCTS_FREMD.ncts_Ankunft, "").ToString = "" Then NCTS_FREMD.ncts_Ankunft = NCTS_TMP.MrnDate
|
||||
NCTS_FREMD.ncts_Status = 53
|
||||
Case "TRANSIT_CLOSE"
|
||||
If If(NCTS_FREMD.ncts_Ankunft, "").ToString = "" Then NCTS_FREMD.ncts_Ankunft = NCTS_TMP.MrnDate
|
||||
If If(NCTS_FREMD.ncts_Erledigung, "").ToString = "" Then NCTS_FREMD.ncts_Erledigung = NCTS_TMP.MrnDate
|
||||
NCTS_FREMD.ncts_Status = 60
|
||||
End Select
|
||||
End If
|
||||
|
||||
NCTS_FREMD.ncts_Status_KEWILL_Equivalent = NCTS_FREMD.ncts_Status
|
||||
NCTS_FREMD.ncts_ObjectName = NCTS_TMP.Lrn
|
||||
NCTS_FREMD.ncts_ActiveBorderTransportMeans_1_IdentificationNumber = NCTS_TMP.Trailer
|
||||
|
||||
|
||||
If File.Exists(tempFilePath) Then
|
||||
File.Delete(tempFilePath)
|
||||
NCTS_FREMD.LOAD_Guarantee()
|
||||
|
||||
NCTS_FREMD.ncts_GUARANTEE.Clear()
|
||||
|
||||
|
||||
If NCTS_TMP.GuaranteeAmount > 0 AndAlso NCTS_TMP.Grn IsNot Nothing Then
|
||||
|
||||
Dim GRT = New cNCTS_FREMD_Guarantee
|
||||
GRT.nctsGRT_Type = Nothing
|
||||
|
||||
GRT.nctsGRT_AccessCode = Nothing
|
||||
GRT.nctsGRT_GRN = NCTS_TMP.Grn
|
||||
GRT.nctsGRT_AmountToBeCoveredFremdWaehrung = NCTS_TMP.GuaranteeAmount
|
||||
GRT.nctsGRT_Currency = NCTS_TMP.GuaranteeAmountCurrency
|
||||
|
||||
' MsgBox(If(GRT.nctsGRT_Currency, ""))
|
||||
'--> EUR
|
||||
If GRT.nctsGRT_AmountToBeCoveredFremdWaehrung IsNot Nothing Then
|
||||
If If(GRT.nctsGRT_Currency, "") <> "EUR" Then
|
||||
Dim betragEUR = VERAG_PROG_ALLGEMEIN.cEZB_Waehrungskurse.EXCHANGE_CURTOEUR(GRT.nctsGRT_AmountToBeCoveredFremdWaehrung, GRT.nctsGRT_Currency, NCTS_FREMD.ncts_Trans_DatumZeit.ToShortDateString)
|
||||
GRT.nctsGRT_AmountToBeCovered = If(betragEUR > 0, betragEUR, GRT.nctsGRT_AmountToBeCoveredFremdWaehrung)
|
||||
Else
|
||||
GRT.nctsGRT_AmountToBeCovered = GRT.nctsGRT_AmountToBeCoveredFremdWaehrung
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
NCTS_FREMD.ncts_GUARANTEE.Clear()
|
||||
NCTS_FREMD.ncts_GUARANTEE.Add(GRT)
|
||||
End If
|
||||
|
||||
NCTS_FREMD.SAVE_ALL()
|
||||
|
||||
Console.WriteLine("Temporäre Datei gelöscht.")
|
||||
End If
|
||||
End If
|
||||
Return result
|
||||
|
||||
|
||||
|
||||
|
||||
'Dim SS = VERAG_PROG_ALLGEMEIN.cNCTS_ATEZ_query_declaration_response.root.LoadFromFile("")
|
||||
|
||||
'For Each c In SS.properties.content
|
||||
'Next
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
|
||||
End Try
|
||||
Return False
|
||||
|
||||
'Try
|
||||
' Dim result = False
|
||||
' ' This example assumes the Chilkat API to have been previously unlocked.
|
||||
' ' See Global Unlock Sample for sample code.
|
||||
' VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
|
||||
' Dim http As New Chilkat.Http
|
||||
' Dim success As Boolean
|
||||
|
||||
' 'http.SetRequestHeader("API-KEY", "{{API-KEY}}")
|
||||
' http.SetRequestHeader("API-KEY", API_KEY)
|
||||
|
||||
' Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
' success = http.QuickGetSb("https://transcode.singlewindow.io/api/tds/integrations/verag/declarations/messages/ie015-by-mrn/" & MRN, sbResponseBody)
|
||||
' If (success = False) Then
|
||||
' Debug.WriteLine(http.LastErrorText)
|
||||
' Return False
|
||||
' End If
|
||||
|
||||
|
||||
' Debug.WriteLine("Response status code = " & http.LastStatus)
|
||||
' Dim responseString = (sbResponseBody.GetAsString())
|
||||
|
||||
' If responseString <> "" Then
|
||||
' MsgBox(responseString)
|
||||
' Dim tempFilePath = saveStringToTmpXML(responseString)
|
||||
' Dim NCTS_P5 = VERAG_PROG_ALLGEMEIN.NCTS_P5_CC015C.CC015CType.LoadFromFile(tempFilePath)
|
||||
|
||||
|
||||
' ' result = saveXMLtoNCTS_FREMD(NCTS_P5, MRN)
|
||||
|
||||
|
||||
' ' Dim NCTS_FREMD = VERAG_PROG_ALLGEMEIN.cNCTS_FREMD.LOADByMRN(NCTS_TMP.Mrn, True)
|
||||
' 'If NCTS_FREMD Is Nothing Then NCTS_FREMD = New cNCTS_FREMD
|
||||
' 'NCTS_FREMD.ncts_Partnersystem = "ATEZ"
|
||||
' 'NCTS_FREMD.ncts_MRN = NCTS_TMP.Mrn
|
||||
|
||||
|
||||
' 'NCTS_FREMD.ncts_Eroeffnung = NCTS_TMP.MrnDate
|
||||
|
||||
' 'If NCTS_TMP.MrnDate IsNot Nothing Then
|
||||
' ' If If(NCTS_FREMD.ncts_LimitDate, "").ToString = "" Then NCTS_FREMD.ncts_LimitDate = CDate(NCTS_TMP.MrnDate).AddDays(10)
|
||||
' 'End If
|
||||
|
||||
|
||||
' If File.Exists(tempFilePath) Then
|
||||
' File.Delete(tempFilePath)
|
||||
|
||||
' Console.WriteLine("Temporäre Datei gelöscht.")
|
||||
' End If
|
||||
' End If
|
||||
' Return result
|
||||
|
||||
'Catch ex As Exception
|
||||
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
'End Try
|
||||
'Return False
|
||||
End Function
|
||||
|
||||
Private Shared Function saveStringToTmpXML(xmlString) As String
|
||||
@@ -455,4 +597,14 @@ Public Class cATEZ_NCTS_declarations_ApiResponseHandler
|
||||
Throw New Exception("Error while processing JSON response: " & ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ProcessJsonResponseContent(jsonResponse As String) As cATEZ_NCTS_declarations_Content
|
||||
Try
|
||||
Dim result As cATEZ_NCTS_declarations_Content = JsonConvert.DeserializeObject(Of cATEZ_NCTS_declarations_Content)(jsonResponse)
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
' Handle error (e.g., log or rethrow)
|
||||
Throw New Exception("Error while processing JSON response: " & ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user