diff --git a/JobRunner/App.config b/JobRunner/App.config
index 584c1495..3249a680 100644
--- a/JobRunner/App.config
+++ b/JobRunner/App.config
@@ -40,6 +40,9 @@
+
+
+
\ No newline at end of file
diff --git a/JobRunner/JobRunner.vb b/JobRunner/JobRunner.vb
index 0d94aefb..70a97413 100644
--- a/JobRunner/JobRunner.vb
+++ b/JobRunner/JobRunner.vb
@@ -11,12 +11,14 @@ Public Class JobRunner
Private ReadOnly _interval As Long
Private ReadOnly _logConfig As LogConfig
Private ReadOnly _logger As Logger
+ Private ReadOnly _mssql As MSSQLServer
Private ReadOnly _firebird As Firebird
- Public Sub New(LogConfig As LogConfig, Firebird As Firebird, Interval As Long)
+ Public Sub New(LogConfig As LogConfig, Firebird As Firebird, MSSQL As MSSQLServer, Interval As Long)
_logConfig = LogConfig
_logger = _logConfig.GetLogger()
_firebird = Firebird
+ _mssql = MSSQL
_interval = Interval
_workerTimer = New Timer()
@@ -58,7 +60,7 @@ Public Class JobRunner
_logger.Debug("Background worker running..")
Dim args As WorkerArgs = e.Argument
- Dim oJob As New ADSyncJob(_logConfig, _firebird)
+ Dim oJob As New ADSyncJob(_logConfig, _firebird, _mssql)
Dim oArgs As New ADSyncArgs() With {
.Enabled = My.Settings.JOB_ADSYNC_ENABLED,
.Interval = My.Settings.JOB_ADSYNC_INTERVAL,
diff --git a/JobRunner/JobRunner.vbproj b/JobRunner/JobRunner.vbproj
index 37a3ec1f..47235060 100644
--- a/JobRunner/JobRunner.vbproj
+++ b/JobRunner/JobRunner.vbproj
@@ -51,6 +51,9 @@
..\packages\NLog.4.5.11\lib\net45\NLog.dll
+
+ ..\packages\Quartz.3.0.7\lib\net452\Quartz.dll
+
@@ -58,6 +61,7 @@
+
@@ -82,6 +86,7 @@
+
True
Application.myapp
diff --git a/JobRunner/JobRunner2.vb b/JobRunner/JobRunner2.vb
new file mode 100644
index 00000000..d0fcea3e
--- /dev/null
+++ b/JobRunner/JobRunner2.vb
@@ -0,0 +1,113 @@
+Imports System.Collections.Specialized
+Imports DigitalData.Modules.Database
+Imports DigitalData.Modules.Jobs
+Imports DigitalData.Modules.Logging
+Imports Quartz
+Imports Quartz.Impl
+Imports Quartz.Logging
+
+Public Class JobRunner2
+ Private _LogConfig As LogConfig
+ Private _Logger As Modules.Logging.Logger
+ Private _firebird As Firebird
+ Private _mssql As MSSQLServer
+
+ Private _Props As New NameValueCollection From {
+ {"quartz.serializer.type", "binary"}
+ }
+ 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
+ End Sub
+
+ Public Async Sub Start()
+ Logging.LogProvider.SetCurrentLogProvider(New LogProvider(_Logger))
+
+ Dim oProps As New NameValueCollection From {
+ {"quartz.serializer.type", "binary"}
+ }
+ _factory = New StdSchedulerFactory(oProps)
+ _scheduler = Await _factory.GetScheduler()
+
+ Await _scheduler.Start()
+
+ Dim oJobData As New JobDataMap From {
+ {"LogConfig", _LogConfig},
+ {"Firebird", _firebird},
+ {"MSSQL", _mssql},
+ {"RootPath", My.Settings.JOB_ADSYNC_ROOT_PATH}
+ }
+
+ Dim oJobDetail = JobBuilder.Create(Of ADJob)().
+ WithIdentity("activedirectory-sync").
+ UsingJobData(oJobData).
+ Build()
+
+ Dim oTrigger = TriggerBuilder.Create().
+ WithIdentity("activedirectory-sync-trigger").
+ StartNow().
+ WithCronSchedule("1 0 * * *").
+ Build()
+
+ Await _scheduler.ScheduleJob(oJobDetail, oTrigger)
+ End Sub
+
+ Public Async Sub [Stop]()
+ Await _scheduler.Shutdown()
+ End Sub
+
+ Public Class ADJob
+ Implements Quartz.IJob
+
+ Public Async Function Execute(context As IJobExecutionContext) As Task Implements Quartz.IJob.Execute
+ Dim oJobData = context.MergedJobDataMap
+ Dim oLogConfig As LogConfig = oJobData.Item("LogConfig")
+ Dim oFirebird As Firebird = oJobData.Item("Firebird")
+ Dim oMSSQL As MSSQLServer = oJobData.Item("MSSQL")
+ Dim oRootPath As String = oJobData.Item("RootPath")
+ Dim oADJobArgs = New ADSyncArgs() With {
+ .RootPath = oRootPath
+ }
+
+ Dim oADSyncJob As New ADSyncJob(oLogConfig, oFirebird, oMSSQL)
+ oADSyncJob.Start(oADJobArgs)
+
+ Await Task.CompletedTask
+ End Function
+ End Class
+
+ Private Class LogProvider
+ Implements ILogProvider
+
+ Private _Logger As Modules.Logging.Logger
+
+ Public Sub New(Logger As Modules.Logging.Logger)
+ MyBase.New()
+ _Logger = Logger
+ End Sub
+
+ Private Function GetLogger(name As String) As Logging.Logger Implements ILogProvider.GetLogger
+ Return Function(level, func, exception, parameters)
+ If level >= LogLevel.Info AndAlso func IsNot Nothing Then
+ _Logger.Info(func())
+ End If
+
+ Return True
+ End Function
+ End Function
+
+ Private Function OpenNestedContext(message As String) As IDisposable Implements ILogProvider.OpenNestedContext
+ Throw New NotImplementedException()
+ End Function
+
+ Private Function OpenMappedContext(key As String, value As String) As IDisposable Implements ILogProvider.OpenMappedContext
+ Throw New NotImplementedException()
+ End Function
+ End Class
+
+End Class
diff --git a/JobRunner/My Project/Settings.Designer.vb b/JobRunner/My Project/Settings.Designer.vb
index a28f946b..5416b196 100644
--- a/JobRunner/My Project/Settings.Designer.vb
+++ b/JobRunner/My Project/Settings.Designer.vb
@@ -143,6 +143,15 @@ Namespace My
Return CType(Me("JOB_ADSYNC_ROOT_PATH"),String)
End Get
End Property
+
+ _
+ Public ReadOnly Property DB_CONNECTIONSTRING() As String
+ Get
+ Return CType(Me("DB_CONNECTIONSTRING"),String)
+ End Get
+ End Property
End Class
End Namespace
diff --git a/JobRunner/My Project/Settings.settings b/JobRunner/My Project/Settings.settings
index 3281b731..85f45ced 100644
--- a/JobRunner/My Project/Settings.settings
+++ b/JobRunner/My Project/Settings.settings
@@ -32,5 +32,8 @@
+
+
+
\ No newline at end of file
diff --git a/JobRunner/WindowsService.vb b/JobRunner/WindowsService.vb
index cfca9dfa..b4ae1a08 100644
--- a/JobRunner/WindowsService.vb
+++ b/JobRunner/WindowsService.vb
@@ -7,8 +7,9 @@ Public Class WindowsService
Private _logConfig As LogConfig
Private _logger As Logger
Private _firebird As Firebird
+ Private _mssql As MSSQLServer
- Private _jobRunner As JobRunner
+ Private _jobRunner As JobRunner2
Protected Overrides Sub OnStart(ByVal args() As String)
_logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
@@ -23,13 +24,21 @@ Public Class WindowsService
Dim oInterval As Long = My.Settings.JOB_INTERVAL
_firebird = New Firebird(_logConfig, oDataSource, oDatabase, oUser, oPassword)
+ _mssql = New MSSQLServer(_logConfig, My.Settings.DB_CONNECTIONSTRING)
Try
- _jobRunner = New JobRunner(_logConfig, _firebird, oInterval)
+ _jobRunner = New JobRunner2(_logConfig, _mssql, _firebird)
_jobRunner.Start()
Catch ex As Exception
_logger.Error(ex)
End Try
+
+ 'Try
+ ' _jobRunner = New JobRunner(_logConfig, _firebird, oInterval)
+ ' _jobRunner.Start()
+ 'Catch ex As Exception
+ ' _logger.Error(ex)
+ 'End Try
End Sub
Protected Overrides Sub OnStop()
diff --git a/JobRunner/packages.config b/JobRunner/packages.config
index f89fa324..80a2f1fc 100644
--- a/JobRunner/packages.config
+++ b/JobRunner/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file