Projektdateien hinzufügen.
This commit is contained in:
18
ECM.JobRunner.Windows/WCF/IJobRunner.vb
Normal file
18
ECM.JobRunner.Windows/WCF/IJobRunner.vb
Normal file
@@ -0,0 +1,18 @@
|
||||
Imports System.ServiceModel
|
||||
Imports ECM.JobRunner.Common
|
||||
|
||||
Namespace WCF
|
||||
<ServiceContract(Name:="IEDMIService", [Namespace]:="http://DigitalData.Services.EDMIService")>
|
||||
Public Interface IJobRunner
|
||||
|
||||
<OperationContract>
|
||||
Function GetHeartbeat() As Date
|
||||
|
||||
<OperationContract>
|
||||
Function GetJobHistory() As GetJobHistory.GetJobHistoryResponse
|
||||
|
||||
<OperationContract>
|
||||
Function GetJobConfig() As GetJobConfig.GetJobConfigResponse
|
||||
End Interface
|
||||
|
||||
End Namespace
|
||||
49
ECM.JobRunner.Windows/WCF/JobRunner.vb
Normal file
49
ECM.JobRunner.Windows/WCF/JobRunner.vb
Normal file
@@ -0,0 +1,49 @@
|
||||
Imports System.ServiceModel
|
||||
Imports System.ServiceModel.Description
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Messaging.WCF
|
||||
Imports ECM.JobRunner.Common
|
||||
|
||||
Namespace WCF
|
||||
|
||||
Public Class JobRunner
|
||||
Implements IJobRunner
|
||||
|
||||
Public Shared State As State
|
||||
Public Shared LogConfig As LogConfig
|
||||
Public Shared Database As MSSQLServer
|
||||
|
||||
''' <summary>
|
||||
''' See: https://stackoverflow.com/questions/42327988/addserviceendpoint-throws-key-is-null
|
||||
''' </summary>
|
||||
''' <param name="Config"></param>
|
||||
Public Shared Sub Configure(Config As ServiceConfiguration)
|
||||
Dim oBaseAddress = Config.BaseAddresses.Item(0)
|
||||
Dim oBinding = Binding.GetBinding()
|
||||
Dim oAddress = New EndpointAddress(oBaseAddress)
|
||||
Dim oDescription = ContractDescription.GetContract(GetType(IJobRunner), GetType(JobRunner))
|
||||
Dim oEndpoint As New ServiceEndpoint(oDescription, oBinding, oAddress)
|
||||
|
||||
Config.AddServiceEndpoint(oEndpoint)
|
||||
Config.Description.Behaviors.Add(New ServiceDebugBehavior With {
|
||||
.IncludeExceptionDetailInFaults = True
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Function GetHeartbeat() As Date Implements IJobRunner.GetHeartbeat
|
||||
Return Now
|
||||
End Function
|
||||
|
||||
Public Function GetJobHistory() As GetJobHistory.GetJobHistoryResponse Implements IJobRunner.GetJobHistory
|
||||
Dim oMethod As New GetJobHistory.GetJobHistoryMethod(LogConfig, Database, State)
|
||||
Return oMethod.Run()
|
||||
End Function
|
||||
|
||||
Public Function GetJobConfig() As GetJobConfig.GetJobConfigResponse Implements IJobRunner.GetJobConfig
|
||||
Dim oMethod As New GetJobConfig.GetJobConfigMethod(LogConfig, Database, State)
|
||||
Return oMethod.Run()
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
48
ECM.JobRunner.Windows/WCF/Methods/Base.vb
Normal file
48
ECM.JobRunner.Windows/WCF/Methods/Base.vb
Normal file
@@ -0,0 +1,48 @@
|
||||
Imports System.Runtime.Serialization
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Base
|
||||
Public Class BaseMethod
|
||||
Inherits BaseClass
|
||||
|
||||
Friend ReadOnly Database As MSSQLServer
|
||||
Friend ReadOnly State As State
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pState As State)
|
||||
MyBase.New(pLogConfig)
|
||||
Database = pDatabase
|
||||
State = pState
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Public MustInherit Class BaseResponse
|
||||
<DataMember>
|
||||
Public Property OK As Boolean
|
||||
<DataMember>
|
||||
Public Property ErrorMessage As String
|
||||
<DataMember>
|
||||
Public Property ErrorDetails As String
|
||||
|
||||
Public Sub New()
|
||||
OK = True
|
||||
End Sub
|
||||
|
||||
Public Sub New(Message As String)
|
||||
OK = False
|
||||
ErrorMessage = Message
|
||||
End Sub
|
||||
|
||||
Public Sub New(Exception As Exception)
|
||||
OK = False
|
||||
ErrorMessage = Exception.Message
|
||||
End Sub
|
||||
|
||||
Public Sub New(Exception As Exception, Details As String)
|
||||
OK = False
|
||||
ErrorMessage = Exception.Message
|
||||
ErrorDetails = Details
|
||||
End Sub
|
||||
End Class
|
||||
End Class
|
||||
36
ECM.JobRunner.Windows/WCF/Methods/GetJobConfig.vb
Normal file
36
ECM.JobRunner.Windows/WCF/Methods/GetJobConfig.vb
Normal file
@@ -0,0 +1,36 @@
|
||||
Imports System.Runtime.Serialization
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports ECM.JobRunner.Common
|
||||
|
||||
Public Class GetJobConfig
|
||||
Public Class GetJobConfigMethod
|
||||
Inherits Base.BaseMethod
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pState As State)
|
||||
MyBase.New(pLogConfig, pDatabase, pState)
|
||||
End Sub
|
||||
|
||||
Public Function Run() As GetJobConfigResponse
|
||||
Return New GetJobConfigResponse With {
|
||||
.JobTypes = State.JobTypes,
|
||||
.JobDefinitions = State.JobDefinitions
|
||||
}
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class GetJobConfigResponse
|
||||
Inherits Base.BaseResponse
|
||||
|
||||
<DataMember>
|
||||
Public Property JobTypes As List(Of JobType)
|
||||
|
||||
<DataMember>
|
||||
Public Property JobDefinitions As List(Of JobDefinition)
|
||||
End Class
|
||||
|
||||
End Class
|
||||
|
||||
25
ECM.JobRunner.Windows/WCF/Methods/GetJobHistory.vb
Normal file
25
ECM.JobRunner.Windows/WCF/Methods/GetJobHistory.vb
Normal file
@@ -0,0 +1,25 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports ECM.JobRunner.Common
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Public Class GetJobHistory
|
||||
Public Class GetJobHistoryMethod
|
||||
Inherits Base.BaseMethod
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pState As State)
|
||||
MyBase.New(pLogConfig, pDatabase, pState)
|
||||
End Sub
|
||||
|
||||
Public Function Run() As GetJobHistoryResponse
|
||||
Return New GetJobHistoryResponse With {.Items = State.JobHistory.Entries}
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Public Class GetJobHistoryResponse
|
||||
Inherits Base.BaseResponse
|
||||
|
||||
<DataMember>
|
||||
Public Property Items As List(Of HistoryItem)
|
||||
End Class
|
||||
End Class
|
||||
73
ECM.JobRunner.Windows/WCF/ServiceHost.vb
Normal file
73
ECM.JobRunner.Windows/WCF/ServiceHost.vb
Normal file
@@ -0,0 +1,73 @@
|
||||
Imports System.ServiceModel
|
||||
Imports System.ServiceModel.Channels
|
||||
Imports System.ServiceModel.Description
|
||||
|
||||
Namespace WCF
|
||||
|
||||
Public Class ServiceHost(Of T)
|
||||
Inherits ServiceHost
|
||||
|
||||
Public Sub New(baseAddresses As Uri())
|
||||
MyBase.New(GetType(T), baseAddresses)
|
||||
End Sub
|
||||
|
||||
Public Sub New(singletonInstance As Object, baseAddresses As Uri())
|
||||
MyBase.New(singletonInstance, baseAddresses)
|
||||
End Sub
|
||||
|
||||
Public Sub EnableMetadataExchange(ByVal Optional EnableHttpGet As Boolean = True)
|
||||
If State = CommunicationState.Opened Then
|
||||
Throw New InvalidOperationException("Host is already opened")
|
||||
End If
|
||||
|
||||
Dim oMetadataBehavior As ServiceMetadataBehavior = Description.Behaviors.Find(Of ServiceMetadataBehavior)()
|
||||
|
||||
If oMetadataBehavior Is Nothing Then
|
||||
oMetadataBehavior = New ServiceMetadataBehavior()
|
||||
Description.Behaviors.Add(oMetadataBehavior)
|
||||
|
||||
If BaseAddresses.Any(Function(uri) uri.Scheme = "http") Then
|
||||
oMetadataBehavior.HttpGetEnabled = EnableHttpGet
|
||||
Else
|
||||
oMetadataBehavior.HttpGetEnabled = False
|
||||
End If
|
||||
End If
|
||||
|
||||
AddAllMexEndPoints()
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property HasMexEndpoint As Boolean
|
||||
Get
|
||||
Return Description.Endpoints.Any(Function(endpoint) endpoint.Contract.ContractType = GetType(IMetadataExchange))
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub AddAllMexEndPoints()
|
||||
Debug.Assert(HasMexEndpoint = False)
|
||||
|
||||
For Each baseAddress As Uri In BaseAddresses
|
||||
Dim oBinding As Binding = Nothing
|
||||
|
||||
Select Case baseAddress.Scheme
|
||||
Case "net.tcp"
|
||||
oBinding = MetadataExchangeBindings.CreateMexTcpBinding()
|
||||
Exit Select
|
||||
Case "net.pipe"
|
||||
oBinding = MetadataExchangeBindings.CreateMexNamedPipeBinding()
|
||||
Exit Select
|
||||
Case "http"
|
||||
oBinding = MetadataExchangeBindings.CreateMexHttpBinding()
|
||||
Exit Select
|
||||
Case "https"
|
||||
oBinding = MetadataExchangeBindings.CreateMexHttpsBinding()
|
||||
Exit Select
|
||||
End Select
|
||||
|
||||
If oBinding IsNot Nothing Then
|
||||
AddServiceEndpoint(GetType(IMetadataExchange), oBinding, "mex")
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user