From 37fc5ad3ad4dd8281e6741355aeebb692a07bac5 Mon Sep 17 00:00:00 2001 From: Andreas Luxbauer Date: Thu, 24 Apr 2025 17:06:16 +0200 Subject: [PATCH] Telotec API --- TELOTEK_Worker_lib/TELOTEC_Worker_lib.vbproj | 9 +- TELOTEK_Worker_lib/cTelokec.vb | 135 +++++++++++++++++++ UID/usrctlProcedures.Designer.vb | 122 ++++++++++++++--- UID/usrctlProcedures.resx | 6 - UID/usrctlProcedures.vb | 58 ++++++++ 5 files changed, 305 insertions(+), 25 deletions(-) diff --git a/TELOTEK_Worker_lib/TELOTEC_Worker_lib.vbproj b/TELOTEK_Worker_lib/TELOTEC_Worker_lib.vbproj index 4bc99f6..e583185 100644 --- a/TELOTEK_Worker_lib/TELOTEC_Worker_lib.vbproj +++ b/TELOTEK_Worker_lib/TELOTEC_Worker_lib.vbproj @@ -53,9 +53,6 @@ - - ..\VERAG_PROG_ALLGEMEIN\bin\Debug\VERAG_PROG_ALLGEMEIN.dll - @@ -113,5 +110,11 @@ Designer + + + {a3b497bd-842c-4a2b-b398-ed1976849df1} + VERAG_PROG_ALLGEMEIN + + \ No newline at end of file diff --git a/TELOTEK_Worker_lib/cTelokec.vb b/TELOTEK_Worker_lib/cTelokec.vb index fcdf331..31bb75b 100644 --- a/TELOTEK_Worker_lib/cTelokec.vb +++ b/TELOTEK_Worker_lib/cTelokec.vb @@ -1244,6 +1244,139 @@ Public Class cTelotec_Anmeldung End Function + + Public Shared Function ConvertTAMessageToTelotec(msg As VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) As cTelotec_Anmeldung + Dim telotec As New cTelotec_Anmeldung() + + With msg + If .declarationContent IsNot Nothing Then + Dim decl = .declarationContent + + telotec.telanm_ART = "TA" + telotec.telanm_BezugsNr = .lrn + telotec.telanm_CRN = .mrn + telotec.MsgType = .msgType + telotec.Refs_LRN = .lrn + telotec.Refs_CRN = .mrn + + telotec.Mandant_ID = decl.mandant_ID + telotec.Referenz_ID = decl.interfaceReferenceId + telotec.dec_CreatePersonalID = decl.erstellPersonalID + telotec.dec_CreateDate = decl.erstellDatum + telotec.dec_Template_ID = decl.template_ID + telotec.dec_TotNet = decl.totNet + telotec.dec_TotNetSplit_IND = decl.totNetSplit_IND + telotec.dec_FillPackList_IND = decl.fillPackList_IND + telotec.dec_Memo = decl.memo + + telotec.Hea_DecTy = decl.declarationType + telotec.Hea_Simp = decl.reducedDatasetIndicator + telotec.Hea_DecDT = decl.declarationAcceptanceDate + telotec.Hea_WoffD = decl.writeOffDate + telotec.Hea_AccDT = decl.declarationAcceptanceDate + telotec.Hea_ProArrDT = decl.presentationOfTheGoodsDateAndTime + telotec.Hea_PlaDepDT = decl.presentationOfTheGoodsDateAndTime + telotec.Hea_TotGross = decl.grossMass + ' telotec.Hea_PayMet = decl.methodOfPayment int erw + telotec.Hea_SecInd = decl.security + telotec.Hea_DestLNG = decl.countryOfDestination + telotec.Hea_DepLNG = decl.countryOfDispatch + telotec.Transp_InMo = decl.inlandModeOfTransport + telotec.Transp_BordMo = decl.modeOfTransportAtTheBorder + telotec.Transp_ContInd = decl.containerIndicator + telotec.Transp_DepIdnt = SafeFirst(decl.departureTransportMeans, Function(dt) dt.identificationNumber) + telotec.Transp_DepNat = SafeFirst(decl.departureTransportMeans, Function(dt) dt.nationality) + + ' Consignor/Consignee + telotec.ConorTra_Na = SafeGetName(decl.consignor) + 'telotec.ConorTra_Strt = decl.consignor.streetAndNumber + 'telotec.ConorTra_Pst = decl.consignor?.postcode + 'telotec.ConorTra_Cty = decl.consignor?.city + 'telotec.ConorTra_Ctry = decl.consignor?.country + telotec.ConorTra_TIN = decl.consignor?.identificationNumber + + telotec.ConeeTra_Na = SafeGetName(decl.consignee) + telotec.ConeeTra_Strt = decl.consignee?.streetAndNumber + telotec.ConeeTra_Pst = decl.consignee?.postcode + telotec.ConeeTra_Cty = decl.consignee?.city + telotec.ConeeTra_Ctry = decl.consignee?.country + telotec.ConeeTra_TIN = decl.consignee?.identificationNumber + + telotec.Represent_Na = decl.representative?.contactPersonName + telotec.Represent_RIN = decl.representative?.identificationNumber + + telotec.Locs_Disp = decl.countryOfDispatch + telotec.Locs_Dest = decl.countryOfDestination + telotec.Locs_GdsLoc = decl.locationOfGoods_PlaceOfGoods + telotec.Locs_GdsLocCd = decl.locationOfGoods_CustomsOffice + + ' HouseConsignments inkl. ConsignmentItems und Packaging + 'If decl.houseConsignment IsNot Nothing Then + ' telotec.HouseConsignments = New List(Of cTelotec_Positionsdaten)() + ' For Each hc In decl.houseConsignment + ' Dim newHc As New cTelotec_HouseConsignment() + ' newHc.CountryOfDispatch = hc.countryOfDispatch + ' newHc.CountryOfDestination = hc.countryOfDestination + ' newHc.GrossMass = hc.grossMass + ' newHc.ReferenceNumberUCR = hc.referenceNumberUCR + ' newHc.MethodOfPayment = hc.methodOfPayment + + ' If hc.consignmentItem IsNot Nothing Then + ' newHc.ConsignmentItems = New List(Of cTelotec_ConsignmentItem)() + ' For Each item In hc.consignmentItem + ' Dim newItem As New cTelotec_ConsignmentItem() + ' newItem.GoodsItemNumber = item.goodsItemNumber + ' newItem.DeclarationGoodsItemNumber = item.declarationGoodsItemNumber + ' newItem.DeclarationType = item.declarationType + ' newItem.CountryOfDispatch = item.countryOfDispatch + ' newItem.CountryOfDestination = item.countryOfDestination + ' newItem.DescriptionOfGoods = item.descriptionOfGoods + ' newItem.GrossMass = item.grossMass + ' newItem.NetMass = item.netMass + ' newItem.MethodOfPayment = item.methodOfPayment + ' newItem.ReferenceNumberUCR = item.referenceNumberUCR + + ' If item.packaging IsNot Nothing Then + ' newItem.Packaging = New List(Of cTelotec_Packaging)() + ' For Each pack In item.packaging + ' Dim newPack As New cTelotec_Packaging() + ' newPack.TypeOfPackages = pack.typeOfPackages + ' newPack.NumberOfPackages = pack.numberOfPackages + ' newPack.ShippingMarks = pack.shippingMarks + ' newItem.Packaging.Add(newPack) + ' Next + ' End If + + ' newHc.ConsignmentItems.Add(newItem) + ' Next + ' End If + + ' telotec.HouseConsignments.Add(newHc) + ' Next + 'End If + End If + End With + + telotec.telanm_LetzteBearbeitung = Now + telotec.telanm_Erstellung = Now + telotec.telanm_Erstellung_SB = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID + telotec.telanm_LetzteBearbeitung_SB = VERAG_PROG_ALLGEMEIN.cAllgemein.USRID + telotec.ComIndicator = True + telotec.initData() + + Return telotec + End Function + + Private Shared Function SafeFirst(Of T, R)(list As List(Of T), selector As Func(Of T, R)) As R + If list Is Nothing OrElse list.Count = 0 Then Return Nothing + Return selector(list(0)) + End Function + + Private Shared Function SafeGetName(party As Object) As String + If party Is Nothing Then Return Nothing + Return If(party?.consignorName, party?.consigneeName, "") + End Function + End Class @@ -1971,5 +2104,7 @@ Public Class cTelotec_PositionsdatenDokumente Return "" End Function + + End Class diff --git a/UID/usrctlProcedures.Designer.vb b/UID/usrctlProcedures.Designer.vb index 92b5866..591b232 100644 --- a/UID/usrctlProcedures.Designer.vb +++ b/UID/usrctlProcedures.Designer.vb @@ -24,6 +24,8 @@ Partial Class usrctlProcedures Private Sub InitializeComponent() Me.TabControl1 = New System.Windows.Forms.TabControl() Me.TabPage3 = New System.Windows.Forms.TabPage() + Me.Label16 = New System.Windows.Forms.Label() + Me.txtHMRCApplName = New System.Windows.Forms.TextBox() Me.Button44 = New System.Windows.Forms.Button() Me.CheckBox6 = New System.Windows.Forms.CheckBox() Me.TextBox15 = New System.Windows.Forms.TextBox() @@ -76,6 +78,12 @@ Partial Class usrctlProcedures Me.Label1 = New System.Windows.Forms.Label() Me.Button1 = New System.Windows.Forms.Button() Me.tbxLog = New System.Windows.Forms.TextBox() + Me.TabPage4 = New System.Windows.Forms.TabPage() + Me.Button46 = New System.Windows.Forms.Button() + Me.tctModalTEstLRN = New System.Windows.Forms.TextBox() + Me.Button45 = New System.Windows.Forms.Button() + Me.TabPage5 = New System.Windows.Forms.TabPage() + Me.Button47 = New System.Windows.Forms.Button() Me.Button18 = New System.Windows.Forms.Button() Me.TextBox1 = New System.Windows.Forms.TextBox() Me.lblAnzahl = New System.Windows.Forms.Label() @@ -129,8 +137,7 @@ Partial Class usrctlProcedures Me.Button43 = New System.Windows.Forms.Button() Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.DataGridViewTextBoxColumn2 = New System.Windows.Forms.DataGridViewTextBoxColumn() - Me.txtHMRCApplName = New System.Windows.Forms.TextBox() - Me.Label16 = New System.Windows.Forms.Label() + Me.Button48 = New System.Windows.Forms.Button() Me.TabControl1.SuspendLayout() Me.TabPage3.SuspendLayout() Me.TabPage1.SuspendLayout() @@ -138,6 +145,8 @@ Partial Class usrctlProcedures Me.GroupBox1.SuspendLayout() CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit() Me.TabPage2.SuspendLayout() + Me.TabPage4.SuspendLayout() + Me.TabPage5.SuspendLayout() Me.SuspendLayout() ' 'TabControl1 @@ -145,6 +154,8 @@ Partial Class usrctlProcedures Me.TabControl1.Controls.Add(Me.TabPage3) Me.TabControl1.Controls.Add(Me.TabPage1) Me.TabControl1.Controls.Add(Me.TabPage2) + Me.TabControl1.Controls.Add(Me.TabPage4) + Me.TabControl1.Controls.Add(Me.TabPage5) Me.TabControl1.Location = New System.Drawing.Point(7, 407) Me.TabControl1.Name = "TabControl1" Me.TabControl1.SelectedIndex = 0 @@ -177,6 +188,22 @@ Partial Class usrctlProcedures Me.TabPage3.Text = "TabPage3" Me.TabPage3.UseVisualStyleBackColor = True ' + 'Label16 + ' + Me.Label16.AutoSize = True + Me.Label16.Location = New System.Drawing.Point(434, 58) + Me.Label16.Name = "Label16" + Me.Label16.Size = New System.Drawing.Size(169, 13) + Me.Label16.TabIndex = 80 + Me.Label16.Text = "fremde HMRC Application (Name):" + ' + 'txtHMRCApplName + ' + Me.txtHMRCApplName.Location = New System.Drawing.Point(437, 71) + Me.txtHMRCApplName.Name = "txtHMRCApplName" + Me.txtHMRCApplName.Size = New System.Drawing.Size(159, 20) + Me.txtHMRCApplName.TabIndex = 79 + ' 'Button44 ' Me.Button44.Location = New System.Drawing.Point(437, 9) @@ -662,6 +689,66 @@ Partial Class usrctlProcedures Me.tbxLog.Size = New System.Drawing.Size(380, 380) Me.tbxLog.TabIndex = 4 ' + 'TabPage4 + ' + Me.TabPage4.Controls.Add(Me.Button46) + Me.TabPage4.Controls.Add(Me.tctModalTEstLRN) + Me.TabPage4.Controls.Add(Me.Button45) + Me.TabPage4.Location = New System.Drawing.Point(4, 22) + Me.TabPage4.Name = "TabPage4" + Me.TabPage4.Padding = New System.Windows.Forms.Padding(3) + Me.TabPage4.Size = New System.Drawing.Size(601, 288) + Me.TabPage4.TabIndex = 3 + Me.TabPage4.Text = "MODAL" + Me.TabPage4.UseVisualStyleBackColor = True + ' + 'Button46 + ' + Me.Button46.Location = New System.Drawing.Point(221, 42) + Me.Button46.Name = "Button46" + Me.Button46.Size = New System.Drawing.Size(145, 49) + Me.Button46.TabIndex = 67 + Me.Button46.Text = "NCTS TEST Senden" + Me.Button46.UseVisualStyleBackColor = True + ' + 'tctModalTEstLRN + ' + Me.tctModalTEstLRN.Location = New System.Drawing.Point(24, 16) + Me.tctModalTEstLRN.Name = "tctModalTEstLRN" + Me.tctModalTEstLRN.Size = New System.Drawing.Size(145, 20) + Me.tctModalTEstLRN.TabIndex = 66 + Me.tctModalTEstLRN.Text = "LRN" + ' + 'Button45 + ' + Me.Button45.Location = New System.Drawing.Point(24, 42) + Me.Button45.Name = "Button45" + Me.Button45.Size = New System.Drawing.Size(145, 49) + Me.Button45.TabIndex = 16 + Me.Button45.Text = "IMPORT TEST Senden" + Me.Button45.UseVisualStyleBackColor = True + ' + 'TabPage5 + ' + Me.TabPage5.Controls.Add(Me.Button48) + Me.TabPage5.Controls.Add(Me.Button47) + Me.TabPage5.Location = New System.Drawing.Point(4, 22) + Me.TabPage5.Name = "TabPage5" + Me.TabPage5.Padding = New System.Windows.Forms.Padding(3) + Me.TabPage5.Size = New System.Drawing.Size(601, 288) + Me.TabPage5.TabIndex = 4 + Me.TabPage5.Text = "Teleotec" + Me.TabPage5.UseVisualStyleBackColor = True + ' + 'Button47 + ' + Me.Button47.Location = New System.Drawing.Point(20, 24) + Me.Button47.Name = "Button47" + Me.Button47.Size = New System.Drawing.Size(145, 49) + Me.Button47.TabIndex = 62 + Me.Button47.Text = "getTAD" + Me.Button47.UseVisualStyleBackColor = True + ' 'Button18 ' Me.Button18.Location = New System.Drawing.Point(59, 183) @@ -1141,21 +1228,14 @@ Partial Class usrctlProcedures Me.DataGridViewTextBoxColumn2.HeaderText = "anz" Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2" ' - 'txtHMRCApplName + 'Button48 ' - Me.txtHMRCApplName.Location = New System.Drawing.Point(437, 71) - Me.txtHMRCApplName.Name = "txtHMRCApplName" - Me.txtHMRCApplName.Size = New System.Drawing.Size(159, 20) - Me.txtHMRCApplName.TabIndex = 79 - ' - 'Label16 - ' - Me.Label16.AutoSize = True - Me.Label16.Location = New System.Drawing.Point(434, 58) - Me.Label16.Name = "Label16" - Me.Label16.Size = New System.Drawing.Size(169, 13) - Me.Label16.TabIndex = 80 - Me.Label16.Text = "fremde HMRC Application (Name):" + Me.Button48.Location = New System.Drawing.Point(209, 24) + Me.Button48.Name = "Button48" + Me.Button48.Size = New System.Drawing.Size(145, 49) + Me.Button48.TabIndex = 63 + Me.Button48.Text = "getTAD File" + Me.Button48.UseVisualStyleBackColor = True ' 'usrctlProcedures ' @@ -1226,6 +1306,9 @@ Partial Class usrctlProcedures CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit() Me.TabPage2.ResumeLayout(False) Me.TabPage2.PerformLayout() + Me.TabPage4.ResumeLayout(False) + Me.TabPage4.PerformLayout() + Me.TabPage5.ResumeLayout(False) Me.ResumeLayout(False) Me.PerformLayout() @@ -1339,4 +1422,11 @@ Partial Class usrctlProcedures Friend WithEvents Button44 As Button Friend WithEvents Label16 As Label Friend WithEvents txtHMRCApplName As TextBox + Friend WithEvents TabPage4 As TabPage + Friend WithEvents tctModalTEstLRN As TextBox + Friend WithEvents Button45 As Button + Friend WithEvents Button46 As Button + Friend WithEvents TabPage5 As TabPage + Friend WithEvents Button47 As Button + Friend WithEvents Button48 As Button End Class diff --git a/UID/usrctlProcedures.resx b/UID/usrctlProcedures.resx index c9977e7..508fc32 100644 --- a/UID/usrctlProcedures.resx +++ b/UID/usrctlProcedures.resx @@ -123,10 +123,4 @@ True - - True - - - True - \ No newline at end of file diff --git a/UID/usrctlProcedures.vb b/UID/usrctlProcedures.vb index cc89296..4c0f7bc 100644 --- a/UID/usrctlProcedures.vb +++ b/UID/usrctlProcedures.vb @@ -19,6 +19,7 @@ Imports Chilkat Imports TELOTEC_Worker Imports GrapeCity Imports VERAG_PROG_ALLGEMEIN +Imports VERAG_PROG_ALLGEMEIN.cTelotecAPI 'Imports Microsoft.Office.Interop Public Class usrctlProcedures @@ -3907,6 +3908,63 @@ Public Class usrctlProcedures End If + End Sub + + Private Sub Button45_Click(sender As Object, e As EventArgs) Handles Button45.Click + VERAG_PROG_ALLGEMEIN.cModalTransIMPORT.CreateAndSendMinimalImportDeclaration(tctModalTEstLRN.Text) + End Sub + + Private Sub Button46_Click(sender As Object, e As EventArgs) Handles Button46.Click + VERAG_PROG_ALLGEMEIN.cModalTransNCTS.TestNCTSSend() + + End Sub + + Private Sub Button47_Click(sender As Object, e As EventArgs) Handles Button47.Click + Dim TELO As New VERAG_PROG_ALLGEMEIN.cTelotecAPI + + Dim messages As List(Of VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) = TELO.GetTAMessages() + + + MsgBox(messages.Count) + + For Each mmm In messages + MsgBox(mmm.lrn) + MsgBox(mmm.declarationContent.anmeldedatum) + Next + End Sub + + Private Sub Button48_Click(sender As Object, e As EventArgs) Handles Button48.Click + Dim TELO As New VERAG_PROG_ALLGEMEIN.cTelotecAPI + + Dim messages As New List(Of TAMessage)() + + Using ofd As New OpenFileDialog() + ofd.Title = "Wähle eine JSON-Datei mit TA-Nachrichten" + ofd.InitialDirectory = "\\datenarchiv\Datenarchiv\TELOTEC\ECHTSYSTEM\Nachrichtendaten_Ablage_JSON\" + ofd.Filter = "JSON-Dateien (*.json)|*.json|Alle Dateien (*.*)|*.*" + + If ofd.ShowDialog() = DialogResult.OK Then + Dim selectedPath As String = ofd.FileName + messages = TELO.ParseTAMessagesFromFile(selectedPath) + + + MsgBox(messages.Count) + + For Each mmm In messages + MsgBox(mmm.lrn) + Dim TELO_ANM = TELOTEC_Worker.cTelotec_Anmeldung.ConvertTAMessageToTelotec(mmm) + If TELO_ANM.SAVE() Then + MsgBox("SUSSSSS") + End If + + Next + + Else + Console.WriteLine("🔕 Keine Datei ausgewählt.") + End If + End Using + + End Sub