small changes and fixes for jobrunner
This commit is contained in:
parent
3bd9c04b9c
commit
0bf0f8a05d
@ -2,22 +2,28 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Public Class JobConfigParser
|
||||
Private Shared JobOptionsRegex As New Regex("(?<enabled>True|False)\|(?<cron>[\w\d\s,\?*-/]*)(?:\|(?<args>(?:\w*::\w*,?)*))?")
|
||||
Private Shared JobArgumentsRegex As New Regex("(?:(?:\w+::\w+,?)?)+")
|
||||
Private Shared JobOptionsRegex As New Regex("(?<enabled>True|False)\|(?<cron>[\w\d\s,\?*-/]*)(?:\|(?<args>(?:\w*::[^,\n]+,?)*))?")
|
||||
Private Shared JobArgumentsRegex As New Regex("(?:(?:\w+::[^,\n]+,?)?)+")
|
||||
Private Const ARGS_ITEM_DELIMITER As String = ","
|
||||
Private Const ARGS_KEYVALUE_DELIMITER As String = "::"
|
||||
Private Const ARGS_LIST_DELIMITER As String = "|"
|
||||
|
||||
|
||||
Public Shared Function ParseConfig(ConfigString As String) As JobConfig
|
||||
If JobOptionsRegex.IsMatch(ConfigString) Then
|
||||
Dim oMatches = JobOptionsRegex.Matches(ConfigString)
|
||||
Dim oOptions As New JobConfig
|
||||
|
||||
If oMatches.Count = 1 Then
|
||||
Dim oMatch = oMatches.Item(0)
|
||||
Dim oSplitOptions As String() = ConfigString.Split(ARGS_LIST_DELIMITER)
|
||||
|
||||
oOptions.Enabled = CBool(oMatch.Groups("enabled").Value)
|
||||
oOptions.CronExpression = oMatch.Groups("cron").Value
|
||||
oOptions.Arguments = ParseOptionalArguments(oMatch.Groups("args").Value)
|
||||
If oSplitOptions.Length = 3 Then
|
||||
oOptions.Enabled = CBool(oSplitOptions(0))
|
||||
oOptions.CronExpression = oSplitOptions(1)
|
||||
oOptions.Arguments = New Dictionary(Of String, String)
|
||||
ElseIf oSplitOptions.Length = 2 Then
|
||||
oOptions.Enabled = CBool(oSplitOptions(0))
|
||||
oOptions.CronExpression = oSplitOptions(1)
|
||||
oOptions.Arguments = ParseOptionalArguments(oSplitOptions(2))
|
||||
Else
|
||||
Throw New ArgumentException("Config Malformed")
|
||||
End If
|
||||
@ -37,6 +43,7 @@ Public Class JobConfigParser
|
||||
For Each oArg In oArgs
|
||||
Dim oDelimiter As String() = New String() {ARGS_KEYVALUE_DELIMITER}
|
||||
Dim oArgSplit = oArg.Split(oDelimiter, StringSplitOptions.RemoveEmptyEntries)
|
||||
Regex.Split(oArg, "::")
|
||||
|
||||
If oArgSplit.Length = 2 Then
|
||||
oArgsDictionary.Add(oArgSplit(0), oArgSplit(1))
|
||||
|
||||
@ -52,8 +52,8 @@ Public Class ActiveDirectoryInterface
|
||||
Dim oSyncedUsers As New List(Of ADUser)
|
||||
Dim oGroupId As Int64 = Nothing
|
||||
|
||||
Dim oFirebirdSync As New SyncUsers.Firebird(_logConfig, _firebird)
|
||||
Dim oSQLSync As New SyncUsers.MSSQL(_logConfig, _mssql)
|
||||
Dim oFirebirdSync As New SyncUsers.FirebirdSync(_logConfig, _firebird)
|
||||
Dim oSQLSync As New SyncUsers.MSSQLSync(_logConfig, _mssql)
|
||||
Dim oSyncedUsersFirebird, oSyncedUsersMSSQL As List(Of ADUser)
|
||||
|
||||
Try
|
||||
@ -73,13 +73,17 @@ Public Class ActiveDirectoryInterface
|
||||
' Do the actual sync into firebird
|
||||
If _firebird IsNot Nothing Then
|
||||
oSyncedUsersFirebird = oFirebirdSync.SyncUsers(GroupName, oUsers, AttributeMappings)
|
||||
_logger.Info("Synced {0} users to Firebird", oSyncedUsersFirebird.Count)
|
||||
If oSyncedUsersFirebird.Count > 0 Then
|
||||
_logger.Info("Synced {0} users to Firebird", oSyncedUsersFirebird.Count)
|
||||
End If
|
||||
End If
|
||||
|
||||
' Do the actual sync into MSSQL
|
||||
If _mssql IsNot Nothing Then
|
||||
oSyncedUsersMSSQL = oSQLSync.SyncUsers(GroupName, oUsers, AttributeMappings)
|
||||
_logger.Info("Synced {0} users to MSSQLServer", oSyncedUsersMSSQL.Count)
|
||||
If oSyncedUsersMSSQL.Count > 0 Then
|
||||
_logger.Info("Synced {0} users to MSSQLServer", oSyncedUsersMSSQL.Count)
|
||||
End If
|
||||
End If
|
||||
|
||||
Return oUsers
|
||||
@ -180,7 +184,7 @@ Public Class ActiveDirectoryInterface
|
||||
_logger.Warn("Could not fetch CustomAttributes for user {0}", oUser)
|
||||
End If
|
||||
|
||||
_logger.Info("Trying to add User {0} to user list", oUser)
|
||||
_logger.Debug("Trying to add User {0} to user list", oUser)
|
||||
|
||||
Dim oNewUser As New ADUser With {
|
||||
.SId = oUser.Sid,
|
||||
|
||||
@ -3,7 +3,7 @@ Imports DigitalData.Modules.Interfaces
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace SyncUsers
|
||||
Public Class Firebird
|
||||
Public Class FirebirdSync
|
||||
Implements ISyncUsers
|
||||
|
||||
Private ReadOnly _logConfig As LogConfig
|
||||
@ -25,7 +25,7 @@ Namespace SyncUsers
|
||||
oGroupId = GetGroupId(GroupName)
|
||||
|
||||
If oGroupId = 0 Then
|
||||
_logger.Warn("Group {0} does not exist in database. Exiting", GroupName)
|
||||
_logger.Debug("Group {0} does not exist in database or is not enabled for sync.", GroupName)
|
||||
Return oSyncedUsers
|
||||
End If
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace SyncUsers
|
||||
Public Class MSSQL
|
||||
Public Class MSSQLSync
|
||||
Implements ISyncUsers
|
||||
|
||||
Private _logConfig As LogConfig
|
||||
|
||||
@ -14,7 +14,8 @@ Public Class JobRunner
|
||||
Private _mssql As MSSQLServer
|
||||
|
||||
Private _Props As New NameValueCollection From {
|
||||
{"quartz.serializer.type", "binary"}
|
||||
{"quartz.serializer.type", "binary"},
|
||||
{"quartz.threadPool.threadCount", 1}
|
||||
}
|
||||
Private _factory As StdSchedulerFactory
|
||||
Private _scheduler As IScheduler
|
||||
@ -98,11 +99,11 @@ Public Class JobRunner
|
||||
Dim oFirebird As Firebird = oJobData.Item("Firebird")
|
||||
Dim oMSSQL As MSSQLServer = oJobData.Item("MSSQL")
|
||||
Dim oArgs As Dictionary(Of String, String) = oJobData.Item("Args")
|
||||
Dim oRootPath As String = oArgs.Item("RootPath")
|
||||
Dim oADJobArgs = New ADSyncArgs()
|
||||
|
||||
Dim oADJobArgs = New ADSyncArgs() With {
|
||||
.RootPath = oRootPath
|
||||
}
|
||||
If oArgs.ContainsKey("RootPath") Then
|
||||
oADJobArgs.RootPath = oArgs.Item("RootPath")
|
||||
End If
|
||||
|
||||
Dim oADSyncJob As New ADSyncJob(oLogConfig, oFirebird, oMSSQL)
|
||||
oADSyncJob.Start(oADJobArgs)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user