Projektdateien hinzufügen.
This commit is contained in:
104
ECM.JobRunner.Windows/State.vb
Normal file
104
ECM.JobRunner.Windows/State.vb
Normal file
@@ -0,0 +1,104 @@
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports ECM.JobRunner.Common
|
||||
Imports ECM.JobRunner.Windows.Scheduler
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
Public Class State
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly Database As MSSQLServer
|
||||
|
||||
Public ReadOnly JobHistory As JobHistory
|
||||
Public ReadOnly Property JobTypes As New List(Of JobType)
|
||||
Public ReadOnly Property JobDefinitions As New List(Of JobDefinition)
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
|
||||
MyBase.New(pLogConfig)
|
||||
Database = pDatabase
|
||||
JobHistory = New JobHistory(pLogConfig)
|
||||
|
||||
_JobTypes = GetJobTypes()
|
||||
_JobDefinitions = GetJobDefinitions(_JobTypes)
|
||||
End Sub
|
||||
|
||||
Public Sub Reload()
|
||||
_JobTypes = GetJobTypes()
|
||||
_JobDefinitions = GetJobDefinitions(_JobTypes)
|
||||
End Sub
|
||||
|
||||
Private Function GetJobTypes() As List(Of JobType)
|
||||
Dim oTypes As New List(Of JobType)
|
||||
Try
|
||||
Logger.Info("Loading Job Types..")
|
||||
|
||||
Dim oSQL As String = "SELECT * FROM TBECM_JR_TYPE WHERE ACTIVE = 1"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("Database Error while loading Job Types!")
|
||||
Return oTypes
|
||||
End If
|
||||
|
||||
Logger.Info("[{0}] Job Types loaded!", oTable.Rows.Count)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oType As New JobType With {
|
||||
.Id = oRow.ItemEx("GUID", 0),
|
||||
.Name = oRow.ItemEx("JOB_TYPE", ""),
|
||||
.Active = oRow.ItemEx("ACTIVE", 0)
|
||||
}
|
||||
oTypes.Add(oType)
|
||||
|
||||
Logger.Debug("Adding Job Type [{0}]", oType.Name)
|
||||
Next
|
||||
|
||||
Return oTypes
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oTypes
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetJobDefinitions(pJobTypes As List(Of JobType)) As List(Of JobDefinition)
|
||||
Dim oJobs As New List(Of JobDefinition)
|
||||
|
||||
Try
|
||||
Dim oSQL As String = "SELECT * FROM TBECM_JR_JOB"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("Database Error while loading Jobs!")
|
||||
Return oJobs
|
||||
End If
|
||||
|
||||
Logger.Info("[{0}] Jobs loaded!", oTable.Rows.Count)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oTypeId = oRow.ItemEx("JOB_TYPE_ID", 0)
|
||||
Dim oJob As New JobDefinition With {
|
||||
.Id = oRow.ItemEx("GUID", 0),
|
||||
.TypeId = oTypeId,
|
||||
.Type = pJobTypes.Where(Function(t) t.Id = oTypeId).SingleOrDefault,
|
||||
.Name = oRow.ItemEx("TITLE", ""),
|
||||
.Active = oRow.ItemEx("ACTIVE", 0),
|
||||
.CronSchedule = oRow.ItemEx("QUARTZ_DEF", "")
|
||||
}
|
||||
oJobs.Add(oJob)
|
||||
|
||||
Logger.Debug("Adding Job [{0}]", oJob.Name)
|
||||
Next
|
||||
|
||||
Return oJobs
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oJobs
|
||||
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user