finish adsync for now, add test job
This commit is contained in:
@@ -7,9 +7,6 @@
|
||||
</configSections>
|
||||
<applicationSettings>
|
||||
<DigitalData.Services.JobRunner.My.MySettings>
|
||||
<setting name="JOB_ADSYNC_ROOT_PATH" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="LOG_PATH" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
@@ -28,6 +25,15 @@
|
||||
<setting name="FIREBIRD_PASSWORD" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="LOG_DEBUG" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="ADSYNC_CONFIG" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="TEST_CONFIG" serializeAs="String">
|
||||
<value>False|10/0 * * * * ?|Foo:Bar</value>
|
||||
</setting>
|
||||
</DigitalData.Services.JobRunner.My.MySettings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
@@ -1,4 +1,5 @@
|
||||
Imports System.Collections.Specialized
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Jobs
|
||||
Imports DigitalData.Modules.Logging
|
||||
@@ -39,34 +40,50 @@ Public Class JobRunner
|
||||
|
||||
_Logger.Info("Starting Scheduler..")
|
||||
Await _scheduler.Start()
|
||||
_Logger.Info("Done")
|
||||
|
||||
Dim oJobData As New JobDataMap From {
|
||||
{"LogConfig", _LogConfig},
|
||||
{"Firebird", _firebird},
|
||||
{"MSSQL", _mssql},
|
||||
{"RootPath", My.Settings.JOB_ADSYNC_ROOT_PATH}
|
||||
}
|
||||
' [START] Job Scheduling
|
||||
' ADSync
|
||||
Await ScheduleJob(Of ADJob)("ADSync", My.Settings.ADSYNC_CONFIG)
|
||||
' Test Job
|
||||
Await ScheduleJob(Of TestJob)("TestJob", My.Settings.TEST_CONFIG)
|
||||
' [END] Job Scheduling
|
||||
|
||||
Dim oJobDetail = JobBuilder.Create(Of ADJob)().
|
||||
WithIdentity("activedirectory-sync").
|
||||
UsingJobData(oJobData).
|
||||
Build()
|
||||
|
||||
Dim oTrigger = TriggerBuilder.Create().
|
||||
WithIdentity("activedirectory-sync-trigger").
|
||||
StartNow().
|
||||
WithCronSchedule("0 0/1 * * * ?").
|
||||
Build()
|
||||
|
||||
_Logger.Info("Starting ADSync Job..")
|
||||
Await _scheduler.ScheduleJob(oJobDetail, oTrigger)
|
||||
_Logger.Info("Done")
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Job Failed.")
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Async Function ScheduleJob(Of T As Quartz.IJob)(JobName As String, JobConfigString As String) As Task
|
||||
Dim oJobIdentity As String = JobName
|
||||
Dim oTriggerIdentity As String = JobName & "-Trigger"
|
||||
Dim oJobConfig As JobConfig = JobConfigParser.ParseConfig(JobConfigString)
|
||||
Dim oJobData As New JobDataMap From {
|
||||
{"LogConfig", _LogConfig},
|
||||
{"Firebird", _firebird},
|
||||
{"MSSQL", _mssql},
|
||||
{"Args", oJobConfig.Arguments}
|
||||
}
|
||||
|
||||
Dim oJobDetail = JobBuilder.Create(Of T)().
|
||||
WithIdentity(oJobIdentity).
|
||||
UsingJobData(oJobData).
|
||||
Build()
|
||||
|
||||
Dim oTrigger = TriggerBuilder.Create().
|
||||
WithIdentity(oTriggerIdentity).
|
||||
StartNow().
|
||||
WithCronSchedule(oJobConfig.CronExpression).
|
||||
Build()
|
||||
|
||||
If oJobConfig.Enabled Then
|
||||
Await _scheduler.ScheduleJob(oJobDetail, oTrigger)
|
||||
_Logger.Info("Job {0} started.", JobName)
|
||||
Else
|
||||
_Logger.Info("Job {0} is disabled.", JobName)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Async Sub [Stop]()
|
||||
_Logger.Info("Stopping JobRunner")
|
||||
Await _scheduler.Shutdown()
|
||||
@@ -80,7 +97,9 @@ Public Class JobRunner
|
||||
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 oArgs As Dictionary(Of String, String) = oJobData.Item("Args")
|
||||
Dim oRootPath As String = oArgs.Item("RootPath")
|
||||
|
||||
Dim oADJobArgs = New ADSyncArgs() With {
|
||||
.RootPath = oRootPath
|
||||
}
|
||||
@@ -91,6 +110,21 @@ Public Class JobRunner
|
||||
Return Task.FromResult(True)
|
||||
End Function
|
||||
End Class
|
||||
Public Class TestJob
|
||||
Implements Quartz.IJob
|
||||
|
||||
Public Function Execute(context As IJobExecutionContext) As Task Implements Quartz.IJob.Execute
|
||||
Dim oJobData = context.MergedJobDataMap
|
||||
Dim oLogConfig As LogConfig = oJobData.Item("LogConfig")
|
||||
Dim oArgs As Dictionary(Of String, String) = oJobData.Item("Args")
|
||||
Dim oArg1 As String = oArgs.Item("Arg1")
|
||||
Dim oLogger = oLogConfig.GetLogger()
|
||||
|
||||
oLogger.Info("Running Test Job With Arg1: {0}", oArg1)
|
||||
|
||||
Return Task.FromResult(True)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Private Class LogProvider
|
||||
Implements ILogProvider
|
||||
@@ -126,5 +160,4 @@ Public Class JobRunner
|
||||
Throw New NotImplementedException()
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Class
|
||||
|
||||
@@ -11,8 +11,9 @@ Public Class JobRunnerService
|
||||
Private _jobrunner As JobRunner
|
||||
|
||||
Protected Overrides Sub OnStart(ByVal args() As String)
|
||||
_logConfig = New LogConfig(PathType.CustomPath, My.Settings.LOG_PATH)
|
||||
_logConfig.Debug = True
|
||||
_logConfig = New LogConfig(PathType.CustomPath, My.Settings.LOG_PATH) With {
|
||||
.Debug = My.Settings.LOG_DEBUG
|
||||
}
|
||||
_logger = _logConfig.GetLogger()
|
||||
_logger.Info("Starting Service {0}", ServiceName)
|
||||
|
||||
|
||||
36
Service.JobRunner/My Project/Settings.Designer.vb
generated
36
Service.JobRunner/My Project/Settings.Designer.vb
generated
@@ -54,15 +54,6 @@ Namespace My
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property JOB_ADSYNC_ROOT_PATH() As String
|
||||
Get
|
||||
Return CType(Me("JOB_ADSYNC_ROOT_PATH"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
@@ -116,6 +107,33 @@ Namespace My
|
||||
Return CType(Me("FIREBIRD_PASSWORD"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("False")> _
|
||||
Public ReadOnly Property LOG_DEBUG() As Boolean
|
||||
Get
|
||||
Return CType(Me("LOG_DEBUG"),Boolean)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property ADSYNC_CONFIG() As String
|
||||
Get
|
||||
Return CType(Me("ADSYNC_CONFIG"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("False|10/0 * * * * ?|Foo:Bar")> _
|
||||
Public ReadOnly Property TEST_CONFIG() As String
|
||||
Get
|
||||
Return CType(Me("TEST_CONFIG"),String)
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="JOB_ADSYNC_ROOT_PATH" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="LOG_PATH" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
@@ -23,5 +20,14 @@
|
||||
<Setting Name="FIREBIRD_PASSWORD" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="LOG_DEBUG" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="ADSYNC_CONFIG" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="TEST_CONFIG" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">False|10/0 * * * * ?|Foo:Bar</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
Reference in New Issue
Block a user