07-12-2022
This commit is contained in:
@@ -4,34 +4,86 @@ Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports ECM.JobRunner.Common
|
||||
Imports ECM.JobRunner.Windows.Scheduler
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports DigitalData.Modules.Windream
|
||||
|
||||
Public Class State
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly Database As MSSQLServer
|
||||
Private ReadOnly Windream As Windream
|
||||
|
||||
Public ReadOnly JobHistory As JobHistory
|
||||
Public ReadOnly JobStatus As JobStatus
|
||||
|
||||
Public ReadOnly Property JobTypes As New List(Of JobType)
|
||||
Public ReadOnly Property ObjectTypes As New List(Of ObjectType)
|
||||
|
||||
Public ReadOnly Property JobDefinitions As New List(Of JobDefinition)
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
|
||||
Public ReadOnly Property ProfileDefintions As New ProfileDefinitions
|
||||
|
||||
Public Class ProfileDefinitions
|
||||
Public Property ImportProfiles As New List(Of ImportProfile)
|
||||
End Class
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pWindream As Windream)
|
||||
MyBase.New(pLogConfig)
|
||||
Database = pDatabase
|
||||
Windream = pWindream
|
||||
JobHistory = New JobHistory(pLogConfig)
|
||||
JobStatus = New JobStatus(pLogConfig)
|
||||
|
||||
_JobTypes = GetJobTypes()
|
||||
_JobDefinitions = GetJobDefinitions(_JobTypes)
|
||||
LoadData()
|
||||
End Sub
|
||||
|
||||
Public Sub Reload()
|
||||
_JobTypes = GetJobTypes()
|
||||
_JobDefinitions = GetJobDefinitions(_JobTypes)
|
||||
LoadData()
|
||||
End Sub
|
||||
|
||||
Private Sub LoadData()
|
||||
_JobTypes = GetJobTypes()
|
||||
_ObjectTypes = GetObjectTypes()
|
||||
|
||||
_JobDefinitions = GetJobDefinitions(_JobTypes)
|
||||
_ProfileDefintions.ImportProfiles = GetImportProfiles()
|
||||
End Sub
|
||||
|
||||
Private Function GetObjectTypes() As List(Of ObjectType)
|
||||
Dim oObjectTypes As New List(Of ObjectType)
|
||||
Try
|
||||
Logger.Info("Loading Windream Object Types..")
|
||||
Dim oObjectTypesNames = Windream.ObjectTypes
|
||||
Logger.Info("[{0}] Windream Object Types loaded!", oObjectTypes.Count)
|
||||
|
||||
For Each oObjectTypeName In oObjectTypesNames
|
||||
Dim oObjectType = New ObjectType With {
|
||||
.Name = oObjectTypeName,
|
||||
.Indexes = GetIndexesFor(oObjectTypeName)
|
||||
}
|
||||
oObjectTypes.Add(oObjectType)
|
||||
Next
|
||||
|
||||
Return oObjectTypes
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oObjectTypes
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetIndexesFor(pObjectType As String) As List(Of String)
|
||||
Dim oIndexes As New List(Of String)
|
||||
Try
|
||||
Logger.Info("Loading Windream Indexes for [{0}]..", pObjectType)
|
||||
oIndexes = Windream.GetIndiciesByObjecttype(pObjectType)
|
||||
Logger.Info("[{0}] Windream Indexes loaded!", oIndexes.Count)
|
||||
|
||||
Return oIndexes
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oIndexes
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetJobTypes() As List(Of JobType)
|
||||
Dim oTypes As New List(Of JobType)
|
||||
Try
|
||||
@@ -67,6 +119,44 @@ Public Class State
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetImportProfiles() As List(Of ImportProfile)
|
||||
Dim oProfiles As New List(Of ImportProfile)
|
||||
|
||||
Try
|
||||
Logger.Info("Loading Profiles..")
|
||||
|
||||
Dim oSQL As String = "SELECT * FROM TBECM_JR_FIW_PROFILE"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("Database Error while loading Profiles!")
|
||||
Return oProfiles
|
||||
End If
|
||||
|
||||
Logger.Info("[{0}] Profiles loaded!", oTable.Rows.Count)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oTypeId = oRow.ItemEx("JOB_TYPE_ID", 0)
|
||||
Dim oProfile As New ImportProfile With {
|
||||
.Id = oRow.ItemEx("GUID", 0),
|
||||
.JobId = oRow.ItemEx("JR_JOB_ID", 0),
|
||||
.SourceFolder = oRow.ItemEx("SOURCE_FOLDER", "")
|
||||
}
|
||||
|
||||
oProfiles.Add(oProfile)
|
||||
|
||||
Logger.Debug("Adding Profile for Folder [{0}]", oProfile.SourceFolder)
|
||||
Next
|
||||
|
||||
Return oProfiles
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oProfiles
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetJobDefinitions(pJobTypes As List(Of JobType)) As List(Of JobDefinition)
|
||||
Dim oJobs As New List(Of JobDefinition)
|
||||
|
||||
@@ -92,7 +182,8 @@ Public Class State
|
||||
.Name = oRow.ItemEx("TITLE", ""),
|
||||
.Active = oRow.ItemEx("ACTIVE", 0),
|
||||
.CronSchedule = oRow.ItemEx("QUARTZ_DEF", "")
|
||||
}
|
||||
}
|
||||
|
||||
oJobs.Add(oJob)
|
||||
|
||||
Logger.Debug("Adding Job [{0}]", oJob.Name)
|
||||
|
||||
Reference in New Issue
Block a user