API Einstellungen, Überstundenauszahlung, Sammelrechnungsdruck, etc

This commit is contained in:
2024-04-17 08:50:07 +02:00
parent 928df14ded
commit 39169c98f8
14 changed files with 230 additions and 56 deletions

View File

@@ -1,6 +1,7 @@
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
@@ -610,18 +611,29 @@ Public Class cATEZ_NCTS_IN
'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
Dim SQl As 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")
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
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
@@ -631,6 +643,8 @@ Public Class cATEZ_NCTS_IN
Return "200"
End If
If apiSettingsloaded = False Then Return "400"
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
Dim rest As New Chilkat.Rest
@@ -650,8 +664,8 @@ Public Class cATEZ_NCTS_IN
Dim json As New Chilkat.JsonObject
json.UpdateString("password", "V3r4gAtez2023!")
json.UpdateString("username", "atez-integration@verag.ag")
json.UpdateString("password", API.Rows(0).Item("api_password"))
json.UpdateString("username", API.Rows(0).Item("api_user"))
rest.AddHeader("Content-Type", contentType)

View File

@@ -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)

View File

@@ -352,15 +352,30 @@ End Class
Public Class cDigicustAPI
'PROD
Shared API_STRING As String = "https://api.digicust.com"
Shared API_STRING As String
Shared token As String = ""
Shared api As New DataTable
Shared refresh_token As String = ""
Public dataTable As New DataTable()
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 ='" & IIf(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")
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 _token As String) As String
Try
Dim session = New cDigicustSessions()
If Not IsDBNull(session.token) AndAlso session.token IsNot Nothing Then
@@ -371,6 +386,8 @@ Public Class cDigicustAPI
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
If apiSettingsloaded = False Then Return "400"
Dim rest As New Chilkat.Rest
Dim success As Boolean
Dim bTls As Boolean = True
@@ -385,8 +402,9 @@ Public Class cDigicustAPI
End If
Dim json As New Chilkat.JsonObject
success = json.UpdateString("username", "edv@verag.ag")
success = json.UpdateString("password", "hbG&%RhpE6kjV@r")
success = json.UpdateString("username", api.Rows(0).Item("user"))
success = json.UpdateString("password", api.Rows(0).Item("password"))
rest.AddHeader("Content-Type", contentType)

View File

@@ -4,22 +4,35 @@ Imports System.Runtime.Remoting
Imports System.Text
Imports System.Threading
Imports System.Windows.Forms
Imports DocumentFormat.OpenXml.Wordprocessing
Imports Microsoft.Office.Interop.Outlook
Public Class cTimasAPI
Dim API_STRING = "https://zeit.verag.ag"
Public API_STRING
Dim API As New DataTable
Dim rest As New Chilkat.Rest
Dim SQL As New SQL
Dim apiSettingsloaded As Boolean = False
Sub New()
Sub New(program As String)
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
API = SQL.loadDgvBySql("SELECT top(1) * FROM tblAPIEinstellungen WHERE api_program='" & program & "' and api_productive ='" & IIf(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")
End If
End Sub
Public Function checkConnectionTImas(ByRef failureText As String) As Boolean
Try
Dim success As Boolean
If apiSettingsloaded = False Then Return False
rest.VerboseLogging = True
Dim bTls As Boolean = True
@@ -33,7 +46,7 @@ Public Class cTimasAPI
Return False
End If
success = rest.SetAuthBasic("admin", "BmWr501956")
success = rest.SetAuthBasic(API.Rows(0).Item("api_user"), API.Rows(0).Item("api_password"))
If (success <> True) Then
Debug.WriteLine("BAFailReason: " & rest.ConnectFailReason)