jj: add service config form

This commit is contained in:
Jonathan Jenne
2019-01-29 16:32:37 +01:00
parent 94376068d6
commit 6ede3e1be9
14 changed files with 521 additions and 40 deletions

View File

@@ -4,24 +4,66 @@ Imports System.ServiceModel
Imports EDMI_ClientSuite.NetworkService_DDEDM
Public Class ClassInit
Private Const OPEN_TIMEOUT = 10
Private Const OPEN_TIMEOUT_SECONDS = 3
Private Const MAX_MESSAGE_SIZE = 2147483647
Private Const MAX_BUFFER_SIZE = 2147483647
Private Const MAX_ARRAY_LENGTH = 2147483647
Private Const MAX_STRING_LENGTH = 2147483647
Private Const MAX_CONNECTIONS = 10000
Public Property _LogConfig As LogConfig
Public Enum ConnectionTestResult
Successful
NotFound
Unknown
End Enum
Private ReadOnly _Logger As Logger
Public Sub New()
_LogConfig = New LogConfig(PathType.AppData)
_Logger = My.LogConfig.GetLogger()
End Sub
Public Function CreateService() As ChannelFactory(Of IEDMServiceChannel)
Return CreateChannelFactory()
Public Function TestConnectionURLExists()
Return My.Settings.ICMServiceAddress <> String.Empty
End Function
Private Function CreateChannelFactory() As ChannelFactory(Of IEDMServiceChannel)
Public Async Function TestConnectionAsync(EndpointURL As String) As Task(Of ConnectionTestResult)
Return Await Task.Factory.StartNew(Function()
Try
Dim oChannelFactory = GetChannelFactory(EndpointURL)
Dim oChannel = oChannelFactory.CreateChannel()
oChannel.OperationTimeout = New TimeSpan(0, 0, OPEN_TIMEOUT_SECONDS)
oChannel.Open()
oChannel.Close()
Return ConnectionTestResult.Successful
Catch ex As EndpointNotFoundException
Return ConnectionTestResult.NotFound
Catch ex As Exception
Return ConnectionTestResult.Unknown
End Try
End Function)
End Function
Public Function GetChannelFactory() As ChannelFactory(Of IEDMServiceChannel)
Return GetChannelFactory(My.Settings.ICMServiceAddress)
End Function
Public Function GetChannelFactory(EndpointURL As String) As ChannelFactory(Of IEDMServiceChannel)
Dim oBinding = GetBinding()
Dim oEndpoint = GetEndpoint(EndpointURL)
Dim oFactory As New ChannelFactory(Of IEDMServiceChannel)(oBinding, oEndpoint)
Return oFactory
End Function
Private Function GetEndpoint(EndpointURL As String) As EndpointAddress
Dim oEndpoint = New EndpointAddress(EndpointURL)
Return oEndpoint
End Function
Private Function GetBinding() As NetTcpBinding
Dim oBinding As New NetTcpBinding()
oBinding.Security.Mode = SecurityMode.Transport
oBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows
@@ -31,10 +73,9 @@ Public Class ClassInit
oBinding.MaxConnections = MAX_CONNECTIONS
oBinding.ReaderQuotas.MaxArrayLength = MAX_ARRAY_LENGTH
oBinding.ReaderQuotas.MaxStringContentLength = MAX_STRING_LENGTH
oBinding.OpenTimeout = New TimeSpan(0, 0, OPEN_TIMEOUT)
Dim oEndpointAddress = New EndpointAddress(My.Settings.EDM_NetworkService_Adress)
oBinding.OpenTimeout = New TimeSpan(0, 0, OPEN_TIMEOUT_SECONDS)
Return New ChannelFactory(Of IEDMServiceChannel)(oBinding, oEndpointAddress)
Return oBinding
End Function
End Class