06-12-2022
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
Imports System.ServiceModel
|
||||
Imports ECM.JobRunner.Common
|
||||
Imports ECM.JobRunner.Windows.UpdateJob
|
||||
Imports ECM.JobRunner.Windows.GetJobStatus
|
||||
Imports ECM.JobRunner.Windows.GetJobConfig
|
||||
|
||||
Namespace WCF
|
||||
<ServiceContract(Name:="IEDMIService", [Namespace]:="http://DigitalData.Services.EDMIService")>
|
||||
@@ -9,10 +12,13 @@ Namespace WCF
|
||||
Function GetHeartbeat() As Date
|
||||
|
||||
<OperationContract>
|
||||
Function GetJobHistory() As GetJobHistory.GetJobHistoryResponse
|
||||
Function GetJobStatus() As GetJobStatusResponse
|
||||
|
||||
<OperationContract>
|
||||
Function GetJobConfig() As GetJobConfig.GetJobConfigResponse
|
||||
Function UpdateJob(pData As UpdateJobRequest) As UpdateJobResponse
|
||||
|
||||
<OperationContract>
|
||||
Function GetJobConfig() As GetJobConfigResponse
|
||||
End Interface
|
||||
|
||||
End Namespace
|
||||
|
||||
@@ -3,7 +3,7 @@ Imports System.ServiceModel.Description
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Messaging.WCF
|
||||
Imports ECM.JobRunner.Common
|
||||
Imports ECM.JobRunner.Windows.Scheduler
|
||||
|
||||
Namespace WCF
|
||||
|
||||
@@ -13,6 +13,7 @@ Namespace WCF
|
||||
Public Shared State As State
|
||||
Public Shared LogConfig As LogConfig
|
||||
Public Shared Database As MSSQLServer
|
||||
Public Shared Scheduler As JobScheduler
|
||||
|
||||
''' <summary>
|
||||
''' See: https://stackoverflow.com/questions/42327988/addserviceendpoint-throws-key-is-null
|
||||
@@ -35,8 +36,8 @@ Namespace WCF
|
||||
Return Now
|
||||
End Function
|
||||
|
||||
Public Function GetJobHistory() As GetJobHistory.GetJobHistoryResponse Implements IJobRunner.GetJobHistory
|
||||
Dim oMethod As New GetJobHistory.GetJobHistoryMethod(LogConfig, Database, State)
|
||||
Public Function GetJobHistory() As GetJobStatus.GetJobStatusResponse Implements IJobRunner.GetJobStatus
|
||||
Dim oMethod As New GetJobStatus.GetJobStatusMethod(LogConfig, Database, State, Scheduler)
|
||||
Return oMethod.Run()
|
||||
End Function
|
||||
|
||||
@@ -44,6 +45,11 @@ Namespace WCF
|
||||
Dim oMethod As New GetJobConfig.GetJobConfigMethod(LogConfig, Database, State)
|
||||
Return oMethod.Run()
|
||||
End Function
|
||||
|
||||
Public Function UpdateJob(pData As UpdateJob.UpdateJobRequest) As UpdateJob.UpdateJobResponse Implements IJobRunner.UpdateJob
|
||||
Dim oMethod As New UpdateJob.UpdateJobMethod(LogConfig, Database, State, Scheduler)
|
||||
Return oMethod.Run(pData)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
|
||||
@@ -18,8 +18,6 @@ Public Class GetJobConfig
|
||||
.JobDefinitions = State.JobDefinitions
|
||||
}
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class GetJobConfigResponse
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
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
|
||||
37
ECM.JobRunner.Windows/WCF/Methods/GetJobStatus.vb
Normal file
37
ECM.JobRunner.Windows/WCF/Methods/GetJobStatus.vb
Normal file
@@ -0,0 +1,37 @@
|
||||
Imports System.Collections.ObjectModel
|
||||
Imports System.Runtime.Serialization
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports ECM.JobRunner.Common
|
||||
Imports ECM.JobRunner.Windows.Scheduler
|
||||
|
||||
Public Class GetJobStatus
|
||||
Public Class GetJobStatusMethod
|
||||
Inherits Base.BaseMethod
|
||||
|
||||
Private ReadOnly Scheduler As JobScheduler
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pState As State, pScheduler As JobScheduler)
|
||||
MyBase.New(pLogConfig, pDatabase, pState)
|
||||
Scheduler = pScheduler
|
||||
End Sub
|
||||
|
||||
Public Function Run() As GetJobStatusResponse
|
||||
Return New GetJobStatusResponse With {
|
||||
.HistoryItems = State.JobHistory.Entries,
|
||||
.StatusItems = State.JobStatus.Entries
|
||||
}
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Public Class GetJobStatusResponse
|
||||
Inherits Base.BaseResponse
|
||||
|
||||
<DataMember>
|
||||
Public Property HistoryItems As List(Of HistoryItem)
|
||||
|
||||
<DataMember>
|
||||
Public Property StatusItems As List(Of StatusItem)
|
||||
End Class
|
||||
End Class
|
||||
93
ECM.JobRunner.Windows/WCF/Methods/UpdateJob.vb
Normal file
93
ECM.JobRunner.Windows/WCF/Methods/UpdateJob.vb
Normal file
@@ -0,0 +1,93 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports ECM.JobRunner.Common
|
||||
Imports ECM.JobRunner.Windows.Scheduler
|
||||
|
||||
Public Class UpdateJob
|
||||
Public Class UpdateJobMethod
|
||||
Inherits Base.BaseMethod
|
||||
|
||||
Private ReadOnly Scheduler As JobScheduler
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pState As State, pScheduler As JobScheduler)
|
||||
MyBase.New(pLogConfig, pDatabase, pState)
|
||||
Scheduler = pScheduler
|
||||
End Sub
|
||||
|
||||
Public Function Run(pData As UpdateJobRequest) As UpdateJobResponse
|
||||
Dim oResponse As Boolean = False
|
||||
|
||||
Select Case pData.Action
|
||||
Case UpdateJobRequest.UpdateJobAction.Update
|
||||
oResponse = DoUpdateJob(pData)
|
||||
|
||||
Case UpdateJobRequest.UpdateJobAction.Create
|
||||
oResponse = DoCreateJob(pData)
|
||||
|
||||
Case UpdateJobRequest.UpdateJobAction.Delete
|
||||
oResponse = DoDeleteJob(pData)
|
||||
|
||||
End Select
|
||||
|
||||
If oResponse Then
|
||||
Scheduler.Reload()
|
||||
End If
|
||||
|
||||
Return New UpdateJobResponse With {.OK = oResponse}
|
||||
End Function
|
||||
|
||||
Private Function DoUpdateJob(pData As UpdateJobRequest) As Boolean
|
||||
Dim oJob = pData.Job
|
||||
Dim oSQL As String = "UPDATE TBECM_JR_JOB SET TITLE = @TITLE, QUARTZ_DEF = @CRON, JOB_TYPE_ID = @TYPE_ID, ACTIVE = @ACTIVE WHERE GUID = @GUID"
|
||||
Dim oCommand As New SqlClient.SqlCommand(oSQL)
|
||||
|
||||
oCommand.Parameters.Add("TITLE", SqlDbType.NVarChar, 250).Value = oJob.Name
|
||||
oCommand.Parameters.Add("CRON", SqlDbType.NVarChar, 250).Value = oJob.CronSchedule
|
||||
oCommand.Parameters.Add("TYPE_ID", SqlDbType.Int).Value = oJob.TypeId
|
||||
oCommand.Parameters.Add("ACTIVE", SqlDbType.Bit).Value = oJob.Active
|
||||
oCommand.Parameters.Add("GUID", SqlDbType.Int).Value = oJob.Id
|
||||
|
||||
Return Database.ExecuteNonQuery(oCommand)
|
||||
End Function
|
||||
|
||||
Private Function DoCreateJob(pData As UpdateJobRequest) As Boolean
|
||||
Dim oJob = pData.Job
|
||||
Dim oSQL As String = "INSERT INTO TBECM_JR_JOB (TITLE, QUARTZ_DEF, JOB_TYPE_ID, ACTIVE) VALUES (@TITLE, @CRON, @TYPE_ID, @ACTIVE)"
|
||||
Dim oCommand As New SqlClient.SqlCommand(oSQL)
|
||||
|
||||
oCommand.Parameters.Add("TITLE", SqlDbType.NVarChar, 250).Value = oJob.Name
|
||||
oCommand.Parameters.Add("CRON", SqlDbType.NVarChar, 250).Value = oJob.CronSchedule
|
||||
oCommand.Parameters.Add("TYPE_ID", SqlDbType.Int).Value = oJob.TypeId
|
||||
oCommand.Parameters.Add("ACTIVE", SqlDbType.Bit).Value = oJob.Active
|
||||
|
||||
Return Database.ExecuteNonQuery(oCommand)
|
||||
End Function
|
||||
|
||||
Private Function DoDeleteJob(pData As UpdateJobRequest) As Boolean
|
||||
Dim oJob = pData.Job
|
||||
Dim oSQL As String = "DELETE FROM TBECM_JR_JOB WHERE GUID = @GUID"
|
||||
Dim oCommand As New SqlClient.SqlCommand(oSQL)
|
||||
|
||||
oCommand.Parameters.Add("GUID", SqlDbType.Int).Value = oJob.Id
|
||||
|
||||
Return Database.ExecuteNonQuery(oCommand)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
|
||||
|
||||
Public Class UpdateJobRequest
|
||||
Public Enum UpdateJobAction
|
||||
Create
|
||||
Update
|
||||
Delete
|
||||
End Enum
|
||||
|
||||
Public Action As UpdateJobAction
|
||||
Public Job As JobRunnerReference.JobDefinition
|
||||
End Class
|
||||
|
||||
Public Class UpdateJobResponse
|
||||
Inherits Base.BaseResponse
|
||||
End Class
|
||||
End Class
|
||||
Reference in New Issue
Block a user