Revert "commit"

This commit is contained in:
2024-10-02 08:59:41 +00:00
parent 298156bc8d
commit a39d888c67
2987 changed files with 174 additions and 13775 deletions

View File

@@ -0,0 +1,205 @@
Public Class HEAHEA
Public Property RefNumHEA4 As String
Public Property TypOfDecHEA24 As String
Public Property CouOfDesCodHEA30 As String
Public Property PlaOfLoaCodHEA46 As String
Public Property CouOfDisCodHEA55 As String
Public Property TraModAtBorHEA76 As String
Public Property IdeOfMeaOfTraAtDHEA78 As String
Public Property IdeOfMeaOfTraAtDHEA78LNG As String
Public Property NatOfMeaOfTraAtDHEA80 As String
Public Property IdeOfMeaOfTraCroHEA85 As String
Public Property IdeOfMeaOfTraCroHEA85LNG As String
Public Property NatOfMeaOfTraCroHEA87 As String
Public Property ConIndHEA96 As String
Public Property NCTSAccDocHEA601LNG As String
Public Property TotNumOfIteHEA305 As String
Public Property TotNumOfPacHEA306 As String
Public Property TotGroMasHEA307 As String
Public Property DecDatHEA383 As String
Public Property DecPlaHEA394 As String
Public Property DecPlaHEA394LNG As String
Public Property SecHEA358 As String
Public Property CodPlUnHEA357 As String
Public Property Tanker As String
Public Property ComRefNumHEA As String
End Class
Public Class REPREP
Public Property NamREP5 As String
End Class
Public Class GUAREFREF
Public Property GuaRefNumGRNREF1 As String
Public Property OthGuaRefREF4 As String
Public Property AccCodREF6 As String
Public Property CurREF8 As String
Public Property AmoConREF7 As String
End Class
Public Class GUAGUA
Public Property GuaTypGUA1 As String
Public Property GUAREFREF As GUAREFREF
End Class
Public Class TRAPRIPC1
Public Property NamCO17 As String
Public Property StrAndNumCO122 As String
Public Property PosCodCO123 As String
Public Property CitCO124 As String
Public Property CouCO125 As String
Public Property NADLNGCO As String
Public Property TINCO159 As String
End Class
Public Class TRACONCO1
Public Property NamCO17 As String
Public Property StrAndNumCO122 As String
Public Property PosCodCO123 As String
Public Property CitCO124 As String
Public Property CouCO125 As String
Public Property NADLNGCO As String
Public Property TINCO159 As String
End Class
Public Class TRACONCE1
Public Property NamCO17 As String
Public Property StrAndNumCO122 As String
Public Property PosCodCO123 As String
Public Property CitCO124 As String
Public Property CouCO125 As String
Public Property NADLNGCO As String
Public Property TINCO159 As String
End Class
Public Class TRACONSEC029
Public Property NameTRACONSEC033 As String
Public Property StrNumTRACONSEC035 As String
Public Property PosCodTRACONSEC034 As String
Public Property CitTRACONSEC030 As String
Public Property CouCodTRACONSEC031 As String
Public Property TRACONSEC029LNG As String
Public Property TINTRACONSEC036 As String
End Class
Public Class CUSOFFDEPEPT
Public Property RefNumEPT1 As String
End Class
Public Class CUSOFFTRARNS
Public Property RefNumRNS1 As String
Public Property ArrTimTRACUS085 As String
End Class
Public Class CUSOFFDESEST
Public Property RefNumEST1 As String
End Class
Public Class PRODOCDC2
Public Property DocTypDC21 As String
Public Property DocRefDC23 As String
Public Property DocRefDCLNG As String
Public Property ComOfInfDC25 As String
Public Property ComOfInfDC25LNG As String
End Class
Public Class PREADMREFAR2
Public Property PreDocTypAR21 As String
Public Property PreDocRefAR26 As String
Public Property PreDocRefLNG As String
Public Property ComOfInfAR29 As String
Public Property ComOfInfAR29LNG As String
End Class
Public Class CONNR2
Public Property ConNumNR21 As String
End Class
Public Class PACGS2
Public Property MarNumOfPacGS21 As String
Public Property MarNumOfPacGS21LNG As String
Public Property KinOfPacGS23 As String
Public Property NumOfPacGS24 As String
End Class
Public Class TRACONCE2
Public Property NamCE27 As String
Public Property StrAndNumCE222 As String
Public Property PosCodCE223 As String
Public Property CitCE224 As String
Public Property CouCE225 As String
Public Property NADLNGGICE As String
Public Property TINCE259 As String
End Class
Public Class GOOITEGD
Public Property IteNumGDS7 As String
Public Property ComCodTarCodGDS10 As String
Public Property GooDesGDS23 As String
Public Property GooDesGDS23LNG As String
Public Property GroMasGDS46 As String
Public Property NetMasGDS48 As String
Public Property IhrBeyanNo As String
Public Property IhrBeyanTip As String
Public Property IhrBeyanParcali As String
Public Property PRODOCDC2 As PRODOCDC2()
Public Property PREADMREFAR2 As PREADMREFAR2
Public Property CONNR2 As CONNR2()
Public Property PACGS2 As PACGS2()
Public Property CouOfDesGDS59 As String
Public Property CouOfDisGDS58 As String
Public Property TRACONCO2 As String
Public Property TRACONCE2 As TRACONCE2
Public Property TRACORSECGOO021 As String
Public Property TRACONSECGOO013 As String
End Class
Public Class ITI
Public Property CouOfRouCodITI1 As String
End Class
Public Class CARTRA100
Public Property NamCARTRA121 As String
Public Property StrAndNumCARTRA254 As String
Public Property PosCodCARTRA121 As String
Public Property CitCARTRA789 As String
Public Property CouCodCARTRA587 As String
Public Property NADCARTRA121 As String
Public Property TINCARTRA254 As String
End Class
Public Class TRACORSEC037
Public Property NamTRACORSEC041 As String
Public Property StrNumTRACORSEC043 As String
Public Property PosCodTRACORSEC042 As String
Public Property CitTRACORSEC038 As String
Public Property CouCodTRACORSEC039 As String
Public Property TRACORSEC037LNG As String
Public Property TINTRACORSEC044 As String
End Class
Public Class CC015B
Public Property RefId As String
Public Property MRNNumber As String
Public Property HEAHEA As HEAHEA
Public Property REPREP As REPREP
Public Property SEAINFSLI As String
Public Property GUAGUA As GUAGUA
Public Property TRAPRIPC1 As TRAPRIPC1
Public Property TRACONCO1 As TRACONCO1
Public Property TRACONCE1 As TRACONCE1
Public Property CUSOFFDEPEPT As CUSOFFDEPEPT
Public Property CUSOFFTRARNS As CUSOFFTRARNS()
Public Property CUSOFFDESEST As CUSOFFDESEST
Public Property GOOITEGDS As GOOITEGD()
Public Property ITI As ITI()
Public Property CARTRA100 As CARTRA100
Public Property TRACORSEC037 As TRACORSEC037
Public Property TRACONSEC029 As TRACONSEC029
End Class
Public Class cATEZ_NCTS
Public Property CC015B As CC015B
End Class

View File

@@ -0,0 +1,897 @@
Imports System.Data.SqlClient
Imports System.Net
Imports System.Reflection
Imports System.ServiceModel.Configuration
Imports System.ServiceModel.Security
Imports System.Threading
Imports System.Web.Routing
Imports System.Windows.Forms
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
Imports Chilkat
Imports Newtonsoft.Json.Linq
Public Class cATEZ_NCTS_Sessions
Public Property session_Id As Integer
Public Property token As String
Public Property datetime As DateTime = Now()
Public Property refresh_token As String
Public Property token_validuntil As DateTime
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Public 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("session_Id", session_Id, , True, True))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("token", token))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("datetime", datetime))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("refresh_token", refresh_token))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("token_validuntil", token_validuntil))
Return list
End Function
Sub New()
LOAD()
End Sub
Sub New(token As String, refreshtoken As String, timestamp As DateTime)
Me.token = token
Me.refresh_token = refreshtoken
token_validuntil = timestamp
SAVE()
End Sub
Public Function SAVE(Optional errHinweis = "") As Boolean
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim sqlstr = " BEGIN TRAN " & getInsertCmd() &
" commit tran "
Dim IdTMP = session_Id
IdTMP = SQL.doSQLVarListID(IdTMP, sqlstr, "FMZOLL", , list, , errHinweis)
If session_Id <= 0 Then session_Id = IdTMP
Return session_Id > 0
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_Sessions (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Return ""
End Function
Public Sub LOAD()
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("SELECT TOP(1) * FROM tblATEZ_NCTS_Sessions where token_validuntil >= dateadd(minute,-10,getdate()) order by datetime desc ", conn)
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
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
End Class
Public Class cATEZ_NCTS_DATA
Public Property Id As Integer
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 DAKOSY_Procedure As String
Public Property status As Object
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 AvisoId As Integer
Public Property SendungsId As Integer
Public Property atezId As String
Public Property erstellerId As Integer
Public Property dakosy_ref As String
Public Property selectedDocuments As String
Public Property fehlerbeschreibung As String
Public Property json As String
Public Property sessionId As Integer
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Public 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("AvisoId", AvisoId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("SendungsId", SendungsId))
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("DAKOSY_Procedure", DAKOSY_Procedure))
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("atezId", atezId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("status", status))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("erstellung", erstellung))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("erstellerId", erstellerId))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dakosy_ref", dakosy_ref))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("selectedDocuments", selectedDocuments))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fehlerbeschreibung", fehlerbeschreibung))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sessionId", sessionId))
Return list
End Function
Sub New()
End Sub
Sub New(Id)
Me.Id = Id
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 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] SET " & str & " WHERE Id=@Id ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
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 (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
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 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
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Public Shared Function LOAD_ByBezugsNr(VERAG_LRN) As cATEZ_NCTS_DATA
Try
Dim ATEZ As New cATEZ_NCTS_DATA
ATEZ.hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("SELECT * FROM tblATEZ_NCTS WHERE VERAG_LRN=@VERAG_LRN ", conn)
cmd.Parameters.AddWithValue("@VERAG_LRN", VERAG_LRN)
Dim dr = cmd.ExecuteReader()
If dr.Read Then
For Each li In ATEZ.getParameterList()
Dim propInfo As PropertyInfo = ATEZ.GetType.GetProperty(li.Scalarvariable)
If dr.Item(li.Text) Is DBNull.Value Then
propInfo.SetValue(ATEZ, Nothing)
Else
propInfo.SetValue(ATEZ, dr.Item(li.Text))
End If
Next
ATEZ.hasEntry = True
End If
dr.Close()
End Using
End Using
Return ATEZ
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Return Nothing
End Function
Public Function delete() As Boolean
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Dim v = SQL.doSQL("delete FROM tblATEZ_NCTS WHERE id='" & Id & "'", "FMZOLL")
End Function
End Class
Public Class cATEZ_NCTS_TransitCustomsOffice
Public Property Id As Integer
Public Property AtezNCTS_Id As Integer
Public Property TransitCustomsOffice As String
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Public hasEntry As Boolean = False
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("AtezNCTS_Id", AtezNCTS_Id))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("TransitCustomsOffice", TransitCustomsOffice))
Return list
End Function
Sub New(AtezNCTS_Id, TransitCustomsOffice)
Me.AtezNCTS_Id = AtezNCTS_Id
Me.TransitCustomsOffice = TransitCustomsOffice
SAVE()
End Sub
Sub New(Id)
Me.Id = Id
LOAD()
End Sub
Sub New()
End Sub
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_TransitCustomsOffice WITH(updlock,serializable) WHERE AtezNCTS_Id = @AtezNCTS_Id AND TransitCustomsOffice = @TransitCustomsOffice ) " &
" 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_TransitCustomsOffice] SET " & str & " WHERE AtezNCTS_Id = @AtezNCTS_Id AND TransitCustomsOffice = @TransitCustomsOffice ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
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_TransitCustomsOffice (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
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_TransitCustomsOffice 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
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Shared Sub LOAD_LIST_ByNCTS(ByRef TCO_LIST As List(Of cATEZ_NCTS_TransitCustomsOffice), tco_nctsId As Integer)
If TCO_LIST Is Nothing Then TCO_LIST = New List(Of cATEZ_NCTS_TransitCustomsOffice)
TCO_LIST.Clear()
Dim SQL As New SQL
For Each r In SQL.loadDgvBySql("SELECT id FROM tblATEZ_NCTS_TransitCustomsOffice WHERE AtezNCTS_Id=" & tco_nctsId, "FMZOLL").Rows
TCO_LIST.Add(New VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_TransitCustomsOffice(r("id")))
Next
End Sub
Public Shared Function delete(ATEZid As Integer) As Boolean
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Dim v = SQL.doSQL("delete FROM tblATEZ_NCTS_TransitCustomsOffice WHERE AtezNCTS_Id='" & ATEZid & "'", "FMZOLL")
End Function
End Class
Public Class cATEZ_NCTS_Routen
Public Property Id As Integer
Public Property AtezNCTS_Id As Integer
Public Property Route_Country As String
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Public hasEntry As Boolean = False
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("AtezNCTS_Id", AtezNCTS_Id))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Route_Country", Route_Country))
Return list
End Function
Sub New(AtezNCTS_Id, Route_Country)
Me.AtezNCTS_Id = AtezNCTS_Id
Me.Route_Country = Route_Country
SAVE()
End Sub
Sub New(Id)
Me.Id = Id
LOAD()
End Sub
Sub New()
End Sub
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_Routen 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_Routen] SET " & str & " WHERE Id=@Id ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
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_Routen (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
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_Routen 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
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Shared Sub LOAD_LIST_ByNCTS(ByRef ROUTEN_LIST As List(Of cATEZ_NCTS_Routen), routen_nctsId As Integer)
If ROUTEN_LIST Is Nothing Then ROUTEN_LIST = New List(Of cATEZ_NCTS_Routen)
ROUTEN_LIST.Clear()
Dim SQL As New SQL
For Each r In SQL.loadDgvBySql("SELECT id FROM tblATEZ_NCTS_Routen WHERE AtezNCTS_Id=" & routen_nctsId, "FMZOLL").Rows
ROUTEN_LIST.Add(New VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen(r("id")))
Next
End Sub
Public Shared Function delete(ATEZid As Integer) As Boolean
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Dim v = SQL.doSQL("delete FROM tblATEZ_NCTS_Routen WHERE AtezNCTS_Id='" & ATEZid & "'", "FMZOLL")
End Function
End Class
Public Class cATEZ_NCTS_IN
'DEV
'Shared API_STRING As String = "https://dev-tds.singlewindow.io"
'PROD
Shared API_STRING As String = "https://transcom.singlewindow.io"
Shared API As New DataTable
Shared token As String = ""
Shared refresh_token As String = ""
Public dataTable As New DataTable()
Shared jsonData As New Chilkat.JsonObject
Public Shared sessionID As Integer = -1
Shared rest As New Chilkat.Rest
Dim SQl As New SQL
Shared apiSettingsloaded As Boolean = False
Sub New(program As String)
API = SQl.loadDgvBySql("SELECT top(1) * FROM tblAPIEinstellungen WHERE api_program='" & program & "' and api_productive ='" & If(VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM, "0", "1") & "'", "ADMIN")
If API.Rows.Count = 0 Then
MsgBox("keine gültigen API-Einstellungen für " & program & " gefunden!")
Else
apiSettingsloaded = True
API_STRING = API.Rows(0).Item("api_url")
If Not IsDBNull(API.Rows(0).Item("api_debugpath")) AndAlso API.Rows(0).Item("api_debugpath") <> "" Then
Rest.VerboseLogging = True
Rest.DebugLogFilePath = API.Rows(0).Item("api_debugpath") & program & IIf(VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM, "_Test", "") & ".txt"
Else
Rest.VerboseLogging = False
End If
End If
API_STRING = API.Rows(0).Item("api_url")
End Sub
Shared Function SendRequestAuthentificationToken(ByVal myuri As String, ByVal contentType As String, ByVal method As String, ByRef Itoken As String) As String
Try
Dim session = New cATEZ_NCTS_Sessions()
If Not IsDBNull(session.token) AndAlso session.token IsNot Nothing Then
Itoken = session.token
token = Itoken
sessionID = session.session_Id
Return "200"
End If
If apiSettingsloaded = False Then Return "400"
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
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", API.Rows(0).Item("api_password"))
json.UpdateString("username", API.Rows(0).Item("api_user"))
rest.AddHeader("Content-Type", contentType)
Dim sbRequestBody As New Chilkat.StringBuilder
json.EmitSb(sbRequestBody)
'DEBUG-Mode -> no request will be sent!
'rest.DebugMode = True
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)
Itoken = jsonResp.StringOf("access_token")
token = Itoken
refresh_token = jsonResp.StringOf("refresh_token")
Dim now As DateTime = DateTime.Now()
now = now.AddSeconds(jsonResp.IntOf("expires_in"))
session = New cATEZ_NCTS_Sessions(Itoken, refresh_token, now.ToString("yyyy-MM-dd HH:mm:ss"))
sessionID = session.session_Id
Return rest.ResponseStatusCode
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, 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
jsonData.EmitSb(sbRequestBody)
Debug.WriteLine(sbRequestBody)
'DEBUG-Mode -> no request will be sent!
'rest.DebugMode = True
'rest.PercentDoneOnSend = True
rest.IdleTimeoutMs = 5000 * 31
success = rest.SendReqSb("POST", "/api/integrations/verag", sbRequestBody)
Dim responseStatusCode = rest.ReadResponseHeader()
If (responseStatusCode < 0) Then
For i = 0 To 30 'Versuche den Header 30x abzufragen (funktioniert ab und zu nicht).
responseStatusCode = rest.ReadResponseHeader()
If responseStatusCode > 0 Then Exit For
Thread.Sleep(5000)
i = i + 1
Next
If rest.ResponseStatusCode <> 200 Then
If responseStatusCode = -1 Then
Return responseStatusCode
End If
MsgBox(rest.LastErrorText)
failureDesc = responseStatusCode & "-" & rest.ResponseStatusText
Return failureDesc
End If
End If
Dim sbResponseBody As New Chilkat.StringBuilder
rest.ReadRespSb(sbResponseBody)
If (rest.LastMethodSuccess <> True) Then
Debug.WriteLine(rest.LastErrorText)
failureDesc = rest.LastErrorText
Return failureDesc
Else
If (rest.ResponseStatusCode <> 200) Then
If rest.ResponseStatusCode = 500 Then
Dim jsonResultFailure As New Chilkat.JsonObject
jsonResultFailure.LoadSb(sbResponseBody)
jsonResultFailure.Emit()
failureDesc = "ATEZ: " & jsonResultFailure.StringOf("code") & "-" & jsonResultFailure.StringOf("message")
Return failureDesc
Else
failureDesc = rest.ResponseStatusCode & "-" & rest.ResponseStatusText
Return failureDesc
End If
Else
Dim jsonResult As New Chilkat.JsonObject
success = jsonResult.LoadSb(sbResponseBody)
jsonResult.Emit()
Return jsonResult.StringOf("atezId")
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
Shared Function setJson(ncts As cATEZ_NCTS_DATA)
jsonData.Clear()
ncts.json = ""
Dim success As Boolean
success = jsonData.UpdateString("VERAG_LRN", ncts.VERAG_LRN)
success = jsonData.UpdateString("LicensePlateContainerNo", ncts.LicensePlateContainerNo)
success = jsonData.UpdateString("DAKOSY.TemplateCode", ncts.DAKOSY_TemplateCode)
success = jsonData.UpdateString("DAKOSY.IOPartner", ncts.DAKOSY_IOPartner)
success = jsonData.UpdateString("DAKOSY.Division1", ncts.DAKOSY_Division1)
success = jsonData.UpdateString("DAKOSY.Division2", ncts.DAKOSY_Division2)
success = jsonData.UpdateString("DAKOSY.Division3", ncts.DAKOSY_Division3)
success = jsonData.UpdateString("DAKOSY.Procedure", ncts.DAKOSY_Procedure)
success = jsonData.UpdateString("DepartureCustomsOffice", ncts.DepartureCustomsOffice)
success = jsonData.UpdateString("DestinationCustomsOffice", ncts.DestinationCustomsOffice)
success = jsonData.UpdateString("DatDeterminationLimit", ncts.DatDeterminationLimit)
success = jsonData.UpdateString("CoolingTemperature", ncts.CoolingTemperature)
success = jsonData.UpdateString("Carrier.Name", ncts.Carrier_Name)
success = jsonData.UpdateString("Carrier.Adress.Country", ncts.Carrier_Adress_Country)
success = jsonData.UpdateString("Carrier.Adress.Postcode", ncts.Carrier_Adress_Postcode)
success = jsonData.UpdateString("Carrier.Adress.City", ncts.Carrier_Adress_City)
success = jsonData.UpdateString("Carrier.Adress.Street", ncts.Carrier_Adress_Street)
success = jsonData.UpdateString("Guarantee.GRN", ncts.Guarantee_GRN)
Dim Route_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen)
VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen.LOAD_LIST_ByNCTS(Route_LIST, ncts.Id)
Dim i As Integer = 0
For Each route As cATEZ_NCTS_Routen In Route_LIST
success = jsonData.UpdateString("Route[" & i & "].Country", route.Route_Country)
i = i + 1
Next
Dim TCO_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_TransitCustomsOffice)
VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_TransitCustomsOffice.LOAD_LIST_ByNCTS(TCO_LIST, ncts.Id)
i = 0
For Each tco In TCO_LIST
success = jsonData.UpdateString("TransitCustomsOffices[" & i & "].TransitCustomsOffice", tco.TransitCustomsOffice)
i = i + 1
Next
Debug.WriteLine(jsonData.Emit())
Return success
End Function
Public Function setJsonPDF(ncts As cATEZ_NCTS_DATA, dgv As DataGridView)
Dim success As Boolean
Dim i As Integer = 0
For Each r As DataGridViewRow In dgv.Rows
Dim isSelected = IIf(DBNull.Value Is r.Cells("anh_selekt").Value, False, r.Cells("anh_selekt").Value)
If isSelected Then
Dim bd As New Chilkat.BinData
'Dim json1 As New Chilkat.JsonObject
success = bd.LoadFile(VERAG_PROG_ALLGEMEIN.cDATENSERVER.GET_PDFPath_BY_DocID(r.Cells("anh_docId").Value))
success = jsonData.UpdateString("Attachments.Attachment[" & i & "].FileType", r.Cells("anh_Typ").Value)
success = jsonData.UpdateString("Attachments.Attachment[" & i & "].DocumentType", IIf(r.Cells("anh_Art").Value IsNot DBNull.Value, r.Cells("anh_Art").Value, "OTHER"))
success = jsonData.UpdateString("Attachments.Attachment[" & i & "].base64BinaryStream", bd.GetEncoded("base64"))
i = i + 1
End If
Next
ncts.json &= jsonData.Emit()
Debug.WriteLine(jsonData.Emit())
Return success
End Function
End Class