CreditSafe Check

This commit is contained in:
2023-03-22 12:37:00 +01:00
parent 69599f989d
commit c6b08132a3
7 changed files with 224 additions and 22 deletions

View File

@@ -1,4 +1,16 @@
Public Class frmMitarbDetails

Imports System.IO
Imports System.Net
Imports System.Net.Http
Imports System.Net.WebRequestMethods
Imports System.Security.Policy
Imports System.Text
Imports System.Windows
Imports Newtonsoft.Json
Public Class frmMitarbDetails
Private UID As New cMitarbeiter
Private berechtigungen As New List(Of cBerechtigungen)
@@ -834,4 +846,74 @@
End If
cboFirmaHaupt.Enabled = (cboFirma.Text = "ALLE")
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim myUrl As New Uri("https://connect.creditsafe.com/v1/authenticate")
lblCheckconnection.Text = ""
If txtCSUser.Text = "" Then
lblCheckconnection.Text = "User ist leer!"
Exit Sub
End If
If txtCSPW.Text = "" Then
lblCheckconnection.Text = "Passwort ist leer!"
Exit Sub
End If
Dim csUser As New CreditSafeUser(txtCSUser.Text, txtCSPW.Text)
Dim yourJSONString = JsonConvert.SerializeObject(csUser)
lblCheckconnection.Text = SendRequest(myUrl, yourJSONString, "application/json", "POST")
End Sub
Private Function SendRequest(uri As Uri, jsonString As String, contentType As String, method As String) As String
Dim response As HttpWebResponse
Dim request As WebRequest
Dim jsonDataBytes = Encoding.UTF8.GetBytes(jsonString)
Try
request = WebRequest.Create(uri)
request.ContentLength = jsonDataBytes.Length
request.ContentType = contentType
request.Method = method
Using requestStream = request.GetRequestStream
requestStream.Write(jsonDataBytes, 0, jsonDataBytes.Length)
requestStream.Close()
End Using
response = request.GetResponse
Return response.StatusDescription
Catch ex As WebException
Dim ExResponse = TryCast(ex.Response, HttpWebResponse)
Return ExResponse.StatusDescription
End Try
End Function
End Class
Public Class CreditSafeUser
Public Property username As String
Public Property password As String
Public Sub New(_username As String, _password As String)
username = _username
password = _password
End Sub
End Class