Digicust, Timas, Essensbestellungen

This commit is contained in:
2023-11-13 16:07:30 +01:00
parent 530552aaa6
commit e5f1d2ef4a
5 changed files with 92 additions and 32 deletions

View File

@@ -1,16 +1,10 @@
Imports System.ComponentModel.Design
Imports System.Data.SqlClient
Imports System.Data.SqlClient
Imports System.Net
Imports System.Reflection
Imports System.ServiceModel.Security
Imports System.Threading
Imports System.Windows.Forms
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
Imports Chilkat
Imports iTextSharp.text
Imports Newtonsoft.Json.Linq
Imports Org.BouncyCastle.Bcpg
Imports VERAG_PROG_ALLGEMEIN.cCreditSafeAPI
Public Class cDigicustSessions
@@ -124,6 +118,8 @@ Public Class cDigicustSettings
Public Property valid As Boolean
Public Property companyId As Integer
Public Property description As String
Public Property type As String
Public Property companyGroup As String
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
@@ -140,6 +136,8 @@ Public Class cDigicustSettings
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("valid", valid))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("companyId", companyId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("description", description))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("companyGroup", companyGroup))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("type", Type))
Return list
End Function
@@ -209,6 +207,9 @@ Public Class cDigicustSendungen
Public Property prepaper_code As String
Public Property licencePlate As String
Public Property lkwCountryId As String
Public Property customsOfficeNr As String
Public Property settingsId As Integer
Public Property type As String
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
@@ -244,6 +245,9 @@ Public Class cDigicustSendungen
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("prepaper_code", prepaper_code))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("licencePlate", licencePlate))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("lkwCountryId", lkwCountryId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("customsOfficeNr", customsOfficeNr))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("settingsId", settingsId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("type", type))
Return list
End Function
@@ -405,7 +409,7 @@ Public Class cDigicustAPI
now = now.AddSeconds(jsonResp.IntOf("expires_in"))
session = New cDigicustSessions(_token, refresh_token, now.ToString("yyyy-MM-dd HH:mm:ss"))
Return rest.ResponseStatusCode & " " & rest.ResponseStatusText
Return rest.ResponseStatusCode
Catch ex As WebException
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
@@ -421,7 +425,8 @@ Public Class cDigicustAPI
End Function
Shared Function uploadingCase(dig As cDigicustSendungen, settings As cDigicustSettings, dgv As DataGridView, withAvisoData As Boolean) As Boolean
Shared Function uploadingCase(dig As cDigicustSendungen, settings As cDigicustSettings, dgv As DataGridView, withAvisoData As Boolean, sender As Boolean, recipient As Boolean) As Boolean
Dim rest As New Chilkat.Rest
Dim success As Boolean
@@ -491,7 +496,7 @@ Public Class cDigicustAPI
rest.SetMultipartBodyString(dig.reference)
counter += 1
If withAvisoData Then createUserinput(rest, counter, dig)
If withAvisoData Then createUserinput(rest, counter, dig, sender, recipient)
rest.PartSelector = "0"
@@ -559,6 +564,12 @@ Public Class cDigicustAPI
Dim jsonResp = New Chilkat.JsonObject()
jsonResp.Load(responseBodyStr)
If (jsonResp.LastMethodSuccess <> True) Then
MsgBox(rest.LastErrorText)
Return False
End If
Dim dateTime As New Chilkat.CkDateTime
Dim getAsLocal As Boolean = False
jsonResp.DateOf("result.createdAt", dateTime)
@@ -639,7 +650,7 @@ Public Class cDigicustAPI
End Function
Shared Function createUserinput(ByRef rest As Chilkat.Rest, ByRef counter As Integer, ByVal sendung As cDigicustSendungen)
Shared Function createUserinput(ByRef rest As Chilkat.Rest, ByRef counter As Integer, ByVal sendung As cDigicustSendungen, ByRef sender As Boolean, ByRef recipient As Boolean)
'zusätzliche Informationen aus dem AVISO
@@ -653,22 +664,59 @@ Public Class cDigicustAPI
json.UpdateString("documentStatus", "finished")
json.UpdateString("documentType", "UserInput")
If sendung.consignee_name <> "" Then json.UpdateString("annotatedAggregated.consignee.name.input", sendung.consignee_name)
If recipient Then 'im DIGICUST werden Stakeholder Buyer, Importeur, Declarant, und Consignee gesetzt!
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_name <> "" Then
json.UpdateString("annotatedAggregated.consignee.name.input", sendung.consignee_name)
json.UpdateString("annotatedAggregated.declarant.name.input", sendung.consignee_name)
json.UpdateString("annotatedAggregated.importer.name.input", sendung.consignee_name)
json.UpdateString("annotatedAggregated.buyer.name.input", sendung.consignee_name)
End If
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, ""))
json.UpdateString("annotatedAggregated.declarant.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, ""))
json.UpdateString("annotatedAggregated.importer.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, ""))
json.UpdateString("annotatedAggregated.buyer.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, ""))
End If
If sendung.consignee_eori <> "" Then
json.UpdateString("annotatedAggregated.consignee.EORI.input", sendung.consignee_eori)
json.UpdateString("annotatedAggregated.declarant.EORI.input", sendung.consignee_eori)
json.UpdateString("annotatedAggregated.importer.EORI.input", sendung.consignee_eori)
json.UpdateString("annotatedAggregated.buyer.EORI.input", sendung.consignee_eori)
End If
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", "Border")
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
'json.UpdateString("annotatedAggregated.consignee.email.input", "")
'json.UpdateString("annotatedAggregated.consignee.contactPerson.input", "Herr Berger")
'json.UpdateString("annotatedAggregated.consignee.VAT.input", "")
If sender Then 'im DIGICUST werden Stakeholder Shipper und Exporter gesetzt!
If sendung.consignor_name <> "" Then
json.UpdateString("annotatedAggregated.shipper.name.input", sendung.consignor_name)
json.UpdateString("annotatedAggregated.exporter.name.input", sendung.consignor_name)
End If
If sendung.consignor_address <> "" Then
json.UpdateString("annotatedAggregated.shipper.address.input", sendung.consignor_address & IIf(sendung.consignor_postcode <> "", " / " & sendung.consignor_postcode, "") & IIf(sendung.consignor_city_name <> "", " " & sendung.consignor_city_name, ""))
json.UpdateString("annotatedAggregated.exporter.address.input", sendung.consignor_address & IIf(sendung.consignor_postcode <> "", " / " & sendung.consignor_postcode, "") & IIf(sendung.consignor_city_name <> "", " " & sendung.consignor_city_name, ""))
End If
If sendung.consignor_eori <> "" Then
json.UpdateString("annotatedAggregated.shipper.EORI.input", sendung.consignor_eori)
json.UpdateString("annotatedAggregated.exporter.EORI.input", sendung.consignor_eori)
End If
End If
If Not (sendung.licencePlate = "" And sendung.lkwCountryId = "") Then
json.UpdateString("annotatedAggregated.meansOfTransportation[0].type", "Border")
json.UpdateString("annotatedAggregated.meansOfTransportation[0].value", "Road")
If sendung.licencePlate <> "" Then json.UpdateString("annotatedAggregated.meansOfTransportation[0].licensePlate", sendung.licencePlate)
If sendung.lkwCountryId <> "" Then json.UpdateString("annotatedAggregated.meansOfTransportation[0].countryCode", sendung.lkwCountryId)
End If
If sendung.customsOfficeNr <> "" AndAlso sendung.type <> "" Then
json.UpdateString("annotatedAggregated.customsOffices[0].value", sendung.customsOfficeNr)
json.UpdateString("annotatedAggregated.customsOffices[0].officeType", sendung.type)
End If
rest.PartSelector = counter