diff --git a/DDMonorepo.sln b/DDMonorepo.sln
index 0019dc38..a21dd992 100644
--- a/DDMonorepo.sln
+++ b/DDMonorepo.sln
@@ -69,10 +69,10 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "License", "Modules.License\
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ADSyncTest", "GUIs.Test.ADSyncTest\ADSyncTest.vbproj", "{7386AB04-DF8D-4DFB-809D-1FAC8212CB7E}"
EndProject
-Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "JobRunner", "JobRunner\JobRunner.vbproj", "{59461E98-A5AF-438C-A651-5021ACAE82AD}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GUIs.Test", "GUIs.Test", "{CC368D6A-6AC4-4EB9-A092-14700FABEF7A}"
EndProject
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "JobRunner", "Service.JobRunner\JobRunner.vbproj", "{926E6474-5613-4373-BB99-B101158B91EF}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -175,10 +175,10 @@ Global
{7386AB04-DF8D-4DFB-809D-1FAC8212CB7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7386AB04-DF8D-4DFB-809D-1FAC8212CB7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7386AB04-DF8D-4DFB-809D-1FAC8212CB7E}.Release|Any CPU.Build.0 = Release|Any CPU
- {59461E98-A5AF-438C-A651-5021ACAE82AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {59461E98-A5AF-438C-A651-5021ACAE82AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {59461E98-A5AF-438C-A651-5021ACAE82AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {59461E98-A5AF-438C-A651-5021ACAE82AD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {926E6474-5613-4373-BB99-B101158B91EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {926E6474-5613-4373-BB99-B101158B91EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {926E6474-5613-4373-BB99-B101158B91EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {926E6474-5613-4373-BB99-B101158B91EF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -208,7 +208,7 @@ Global
{CBE9322E-67A1-4CC5-B25F-4A1B4C9FC55C} = {7AF3F9C2-C939-4A08-95C1-0453207E298A}
{5EBACBFA-F11A-4BBF-8D02-91461F2293ED} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC}
{7386AB04-DF8D-4DFB-809D-1FAC8212CB7E} = {CC368D6A-6AC4-4EB9-A092-14700FABEF7A}
- {59461E98-A5AF-438C-A651-5021ACAE82AD} = {7AF3F9C2-C939-4A08-95C1-0453207E298A}
+ {926E6474-5613-4373-BB99-B101158B91EF} = {7AF3F9C2-C939-4A08-95C1-0453207E298A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286}
diff --git a/GUIs.Test.ADSyncTest/Form1.vb b/GUIs.Test.ADSyncTest/Form1.vb
index 8e546f27..079f5f27 100644
--- a/GUIs.Test.ADSyncTest/Form1.vb
+++ b/GUIs.Test.ADSyncTest/Form1.vb
@@ -20,8 +20,6 @@ Public Class Form1
_sync = New ActiveDirectoryInterface(_logConfig, Nothing, _sql)
_sync.Authenticate()
-
-
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
diff --git a/JobRunner/JobRunner.vb b/JobRunner/JobRunner.vb
deleted file mode 100644
index 70a97413..00000000
--- a/JobRunner/JobRunner.vb
+++ /dev/null
@@ -1,83 +0,0 @@
-Imports System.ComponentModel
-Imports System.Timers
-Imports DigitalData.Modules.Database
-Imports DigitalData.Modules.Jobs
-Imports DigitalData.Modules.Logging
-
-Public Class JobRunner
- Private WithEvents _workerThread As BackgroundWorker
- Private WithEvents _workerTimer As Timer
-
- 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, MSSQL As MSSQLServer, Interval As Long)
- _logConfig = LogConfig
- _logger = _logConfig.GetLogger()
- _firebird = Firebird
- _mssql = MSSQL
- _interval = Interval
-
- _workerTimer = New Timer()
- _workerThread = New BackgroundWorker() With {
- .WorkerReportsProgress = True,
- .WorkerSupportsCancellation = True
- }
- End Sub
-
- Public Sub Start()
- _workerTimer.Interval = _interval * 1000
- _workerTimer.Start()
- _logger.Debug("JobRunner started with {0}s Interval.", _interval)
- End Sub
-
- Public Sub [Stop]()
- Try
- _logger.Debug("Stopping Background worker...")
- If _workerThread.IsBusy Then
- _workerThread.CancelAsync()
- _logger.Debug("Background Worker cancelled.")
- End If
- _workerTimer.Stop()
- _logger.Debug("Background Worker stopped.")
- Catch ex As Exception
- _logger.Error(ex)
- End Try
- End Sub
-
- Private Sub TimerElapsed(sender As Object, e As ElapsedEventArgs) Handles _workerTimer.Elapsed
- If Not _workerThread.IsBusy Then
- _workerThread.RunWorkerAsync()
- Else
- _logger.Warn("Background Worker is busy. Waiting for next interval.")
- End If
- End Sub
-
- Private Sub DoWork(sender As Object, e As DoWorkEventArgs) Handles _workerThread.DoWork
- _logger.Debug("Background worker running..")
-
- Dim args As WorkerArgs = e.Argument
- 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,
- .RootPath = My.Settings.JOB_ADSYNC_ROOT_PATH
- }
-
- If oJob.ShouldStart(oArgs) Then
- oJob.Start(oArgs)
- End If
- End Sub
-
- Private Sub WorkCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles _workerThread.RunWorkerCompleted
- If e.Error Is Nothing Then
- _logger.Debug("Background worker completed!")
- Else
- _logger.Warn("Background worker failed!")
- _logger.Error(e.Error)
- End If
- End Sub
-End Class
diff --git a/JobRunner/My Project/Settings.settings b/JobRunner/My Project/Settings.settings
deleted file mode 100644
index 85f45ced..00000000
--- a/JobRunner/My Project/Settings.settings
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
- DDJobRunner
-
-
- Digital Data Job Runner
-
-
- False
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 120
-
-
- 120
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/JobRunner/ProjectInstaller.vb b/JobRunner/ProjectInstaller.vb
deleted file mode 100644
index e066985c..00000000
--- a/JobRunner/ProjectInstaller.vb
+++ /dev/null
@@ -1,24 +0,0 @@
-Imports System.ComponentModel
-Imports System.Configuration.Install
-Imports System.ServiceProcess
-
-
-Public Class ProjectInstaller
- Inherits Installer
-
- Private ReadOnly process As ServiceProcessInstaller
- Private ReadOnly components As IContainer
- Private ReadOnly service As ServiceInstaller
-
- Public Sub New()
- process = New ServiceProcessInstaller With {
- .Account = ServiceAccount.LocalSystem
- }
- service = New ServiceInstaller With {
- .ServiceName = My.Settings.SERVICE_NAME,
- .DisplayName = My.Settings.SERVICE_DISPLAY_NAME
- }
- Installers.Add(process)
- Installers.Add(service)
- End Sub
-End Class
diff --git a/JobRunner/WindowsService.vb b/JobRunner/WindowsService.vb
deleted file mode 100644
index b4ae1a08..00000000
--- a/JobRunner/WindowsService.vb
+++ /dev/null
@@ -1,48 +0,0 @@
-Imports System.IO
-Imports DigitalData.Modules.Database
-Imports DigitalData.Modules.Logging
-Imports DigitalData.Modules.Logging.LogConfig
-
-Public Class WindowsService
- Private _logConfig As LogConfig
- Private _logger As Logger
- Private _firebird As Firebird
- Private _mssql As MSSQLServer
-
- Private _jobRunner As JobRunner2
-
- Protected Overrides Sub OnStart(ByVal args() As String)
- _logConfig = New LogConfig(PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
- _logConfig.Debug = True
- _logger = _logConfig.GetLogger()
- _logger.Info($"{My.Settings.SERVICE_NAME} is starting.")
-
- Dim oDataSource As String = My.Settings.DB_DATASOURCE
- Dim oDatabase As String = My.Settings.DB_DATABASE
- Dim oUser As String = My.Settings.DB_USER
- Dim oPassword As String = My.Settings.DB_PASSWORD
- 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 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()
- _jobRunner.Stop()
- _logger.Info($"{My.Settings.SERVICE_NAME} is stopping.")
- End Sub
-End Class
diff --git a/Jobs/EDMI/ADSync/ADSyncJob.vb b/Jobs/EDMI/ADSync/ADSyncJob.vb
index dfd4c223..34020432 100644
--- a/Jobs/EDMI/ADSync/ADSyncJob.vb
+++ b/Jobs/EDMI/ADSync/ADSyncJob.vb
@@ -13,33 +13,39 @@ Public Class ADSyncJob
End Sub
Public Sub Start(Arguments As ADSyncArgs) Implements IJob(Of ADSyncArgs).Start
- Dim oSync = New ActiveDirectoryInterface(_LogConfig, _Firebird, _MSSQL, Arguments.RootPath)
Dim oJobName As String = [GetType]().Name
- _Logger.Info("Running job {0}", oJobName)
+ Try
+ Dim oSync = New ActiveDirectoryInterface(_LogConfig, _Firebird, _MSSQL, Arguments.RootPath)
- If oSync.Authenticate() = False Then
- _Logger.Warn("Job {0} could not be completed! Authentication failed!", oJobName)
- Exit Sub
- End If
- Dim oGroups As List(Of ADGroup) = oSync.ListGroups()
+ _Logger.Info("Running job {0}", oJobName)
- _Logger.Debug("Found {0} Groups", oGroups.Count)
-
- For Each oGroup In oGroups
- _Logger.Debug("Syncing Group {0}", oGroup.Name)
- Dim oSyncedUsers = oSync.SyncUsersForGroup(oGroup.Name)
-
- If oSyncedUsers Is Nothing Then
- _Logger.Warn("Group {0} could not be synced!", oGroup)
- Else
- _Logger.Debug("Group {0} synced", oGroup)
- _Logger.Debug("Synced {0} users", oSyncedUsers.Count)
+ If oSync.Authenticate() = False Then
+ _Logger.Warn("Job {0} could not be completed! Authentication failed!", oJobName)
+ Exit Sub
End If
- Next
- _Logger.Info("Job {0} completed!", oJobName)
+ Dim oGroups As List(Of ADGroup) = oSync.ListGroups()
+
+ _Logger.Debug("Found {0} Groups", oGroups.Count)
+
+ For Each oGroup In oGroups
+ _Logger.Debug("Syncing Group {0}", oGroup.Name)
+ Dim oSyncedUsers = oSync.SyncUsersForGroup(oGroup.Name)
+
+ If oSyncedUsers Is Nothing Then
+ _Logger.Warn("Group {0} could not be synced!", oGroup)
+ Else
+ _Logger.Debug("Synced {0} users for group {1}", oSyncedUsers.Count, oGroup)
+ End If
+ Next
+
+ _Logger.Info("Job {0} completed!", oJobName)
+ Catch ex As Exception
+ _Logger.Warn("Job {0} failed!", oJobName)
+ _Logger.Error(ex)
+ End Try
End Sub
Public Function ShouldStart(Arguments As ADSyncArgs) As Boolean Implements IJob(Of ADSyncArgs).ShouldStart
diff --git a/Modules.Interfaces/ActiveDirectoryInterface.vb b/Modules.Interfaces/ActiveDirectoryInterface.vb
index d3e8d8df..49e81a03 100644
--- a/Modules.Interfaces/ActiveDirectoryInterface.vb
+++ b/Modules.Interfaces/ActiveDirectoryInterface.vb
@@ -34,10 +34,17 @@ Public Class ActiveDirectoryInterface
Else
_rootPath = RootPath
End If
+
+ _logger.Info("Using RootPath {0}", _rootPath)
End Sub
Public Function SyncUsersForGroup(GroupName As String) As List(Of ADUser)
- Return SyncUsersForGroup(GroupName, New List(Of AttributeMapping))
+ Try
+ Return SyncUsersForGroup(GroupName, New List(Of AttributeMapping))
+ Catch ex As Exception
+ _logger.Error(ex)
+ Return Nothing
+ End Try
End Function
Public Function SyncUsersForGroup(GroupName As String, AttributeMappings As List(Of AttributeMapping)) As List(Of ADUser)
@@ -143,39 +150,53 @@ Public Class ActiveDirectoryInterface
Return oUsers
End If
+ _logger.Debug("Listing members of Group {0}", GroupName)
+
Using oMembers = oGroupPrincipal.GetMembers(True)
For Each oMember As Principal In oMembers
- If TypeOf oMember Is UserPrincipal Then
- Dim oUser As UserPrincipal = DirectCast(oMember, UserPrincipal)
- Dim oUserEx As UserPrincipalEx = UserPrincipalEx.FindByIdentity(oContext, oUser.SamAccountName)
- Dim oCustomAttributes As New List(Of ADUser.CustomAttribute)
+ Try
+ If TypeOf oMember Is UserPrincipal Then
+ Dim oUser As UserPrincipal = DirectCast(oMember, UserPrincipal)
+ Dim oUserEx As UserPrincipalEx = UserPrincipalEx.FindByIdentity(oContext, oUser.SamAccountName)
+ Dim oCustomAttributes As New List(Of ADUser.CustomAttribute)
- For Each oMap As AttributeMapping In AttributeMappings
- Dim oAttributeValue = oUserEx.GetAttributeValue(oMap.AttributeName)
+ ' TODO: Figure out why oUserEx can be nothing for certain users
+ If oUserEx IsNot Nothing Then
+ For Each oMap As AttributeMapping In AttributeMappings
+ Dim oAttributeValue = oUserEx.GetAttributeValue(oMap.AttributeName)
- If oAttributeValue <> String.Empty Then
- _logger.Debug("Attribute {0} is not empty.", oMap.AttributeName)
+ If oAttributeValue <> String.Empty Then
+ _logger.Debug("Attribute {0} is not empty.", oMap.AttributeName)
- oCustomAttributes.Add(New ADUser.CustomAttribute() With {
- .Name = oMap.AttributeName,
- .Value = oAttributeValue,
- .FirebirdSyskey = oMap.FirebirdSyskey,
- .MSSQLColumn = oMap.MSSQLColumn
- })
+ oCustomAttributes.Add(New ADUser.CustomAttribute() With {
+ .Name = oMap.AttributeName,
+ .Value = oAttributeValue,
+ .FirebirdSyskey = oMap.FirebirdSyskey,
+ .MSSQLColumn = oMap.MSSQLColumn
+ })
+ End If
+ Next
+ Else
+ _logger.Warn("Could not fetch CustomAttributes for user {0}", oUser)
End If
- Next
- oUsers.Add(New ADUser() With {
- .GUID = oUserEx.Guid,
- .SId = oUserEx.Sid,
- .samAccountName = oUserEx.SamAccountName,
- .Surname = oUserEx.Surname,
- .Middlename = oUserEx.MiddleName,
- .GivenName = oUserEx.GivenName,
- .Email = oUserEx.EmailAddress,
- .CustomAttributes = oCustomAttributes
- })
- End If
+ _logger.Info("Trying to add User {0} to user list", oUser)
+
+ Dim oNewUser As New ADUser With {
+ .SId = oUser.Sid,
+ .samAccountName = oUser.SamAccountName,
+ .Middlename = oUser.MiddleName,
+ .GivenName = oUser.GivenName,
+ .Email = oUser.EmailAddress,
+ .CustomAttributes = oCustomAttributes
+ }
+
+ oUsers.Add(oNewUser)
+ End If
+ Catch ex As Exception
+ _logger.Warn("User could not be processed")
+ _logger.Error(ex)
+ End Try
Next
End Using
End Using
@@ -184,7 +205,7 @@ Public Class ActiveDirectoryInterface
Return oUsers
Catch ex As Exception
_logger.Error(ex)
- Throw ex
+ Return oUsers
End Try
End Function
@@ -229,7 +250,7 @@ Public Class ActiveDirectoryInterface
Try
Return Result.Properties.Item(PropertyName).Item(0)
Catch ex As Exception
- _logger.Warn("Property {0} not found")
+ _logger.Warn("Property {0} not found", PropertyName)
Return String.Empty
End Try
End Function
diff --git a/Modules.Interfaces/ActiveDirectoryInterface/ActiveDirectoryGroup.vb b/Modules.Interfaces/ActiveDirectoryInterface/ActiveDirectoryGroup.vb
index 8535f34b..6cee7990 100644
--- a/Modules.Interfaces/ActiveDirectoryInterface/ActiveDirectoryGroup.vb
+++ b/Modules.Interfaces/ActiveDirectoryInterface/ActiveDirectoryGroup.vb
@@ -8,6 +8,6 @@
Public ObjectCategory As String
Public Overrides Function ToString() As String
- Return $"SAMAccountName={SAMAccountName}, ObjectClass={ObjectClass}, CN={CN}, Description={Description}, DistinguishedName={DistinguishedName}, Name={Name}, ObjectCategory={ObjectCategory}"
+ Return $"SAMAccountName={SAMAccountName}"
End Function
End Class
diff --git a/JobRunner/App.config b/Service.JobRunner/App.config
similarity index 50%
rename from JobRunner/App.config
rename to Service.JobRunner/App.config
index 3249a680..3c284e0b 100644
--- a/JobRunner/App.config
+++ b/Service.JobRunner/App.config
@@ -5,42 +5,27 @@
-
-
-
-
- DDJobRunner
-
-
- Digital Data Job Runner
-
-
- False
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 120
-
-
- 120
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/JobRunner/JobRunner2.vb b/Service.JobRunner/JobRunner.vb
similarity index 50%
rename from JobRunner/JobRunner2.vb
rename to Service.JobRunner/JobRunner.vb
index d0fcea3e..6908bf59 100644
--- a/JobRunner/JobRunner2.vb
+++ b/Service.JobRunner/JobRunner.vb
@@ -6,9 +6,9 @@ Imports Quartz
Imports Quartz.Impl
Imports Quartz.Logging
-Public Class JobRunner2
+Public Class JobRunner
Private _LogConfig As LogConfig
- Private _Logger As Modules.Logging.Logger
+ Private _Logger As DigitalData.Modules.Logging.Logger
Private _firebird As Firebird
Private _mssql As MSSQLServer
@@ -26,45 +26,56 @@ Public Class JobRunner2
End Sub
Public Async Sub Start()
- Logging.LogProvider.SetCurrentLogProvider(New LogProvider(_Logger))
+ Try
+ Logging.LogProvider.SetCurrentLogProvider(New LogProvider(_Logger))
- Dim oProps As New NameValueCollection From {
- {"quartz.serializer.type", "binary"}
- }
- _factory = New StdSchedulerFactory(oProps)
- _scheduler = Await _factory.GetScheduler()
+ _Logger.Info("Starting JobRunner")
- Await _scheduler.Start()
+ Dim oProps As New NameValueCollection From {
+ {"quartz.serializer.type", "binary"}
+ }
+ _factory = New StdSchedulerFactory(oProps)
+ _scheduler = Await _factory.GetScheduler()
- Dim oJobData As New JobDataMap From {
- {"LogConfig", _LogConfig},
- {"Firebird", _firebird},
- {"MSSQL", _mssql},
- {"RootPath", My.Settings.JOB_ADSYNC_ROOT_PATH}
- }
+ _Logger.Info("Starting Scheduler..")
+ Await _scheduler.Start()
+ _Logger.Info("Done")
- Dim oJobDetail = JobBuilder.Create(Of ADJob)().
- WithIdentity("activedirectory-sync").
- UsingJobData(oJobData).
- Build()
+ Dim oJobData As New JobDataMap From {
+ {"LogConfig", _LogConfig},
+ {"Firebird", _firebird},
+ {"MSSQL", _mssql},
+ {"RootPath", My.Settings.JOB_ADSYNC_ROOT_PATH}
+ }
- Dim oTrigger = TriggerBuilder.Create().
- WithIdentity("activedirectory-sync-trigger").
- StartNow().
- WithCronSchedule("1 0 * * *").
- Build()
+ Dim oJobDetail = JobBuilder.Create(Of ADJob)().
+ WithIdentity("activedirectory-sync").
+ UsingJobData(oJobData).
+ Build()
- Await _scheduler.ScheduleJob(oJobDetail, oTrigger)
+ 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.Error(ex)
+ End Try
End Sub
Public Async Sub [Stop]()
+ _Logger.Info("Stopping JobRunner")
Await _scheduler.Shutdown()
End Sub
Public Class ADJob
Implements Quartz.IJob
- Public Async Function Execute(context As IJobExecutionContext) As Task Implements Quartz.IJob.Execute
+ Public 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")
@@ -77,24 +88,28 @@ Public Class JobRunner2
Dim oADSyncJob As New ADSyncJob(oLogConfig, oFirebird, oMSSQL)
oADSyncJob.Start(oADJobArgs)
- Await Task.CompletedTask
+ Return Task.FromResult(True)
End Function
End Class
Private Class LogProvider
Implements ILogProvider
- Private _Logger As Modules.Logging.Logger
+ Private _Logger As DigitalData.Modules.Logging.Logger
- Public Sub New(Logger As Modules.Logging.Logger)
+ Public Sub New(Logger As DigitalData.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())
+ If exception IsNot Nothing Then
+ _Logger.Error(exception)
+ ElseIf level >= LogLevel.Debug AndAlso func IsNot Nothing Then
+ _Logger.Debug(func(), parameters)
+ ElseIf level >= LogLevel.Info AndAlso func IsNot Nothing Then
+ _Logger.Info(func(), parameters)
End If
Return True
@@ -102,10 +117,12 @@ Public Class JobRunner2
End Function
Private Function OpenNestedContext(message As String) As IDisposable Implements ILogProvider.OpenNestedContext
+ _Logger.Warn("OpenNestedContext is not implemented")
Throw New NotImplementedException()
End Function
Private Function OpenMappedContext(key As String, value As String) As IDisposable Implements ILogProvider.OpenMappedContext
+ _Logger.Warn("OpenMappedContext is not implemented")
Throw New NotImplementedException()
End Function
End Class
diff --git a/JobRunner/JobRunner.vbproj b/Service.JobRunner/JobRunner.vbproj
similarity index 86%
rename from JobRunner/JobRunner.vbproj
rename to Service.JobRunner/JobRunner.vbproj
index 47235060..aa9af41c 100644
--- a/JobRunner/JobRunner.vbproj
+++ b/Service.JobRunner/JobRunner.vbproj
@@ -4,9 +4,9 @@
Debug
AnyCPU
- {59461E98-A5AF-438C-A651-5021ACAE82AD}
+ {926E6474-5613-4373-BB99-B101158B91EF}
WinExe
- DigitalData.Services.JobRunner.WindowsService
+ DigitalData.Services.JobRunner.JobRunnerService
DigitalData.Services.JobRunner
DigitalData.Services.JobRunner
512
@@ -46,10 +46,13 @@
On
+
+ My Project\app.manifest
+
- ..\packages\NLog.4.5.11\lib\net45\NLog.dll
+ ..\packages\NLog.4.6.2\lib\net45\NLog.dll
..\packages\Quartz.3.0.7\lib\net452\Quartz.dll
@@ -59,14 +62,12 @@
-
-
@@ -86,19 +87,15 @@
-
True
Application.myapp
-
+
Component
-
- Component
-
-
- WindowsService.vb
+
+ JobRunnerService.vb
@@ -111,19 +108,29 @@
Settings.settings
True
+
+ ProjectInstaller.vb
+
+
+ Component
+
+
+ JobRunnerService.vb
+
VbMyResourcesResXFileCodeGenerator
Resources.Designer.vb
My.Resources
Designer
-
- WindowsService.vb
+
+ ProjectInstaller.vb
+
MyApplicationCodeGenerator
Application.Designer.vb
@@ -138,7 +145,7 @@
- {39ec839a-3c30-4922-a41e-6b09d1dde5c3}
+ {39EC839A-3C30-4922-A41E-6B09D1DDE5C3}
Jobs
diff --git a/JobRunner/WindowsService.Designer.vb b/Service.JobRunner/JobRunnerService.Designer.vb
similarity index 82%
rename from JobRunner/WindowsService.Designer.vb
rename to Service.JobRunner/JobRunnerService.Designer.vb
index fb0f2814..8d45e9e1 100644
--- a/JobRunner/WindowsService.Designer.vb
+++ b/Service.JobRunner/JobRunnerService.Designer.vb
@@ -1,11 +1,11 @@
Imports System.ServiceProcess
-
-Partial Class WindowsService
+ _
+Partial Class JobRunnerService
Inherits System.ServiceProcess.ServiceBase
'UserService überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
-
+ _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
@@ -17,8 +17,8 @@ Partial Class WindowsService
End Sub
' Der Haupteinstiegspunkt für den Prozess
-
-
+ _
+ _
Shared Sub Main()
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
@@ -28,7 +28,7 @@ Partial Class WindowsService
'
' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
'
- ServicesToRun = New System.ServiceProcess.ServiceBase() {New WindowsService}
+ ServicesToRun = New System.ServiceProcess.ServiceBase() {New JobRunnerService}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
End Sub
@@ -39,12 +39,14 @@ Partial Class WindowsService
' Hinweis: Die folgende Prozedur ist für den Komponenten-Designer erforderlich.
' Das Bearbeiten ist mit dem Komponenten-Designer möglich.
' Das Bearbeiten mit dem Code-Editor ist nicht möglich.
-
+ _
Private Sub InitializeComponent()
'
- 'Service1
+ 'JobRunnerService
'
- Me.ServiceName = "Service1"
+ Me.CanShutdown = True
+ Me.ServiceName = "DDJobRunner"
End Sub
+
End Class
diff --git a/JobRunner/WindowsService.resx b/Service.JobRunner/JobRunnerService.resx
similarity index 100%
rename from JobRunner/WindowsService.resx
rename to Service.JobRunner/JobRunnerService.resx
diff --git a/Service.JobRunner/JobRunnerService.vb b/Service.JobRunner/JobRunnerService.vb
new file mode 100644
index 00000000..fef04489
--- /dev/null
+++ b/Service.JobRunner/JobRunnerService.vb
@@ -0,0 +1,38 @@
+Imports DigitalData.Modules.Logging
+Imports DigitalData.Modules.Logging.LogConfig
+Imports DigitalData.Modules.Database
+Imports DigitalData.Services.JobRunner
+
+Public Class JobRunnerService
+ Private _logConfig As LogConfig
+ Private _logger As Logger
+ 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)
+ _logConfig.Debug = True
+ _logger = _logConfig.GetLogger()
+ _logger.Info("Starting Service {0}", ServiceName)
+
+ 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)
+ Catch ex As Exception
+ _logger.Error(ex)
+ End Try
+
+ Try
+ _jobrunner = New JobRunner(_logConfig, _mssql, _firebird)
+ _jobrunner.Start()
+ Catch ex As Exception
+ _logger.Error(ex)
+ End Try
+ End Sub
+
+ Protected Overrides Sub OnStop()
+ _jobrunner.Stop()
+ _logger.Info("Stopping Service {0}", ServiceName)
+ End Sub
+End Class
diff --git a/JobRunner/My Project/Application.Designer.vb b/Service.JobRunner/My Project/Application.Designer.vb
similarity index 100%
rename from JobRunner/My Project/Application.Designer.vb
rename to Service.JobRunner/My Project/Application.Designer.vb
diff --git a/JobRunner/My Project/Application.myapp b/Service.JobRunner/My Project/Application.myapp
similarity index 100%
rename from JobRunner/My Project/Application.myapp
rename to Service.JobRunner/My Project/Application.myapp
diff --git a/JobRunner/My Project/AssemblyInfo.vb b/Service.JobRunner/My Project/AssemblyInfo.vb
similarity index 87%
rename from JobRunner/My Project/AssemblyInfo.vb
rename to Service.JobRunner/My Project/AssemblyInfo.vb
index df2bc85e..9c9ed951 100644
--- a/JobRunner/My Project/AssemblyInfo.vb
+++ b/Service.JobRunner/My Project/AssemblyInfo.vb
@@ -8,17 +8,17 @@ Imports System.Runtime.InteropServices
' Werte der Assemblyattribute überprüfen
-
+
-
+
'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
-
+
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
'
diff --git a/JobRunner/My Project/Resources.Designer.vb b/Service.JobRunner/My Project/Resources.Designer.vb
similarity index 100%
rename from JobRunner/My Project/Resources.Designer.vb
rename to Service.JobRunner/My Project/Resources.Designer.vb
diff --git a/JobRunner/My Project/Resources.resx b/Service.JobRunner/My Project/Resources.resx
similarity index 100%
rename from JobRunner/My Project/Resources.resx
rename to Service.JobRunner/My Project/Resources.resx
diff --git a/JobRunner/My Project/Settings.Designer.vb b/Service.JobRunner/My Project/Settings.Designer.vb
similarity index 68%
rename from JobRunner/My Project/Settings.Designer.vb
rename to Service.JobRunner/My Project/Settings.Designer.vb
index 5416b196..edc05f59 100644
--- a/JobRunner/My Project/Settings.Designer.vb
+++ b/Service.JobRunner/My Project/Settings.Designer.vb
@@ -54,87 +54,6 @@ Namespace My
End Get
End Property
- _
- Public ReadOnly Property SERVICE_NAME() As String
- Get
- Return CType(Me("SERVICE_NAME"),String)
- End Get
- End Property
-
- _
- Public ReadOnly Property SERVICE_DISPLAY_NAME() As String
- Get
- Return CType(Me("SERVICE_DISPLAY_NAME"),String)
- End Get
- End Property
-
- _
- Public ReadOnly Property JOB_ADSYNC_ENABLED() As Boolean
- Get
- Return CType(Me("JOB_ADSYNC_ENABLED"),Boolean)
- End Get
- End Property
-
- _
- Public ReadOnly Property DB_DATASOURCE() As String
- Get
- Return CType(Me("DB_DATASOURCE"),String)
- End Get
- End Property
-
- _
- Public ReadOnly Property DB_DATABASE() As String
- Get
- Return CType(Me("DB_DATABASE"),String)
- End Get
- End Property
-
- _
- Public ReadOnly Property DB_USER() As String
- Get
- Return CType(Me("DB_USER"),String)
- End Get
- End Property
-
- _
- Public ReadOnly Property DB_PASSWORD() As String
- Get
- Return CType(Me("DB_PASSWORD"),String)
- End Get
- End Property
-
- _
- Public ReadOnly Property JOB_INTERVAL() As Long
- Get
- Return CType(Me("JOB_INTERVAL"),Long)
- End Get
- End Property
-
- _
- Public ReadOnly Property JOB_ADSYNC_INTERVAL() As Long
- Get
- Return CType(Me("JOB_ADSYNC_INTERVAL"),Long)
- End Get
- End Property
-
_
@@ -147,9 +66,54 @@ Namespace My
_
- Public ReadOnly Property DB_CONNECTIONSTRING() As String
+ Public ReadOnly Property LOG_PATH() As String
Get
- Return CType(Me("DB_CONNECTIONSTRING"),String)
+ Return CType(Me("LOG_PATH"),String)
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property SQL_CONNECTIONSTRING() As String
+ Get
+ Return CType(Me("SQL_CONNECTIONSTRING"),String)
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property FIREBIRD_SERVER() As String
+ Get
+ Return CType(Me("FIREBIRD_SERVER"),String)
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property FIREBIRD_DATABASE() As String
+ Get
+ Return CType(Me("FIREBIRD_DATABASE"),String)
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property FIREBIRD_USER() As String
+ Get
+ Return CType(Me("FIREBIRD_USER"),String)
+ End Get
+ End Property
+
+ _
+ Public ReadOnly Property FIREBIRD_PASSWORD() As String
+ Get
+ Return CType(Me("FIREBIRD_PASSWORD"),String)
End Get
End Property
End Class
diff --git a/Service.JobRunner/My Project/Settings.settings b/Service.JobRunner/My Project/Settings.settings
new file mode 100644
index 00000000..7291f536
--- /dev/null
+++ b/Service.JobRunner/My Project/Settings.settings
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Service.JobRunner/My Project/app.manifest b/Service.JobRunner/My Project/app.manifest
new file mode 100644
index 00000000..ef881eb8
--- /dev/null
+++ b/Service.JobRunner/My Project/app.manifest
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Service.JobRunner/ProjectInstaller.Designer.vb b/Service.JobRunner/ProjectInstaller.Designer.vb
new file mode 100644
index 00000000..2b041329
--- /dev/null
+++ b/Service.JobRunner/ProjectInstaller.Designer.vb
@@ -0,0 +1,47 @@
+ Partial Class ProjectInstaller
+ Inherits System.Configuration.Install.Installer
+
+ 'Installer überschreibt den Löschvorgang zum Bereinigen der Komponentenliste.
+ _
+ Protected Overrides Sub Dispose(ByVal disposing As Boolean)
+ Try
+ If disposing AndAlso components IsNot Nothing Then
+ components.Dispose()
+ End If
+ Finally
+ MyBase.Dispose(disposing)
+ End Try
+ End Sub
+
+ 'Wird vom Komponenten-Designer benötigt.
+ Private components As System.ComponentModel.IContainer
+
+ 'Hinweis: Die folgende Prozedur ist für den Komponenten-Designer erforderlich.
+ 'Das Bearbeiten ist mit dem Komponenten-Designer möglich.
+ 'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
+
+ Private Sub InitializeComponent()
+ Me.ServiceProcessInstaller = New System.ServiceProcess.ServiceProcessInstaller()
+ Me.ServiceInstaller = New System.ServiceProcess.ServiceInstaller()
+ '
+ 'ServiceProcessInstaller
+ '
+ Me.ServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem
+ Me.ServiceProcessInstaller.Password = Nothing
+ Me.ServiceProcessInstaller.Username = Nothing
+ '
+ 'ServiceInstaller
+ '
+ Me.ServiceInstaller.DelayedAutoStart = True
+ Me.ServiceInstaller.DisplayName = "Digital Data Job Runner"
+ Me.ServiceInstaller.ServiceName = "DDJobRunner"
+ '
+ 'ProjectInstaller
+ '
+ Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller, Me.ServiceInstaller})
+
+ End Sub
+
+ Friend WithEvents ServiceProcessInstaller As ServiceProcess.ServiceProcessInstaller
+ Friend WithEvents ServiceInstaller As ServiceProcess.ServiceInstaller
+End Class
diff --git a/Service.JobRunner/ProjectInstaller.resx b/Service.JobRunner/ProjectInstaller.resx
new file mode 100644
index 00000000..b187e235
--- /dev/null
+++ b/Service.JobRunner/ProjectInstaller.resx
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 22, 17
+
+
+ 197, 17
+
+
+ False
+
+
\ No newline at end of file
diff --git a/Service.JobRunner/ProjectInstaller.vb b/Service.JobRunner/ProjectInstaller.vb
new file mode 100644
index 00000000..733dfc0c
--- /dev/null
+++ b/Service.JobRunner/ProjectInstaller.vb
@@ -0,0 +1,16 @@
+Imports System.ComponentModel
+Imports System.Configuration.Install
+
+Public Class ProjectInstaller
+
+ Public Sub New()
+ MyBase.New()
+
+ 'Dieser Aufruf ist für den Komponenten-Designer erforderlich.
+ InitializeComponent()
+
+ 'Initialisierungscode nach dem Aufruf von InitializeComponent hinzufügen
+
+ End Sub
+
+End Class
diff --git a/JobRunner/packages.config b/Service.JobRunner/packages.config
similarity index 60%
rename from JobRunner/packages.config
rename to Service.JobRunner/packages.config
index 80a2f1fc..2f67f3fc 100644
--- a/JobRunner/packages.config
+++ b/Service.JobRunner/packages.config
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file