07-12-2022
This commit is contained in:
@@ -97,6 +97,7 @@ Namespace Scheduler
|
||||
.Name = pJob.Name,
|
||||
.Enabled = pJob.Active,
|
||||
.Arguments = New Dictionary(Of String, String) From {
|
||||
{"Id", pJob.Id},
|
||||
{"Name", pJob.Name}
|
||||
},
|
||||
.CronSchedule = pJob.CronSchedule
|
||||
|
||||
@@ -10,17 +10,24 @@ Namespace Scheduler.Jobs
|
||||
Friend Database As MSSQLServer
|
||||
Friend State As State
|
||||
|
||||
Friend Id As Integer
|
||||
Friend Name As String
|
||||
|
||||
Private ctx As IJobExecutionContext
|
||||
|
||||
Public Function InitializeJob(context As IJobExecutionContext) As Dictionary(Of String, String)
|
||||
ctx = context
|
||||
|
||||
Dim oJobData = context.MergedJobDataMap
|
||||
Dim oArgs As Dictionary(Of String, String) = oJobData.Item(Constants.Scheduler.JOB_CONFIG_ARGUMENTS)
|
||||
LogConfig = oJobData.Item(Constants.Scheduler.JOB_CONFIG_LOGCONFIG)
|
||||
Database = oJobData.Item(Constants.Scheduler.JOB_CONFIG_DATABASE)
|
||||
State = oJobData.Item(Constants.Scheduler.JOB_CONFIG_STATE)
|
||||
Logger = LogConfig.GetLogger()
|
||||
|
||||
Id = Integer.Parse(oArgs.Item("Id"))
|
||||
Name = oArgs.Item("Name")
|
||||
|
||||
State.JobStatus.Start(ctx)
|
||||
Return oJobData.Item(Constants.Scheduler.JOB_CONFIG_ARGUMENTS)
|
||||
End Function
|
||||
|
||||
@@ -8,10 +8,9 @@ Namespace Scheduler.Jobs
|
||||
|
||||
Private Function IJob_Execute(context As IJobExecutionContext) As Task Implements IJob.Execute
|
||||
Dim oArgs = MyBase.InitializeJob(context)
|
||||
Dim oArg1 = oArgs.Item("Arg1")
|
||||
|
||||
Logger.Info("I'm a debug Job!")
|
||||
Logger.Info("Arg1: [{0}]", oArg1)
|
||||
Logger.Info("Name: [{0}]", Name)
|
||||
|
||||
Dim oResult = New JobResult() With {
|
||||
.Description = $"I'm a debug job and my result was [{Guid.NewGuid}]."
|
||||
|
||||
@@ -2,31 +2,107 @@
|
||||
Imports Quartz
|
||||
|
||||
|
||||
|
||||
Namespace Scheduler.Jobs
|
||||
|
||||
''' <summary>
|
||||
'''
|
||||
''' Parameters / Properties
|
||||
''' =======================
|
||||
'''
|
||||
''' - SourceDirectory
|
||||
''' - TargetDirectory
|
||||
''' - Include Subdirectories
|
||||
''' - Delete Subdirectories
|
||||
''' - Backup
|
||||
''' - BackupFolder
|
||||
''' - Overwrite
|
||||
''' - Windream DocType
|
||||
''' - Delete Files
|
||||
''' - Delete Directory
|
||||
''' - Delay
|
||||
'''
|
||||
''' Rules
|
||||
''' ======
|
||||
'''
|
||||
''' - TargetIndex
|
||||
''' - Active
|
||||
''' - Index From
|
||||
''' - Static
|
||||
''' - Static Value
|
||||
''' - File
|
||||
''' - Folder
|
||||
''' - Index Type
|
||||
''' - Separator
|
||||
''' - Current Date
|
||||
''' - Current Short Date
|
||||
''' - KOMPLETT
|
||||
''' - BEREICH
|
||||
''' - REST
|
||||
''' - TRENNZEICHEN
|
||||
''' - Separator
|
||||
''' - Remove Zeroes
|
||||
''' - Include Extension
|
||||
''' - OrderKey
|
||||
'''
|
||||
''' </summary>
|
||||
Public Class FileImportJob
|
||||
Inherits BaseJob
|
||||
Implements IJob
|
||||
|
||||
Public Function Execute(context As IJobExecutionContext) As Task Implements IJob.Execute
|
||||
Dim oArgs = MyBase.InitializeJob(context)
|
||||
Dim oName = oArgs.Item("Name")
|
||||
|
||||
Logger.Info("Running File Import [{0}]", oName)
|
||||
Try
|
||||
Logger.Info("Running File Import [{0}]", Name)
|
||||
|
||||
Dim oMax = 100
|
||||
For index = 1 To oMax
|
||||
UpdateProgress(index, oMax)
|
||||
Threading.Thread.Sleep(100)
|
||||
Next
|
||||
Dim oProfile = State.ProfileDefintions.ImportProfiles.Where(Function(p) p.JobId = Id).SingleOrDefault()
|
||||
|
||||
Dim oResult = New JobResult() With {
|
||||
.Description = $"File Import Job [{oName}] completed!"
|
||||
}
|
||||
Dim oSourceDirectory As String = oProfile.SourceFolder
|
||||
Dim oRecursive As Boolean = oProfile.IncludeSubfolders
|
||||
Dim oFiles = GetFiles(oSourceDirectory, oRecursive)
|
||||
|
||||
context.Result = oResult
|
||||
If oFiles.Count = 0 Then
|
||||
Logger.Info("No Files for Profile [{0}]", Name)
|
||||
Return Task.FromResult(True)
|
||||
End If
|
||||
|
||||
CompleteJob()
|
||||
Return Task.FromResult(True)
|
||||
'Dim oMax = 100
|
||||
'For index = 1 To oMax
|
||||
' UpdateProgress(index, oMax)
|
||||
' Threading.Thread.Sleep(100)
|
||||
'Next
|
||||
|
||||
Dim oResult = New JobResult() With {
|
||||
.Description = $"File Import Job [{Name}] completed!"
|
||||
}
|
||||
|
||||
context.Result = oResult
|
||||
|
||||
Return Task.FromResult(True)
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
|
||||
|
||||
Return Task.FromResult(False)
|
||||
Finally
|
||||
CompleteJob()
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Private Function GetFiles(pDirectory As String, pRecursive As Boolean) As String()
|
||||
Dim oFiles As String()
|
||||
|
||||
If pRecursive Then
|
||||
oFiles = IO.Directory.GetFiles(pDirectory, "*.*", IO.SearchOption.AllDirectories)
|
||||
Logger.Info("Found [{0}] files in Folder [{1}] (and subdirectories)", oFiles.Count, pDirectory)
|
||||
Else
|
||||
oFiles = IO.Directory.GetFiles(pDirectory, "*.*", IO.SearchOption.TopDirectoryOnly)
|
||||
Logger.Info("Found [{0}] files in Folder [{1}]", oFiles.Count, pDirectory)
|
||||
End If
|
||||
|
||||
Return oFiles
|
||||
End Function
|
||||
End Class
|
||||
|
||||
|
||||
@@ -8,12 +8,11 @@ Namespace Scheduler.Jobs
|
||||
|
||||
Public Function Execute(context As IJobExecutionContext) As Task Implements IJob.Execute
|
||||
Dim oArgs = MyBase.InitializeJob(context)
|
||||
Dim oName = oArgs.Item("Name")
|
||||
|
||||
Logger.Info("Running File Index [{0}]", oName)
|
||||
Logger.Info("Running File Index [{0}]", Name)
|
||||
|
||||
Dim oResult = New JobResult() With {
|
||||
.Description = $"File Index Job [{oName}] completed!"
|
||||
.Description = $"File Index Job [{Name}] completed!"
|
||||
}
|
||||
|
||||
context.Result = oResult
|
||||
|
||||
Reference in New Issue
Block a user