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