KVI,NCTS Fremd

This commit is contained in:
2026-04-07 10:10:12 +02:00
parent 0c7e19fe4c
commit c8d81b07d8
11 changed files with 965 additions and 46 deletions

View File

@@ -345,6 +345,7 @@ Public Class cNCTS_FREMD
Property ncts_Eroeffnung As Object = Nothing
Property ncts_Ankunft As Object = Nothing
Property ncts_Erledigung As Object = Nothing
Property ncts_statusFremd As Object = Nothing
Property ncts_GUARANTEE As New List(Of cNCTS_FREMD_Guarantee)
@@ -708,6 +709,7 @@ Public Class cNCTS_FREMD
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ncts_Eroeffnung", ncts_Eroeffnung))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ncts_Ankunft", ncts_Ankunft))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ncts_Erledigung", ncts_Erledigung))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("ncts_statusFremd", ncts_statusFremd))

View File

@@ -1,4 +1,5 @@
Imports Newtonsoft.Json
Imports com.sun.tools.javac.code.Symbol
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Public Class cModalTransNCTS
@@ -154,6 +155,166 @@ Public Class cModalTransNCTS
End Class
Public Class cMT_NCTS_GET_DeclarationResponse
Public Property transaction_id As Integer?
Public Property reference As String
Public Property doc_type As String
Public Property doc_date As String
Public Property vehicle_code As String
Public Property vehicle_coun As String
Public Property trailer_code As String
Public Property trailer_coun As String
Public Property border_cross_vehicle As String
Public Property container As String
Public Property seal_info As String
Public Property security As Boolean?
Public Property tanker As Boolean?
Public Property is_aeo As Boolean?
Public Property aeo_location As String
Public Property transit_date As String
Public Property departure_custom_code As String
Public Property dispatch_country_id As String
Public Property load_place As String
Public Property goods_location As String
Public Property arrival_custom_code As String
Public Property destination_country_id As String
Public Property unload_place As String
Public Property border_custom_code As String
Public Property transit_customs_codes As String
Public Property transit_countries_codes As String
Public Property carrier_name As String
Public Property carrier_address As String
Public Property carrier_postcode As String
Public Property carrier_city As String
Public Property carrier_country_id As String
Public Property carrier_taxno As String
Public Property carrier_eori_code As String
Public Property custom_line As String
Public Property custom_staff_name As String
Public Property trans_method As String
Public Property roro_operator_code As String
Public Property guarantee_price As Decimal?
Public Property guarantee_curr As String
Public Property status As String
Public Property lrn_no As String
Public Property lrn As String
Public Property mrn As String
Public Property mrn_no As String
Public Property lrn_url As String
Public Property manifesto_price As Decimal?
Public Property manifesto_curr As String
Public Property position_no As String
Public Property remote_ref As String
Public Property notes As String
Public Property letter_grn As String
Public Property guarantor_name As String
Public Property guarantor_city As String
Public Property guarantor_taxno As String
Public Property guarantor_address As String
Public Property guarantor_postcode As String
Public Property guarantor_eori_code As String
Public Property guarantor_country_id As String
Public Property mrn_date As String
Public Property stamp_duty As String
Public Property ncts5_checker As Boolean?
Public Property released_at As String
Public Property goods_attributes As List(Of cMT_NCTS_GoodsAttribute)
Public Class cMT_NCTS_GoodsAttribute
Public Property line_no As Integer?
Public Property gtip_code As String
Public Property commodity As String
Public Property brut_wg As Decimal?
Public Property net_wg As Decimal?
Public Property invoice_amount As Decimal?
Public Property invoice_curr As String
Public Property exp_customs_type As String
Public Property exp_customs_partial As Boolean?
Public Property exp_customs_no As String
Public Property manifesto_type As String
Public Property dep_country_id As String
Public Property arv_country_id As String
Public Property sender_taxno As String
Public Property sender_name As String
Public Property sender_address As String
Public Property sender_postcode As String
Public Property sender_city As String
Public Property sender_country_id As String
Public Property sender_eori_code As String
Public Property consignee_taxno As String
Public Property consignee_name As String
Public Property consignee_address As String
Public Property consignee_postcode As String
Public Property consignee_city As String
Public Property consignee_country_id As String
Public Property consignee_eori_code As String
Public Property packs_attributes As List(Of cMT_NCTS_PackAttribute)
Public Property documents_attributes As List(Of cMT_NCTS_DocumentAttribute)
Public Property produced_documents_attributes As List(Of cMT_NCTS_ProducedDocumentAttribute)
End Class
Public Class cMT_NCTS_PackAttribute
Public Property pack_type As String
Public Property pack_count As Integer?
Public Property notes As String
End Class
Public Class cMT_NCTS_DocumentAttribute
Public Property doc_type As String
Public Property doc_no As String
Public Property pre_post As String
End Class
Public Class cMT_NCTS_ProducedDocumentAttribute
Public Property code As String
Public Property reference As String
Public Property status As String
Public Property reason As String
Public Property quantity As Decimal?
End Class
End Class
Public Class cMT_NCTS_GET_TimelineResponse
Public Property transaction_id As Integer?
Public Property reference As String
Public Property doc_type As String
Public Property doc_date As String
Public Property transit_date As String
Public Property status As String
Public Property lrn As String
Public Property mrn As String
Public Property manifesto_price As Decimal?
Public Property manifesto_curr As String
Public Property guarantee_price As Decimal?
Public Property guarantee_diff As Decimal?
Public Property guarantee_curr As String
Public Property seal_no As String
Public Property lrn_date As String
Public Property mrn_date As String
Public Property manifesto_closed_date As String
Public Property vahicle_arrived_date As String
Public Property custom_staff_name As String
Public Property custom_line As String
Public Property timelines As List(Of cMT_NCTS_GET_TimelineItem)
Public Class cMT_NCTS_GET_TimelineItem
Public Property timeline_id As String
Public Property status_date As String
Public Property status_code As String
Public Property notes As String
Public Property source As String
Public Property country_id As String
End Class
End Class
Public Class cMT_NCTS_ApiClient
Private http As New Chilkat.Http()
Private authToken As String
@@ -389,31 +550,28 @@ Public Class cModalTransNCTS
Return result
End Function
' GET Declaration by ID / MRN / LRN / Ref
Public Function GetNCTSDeclaration(identifier As String) As cMT_NCTS_DeclarationRequest
Public Function GetNCTSDeclarationByMRN(mrn As String) As cMT_NCTS_GET_DeclarationResponse
If Not cModalTransBase.Authenticate(authToken) Then
Console.WriteLine("❌ Authentifizierung fehlgeschlagen.")
Return Nothing
End If
http.SetRequestHeader("Authorization", "Bearer " & authToken)
Dim url = $"{cModalTransBase.baseUrl}/api/v1/ncts_declarations/{identifier}"
Dim url = $"{cModalTransBase.baseUrl}/api/v1/ncts_declarations/{mrn}"
Dim resp = http.QuickGetObj(url)
If resp Is Nothing Then
Console.WriteLine("❌ Keine Verbindung: " & http.LastErrorText)
Return Nothing
End If
Select Case resp.StatusCode
Case 200
Try
Dim json = JsonConvert.DeserializeObject(Of JObject)(resp.BodyStr)
Dim data = json.SelectToken("declaration_data")
Console.WriteLine("✅ NCTS-Anmeldung erfolgreich abgerufen.")
Return data.ToObject(Of cMT_NCTS_DeclarationRequest)()
Dim result = JsonConvert.DeserializeObject(Of cMT_NCTS_GET_DeclarationResponse)(resp.BodyStr)
Console.WriteLine("✅ NCTS-Anmeldung erfolgreich abgerufen (MRN).")
Return result
Catch ex As Exception
Console.WriteLine("❌ Fehler beim Parsen: " & ex.Message)
Console.WriteLine(resp.BodyStr)
End Try
Case 401
Console.WriteLine("❌ Zugriff verweigert (401)")
@@ -422,12 +580,160 @@ Public Class cModalTransNCTS
Case Else
Console.WriteLine($"❌ Fehler ({resp.StatusCode}): {resp.BodyStr}")
End Select
Return Nothing
End Function
Public Function ConvertModaltransToNCTSFremd(nctsTmp As cMT_NCTS_GET_DeclarationResponse,
Optional OverrideNCTSFin As Boolean = False,
Optional PartnerSystem As String = "MODALTRANS") As VERAG_PROG_ALLGEMEIN.cNCTS_FREMD
If nctsTmp Is Nothing Then Return Nothing
If String.IsNullOrWhiteSpace(If(nctsTmp.mrn, "")) Then Return Nothing
Dim nctsFremd As VERAG_PROG_ALLGEMEIN.cNCTS_FREMD = VERAG_PROG_ALLGEMEIN.cNCTS_FREMD.LOADByMRN(nctsTmp.mrn, True)
If nctsFremd Is Nothing Then nctsFremd = New VERAG_PROG_ALLGEMEIN.cNCTS_FREMD
If Not OverrideNCTSFin Then
If If(nctsFremd.ncts_Status, 0) = 60 Then
Return nctsFremd
End If
End If
nctsFremd.ncts_Partnersystem = PartnerSystem
nctsFremd.ncts_MRN = nctsTmp.mrn
nctsFremd.ncts_ObjectName = If(If(nctsTmp.lrn, "") <> "", nctsTmp.lrn, nctsTmp.reference)
nctsFremd.ncts_Trans_Referenz = nctsTmp.reference
nctsFremd.ncts_Declarationtype = nctsTmp.doc_type
nctsFremd.ncts_TransitDeclarationType = nctsTmp.doc_type
nctsFremd.ncts_statusFremd = nctsTmp.status
nctsFremd.ncts_CustomsOfficeOfDeparture = nctsTmp.departure_custom_code
nctsFremd.ncts_CustomsOfficeOfDestinationDeclared = nctsTmp.arrival_custom_code
nctsFremd.ncts_CustomsOfficeOfExitForTransitDeclared = nctsTmp.border_custom_code
nctsFremd.ncts_CountryOfDispatch = nctsTmp.dispatch_country_id
nctsFremd.ncts_CountryOfDestination = nctsTmp.destination_country_id
nctsFremd.ncts_PlaceOfLoading_Location = nctsTmp.load_place
nctsFremd.ncts_PlaceOfUnLoading_Location = nctsTmp.unload_place
nctsFremd.ncts_LocationOfGoods_AdditionalIdentifier = nctsTmp.goods_location
' nctsFremd.ncts_ModeOfTransportAtTheBorder = nctsTmp.trans_method
' nctsFremd.ncts_InlandModeOfTransport = nctsTmp.trans_method
'nctsFremd.ncts_GrossMass = nctsTmp.
'''
nctsFremd.ncts_Consignor_Name = nctsTmp.carrier_name
nctsFremd.ncts_Carrier_AdressCode = Nothing
nctsFremd.ncts_Carrier_IdentificationNumber = nctsTmp.carrier_eori_code
nctsFremd.ncts_Carrier_ContactPerson_Name = nctsTmp.custom_staff_name
nctsFremd.ncts_Carrier_ContactPerson_EMailAddress = Nothing
nctsFremd.ncts_Carrier_ContactPerson_PhoneNumber = Nothing
nctsFremd.ncts_Consignee_Name = Nothing
nctsFremd.ncts_ActiveBorderTransportMeans_1_IdentificationNumber = nctsTmp.trailer_code
nctsFremd.ncts_ActiveBorderTransportMeans_1_Nationality = nctsTmp.trailer_coun
nctsFremd.ncts_DepartureTransportMeans_1_IdentificationNumber = nctsTmp.vehicle_code
nctsFremd.ncts_DepartureTransportMeans_1_Nationality = nctsTmp.vehicle_coun
nctsFremd.ncts_ContainerIndicator = nctsTmp.container
nctsFremd.ncts_Security = nctsTmp.security
nctsFremd.ncts_NachrichtenSenderTIN = Nothing
nctsFremd.ncts_NachrichtenSenderNLNR = Nothing
nctsFremd.ncts_NachrichtenempfaengerDST = Nothing
nctsFremd.ncts_Trans_DatumZeit = If(IsDate(nctsTmp.doc_date), CDate(nctsTmp.doc_date), Now)
If IsDate(nctsTmp.transit_date) Then
nctsFremd.ncts_Eroeffnung = CDate(nctsTmp.transit_date)
'If If(nctsFremd.ncts_LimitDate, "").ToString = "" Then
' nctsFremd.ncts_LimitDate = CDate(nctsTmp.limi).AddDays(10)
'End If
ElseIf IsDate(nctsTmp.doc_date) Then
nctsFremd.ncts_Eroeffnung = CDate(nctsTmp.doc_date)
If If(nctsFremd.ncts_LimitDate, "").ToString = "" Then
nctsFremd.ncts_LimitDate = CDate(nctsTmp.doc_date).AddDays(10)
End If
End If
Dim statusNeu As Integer = 0
Select Case UCase(If(nctsTmp.status, ""))
Case "DRAFT", "SENT"
statusNeu = 10
Case "IN_USE", "MRN", "REL_TRA", "MRN_ALL", "MRN_NOTIFIED", "GUAINF", "CTR_DEC", "CTRINFDEP", "WRT_NOT", "MRN_OK", "TRUCK_RELEASED", "TRUCK_IS_READY"
statusNeu = 50
Case "ARR_ADV", "AT_ARRIVAL_POINT"
statusNeu = 53
If If(nctsFremd.ncts_Ankunft, "").ToString = "" Then
End If
Case "TRANSIT_CLOSE", "RELEASED", "COMPLETED"
statusNeu = 60
If If(nctsFremd.ncts_Ankunft, "").ToString = "" Then
End If
If If(nctsFremd.ncts_Erledigung, "").ToString = "" Then
End If
Case "CANCELLED"
statusNeu = 90
Case Else
statusNeu = If(IsNumeric(nctsFremd.ncts_Status), CInt(nctsFremd.ncts_Status), 0)
If statusNeu = 0 Then statusNeu = 50
End Select
nctsFremd.ncts_Status = statusNeu
nctsFremd.ncts_Status_KEWILL_Equivalent = statusNeu
nctsFremd.LOAD_Guarantee()
nctsFremd.ncts_GUARANTEE.Clear()
If nctsTmp.guarantee_price.HasValue AndAlso nctsTmp.guarantee_price.Value > 0 AndAlso If(nctsTmp.letter_grn, "") <> "" Then
Dim grt As New VERAG_PROG_ALLGEMEIN.cNCTS_FREMD_Guarantee
grt.nctsGRT_Type = Nothing
grt.nctsGRT_AccessCode = Nothing
grt.nctsGRT_GRN = nctsTmp.letter_grn
grt.nctsGRT_AmountToBeCoveredFremdWaehrung = nctsTmp.guarantee_price.Value
grt.nctsGRT_Currency = nctsTmp.guarantee_curr
Console.WriteLine("guarantee_curr:" & nctsTmp.guarantee_curr)
If grt.nctsGRT_AmountToBeCoveredFremdWaehrung IsNot Nothing Then
If If(grt.nctsGRT_Currency, "") <> "" AndAlso If(grt.nctsGRT_Currency, "") <> "EUR" Then
Dim betragEUR = VERAG_PROG_ALLGEMEIN.cEZB_Waehrungskurse.EXCHANGE_CURTOEUR(
grt.nctsGRT_AmountToBeCoveredFremdWaehrung,
grt.nctsGRT_Currency,
nctsFremd.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
nctsFremd.ncts_GUARANTEE.Add(grt)
End If
'Status updaten:
If UpdateNCTSFremdStatusFromTimelines(nctsFremd.ncts_MRN, nctsFremd, False) Then
nctsFremd.SAVE_ALL()
End If
Return nctsFremd
End Function
' LIST all declarations
Public Function GetNCTSDeclarations(Optional page As Integer = 1) As List(Of cMT_NCTS_DeclarationResponse)
Public Function GetNCTSDeclarations(fromDate As DateTime, Optional page As Integer = 1) As List(Of cMT_NCTS_DeclarationResponse)
Dim list As New List(Of cMT_NCTS_DeclarationResponse)()
If Not cModalTransBase.Authenticate(authToken) Then
@@ -436,38 +742,239 @@ Public Class cModalTransNCTS
End If
http.SetRequestHeader("Authorization", "Bearer " & authToken)
Dim url = $"{cModalTransBase.baseUrl}/api/v1/ncts_declarations?page={page}"
Dim resp = http.QuickGetObj(url)
Dim fromDateStr As String = fromDate.ToString("yyyy-MM-dd")
Dim url As String = cModalTransBase.baseUrl & "/api/v1/ncts_declarations?from_date=" & fromDateStr & "&page=" & page.ToString()
http.SetRequestHeader("Authorization", "Bearer " & authToken)
Dim resp As Chilkat.HttpResponse = http.QuickGetObj(url)
If resp Is Nothing Then
Console.WriteLine("❌ Keine Verbindung: " & http.LastErrorText)
Return list
End If
If resp Is Nothing Then
Console.WriteLine("❌ Keine Verbindung: " & http.LastErrorText)
Return list
End If
Select Case resp.StatusCode
Case 200
Try
Dim json = JsonConvert.DeserializeObject(Of JObject)(resp.BodyStr)
Dim data = json.SelectToken("data")
If data IsNot Nothing Then
list = data.ToObject(Of List(Of cMT_NCTS_DeclarationResponse))()
Console.WriteLine("✅ Liste der NCTS-Anmeldungen erfolgreich abgerufen.")
Dim token As JToken = JToken.Parse(resp.BodyStr)
If TypeOf token Is JArray Then
list = token.ToObject(Of List(Of cMT_NCTS_DeclarationResponse))()
ElseIf TypeOf token Is JObject Then
Dim obj As JObject = CType(token, JObject)
Dim dataToken As JToken = obj.SelectToken("data")
If dataToken IsNot Nothing AndAlso TypeOf dataToken Is JArray Then
list = dataToken.ToObject(Of List(Of cMT_NCTS_DeclarationResponse))()
Else
Console.WriteLine("⚠️ Antwort ist ein Objekt, aber kein Array unter 'data' gefunden.")
End If
Else
Console.WriteLine("⚠️ Unbekanntes JSON-Format in der Listenantwort.")
End If
Catch ex As Exception
Console.WriteLine("❌ Fehler beim Parsen der Liste: " & ex.Message)
Console.WriteLine(resp.BodyStr)
End Try
Case 401
Console.WriteLine("❌ Zugriff verweigert (401)")
Console.WriteLine("❌ Zugriff verweigert bitte Authentifizierung prüfen.")
Case Else
Console.WriteLine($"❌ Fehler ({resp.StatusCode}): {resp.BodyStr}")
Console.WriteLine("❌ Fehler (" & resp.StatusCode.ToString() & "): " & resp.BodyStr)
End Select
Return list
End Function
Public Function GetAllNCTSDeclarations(fromDate As DateTime) As List(Of cMT_NCTS_DeclarationResponse)
Dim allItems As New List(Of cMT_NCTS_DeclarationResponse)()
Dim currentPage As Integer = 1
Do
Dim pageItems As List(Of cMT_NCTS_DeclarationResponse) = GetNCTSDeclarations(fromDate, currentPage)
If pageItems Is Nothing OrElse pageItems.Count = 0 Then
Exit Do
End If
allItems.AddRange(pageItems)
Console.WriteLine("Seite " & currentPage.ToString() & ": " & pageItems.Count.ToString() & " Einträge geladen.")
currentPage += 1
Loop
Console.WriteLine("Gesamt geladen: " & allItems.Count.ToString() & " Einträge.")
Return allItems
End Function
Public Function GetNCTSDeclarationTimelinesByMRN(mrn As String) As cMT_NCTS_GET_TimelineResponse
If Not cModalTransBase.Authenticate(authToken) Then
Console.WriteLine("❌ Authentifizierung fehlgeschlagen.")
Return Nothing
End If
http.SetRequestHeader("Authorization", "Bearer " & authToken)
Dim url = $"{cModalTransBase.baseUrl}/api/v1/ncts_declarations/{mrn}/timelines"
Dim resp = http.QuickGetObj(url)
If resp Is Nothing Then
Console.WriteLine("❌ Keine Verbindung: " & http.LastErrorText)
Return Nothing
End If
Select Case resp.StatusCode
Case 200
Try
Dim result = JsonConvert.DeserializeObject(Of cMT_NCTS_GET_TimelineResponse)(resp.BodyStr)
Console.WriteLine("✅ NCTS-Timelines erfolgreich abgerufen.")
Return result
Catch ex As Exception
Console.WriteLine("❌ Fehler beim Parsen der Timeline-Antwort: " & ex.Message)
Console.WriteLine(resp.BodyStr)
End Try
Case 400
Console.WriteLine("⚠️ Ungültige Anfrage (400): " & resp.BodyStr)
Case 403
Console.WriteLine("❌ Zugriff verweigert (403): " & resp.BodyStr)
Case 404
Console.WriteLine("⚠️ Anmeldung nicht gefunden (404): " & resp.BodyStr)
Case Else
Console.WriteLine("❌ Fehler (" & resp.StatusCode.ToString() & "): " & resp.BodyStr)
End Select
Return Nothing
End Function
Public Function UpdateNCTSFremdStatusFromTimelines(mrn As String,
ByRef nctsFremd As VERAG_PROG_ALLGEMEIN.cNCTS_FREMD,
Optional OverrideNCTSFin As Boolean = False) As Boolean
Try
If String.IsNullOrWhiteSpace(mrn) Then Return False
If nctsFremd Is Nothing Then Return False
Console.WriteLine("Status Update before:" & If(nctsFremd.ncts_Status, ""))
If Not OverrideNCTSFin Then
If IsNumeric(nctsFremd.ncts_Status) AndAlso (CInt(nctsFremd.ncts_Status) = 60 Or CInt(nctsFremd.ncts_Status) = 90) Then
Return True
End If
End If
Dim tl = GetNCTSDeclarationTimelinesByMRN(mrn)
If tl Is Nothing Then Return False
nctsFremd.ncts_MRN = mrn
Dim dtMrn As DateTime?
Dim dtLrn As DateTime?
Dim dtArrived As DateTime?
Dim dtClosed As DateTime?
If IsDate(tl.mrn_date) Then dtMrn = CDate(tl.mrn_date)
If IsDate(tl.lrn_date) Then dtLrn = CDate(tl.lrn_date)
If IsDate(tl.vahicle_arrived_date) Then dtArrived = CDate(tl.vahicle_arrived_date)
If IsDate(tl.manifesto_closed_date) Then dtClosed = CDate(tl.manifesto_closed_date)
If dtMrn.HasValue Then
nctsFremd.ncts_Eroeffnung = dtMrn.Value
If If(nctsFremd.ncts_LimitDate, "").ToString() = "" Then
nctsFremd.ncts_LimitDate = dtMrn.Value.AddDays(10)
End If
ElseIf dtLrn.HasValue Then
If If(nctsFremd.ncts_Eroeffnung, "").ToString() = "" Then nctsFremd.ncts_Eroeffnung = dtLrn.Value
If If(nctsFremd.ncts_LimitDate, "").ToString() = "" Then
nctsFremd.ncts_LimitDate = dtLrn.Value.AddDays(10)
End If
End If
Dim statusNeu As Integer = If(IsNumeric(nctsFremd.ncts_Status), CInt(nctsFremd.ncts_Status), 0)
Select Case UCase(If(tl.status, ""))
Case "IN_USE", "MRN_NOTIFIED", "WRT_NOT", "GUAINF", "CTR_DEC", "CTRINFDEP", "MRN_ALL", "REL_TRA"
statusNeu = 50
If dtMrn.HasValue Then nctsFremd.ncts_Eroeffnung = dtMrn.Value
Case "ARR_ADV", "ARRIVED"
statusNeu = 53
If If(nctsFremd.ncts_Ankunft, "").ToString() = "" Then
If dtArrived.HasValue Then
nctsFremd.ncts_Ankunft = dtArrived.Value
ElseIf dtMrn.HasValue Then
nctsFremd.ncts_Ankunft = dtMrn.Value
End If
End If
Case "TRANSIT_CLOSE", "RELEASED"
statusNeu = 60
If If(nctsFremd.ncts_Ankunft, "").ToString() = "" Then
If dtArrived.HasValue Then
nctsFremd.ncts_Ankunft = dtArrived.Value
ElseIf dtMrn.HasValue Then
nctsFremd.ncts_Ankunft = dtMrn.Value
End If
End If
If If(nctsFremd.ncts_Erledigung, "").ToString() = "" Then
If dtClosed.HasValue Then
nctsFremd.ncts_Erledigung = dtClosed.Value
ElseIf dtArrived.HasValue Then
nctsFremd.ncts_Erledigung = dtArrived.Value
ElseIf dtMrn.HasValue Then
nctsFremd.ncts_Erledigung = dtMrn.Value
End If
End If
Case "CANCELLED"
statusNeu = 90
End Select
If tl.timelines IsNot Nothing Then
For Each t In tl.timelines.OrderBy(Function(x) If(IsDate(x.status_date), CDate(x.status_date), Date.MinValue))
Select Case UCase(If(t.status_code, ""))
Case "TRUCK_IS_READY", "MRN"
If If(nctsFremd.ncts_Eroeffnung, "").ToString() = "" AndAlso IsDate(t.status_date) Then
nctsFremd.ncts_Eroeffnung = CDate(t.status_date)
End If
If statusNeu < 50 Then statusNeu = 50
Case "ARR_ADV", "AT_ARRIVAL_POINT", "ARRIVED"
If If(nctsFremd.ncts_Ankunft, "").ToString() = "" AndAlso IsDate(t.status_date) Then
nctsFremd.ncts_Ankunft = CDate(t.status_date)
End If
If statusNeu < 53 Then statusNeu = 53
Case "TRANSIT_CLOSE", "RELEASED", "COMPLETED"
If If(nctsFremd.ncts_Ankunft, "").ToString() = "" AndAlso IsDate(t.status_date) Then
nctsFremd.ncts_Ankunft = CDate(t.status_date)
End If
If If(nctsFremd.ncts_Erledigung, "").ToString() = "" AndAlso IsDate(t.status_date) Then
nctsFremd.ncts_Erledigung = CDate(t.status_date)
End If
statusNeu = 60
Case "CANCELLED"
statusNeu = 90
End Select
Next
End If
If statusNeu > 0 Then
nctsFremd.ncts_Status = statusNeu
nctsFremd.ncts_Status_KEWILL_Equivalent = statusNeu
End If
Console.WriteLine("Status Update after:" & If(nctsFremd.ncts_Status, ""))
Return True
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name, VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL)
End Try
Return False
End Function
End Class
Public Shared Function ceateAndSend_NCTS_FromSENDUNG(LRN As String, SND As cSendungen) As Boolean
If SND.tblSnd_AvisoID <= 0 Then Return False
Dim AVISO As cAviso = (New cAvisoDAL).LesenAviso(SND.tblSnd_AvisoID, "")
@@ -686,4 +1193,6 @@ Public Class cModalTransNCTS
Console.WriteLine("❌ Keine Antwort erhalten.")
End If
End Sub
End Class