Merge
This commit is contained in:
@@ -5,6 +5,7 @@ Imports System.Threading
|
|||||||
Imports System.Web.Routing
|
Imports System.Web.Routing
|
||||||
Imports System.Windows.Forms
|
Imports System.Windows.Forms
|
||||||
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
|
Imports System.Windows.Forms.VisualStyles.VisualStyleElement
|
||||||
|
Imports Newtonsoft.Json.Linq
|
||||||
|
|
||||||
Public Class cATEZ_NCTS_DATA
|
Public Class cATEZ_NCTS_DATA
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ Public Class cATEZ_NCTS_DATA
|
|||||||
Public Property AvisoId As Integer
|
Public Property AvisoId As Integer
|
||||||
Public Property SendungsId As Integer
|
Public Property SendungsId As Integer
|
||||||
Public Property atezId As String
|
Public Property atezId As String
|
||||||
Public Property json As String
|
'Public Property json As String
|
||||||
Public Property dakosy_ref As String
|
Public Property dakosy_ref As String
|
||||||
Public Property selectedDocuments As String
|
Public Property selectedDocuments As String
|
||||||
Public Property fehlerbeschreibung As String
|
Public Property fehlerbeschreibung As String
|
||||||
@@ -71,7 +72,7 @@ Public Class cATEZ_NCTS_DATA
|
|||||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("atezId", atezId))
|
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("status", status))
|
||||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("erstellung", erstellung))
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("erstellung", erstellung))
|
||||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("json", json))
|
'list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("json", json))
|
||||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dakosy_ref", dakosy_ref))
|
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("selectedDocuments", selectedDocuments))
|
||||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fehlerbeschreibung", fehlerbeschreibung))
|
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fehlerbeschreibung", fehlerbeschreibung))
|
||||||
@@ -213,13 +214,17 @@ Public Class cATEZ_NCTS_DATA
|
|||||||
Return Nothing
|
Return Nothing
|
||||||
End Function
|
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
|
End Class
|
||||||
|
|
||||||
|
|
||||||
Public Class cATEZ_NCTS_TransitCustomsOffice
|
Public Class cATEZ_NCTS_TransitCustomsOffice
|
||||||
|
|
||||||
Public Property Id As Integer
|
Public Property Id As Integer
|
||||||
|
|
||||||
Public Property AtezNCTS_Id As Integer
|
Public Property AtezNCTS_Id As Integer
|
||||||
Public Property TransitCustomsOffice As String
|
Public Property TransitCustomsOffice As String
|
||||||
|
|
||||||
@@ -240,6 +245,7 @@ Public Class cATEZ_NCTS_TransitCustomsOffice
|
|||||||
Me.AtezNCTS_Id = AtezNCTS_Id
|
Me.AtezNCTS_Id = AtezNCTS_Id
|
||||||
Me.TransitCustomsOffice = TransitCustomsOffice
|
Me.TransitCustomsOffice = TransitCustomsOffice
|
||||||
SAVE()
|
SAVE()
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub New(Id)
|
Sub New(Id)
|
||||||
@@ -247,10 +253,15 @@ Public Class cATEZ_NCTS_TransitCustomsOffice
|
|||||||
LOAD()
|
LOAD()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Sub New()
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Public Function SAVE(Optional errHinweis = "") As Boolean
|
Public Function SAVE(Optional errHinweis = "") As Boolean
|
||||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
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 Id=@Id) " &
|
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 " &
|
" BEGIN " & getUpdateCmd() & " END " &
|
||||||
" Else " &
|
" Else " &
|
||||||
" BEGIN " & getInsertCmd() & " END " &
|
" BEGIN " & getInsertCmd() & " END " &
|
||||||
@@ -273,7 +284,7 @@ Public Class cATEZ_NCTS_TransitCustomsOffice
|
|||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
str = str.Substring(0, str.Length - 1) 'wg. ','
|
str = str.Substring(0, str.Length - 1) 'wg. ','
|
||||||
Return (" UPDATE [tblATEZ_NCTS_TransitCustomsOffice] SET " & str & " WHERE Id=@Id ")
|
Return (" UPDATE [tblATEZ_NCTS_TransitCustomsOffice] SET " & str & " WHERE AtezNCTS_Id = @AtezNCTS_Id AND TransitCustomsOffice = @TransitCustomsOffice ")
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||||
@@ -340,6 +351,14 @@ Public Class cATEZ_NCTS_TransitCustomsOffice
|
|||||||
Next
|
Next
|
||||||
End Sub
|
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
|
End Class
|
||||||
|
|
||||||
Public Class cATEZ_NCTS_Routen
|
Public Class cATEZ_NCTS_Routen
|
||||||
@@ -373,6 +392,10 @@ Public Class cATEZ_NCTS_Routen
|
|||||||
LOAD()
|
LOAD()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Sub New()
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
Public Function SAVE(Optional errHinweis = "") As Boolean
|
Public Function SAVE(Optional errHinweis = "") As Boolean
|
||||||
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
|
||||||
|
|
||||||
@@ -466,6 +489,12 @@ Public Class cATEZ_NCTS_Routen
|
|||||||
Next
|
Next
|
||||||
End Sub
|
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
|
End Class
|
||||||
|
|
||||||
|
|
||||||
@@ -510,6 +539,8 @@ Public Class cATEZ_NCTS_IN
|
|||||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||||
json.EmitSb(sbRequestBody)
|
json.EmitSb(sbRequestBody)
|
||||||
|
|
||||||
|
'DEBUG-Mode -> no request will be sent!
|
||||||
|
'rest.DebugMode = True
|
||||||
|
|
||||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||||
Dim ResponseStr = rest.FullRequestSb(method, myuri, sbRequestBody, sbResponseBody)
|
Dim ResponseStr = rest.FullRequestSb(method, myuri, sbRequestBody, sbResponseBody)
|
||||||
@@ -569,11 +600,15 @@ Public Class cATEZ_NCTS_IN
|
|||||||
|
|
||||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||||
jsonData.EmitSb(sbRequestBody)
|
jsonData.EmitSb(sbRequestBody)
|
||||||
'Debug.WriteLine(sbRequestBody)
|
|
||||||
|
Debug.WriteLine(sbRequestBody)
|
||||||
|
|
||||||
'DEBUG-Mode -> no request will be sent!
|
'DEBUG-Mode -> no request will be sent!
|
||||||
'rest.DebugMode = True
|
'rest.DebugMode = True
|
||||||
|
|
||||||
|
rest.PercentDoneOnSend = True
|
||||||
|
rest.IdleTimeoutMs = 30000
|
||||||
|
|
||||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||||
success = rest.FullRequestSb("POST", "/api/integrations/verag", sbRequestBody, sbResponseBody)
|
success = rest.FullRequestSb("POST", "/api/integrations/verag", sbRequestBody, sbResponseBody)
|
||||||
|
|
||||||
@@ -615,6 +650,7 @@ Public Class cATEZ_NCTS_IN
|
|||||||
|
|
||||||
Shared Function setJson(ncts As cATEZ_NCTS_DATA)
|
Shared Function setJson(ncts As cATEZ_NCTS_DATA)
|
||||||
|
|
||||||
|
jsonData.Clear()
|
||||||
|
|
||||||
Dim success As Boolean
|
Dim success As Boolean
|
||||||
success = jsonData.UpdateString("VERAG_LRN", ncts.VERAG_LRN)
|
success = jsonData.UpdateString("VERAG_LRN", ncts.VERAG_LRN)
|
||||||
@@ -636,6 +672,8 @@ Public Class cATEZ_NCTS_IN
|
|||||||
success = jsonData.UpdateString("Carrier.Adress.Street", ncts.Carrier_Adress_Street)
|
success = jsonData.UpdateString("Carrier.Adress.Street", ncts.Carrier_Adress_Street)
|
||||||
success = jsonData.UpdateString("Guarantee.GRN", ncts.Guarantee_GRN)
|
success = jsonData.UpdateString("Guarantee.GRN", ncts.Guarantee_GRN)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dim Route_LIST As New List(Of VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen)
|
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)
|
VERAG_PROG_ALLGEMEIN.cATEZ_NCTS_Routen.LOAD_LIST_ByNCTS(Route_LIST, ncts.Id)
|
||||||
|
|
||||||
@@ -656,8 +694,7 @@ Public Class cATEZ_NCTS_IN
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
Next
|
Next
|
||||||
|
|
||||||
ncts.json = jsonData.Emit()
|
Debug.WriteLine(jsonData.Emit())
|
||||||
|
|
||||||
|
|
||||||
Return success
|
Return success
|
||||||
|
|
||||||
@@ -681,7 +718,6 @@ Public Class cATEZ_NCTS_IN
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
jsonData.Emit()
|
|
||||||
|
|
||||||
Return success
|
Return success
|
||||||
|
|
||||||
|
|||||||
330
VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb
Normal file
330
VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb
Normal file
@@ -0,0 +1,330 @@
|
|||||||
|
Imports System.Data.SqlClient
|
||||||
|
Imports System.Net
|
||||||
|
Imports System.Reflection
|
||||||
|
Imports System.Threading
|
||||||
|
Imports Chilkat
|
||||||
|
Imports Newtonsoft.Json.Linq
|
||||||
|
Imports VERAG_PROG_ALLGEMEIN.cCreditSafeAPI
|
||||||
|
|
||||||
|
Public Class cDigicust
|
||||||
|
|
||||||
|
Public Property session_Id As Integer
|
||||||
|
Public Property token As String
|
||||||
|
Public Property datetime As DateTime
|
||||||
|
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)
|
||||||
|
token = Me.token
|
||||||
|
refreshtoken = Me.refresh_token
|
||||||
|
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 " & getInsertCmd() & " END " &
|
||||||
|
" 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 tblDigicust_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 tblDigicust_Sessions where token_validuntil >= 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 cDigicustAPI
|
||||||
|
|
||||||
|
'Test
|
||||||
|
'Shared API_STRING As String = "https://connect.sandbox.creditsafe.com"
|
||||||
|
'PROD
|
||||||
|
Shared API_STRING As String = "https://api.digicust.com"
|
||||||
|
Shared token As String = ""
|
||||||
|
Shared refresh_token As String = ""
|
||||||
|
Public dataTable As New DataTable()
|
||||||
|
|
||||||
|
|
||||||
|
Shared Function SendRequestAuthentificationToken(ByVal myuri As String, ByVal contentType As String, ByVal method As String) As String
|
||||||
|
|
||||||
|
Try
|
||||||
|
Dim session = New cDigicust()
|
||||||
|
|
||||||
|
If Not IsDBNull(session.token) AndAlso session.token IsNot Nothing 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
|
||||||
|
success = json.UpdateString("username", "edv@verag.ag")
|
||||||
|
success = json.UpdateString("password", "hbG&%RhpE6kjV@r")
|
||||||
|
|
||||||
|
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")
|
||||||
|
refresh_token = jsonResp.StringOf("refresh_token")
|
||||||
|
Dim now As DateTime = DateTime.Now()
|
||||||
|
now = now.AddSeconds(jsonResp.IntOf("expires_in"))
|
||||||
|
session = New cDigicust(token, refresh_token, now.ToString("yyyy-MM-dd HH:mm:ss"))
|
||||||
|
'"yyyyMMdd HH:mm:ss"
|
||||||
|
|
||||||
|
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(ByRef token As String) As String
|
||||||
|
|
||||||
|
Dim myUri As String = "/generic/api/auth/authenticate"
|
||||||
|
Dim response = SendRequestAuthentificationToken(myUri, "application/json", "POST")
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||||
|
success = rest.FullRequestSb("POST", "/api/integrations/verag", sbRequestBody, 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 = 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 Sub uploadginCase()
|
||||||
|
|
||||||
|
Dim rest As New Chilkat.Rest
|
||||||
|
Dim success As Boolean
|
||||||
|
|
||||||
|
' URL: https://api.digicust.com/upload/api/{customerId}/{projectId}/new
|
||||||
|
Dim bTls As Boolean = True
|
||||||
|
Dim port As Integer = 443
|
||||||
|
Dim bAutoReconnect As Boolean = True
|
||||||
|
success = rest.Connect("api.digicust.com", port, bTls, bAutoReconnect)
|
||||||
|
If (success <> True) Then
|
||||||
|
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
|
||||||
|
Debug.WriteLine(rest.LastErrorText)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rest.PartSelector = "1"
|
||||||
|
Dim fileStream1 As New Chilkat.Stream
|
||||||
|
fileStream1.SourceFile = " path to file1.pdf"
|
||||||
|
rest.AddHeader("Content-Disposition", "form-data; name=""files[]""; filename="" path to file1.pdf""")
|
||||||
|
rest.AddHeader("Content-Type", "application/pdf")
|
||||||
|
rest.SetMultipartBodyStream(fileStream1)
|
||||||
|
|
||||||
|
rest.PartSelector = "2"
|
||||||
|
Dim fileStream2 As New Chilkat.Stream
|
||||||
|
fileStream2.SourceFile = " path to file2.pdf"
|
||||||
|
rest.AddHeader("Content-Disposition", "form-data; name=""files[]""; filename="" path to file2.pdf""")
|
||||||
|
rest.AddHeader("Content-Type", "application/pdf")
|
||||||
|
rest.SetMultipartBodyStream(fileStream2)
|
||||||
|
|
||||||
|
rest.PartSelector = "3"
|
||||||
|
rest.AddHeader("Content-Disposition", "form-data; name=""classifications""")
|
||||||
|
rest.SetMultipartBodyString("[{""fileName"":""file1.pdf"",""documentType"":""invoice""},{""fileName"":""file2.pdf"",""documentType"":""waybill""}]")
|
||||||
|
|
||||||
|
rest.PartSelector = "4"
|
||||||
|
rest.AddHeader("Content-Disposition", "form-data; name=""executionStrategyId""")
|
||||||
|
rest.SetMultipartBodyString("{executionStrategyId}")
|
||||||
|
|
||||||
|
rest.PartSelector = "5"
|
||||||
|
rest.AddHeader("Content-Disposition", "form-data; name=""reference""")
|
||||||
|
rest.SetMultipartBodyString("{reference}")
|
||||||
|
|
||||||
|
rest.PartSelector = "6"
|
||||||
|
rest.AddHeader("Content-Disposition", "form-data; name=""documents""")
|
||||||
|
rest.SetMultipartBodyString("[{""priority"":""afterNormalization"",""annotatedAggregated"":{}}]")
|
||||||
|
|
||||||
|
|
||||||
|
rest.PartSelector = "0"
|
||||||
|
|
||||||
|
rest.AddHeader("Content-Type", "multipart/form-data")
|
||||||
|
rest.AddHeader("Authorization", "Bearer " & token)
|
||||||
|
rest.AddHeader("Expect", "100-continue")
|
||||||
|
|
||||||
|
Dim strResponseBody As String = rest.FullRequestMultipart("POST", "/upload/api/{customerId}/{projectId}/new")
|
||||||
|
If (rest.LastMethodSuccess <> True) Then
|
||||||
|
Debug.WriteLine(rest.LastErrorText)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim respStatusCode As Integer = rest.ResponseStatusCode
|
||||||
|
Debug.WriteLine("response status code = " & respStatusCode)
|
||||||
|
If (respStatusCode >= 400) Then
|
||||||
|
Debug.WriteLine("Response Status Code = " & respStatusCode)
|
||||||
|
Debug.WriteLine("Response Header:")
|
||||||
|
Debug.WriteLine(rest.ResponseHeader)
|
||||||
|
Debug.WriteLine("Response Body:")
|
||||||
|
Debug.WriteLine(strResponseBody)
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
End Class
|
||||||
@@ -367,6 +367,7 @@
|
|||||||
<Compile Include="Classes\cOffene_Posten.vb" />
|
<Compile Include="Classes\cOffene_Posten.vb" />
|
||||||
<Compile Include="Classes\cOffene_Posten_DVO.vb" />
|
<Compile Include="Classes\cOffene_Posten_DVO.vb" />
|
||||||
<Compile Include="Classes\cParkzeiten.vb" />
|
<Compile Include="Classes\cParkzeiten.vb" />
|
||||||
|
<Compile Include="Schnittstellen\Digicast\cDigicustAPI.vb" />
|
||||||
<Compile Include="Schnittstellen\Modaltrans\cOregonNCTSDeclarations.vb" />
|
<Compile Include="Schnittstellen\Modaltrans\cOregonNCTSDeclarations.vb" />
|
||||||
<Compile Include="Classes\cParameter.vb" />
|
<Compile Include="Classes\cParameter.vb" />
|
||||||
<Compile Include="Classes\cProgrammeUpdate.vb" />
|
<Compile Include="Classes\cProgrammeUpdate.vb" />
|
||||||
@@ -760,6 +761,9 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="Classes\USTV\Swagger">
|
||||||
|
<Generator>OpenApiCodeGenerator</Generator>
|
||||||
|
</None>
|
||||||
<None Include="Lizenzen\DynamsoftDotNetTwain.lic">
|
<None Include="Lizenzen\DynamsoftDotNetTwain.lic">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
@@ -1206,9 +1210,18 @@
|
|||||||
<PackageReference Include="esendex-dotnet-sdk">
|
<PackageReference Include="esendex-dotnet-sdk">
|
||||||
<Version>3.8.0</Version>
|
<Version>3.8.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="JsonSubTypes">
|
||||||
|
<Version>2.0.1</Version>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Newtonsoft.Json">
|
<PackageReference Include="Newtonsoft.Json">
|
||||||
<Version>13.0.3</Version>
|
<Version>13.0.3</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
<PackageReference Include="Polly">
|
||||||
|
<Version>7.2.4</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="RestSharp">
|
||||||
|
<Version>110.2.0</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources\easteregg.jpg" />
|
<None Include="Resources\easteregg.jpg" />
|
||||||
|
|||||||
Reference in New Issue
Block a user