Fiskalubersicht, ATEZ-API und Timas API
This commit is contained in:
@@ -0,0 +1,328 @@
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Net
|
||||
Imports System.Reflection
|
||||
Imports System.Threading
|
||||
Imports System.Web.Routing
|
||||
Imports VERAG_PROG_ALLGEMEIN.cCreditSafeAPI
|
||||
|
||||
Public Class cATEZ_NCTS_DATA
|
||||
|
||||
Public Property Id As String
|
||||
Public Property VERAG_LRN As String
|
||||
Public Property LicensePlateContainerNo As String
|
||||
Public Property DepartureCustomsOffice As String
|
||||
Public Property DestinationCustomsOffice As String
|
||||
Public Property DatDeterminationLimit As String
|
||||
Public Property CoolingTemperature As String
|
||||
Public Property DAKOSY_TemplateCode As String
|
||||
Public Property DAKOSY_IOPartner As String
|
||||
Public Property DAKOSY_Division1 As String
|
||||
Public Property DAKOSY_Division2 As String
|
||||
Public Property DAKOSY_Division3 As String
|
||||
Public Property status As Object = 0
|
||||
Property erstellung As DateTime = Now
|
||||
Public Property Route_Country As String
|
||||
Public Property Carrier_Name As String
|
||||
Public Property Carrier_Adress_Country As String
|
||||
Public Property Carrier_Adress_Postcode As String
|
||||
Public Property Carrier_Adress_City As String
|
||||
Public Property Carrier_Adress_Street As String
|
||||
Public Property Carrier_EORI As String
|
||||
Public Property Guarantee_GRN As String
|
||||
Public Property TransitCustomsOffices As cATEZ_NCTS_DATA_TransitCustomsOffice()
|
||||
Public Property Attachments As cATEZ_NCTS_DATA_Attachments
|
||||
|
||||
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
||||
|
||||
Dim hasEntry As Boolean
|
||||
|
||||
Function getParameterList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
|
||||
Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Id", Id, , True, True))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("VERAG_LRN", VERAG_LRN))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("LicensePlateContainerNo", LicensePlateContainerNo))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DepartureCustomsOffice", DepartureCustomsOffice))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DestinationCustomsOffice", DestinationCustomsOffice))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DatDeterminationLimit", DatDeterminationLimit))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("CoolingTemperature", CoolingTemperature))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DAKOSY_TemplateCode", DAKOSY_TemplateCode))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DAKOSY_IOPartner", DAKOSY_IOPartner))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DAKOSY_Division1", DAKOSY_Division1))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DAKOSY_Division2", DAKOSY_Division2))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("DAKOSY_Division3", DAKOSY_Division3))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Route_Country", Route_Country))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Carrier_Name", Carrier_Name))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Carrier_Adress_Country", Carrier_Adress_Country))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Carrier_Adress_Postcode", Carrier_Adress_Postcode))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Carrier_Adress_City", Carrier_Adress_City))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Carrier_Adress_Street", Carrier_Adress_Street))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Carrier_EORI", Carrier_EORI))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Guarantee_GRN", Guarantee_GRN))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("status", status))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("erstellung", erstellung))
|
||||
|
||||
Return list
|
||||
End Function
|
||||
|
||||
Sub New()
|
||||
|
||||
End Sub
|
||||
|
||||
Sub New(VERAG_LRN)
|
||||
Me.VERAG_LRN = VERAG_LRN
|
||||
LOAD()
|
||||
End Sub
|
||||
|
||||
Public Function UPDATE_STATUS(status) As Boolean
|
||||
Me.status = status
|
||||
Return Me.SAVE
|
||||
End Function
|
||||
|
||||
Public Function SAVE(Optional errHinweis = "") As Boolean
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
Dim sqlstr = " BEGIN TRAN IF EXISTS(SELECT * FROM tblATEZ_NCTS_DATA WITH(updlock,serializable) WHERE Id=@Id) " &
|
||||
" BEGIN " & getUpdateCmd() & " END " &
|
||||
" Else " &
|
||||
" BEGIN " & getInsertCmd() & " END " &
|
||||
" commit tran "
|
||||
|
||||
Dim IdTMP = Id
|
||||
IdTMP = SQL.doSQLVarListID(IdTMP, sqlstr, "FMZOLL", , list, , errHinweis)
|
||||
If _Id <= 0 Then Id = IdTMP
|
||||
Return Id > 0
|
||||
End Function
|
||||
|
||||
Public Function getUpdateCmd() As String
|
||||
Try
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
|
||||
Dim str As String = ""
|
||||
For Each i In list
|
||||
If Not i.isPrimaryParam Then
|
||||
str &= "[" & i.Text & "] = @" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
|
||||
End If
|
||||
Next
|
||||
str = str.Substring(0, str.Length - 1) 'wg. ','
|
||||
Return (" UPDATE [tblATEZ_NCTS_DATA] SET " & str & " WHERE Id=@Id ")
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
|
||||
End Try
|
||||
Return ""
|
||||
End Function
|
||||
|
||||
|
||||
Public Function getInsertCmd() As String
|
||||
Try
|
||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||
Dim str As String = ""
|
||||
Dim values As String = ""
|
||||
For Each i In list
|
||||
If Not i.isPrimaryParam Then
|
||||
str &= "[" & i.Text & "],"
|
||||
values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
|
||||
End If
|
||||
Next
|
||||
str = str.Substring(0, str.Length - 1) 'wg. ','
|
||||
values = values.Substring(0, values.Length - 1) 'wg. ','
|
||||
Return (" INSERT INTO tblATEZ_NCTS_DATA (" & str & ") VALUES(" & values & ") ")
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
|
||||
End Try
|
||||
Return ""
|
||||
End Function
|
||||
|
||||
|
||||
Public Sub LOAD()
|
||||
Try
|
||||
hasEntry = False
|
||||
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
||||
Using cmd As New SqlCommand("SELECT * FROM tblATEZ_NCTS_DATA WHERE Id=@Id ", conn)
|
||||
cmd.Parameters.AddWithValue("@Id", Id)
|
||||
Dim dr = cmd.ExecuteReader()
|
||||
If dr.Read Then
|
||||
For Each li In getParameterList()
|
||||
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(li.Scalarvariable)
|
||||
|
||||
If dr.Item(li.Text) Is DBNull.Value Then
|
||||
propInfo.SetValue(Me, Nothing)
|
||||
Else
|
||||
propInfo.SetValue(Me, dr.Item(li.Text))
|
||||
End If
|
||||
|
||||
Next
|
||||
hasEntry = True
|
||||
End If
|
||||
dr.Close()
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
Public Class cATEZ_NCTS_DATA_TransitCustomsOffice
|
||||
Public Property TransitCustomsOffice As String
|
||||
End Class
|
||||
|
||||
Public Class cATEZ_NCTS_DATA_Attachment
|
||||
Public Property FileType As String
|
||||
Public Property DocumentType As String
|
||||
Public Property base64BinaryStream As String
|
||||
End Class
|
||||
|
||||
Public Class cATEZ_NCTS_DATA_Attachments
|
||||
Public Property Attachment As cATEZ_NCTS_DATA_Attachment()
|
||||
End Class
|
||||
|
||||
Public Class cATEZ_NCTS_IN
|
||||
|
||||
|
||||
|
||||
'DEV
|
||||
Shared API_STRING As String = "https://dev-tds.singlewindow.io"
|
||||
Shared token As String = ""
|
||||
Public dataTable As New DataTable()
|
||||
|
||||
|
||||
Shared Function SendRequestAuthentificationToken(ByVal myuri As String, ByVal contentType As String, ByVal method As String, ByRef Itoken As String) As String
|
||||
Try
|
||||
If Itoken <> "" Then Return "token filled"
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
|
||||
Dim rest As New Chilkat.Rest
|
||||
Dim success As Boolean
|
||||
|
||||
|
||||
Dim bTls As Boolean = True
|
||||
Dim port As Integer = 443
|
||||
Dim bAutoReconnect As Boolean = True
|
||||
success = rest.Connect(API_STRING, port, bTls, bAutoReconnect)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
Return rest.LastErrorText
|
||||
|
||||
End If
|
||||
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
json.UpdateString("password", "V3r4gAtez2023!")
|
||||
json.UpdateString("username", "atez-integration@verag.ag")
|
||||
|
||||
|
||||
rest.AddHeader("Content-Type", contentType)
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
json.EmitSb(sbRequestBody)
|
||||
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
Dim ResponseStr = rest.FullRequestSb(method, myuri, sbRequestBody, sbResponseBody)
|
||||
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
Return rest.ResponseStatusCode & " " & rest.ResponseStatusText
|
||||
End If
|
||||
|
||||
Dim jsonResp = New Chilkat.JsonObject()
|
||||
jsonResp.LoadSb(sbResponseBody)
|
||||
|
||||
token = jsonResp.StringOf("access_token")
|
||||
Itoken = token
|
||||
|
||||
Return rest.ResponseStatusCode & " " & rest.ResponseStatusText
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Shared Function authenticate() As String
|
||||
|
||||
Dim myUri As String = API_STRING & "/api/tds/auth/"
|
||||
Dim response = SendRequestAuthentificationToken(myUri, "application/json", "POST", token)
|
||||
|
||||
Return response
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
Shared Function SendRequestWithAuthHeader(acceptContentType As String, json As Chilkat.JsonObject, ByRef failureDesc As String) As String
|
||||
Try
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
|
||||
Dim rest As New Chilkat.Rest
|
||||
Dim success As Boolean
|
||||
|
||||
|
||||
Dim bTls As Boolean = True
|
||||
Dim port As Integer = 443
|
||||
Dim bAutoReconnect As Boolean = True
|
||||
success = rest.Connect(API_STRING, port, bTls, bAutoReconnect)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
failureDesc = rest.LastErrorText
|
||||
Return failureDesc
|
||||
End If
|
||||
|
||||
|
||||
rest.AddHeader("Content-Type", "application/json")
|
||||
rest.AddHeader("Authorization", "Bearer " & token)
|
||||
rest.AddHeader("Accept", acceptContentType)
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
json.EmitSb(sbRequestBody)
|
||||
Debug.WriteLine(sbRequestBody)
|
||||
|
||||
'rest.DebugMode = True
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
success = rest.FullRequestSb("POST", "/api/integrations/verag", sbRequestBody, sbResponseBody)
|
||||
|
||||
'Dim bdRequest As New Chilkat.BinData
|
||||
'success = rest.GetLastDebugRequest(bdRequest)
|
||||
'Debug.WriteLine("----")
|
||||
'Debug.WriteLine(bdRequest.GetString("utf-8"))
|
||||
'Debug.WriteLine("----")
|
||||
|
||||
|
||||
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
failureDesc = rest.LastErrorText
|
||||
Return failureDesc
|
||||
|
||||
Else
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
failureDesc = rest.ResponseStatusText
|
||||
Return failureDesc
|
||||
Else
|
||||
|
||||
Dim jsonResult As New Chilkat.JsonObject
|
||||
success = jsonResult.LoadSb(sbResponseBody)
|
||||
Return jsonResult.Emit()
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user