diff --git a/Service.JobRunner/Config.vb b/Service.JobRunner/Config.vb
new file mode 100644
index 00000000..c1836561
--- /dev/null
+++ b/Service.JobRunner/Config.vb
@@ -0,0 +1,25 @@
+Imports DigitalData.Modules.Jobs
+
+Public Class Config
+ Public Property Debug As Boolean = False
+
+ Public Property SQLConnectionString As String = ""
+
+ Public Property Firebird As New FirebirdConfig
+ Public Property Jobs As New List(Of JobConfig)
+
+ 'Public Enum JobType
+ ' ADSync
+ ' GraphQL
+ ' Test
+ 'End Enum
+
+
+
+ Public Class FirebirdConfig
+ Public Property DataSource As String = "172.24.12.41"
+ Public Property Database As String = "172.24.12.41:E:\DB\Firebird\Databases\EDMI_TEMPLATE\EDMI_MASTER.FDB"
+ Public Property User As String = "sysdba"
+ Public Property Password As String = "dd"
+ End Class
+End Class
diff --git a/Service.JobRunner/JobRunner.vb b/Service.JobRunner/JobRunner.vb
index 93ed80c0..72cfd780 100644
--- a/Service.JobRunner/JobRunner.vb
+++ b/Service.JobRunner/JobRunner.vb
@@ -1,44 +1,29 @@
Imports System.Collections.Specialized
+Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Jobs
Imports DigitalData.Modules.Logging
+Imports DigitalData.Services.JobRunner.Config
Imports Quartz
Imports Quartz.Impl
Imports Quartz.Logging
Public Class JobRunner
- Private _LogConfig As LogConfig
- Private _Logger As DigitalData.Modules.Logging.Logger
- Private _firebird As Firebird
- Private _mssql As MSSQLServer
+ Private ReadOnly _LogConfig As LogConfig
+ Private ReadOnly _Logger As DigitalData.Modules.Logging.Logger
+ Private ReadOnly _firebird As Firebird
+ Private ReadOnly _mssql As MSSQLServer
+ Private ReadOnly _config As Config
- Private _Props As New NameValueCollection From {
- {"quartz.serializer.type", "binary"},
- {"quartz.threadPool.threadCount", 10}
- }
Private _factory As StdSchedulerFactory
Private _scheduler As IScheduler
- Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer, Firebird As Firebird)
- _LogConfig = LogConfig
- _Logger = LogConfig.GetLogger()
- _firebird = Firebird
- _mssql = MSSQL
- Try
- Dim directory As New IO.DirectoryInfo(_LogConfig.LogDirectory)
-
- For Each file As IO.FileInfo In directory.GetFiles
- If (Now - file.CreationTime).Days > 29 Then
- file.Delete()
- Else
- Exit For
- End If
-
-
- Next
- Catch ex As Exception
-
- End Try
+ Public Sub New(pLogConfig As LogConfig, pConfig As Config, pMSSQL As MSSQLServer, pFirebird As Firebird)
+ _LogConfig = pLogConfig
+ _Logger = pLogConfig.GetLogger()
+ _firebird = pFirebird
+ _mssql = pMSSQL
+ _config = pConfig
End Sub
Public Async Sub Start()
@@ -48,7 +33,8 @@ Public Class JobRunner
_Logger.Info("Starting JobRunner")
Dim oProps As New NameValueCollection From {
- {"quartz.serializer.type", "binary"}
+ {"quartz.serializer.type", "binary"},
+ {"quartz.threadPool.threadCount", 10}
}
_factory = New StdSchedulerFactory(oProps)
_scheduler = Await _factory.GetScheduler()
@@ -57,26 +43,30 @@ Public Class JobRunner
Await _scheduler.Start()
' [START] Job Scheduling
- Await ScheduleJob(Of ADJob)("ADSync", My.Settings.ADSYNC_CONFIG)
- Await ScheduleJob(Of TestJob)("TestJob", My.Settings.TEST_CONFIG)
- Await ScheduleJob(Of GraphQLJob)("GraphQLJob", My.Settings.GRAPHQL_CONFIG)
+ Await ScheduleJob(Of ADJob)("ADSync", GetJobConfig(JobConfig.JobType.ADSync))
+ Await ScheduleJob(Of TestJob)("TestJob", GetJobConfig(JobConfig.JobType.Test))
+ Await ScheduleJob(Of GraphQLJob)("GraphQLJob", GetJobConfig(JobConfig.JobType.GraphQL))
' [END] Job Scheduling
Catch ex As Exception
- _Logger.Warn("Job Failed.")
+ _Logger.Warn("Job Failed with message: [{0}].", ex.Message)
_Logger.Error(ex)
End Try
End Sub
- Public Async Function ScheduleJob(Of T As Quartz.IJob)(JobName As String, JobConfigString As String) As Task
+ Public Function GetJobConfig(pName As JobConfig.JobType) As JobConfig
+ Return _config.Jobs.Where(Function(j) j.Name = pName).SingleOrDefault()
+ End Function
+
+ Public Async Function ScheduleJob(Of T As Quartz.IJob)(JobName As String, pJobConfig As JobConfig) As Task
Dim oJobIdentity As String = JobName
Dim oTriggerIdentity As String = JobName & "-Trigger"
- Dim oJobConfig As JobConfig = JobConfigParser.ParseConfig(JobConfigString)
+ Dim oJobConfig As JobConfig = JobConfigParser.ParseConfig(pJobConfig)
Dim oJobData As New JobDataMap From {
{"LogConfig", _LogConfig},
{"Firebird", _firebird},
{"MSSQL", _mssql},
- {"Args", oJobConfig.Arguments}
+ {"Args", oJobConfig.Args}
}
Dim oJob = JobBuilder.Create(Of T)().
@@ -87,7 +77,7 @@ Public Class JobRunner
Dim oTrigger = TriggerBuilder.Create().
WithIdentity(oTriggerIdentity).
StartNow().
- WithCronSchedule(oJobConfig.CronExpression).
+ WithCronSchedule(oJobConfig.CronSchedule).
Build()
If oJobConfig.Enabled Then
@@ -98,8 +88,8 @@ Public Class JobRunner
_Logger.Info("Job {0} is disabled.", JobName)
End If
- ' If StartImmediately is True, start Job after 10 Seconds
- If oJobConfig.StartImmediately Then
+ ' If StartWithoutDelay is True, start Job after 10 Seconds
+ If oJobConfig.StartWithoutDelay Then
Dim oDebugJob = JobBuilder.Create(Of T)().
WithIdentity(oJobIdentity & "-DEBUG").
UsingJobData(oJobData).
@@ -130,8 +120,6 @@ Public Class JobRunner
_Logger = Logger
End Sub
-
-
Private Function GetLogger(name As String) As Logging.Logger Implements ILogProvider.GetLogger
Return Function(level, func, exception, parameters)
If exception IsNot Nothing Then
diff --git a/Service.JobRunner/JobRunner.vbproj b/Service.JobRunner/JobRunner.vbproj
index 38256adb..b6426910 100644
--- a/Service.JobRunner/JobRunner.vbproj
+++ b/Service.JobRunner/JobRunner.vbproj
@@ -50,6 +50,10 @@
My Project\app.manifest
+
+ False
+ ..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll
+
False
..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll
@@ -101,6 +105,7 @@
+
diff --git a/Service.JobRunner/JobRunnerService.vb b/Service.JobRunner/JobRunnerService.vb
index 24106e2a..b4c54629 100644
--- a/Service.JobRunner/JobRunnerService.vb
+++ b/Service.JobRunner/JobRunnerService.vb
@@ -1,31 +1,34 @@
-Imports DigitalData.Modules.Logging
+Imports System.IO
+Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Logging.LogConfig
Imports DigitalData.Modules.Database
-Imports DigitalData.Services.JobRunner
+Imports DigitalData.Modules.Config
Public Class JobRunnerService
Private _logConfig As LogConfig
Private _logger As Logger
+ Private _config As ConfigManager(Of Config)
Private _mssql As MSSQLServer
Private _firebird As Firebird
Private _jobrunner As JobRunner
Protected Overrides Sub OnStart(ByVal args() As String)
- _logConfig = New LogConfig(PathType.CustomPath, My.Settings.LOG_PATH) With {
- .Debug = My.Settings.LOG_DEBUG
- }
+ _logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
_logger = _logConfig.GetLogger()
_logger.Info("Starting Service {0}", ServiceName)
+ _config = New ConfigManager(Of Config)(_logConfig, My.Application.Info.DirectoryPath)
+
+ Dim oFirebird = _config.Config.Firebird
Try
- _mssql = New MSSQLServer(_logConfig, My.Settings.SQL_CONNECTIONSTRING)
- _firebird = New Firebird(_logConfig, My.Settings.FIREBIRD_SERVER, My.Settings.FIREBIRD_DATABASE, My.Settings.FIREBIRD_USER, My.Settings.FIREBIRD_PASSWORD)
+ _mssql = New MSSQLServer(_logConfig, _config.Config.SQLConnectionString)
+ _firebird = New Firebird(_logConfig, oFirebird.DataSource, oFirebird.Database, oFirebird.User, oFirebird.Password)
Catch ex As Exception
_logger.Error(ex)
End Try
Try
- _jobrunner = New JobRunner(_logConfig, _mssql, _firebird)
+ _jobrunner = New JobRunner(_logConfig, _config.Config, _mssql, _firebird)
_jobrunner.Start()
Catch ex As Exception
_logger.Error(ex)