diff --git a/SDL/ZOLLSYSTEM/TELOTEC/eZOLL/EZA/usrCntlTCeZOLL_EZA_Allg.vb b/SDL/ZOLLSYSTEM/TELOTEC/eZOLL/EZA/usrCntlTCeZOLL_EZA_Allg.vb
index 521ac540..56df0570 100644
--- a/SDL/ZOLLSYSTEM/TELOTEC/eZOLL/EZA/usrCntlTCeZOLL_EZA_Allg.vb
+++ b/SDL/ZOLLSYSTEM/TELOTEC/eZOLL/EZA/usrCntlTCeZOLL_EZA_Allg.vb
@@ -445,19 +445,65 @@ Public Class usrCntlTCeZOLL_EZA_Allg
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MyDatagridview1.Columns("clmnTnrNf").Visible = True
- For Each row As DataGridViewRow In MyDatagridview1.Rows
- If row.Cells("clmnTarifnummer").Value <> "" Then
- Dim tnr = VERAG_PROG_ALLGEMEIN.cATEZ_Tariff.GetTariffInfo_SingleOrEmpty(row.Cells("clmnTarifnummer").Value)
- If tnr <> "" Then
- row.Cells("clmnTarifnummer").Value = tnr
- Else
+ 'Zuerste alle Tarifnummern für die Abfrage laden
+ Dim comm As New List(Of String)
+ For Each row As DataGridViewRow In MyDatagridview1.Rows
+ comm.Add(row.Cells("clmnTarifnummer").Value)
+ Next
+
+ 'Abfragen
+ Dim tnr = VERAG_PROG_ALLGEMEIN.cATEZ_Tariff.GetTariffInfo(comm, "TR")
+
+
+ If tnr IsNot Nothing Then
+ 'Jetzt jede Zeile durchlaufen und das Ergebnis eintragen
+ For Each row As DataGridViewRow In MyDatagridview1.Rows
+ Dim found = False
+ Dim result = tnr.Find(Function(x) x.code = row.Cells("clmnTarifnummer").Value)
+ If result IsNot Nothing Then
+ If result.error <> "" Then
+ 'Error bei der Abfrage der TNR
+ row.Cells("clmnTnrNf").Value = result.error
+ Else
+ 'Bei einem Ergebnis -> Treffer
+ If result.mappings.Count = 1 Then
+ row.Cells("clmnTarifnummer").Value = result.mappings(0).commodity_code
+ found = True
+ Else
+ 'Wenn mehrere Optinen -> User Auswahl
+ row.Cells("clmnTnrNf").Value = String.Join(",", result.mappings.OfType(Of VERAG_PROG_ALLGEMEIN.cATEZ_Tariff.cATEZ_TariffItem_Mapping)() _
+ .Where(Function(x) x.commodity_code IsNot Nothing AndAlso x.commodity_code <> "") _
+ .Select(Function(x) x.commodity_code))
+
+ found = True
+ End If
+ End If
+ End If
+
+ 'Nicht gefudnen -> entsprechend zurückgegebn
+ If Not found Then
row.Cells("clmnTnrNf").Value = row.Cells("clmnTarifnummer").Value
row.Cells("clmnTarifnummer").Value = ""
End If
- End If
- lnlTnrCnt.Text = (row.Index + 1) & "/" & MyDatagridview1.RowCount
- Me.Refresh()
- Next
+ Next
+
+ End If
+
+
+ 'For Each row As DataGridViewRow In MyDatagridview1.Rows
+
+ ' If row.Cells("clmnTarifnummer").Value <> "" Then
+ ' Dim tnr = VERAG_PROG_ALLGEMEIN.cATEZ_Tariff.GetTariffInfo_SingleOrEmpty(row.Cells("clmnTarifnummer").Value)
+ ' If tnr <> "" Then
+ ' row.Cells("clmnTarifnummer").Value = tnr
+ ' Else
+ ' row.Cells("clmnTnrNf").Value = row.Cells("clmnTarifnummer").Value
+ ' row.Cells("clmnTarifnummer").Value = ""
+ ' End If
+ ' End If
+ ' lnlTnrCnt.Text = (row.Index + 1) & "/" & MyDatagridview1.RowCount
+ ' Me.Refresh()
+ 'Next
End Sub
End Class
diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/TARIFF/cATEZ_Tariff.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/TARIFF/cATEZ_Tariff.vb
index ff5e7f5f..c0d4226b 100644
--- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/TARIFF/cATEZ_Tariff.vb
+++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/TARIFF/cATEZ_Tariff.vb
@@ -1,102 +1,165 @@
Imports System.Text.RegularExpressions
+Imports System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel
Imports Newtonsoft.Json
+Imports VERAG_PROG_ALLGEMEIN.cATEZ_Tariff
Public Class cATEZ_Tariff
' Klasse zur Darstellung der Ergebnisse
- Public Class cATEZ_TariffItem
- Public Property Id As Integer
- Public Property CommodityCode As String
- Public Property Description As String
- Public Property HeadingId As Integer
- Public Property LanguageCode As String
- Public Property Type As String
+
+
+ Private Shared apiKeyProd = "9a55eba363c2796364ddc1c3b9b126a8"
+ Private Shared apiKeyTest = "305f9e546067631848548b461765a3f8"
+ Private Shared username = "verag"
+
+ Private Shared baseUrlTest As String = "https://test-tariff.singlewindow.io/api/v2-0/tariff-query/commodity-codes/mappings"
+ Private Shared baseUrlProd As String = "https://test-tariff.singlewindow.io/api/v2-0/tariff-query/commodity-codes/mappings"
+
+
+ Public Class cATEZ_TariffItem_RootItem
+ Public Property code As String
+ Public Property mappings As List(Of cATEZ_TariffItem_Mapping)
+ Public Property [error] As String
End Class
- Public Shared Function GetTariffInfo_SingleOrEmpty(searchText As String, Optional countryCode As String = "DE", Optional languageCode As String = "DE", Optional measureType As String = "import", Optional ByRef result As List(Of cATEZ_TariffItem) = Nothing) As String
- If GetTariffInfo(searchText, countryCode, languageCode, measureType, result) = "OK" Then
- If result.Count > 1 Then
- Return ""
+ Public Class cATEZ_TariffItem_Mapping
+ Public Property commodity_code As String
+ Public Property description As String
+ End Class
+
+ Public Shared Function GetTariffInfo(commodities As List(Of String), fromCountry As String, Optional toCountry As String = "EU", Optional languageCode As String = "DE") As List(Of cATEZ_TariffItem_RootItem)
+ Try
+ VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
+
+ ' Create an instance of the HTTP object
+ Dim http As New Chilkat.Http()
+ Dim baseUrl = ""
+
+
+ If True Then 'VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM Then
+ ' Set the headers
+ http.SetRequestHeader("x-api-key", apiKeyTest)
+ http.SetRequestHeader("x-username", username)
+ ' Build the base URL
+ baseUrl = baseUrlTest
Else
- Return result(0).CommodityCode
+ ' Set the headers
+ http.SetRequestHeader("x-api-key", apiKeyProd)
+ http.SetRequestHeader("x-username", username)
+ ' Build the base URL
+ baseUrl = baseUrlProd
End If
- Else
- Return ""
- End If
- End Function
- Public Shared Function GetTariffInfo(searchText As String, Optional countryCode As String = "DE", Optional languageCode As String = "DE", Optional measureType As String = "import", Optional ByRef result As List(Of cATEZ_TariffItem) = Nothing) As String
+ ' Manuell den Query-String erstellen
+ Dim queryParams As String = "?from=" & fromCountry &
+ "&to=" & toCountry &
+ "&language-code=" & languageCode &
+ "&commodites=" & String.Join(",", commodities)
- If searchText = String.Empty Then Return "Error: Empty search String"
- searchText = Regex.Replace(searchText, "[^\d]", "")
- If searchText.Length > 8 Then searchText = searchText.Substring(0, 8)
+ ' Kombiniere die Basis-URL mit den Query-Parametern
+ Dim url As String = baseUrl & queryParams
- ' Chilkat HTTP-Objekt erstellen
- Dim http As New Chilkat.Http()
+ ' Führe die GET-Anfrage aus
+ Dim response As String = http.QuickGetStr(url)
- ' API-URL und Parameter definieren
- Dim baseUrl As String = "https://tariff.singlewindow.io/api/v2-0/tariff-query/public/commodity-codes"
- 'Dim countryCode As String = "DE"
- 'Dim languageCode As String = "DE"
- 'Dim measureType As String = "import"
-
- ' Anfrage-URL mit Parametern erstellen
- Dim url As String = $"{baseUrl}?countryCode={countryCode}&searchText={searchText}&languageCode={languageCode}&measureType={measureType}"
-
- ' HTTP-GET-Anfrage senden
- Dim response As String = http.QuickGetStr(url)
-
- ' Fehlerüberprüfung
- If http.LastMethodSuccess = False Then
- Return $"Error: {http.LastErrorText}"
- End If
-
- ' Statuscode überprüfen
- Dim statusCode As Integer = http.LastStatus
- If statusCode <> 200 Then
- Return $"Error: HTTP Status {statusCode}"
- End If
-
- result = ProcessApiResponse(response)
-
- ' Antwort zurückgeben
- If result.Count = 0 Then
- Return "Error: 0 results"
- End If
- Return "OK"
- End Function
-
- Private Shared Function ProcessApiResponse(jsonResponse As String) As List(Of cATEZ_TariffItem)
- ' Deserialisiere die JSON-Antwort in eine Liste von Objekten
- Dim items As List(Of Dictionary(Of String, Object)) = JsonConvert.DeserializeObject(Of List(Of Dictionary(Of String, Object)))(jsonResponse)
-
- ' Liste für deklarierbare Elemente erstellen
- Dim declarableItems As New List(Of cATEZ_TariffItem)()
-
- ' Ergebnisse durchlaufen
- For Each item As Dictionary(Of String, Object) In items
- If item.ContainsKey("declarable") AndAlso CBool(item("declarable")) = True Then
- Dim tariffItem As New cATEZ_TariffItem() With {
- .Id = CInt(item("id")),
- .CommodityCode = item("commodity_code").ToString(),
- .Description = item("description").ToString(),
- .HeadingId = CInt(item("heading_id")),
- .LanguageCode = item("language_code").ToString(),
- .Type = item("type").ToString()
- }
- declarableItems.Add(tariffItem)
+ ' Prüfe auf Fehler
+ If http.LastMethodSuccess = False Then
+ Throw New Exception("HTTP Request failed: " & http.LastErrorText)
End If
- Next
- Return declarableItems
+
+ ' Return the response
+ Return ConvertJsonToClass(response.ToString)
+
+ Catch ex As Exception
+ VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
+
+ End Try
+ Return Nothing
End Function
- Sub Example()
- ' Beispielaufruf der Funktion
- Dim searchText As String = "6207220000"
- Dim result As String = GetTariffInfo(searchText)
+ Private Shared Function ConvertJsonToClass(response As String) As List(Of cATEZ_TariffItem_RootItem)
+ Try
+ ' Deserialisiere den JSON-String in eine Liste von RootItem-Objekten
+ Dim result As List(Of cATEZ_TariffItem_RootItem) = JsonConvert.DeserializeObject(Of List(Of cATEZ_TariffItem_RootItem))(response)
+ Return result
+ Catch ex As Exception
+ VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
+ Throw New Exception("Fehler bei der JSON-Konvertierung: " & ex.Message)
+ End Try
+ End Function
- ' Ergebnis ausgeben
- Console.WriteLine(result)
- End Sub
+ 'Private Shared Function ProcessApiResponse(jsonResponse As String) As List(Of CommodityMappingData)
+
+ ' Try
+ ' Dim result As List(Of RootItem) = JsonConvert.DeserializeObject(Of List(Of RootItem))(response)
+ ' Dim response As List(Of RootItem) = GetCommodityMappings(apiKey, username, fromCountry, toCountry, languageCode, commodities)
+
+ ' ' Verarbeite und zeige die Antwort an
+ ' For Each item In response
+ ' Console.WriteLine("Code: " & item.code)
+
+ ' If item.mappings IsNot Nothing Then
+ ' For Each mapping In item.mappings
+ ' Console.WriteLine(" Commodity Code: " & mapping.commodity_code)
+ ' Console.WriteLine(" Description: " & mapping.description)
+ ' Next
+ ' End If
+
+ ' If Not String.IsNullOrEmpty(item.error) Then
+ ' Console.WriteLine(" Error: " & item.error)
+ ' End If
+ ' Next
+
+ ' Catch ex As Exception
+ ' Console.WriteLine("Fehler: " & ex.Message)
+ ' End Try
+
+
+
+
+
+ ' Try
+ ' '' Example usage
+ ' 'Dim apiKey As String = "305f9e546067631848548b461765a3f8"
+ ' 'Dim username As String = "verag"
+ ' 'Dim fromCountry As String = "TR"
+ ' 'Dim toCountry As String = "EU"
+ ' 'Dim languageCode As String = "DE"
+ ' 'Dim commodities As New List(Of String) From {
+ ' ' "010121000000",
+ ' ' "010129100000",
+ ' ' "010229290000",
+ ' ' "abcd",
+ ' ' "efgg",
+ ' ' "0123",
+ ' ' "123456789012",
+ ' ' "3926909790"
+ ' '}
+ ' Dim items As List(Of Dictionary(Of String, Object)) = JsonConvert.DeserializeObject(Of List(Of Dictionary(Of String, Object)))(jsonResponse)
+
+ ' ' Liste für deklarierbare Elemente erstellen
+ ' Dim declarableItems As New List(Of CommodityMappingData)()
+
+ ' ' Ergebnisse durchlaufen
+ ' For Each item As Dictionary(Of String, Object) In items
+
+ ' Dim tariffItem As New CommodityMappingData() With {
+ ' .CommodityCode = item("CommodityCode").ToString(),
+ ' .MappedCode = item("MappedCode").ToString(),
+ ' .Description = item(item("Description")),
+ ' .AdditionalInfo = item("AdditionalInfo").ToString()
+ ' }
+ ' declarableItems.Add(tariffItem)
+
+ ' Next
+
+ ' Return declarableItems
+
+ ' Catch ex As Exception
+ ' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
+ ' Console.WriteLine("Error: " & ex.Message)
+ ' End Try
+ ' Return Nothing
+ 'End Function
End Class
diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/TARIFF/cATEZ_Tariff_simple.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/TARIFF/cATEZ_Tariff_simple.vb
new file mode 100644
index 00000000..d26718af
--- /dev/null
+++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/TARIFF/cATEZ_Tariff_simple.vb
@@ -0,0 +1,102 @@
+Imports System.Text.RegularExpressions
+Imports Newtonsoft.Json
+
+Public Class cATEZ_Tariff_simple
+
+ ' Klasse zur Darstellung der Ergebnisse
+ Public Class cATEZ_TariffItem
+ Public Property Id As Integer
+ Public Property CommodityCode As String
+ Public Property Description As String
+ Public Property HeadingId As Integer
+ Public Property LanguageCode As String
+ Public Property Type As String
+ End Class
+
+ Public Shared Function GetTariffInfo_SingleOrEmpty(searchText As String, Optional countryCode As String = "DE", Optional languageCode As String = "DE", Optional measureType As String = "import", Optional ByRef result As List(Of cATEZ_TariffItem) = Nothing) As String
+ If GetTariffInfo(searchText, countryCode, languageCode, measureType, result) = "OK" Then
+ If result.Count > 1 Then
+ Return ""
+ Else
+ Return result(0).CommodityCode
+ End If
+ Else
+ Return ""
+ End If
+ End Function
+
+ Public Shared Function GetTariffInfo(searchText As String, Optional countryCode As String = "DE", Optional languageCode As String = "DE", Optional measureType As String = "import", Optional ByRef result As List(Of cATEZ_TariffItem) = Nothing) As String
+
+ If searchText = String.Empty Then Return "Error: Empty search String"
+ searchText = Regex.Replace(searchText, "[^\d]", "")
+ If searchText.Length > 8 Then searchText = searchText.Substring(0, 8)
+
+ ' Chilkat HTTP-Objekt erstellen
+ Dim http As New Chilkat.Http()
+
+ ' API-URL und Parameter definieren
+ Dim baseUrl As String = "https://tariff.singlewindow.io/api/v2-0/tariff-query/public/commodity-codes"
+ 'Dim countryCode As String = "DE"
+ 'Dim languageCode As String = "DE"
+ 'Dim measureType As String = "import"
+
+ ' Anfrage-URL mit Parametern erstellen
+ Dim url As String = $"{baseUrl}?countryCode={countryCode}&searchText={searchText}&languageCode={languageCode}&measureType={measureType}"
+
+ ' HTTP-GET-Anfrage senden
+ Dim response As String = http.QuickGetStr(url)
+
+ ' Fehlerüberprüfung
+ If http.LastMethodSuccess = False Then
+ Return $"Error: {http.LastErrorText}"
+ End If
+
+ ' Statuscode überprüfen
+ Dim statusCode As Integer = http.LastStatus
+ If statusCode <> 200 Then
+ Return $"Error: HTTP Status {statusCode}"
+ End If
+
+ result = ProcessApiResponse(response)
+
+ ' Antwort zurückgeben
+ If result.Count = 0 Then
+ Return "Error: 0 results"
+ End If
+ Return "OK"
+ End Function
+
+ Private Shared Function ProcessApiResponse(jsonResponse As String) As List(Of cATEZ_TariffItem)
+ ' Deserialisiere die JSON-Antwort in eine Liste von Objekten
+ Dim items As List(Of Dictionary(Of String, Object)) = JsonConvert.DeserializeObject(Of List(Of Dictionary(Of String, Object)))(jsonResponse)
+
+ ' Liste für deklarierbare Elemente erstellen
+ Dim declarableItems As New List(Of cATEZ_TariffItem)()
+
+ ' Ergebnisse durchlaufen
+ For Each item As Dictionary(Of String, Object) In items
+ If item.ContainsKey("declarable") AndAlso CBool(item("declarable")) = True Then
+ Dim tariffItem As New cATEZ_TariffItem() With {
+ .Id = CInt(item("id")),
+ .CommodityCode = item("commodity_code").ToString(),
+ .Description = item("description").ToString(),
+ .HeadingId = CInt(item("heading_id")),
+ .LanguageCode = item("language_code").ToString(),
+ .Type = item("type").ToString()
+ }
+ declarableItems.Add(tariffItem)
+ End If
+ Next
+
+ Return declarableItems
+ End Function
+
+ Sub Example()
+ ' Beispielaufruf der Funktion
+ Dim searchText As String = "6207220000"
+ Dim result As String = GetTariffInfo(searchText)
+
+ ' Ergebnis ausgeben
+ Console.WriteLine(result)
+ End Sub
+End Class
diff --git a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj
index 642d5a50..0f633211 100644
--- a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj
+++ b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj
@@ -420,6 +420,7 @@
+