09-01-2023

This commit is contained in:
Jonathan Jenne
2023-01-17 08:43:08 +01:00
parent 7e7eee7299
commit 0b98902a7f
8 changed files with 58 additions and 35 deletions

View File

@@ -94,7 +94,6 @@ Namespace Scheduler
End Function
Private Async Sub ScheduleJobs()
Logger.Info("Loading [{0}] Job Definitions..", State.JobDefinitions.Count)
For Each oJob In State.JobDefinitions
@@ -109,11 +108,11 @@ Namespace Scheduler
Select Case pJob.TypeId
Case JOB_TYPE_IMPORT
Dim oJobConfig = BuildJobConfig(Of Jobs.FileImportJob)(pJob)
Await ScheduleJob(Of Jobs.FileImportJob)(oJobConfig)
Await ScheduleJob(Of Jobs.FileImportJob)(oJobConfig, pStartManually)
Case JOB_TYPE_INDEX
Dim oJobConfig = BuildJobConfig(Of Jobs.FileIndexJob)(pJob)
Await ScheduleJob(Of Jobs.FileIndexJob)(oJobConfig)
Await ScheduleJob(Of Jobs.FileIndexJob)(oJobConfig, pStartManually)
Case Else
Logger.Warn("Job for TypeId [{0}] is not implemented!", pJob.TypeId)
@@ -182,25 +181,20 @@ Namespace Scheduler
Private Async Function DoScheduleJobWithoutDelay(Of T As IJob)(pJobConfig As JobConfig) As Task
Dim oJobName As String = GetJobName(pJobConfig)
Dim oJobData As JobDataMap = BuildJobData(pJobConfig)
Dim oJob As IJobDetail = BuildJob(Of T)(pJobConfig, oJobData)
Dim oTriggerName As String = GetTriggerName(pJobConfig)
Dim oNoDelayTrigger = TriggerBuilder.Create().
WithIdentity(oTriggerName & "-NO-DELAY").
StartAt(DateBuilder.FutureDate(10, IntervalUnit.Second)).
Build()
Logger.Info("Job {0} will start in 10 Seconds.", oJobName)
Await Scheduler.ScheduleJob(oJob, oNoDelayTrigger)
Logger.Info("Job [{0}] will start now.", oJobName)
Await Scheduler.TriggerJob(New JobKey(oJobName))
End Function
Private Function BuildJob(Of T As IJob)(pJobConfig As JobConfig, pJobData As JobDataMap) As IJobDetail
Dim oJobName = GetJobName(pJobConfig)
Return JobBuilder.Create(Of T)().
Dim oJob = JobBuilder.Create(Of T)().
WithIdentity(pJobConfig.Name).
UsingJobData(pJobData).
StoreDurably().
Build()
Return oJob
End Function
Private Function BuildTrigger(pJobConfig As JobConfig) As ITrigger

View File

@@ -1,9 +1,7 @@
Imports ECM.JobRunner.Windows.Scheduler.Jobs
Imports Quartz
Imports Quartz
Imports System.Text.RegularExpressions
Imports DigitalData.Modules.Filesystem
Imports ECM.JobRunner.Common
Imports FxResources.System
Namespace Scheduler.Jobs
@@ -14,7 +12,7 @@ Namespace Scheduler.Jobs
Private FileEx As File
Public Function Execute(context As IJobExecutionContext) As Task Implements IJob.Execute
Dim oArgs = MyBase.InitializeJob(context)
Dim oArgs = InitializeJob(context)
Try
FileEx = New File(LogConfig)
@@ -46,14 +44,14 @@ Namespace Scheduler.Jobs
LogInfo("{0} files found in source directory {1}", oFileNames.Count.ToString, oProfile.SourceFolder)
' - [ ] Process Rules, build list of files and indexes
' - [x] Process Rules, build list of files and indexes
' - [x] Process Regex to filter out files
' - [x] Check time to filter out files
' - [ ] (Check if files can be accessed)
' - [ ] Check if backup is needed and backup files
' - [x] Import into windream
' - [ ] Create original subfolder structure
' - [ ] Create DateTime Subfolders
' - [x] Create DateTime Subfolders
' - [x] Check if file exists and version
' - [x] Do import
' - [ ] Check for filesize 0
@@ -186,7 +184,7 @@ Namespace Scheduler.Jobs
If pProfile.SubfolderDateFormat <> String.Empty Then
' ToString formatter needs the backslashes escaped again.
Dim oSubfolders = Now.ToString(pProfile.SubfolderDateFormat.Replace())
Dim oSubfolders = Now.ToString(pProfile.SubfolderDateFormat.Replace("\", "\\"))
Dim oFullPath = IO.Path.Combine(pProfile.TargetFolder, oSubfolders)
Logger.Debug("Creating subfolder [{0}] in Target path [{1}]", oSubfolders, pProfile.TargetFolder)
@@ -201,7 +199,7 @@ Namespace Scheduler.Jobs
' Generate new filepath and stream file
Dim oFileName = IO.Path.GetFileName(pFile.FilePath)
Dim oNewFilePath As String = IO.Path.Combine(pProfile.TargetFolder, oFileName)
Dim oNewFilePath As String = IO.Path.Combine(oFinalDirectoryPath, oFileName)
Dim oVersionedFilePath = GetVersionedWindreamPath(oNewFilePath)
If Windream.NewFileStream(pFile.FilePathOriginal, oVersionedFilePath, pProfile.ObjectTypeName) = False Then