API Einstellungen, Überstundenauszahlung, Sammelrechnungsdruck, etc
This commit is contained in:
@@ -1,35 +1,38 @@
|
||||
Imports System.Diagnostics.Eventing.Reader
|
||||
Imports System.IO
|
||||
|
||||
Imports System.Net
|
||||
Imports System.Text
|
||||
Imports System.Threading
|
||||
Imports System.Web.UI.WebControls
|
||||
Imports System.Windows.Forms
|
||||
Imports Chilkat
|
||||
Imports iTextSharp.text.pdf
|
||||
Imports Microsoft.Office.Interop.Outlook
|
||||
Imports Newtonsoft.Json
|
||||
Imports Spire.Pdf.Lists
|
||||
Imports Spire.Pdf.OPC
|
||||
Imports VERAG_PROG_ALLGEMEIN.IDEV_Intrastat
|
||||
Imports VERAG_PROG_ALLGEMEIN.TESTJSON
|
||||
|
||||
|
||||
Public Class cCreditSafeAPI
|
||||
|
||||
'Test
|
||||
'Shared API_STRING As String = "https://connect.sandbox.creditsafe.com"
|
||||
'PROD
|
||||
Shared API_STRING As String = "https://connect.creditsafe.com"
|
||||
Shared API_STRING As String
|
||||
Shared API As New DataTable
|
||||
Shared token As String = ""
|
||||
Public dataTable As New DataTable()
|
||||
Public dataTablecs As New DataTable()
|
||||
Shared 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 ='" & IIf(VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM, "0", "1") & "'", "ADMIN")
|
||||
dataTablecs = API
|
||||
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")
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Shared Function SendRequestAuthentificationToken(myuri As String, user As CreditSafeUser, contentType As String, method As String) As String
|
||||
Shared Function SendRequestAuthentificationToken(myuri As String, contentType As String, method As String, Optional csUser As CreditSafeUser = Nothing) As String
|
||||
Try
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
|
||||
If apiSettingsloaded = False Then Return "400"
|
||||
|
||||
Dim rest As New Chilkat.Rest
|
||||
Dim success As Boolean
|
||||
|
||||
@@ -45,10 +48,15 @@ Public Class cCreditSafeAPI
|
||||
|
||||
End If
|
||||
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
json.UpdateString("username", user.username)
|
||||
json.UpdateString("password", user.password)
|
||||
If csUser IsNot Nothing Then
|
||||
json.UpdateString("username", csUser.username)
|
||||
json.UpdateString("password", csUser.password)
|
||||
Else
|
||||
json.UpdateString("username", API.Rows(0).Item("api_user"))
|
||||
json.UpdateString("password", API.Rows(0).Item("api_password"))
|
||||
End If
|
||||
|
||||
|
||||
rest.AddHeader("Content-Type", contentType)
|
||||
|
||||
@@ -176,11 +184,15 @@ Public Class cCreditSafeAPI
|
||||
End Function
|
||||
|
||||
|
||||
Shared Function authenticate(username As String, passwort As String) As String
|
||||
Shared Function authenticate(Optional username As String = "", Optional password As String = "") As String
|
||||
|
||||
Dim myUri As String = API_STRING & "/v1/authenticate"
|
||||
Dim csUser = New CreditSafeUser(username, passwort)
|
||||
Dim response = SendRequestAuthentificationToken(myUri, csUser, "application/json", "POST")
|
||||
Dim csUser
|
||||
If username <> "" AndAlso password <> "" Then
|
||||
csUser = New CreditSafeUser(username, password)
|
||||
End If
|
||||
|
||||
Dim response = SendRequestAuthentificationToken(myUri, "application/json", "POST", csUser)
|
||||
|
||||
Return response
|
||||
|
||||
@@ -506,6 +518,44 @@ Public Class cCreditSafeAPI
|
||||
|
||||
End Function
|
||||
|
||||
Public Function getSubscriptionCountries() As String
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
|
||||
If apiSettingsloaded = False Then Return "400"
|
||||
|
||||
Dim rest As New Chilkat.Rest
|
||||
Dim success As Boolean
|
||||
|
||||
rest.AddHeader("Authorization", "Bearer <YOUR_JWT_HERE>")
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
success = rest.FullRequestNoBodySb("GET", "/v1/access", sbResponseBody)
|
||||
If (success <> True) Then
|
||||
Return rest.LastErrorText
|
||||
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(sbResponseBody.GetAsString())
|
||||
Return respStatusCode & " " & sbResponseBody.GetAsString()
|
||||
End If
|
||||
|
||||
|
||||
Dim jsonResponse As New Chilkat.JsonObject
|
||||
jsonResponse.LoadSb(sbResponseBody)
|
||||
|
||||
jsonResponse.EmitCompact = False
|
||||
Debug.WriteLine(jsonResponse.Emit())
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Shared Sub setSearchParam(ByRef rest As Chilkat.Rest, ByRef company As Company)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user