Imports DigitalData.Modules.EDMI.API Imports DigitalData.Modules.Logging Public Class frmServiceConfig Private Client As Client Private Logger As Logger Private Const STATUS_CONNECTED = "Connection Established" Private Const STATUS_CONNECTING = "Trying to create connection..." Private Const STATUS_FAILED = "Connection Failed!" Private ConnectionChanged As Boolean = False Private Sub frmServiceConfig_Load(sender As Object, e As EventArgs) Handles Me.Load Logger = My.LogConfig.GetLogger() If My.SystemConfig.AppServerConfig <> String.Empty Then Dim oAddress = Client.ParseServiceAddress(My.SystemConfig.AppServerConfig) txtServiceAddress.Text = oAddress.Item1 txtServicePort.Text = oAddress.Item2 End If If My.Application.Service.Client.IsOnline Then txtStatus.Text = STATUS_CONNECTED End If txtServiceAddress.Focus() End Sub Private Sub btnOK_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOK.ItemClick Try Dim oIPAddress = txtServiceAddress.Text Dim oPort = Integer.Parse(txtServicePort.Text) Dim oEndpointURL = $"net.tcp://{oIPAddress}:{oPort}/DigitalData/Services/Main" Client = New Client(My.LogConfig, oIPAddress, oPort) txtStatus.Text = STATUS_CONNECTING Dim oResult = Client.Connect() If oResult = True Then My.SystemConfig.AppServerConfig = $"{oIPAddress}:{oPort}" My.SystemConfigManager.Save() txtStatus.Text = STATUS_CONNECTED Else txtStatus.Text = STATUS_FAILED ' TODO: Make a connection test that is as elaborate as this one :D 'Select Case oResult ' Case ClassService.ConnectionTestResult.NotFound ' lblStatus.Text = "Dienst konnte nicht gefunden werden. Bitte überprüfen sie Addresse und Port." ' Case ClassService.ConnectionTestResult.EmptyURI ' lblStatus.Text = "Bitte tragen Sie eine gültige Dienst Adresse ein." ' Case ClassService.ConnectionTestResult.Authentication ' lblStatus.Text = "Authentifizierungsfehler. Prüfen Sie, ob sich Ihr Gerät in der korrekten Domäne befindet." ' Case Else ' lblStatus.Text = "Unbekannter Fehler." 'End Select End If Catch ex As Exception Logger.Error(ex) MsgBox("Fehler beim Verbindungsaufbau", MsgBoxStyle.Critical, Text) End Try End Sub End Class