JobRunner, ADInterface
This commit is contained in:
parent
2296b31519
commit
a8ed35aee2
@ -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}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
@ -1,39 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="SERVICE_NAME" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">DDJobRunner</Value>
|
||||
</Setting>
|
||||
<Setting Name="SERVICE_DISPLAY_NAME" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">Digital Data Job Runner</Value>
|
||||
</Setting>
|
||||
<Setting Name="JOB_ADSYNC_ENABLED" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="DB_DATASOURCE" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="DB_DATABASE" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="DB_USER" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="DB_PASSWORD" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="JOB_INTERVAL" Type="System.Int64" Scope="Application">
|
||||
<Value Profile="(Default)">120</Value>
|
||||
</Setting>
|
||||
<Setting Name="JOB_ADSYNC_INTERVAL" Type="System.Int64" Scope="Application">
|
||||
<Value Profile="(Default)">120</Value>
|
||||
</Setting>
|
||||
<Setting Name="JOB_ADSYNC_ROOT_PATH" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="DB_CONNECTIONSTRING" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@ -1,24 +0,0 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Configuration.Install
|
||||
Imports System.ServiceProcess
|
||||
|
||||
<RunInstaller(True)>
|
||||
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
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -5,42 +5,27 @@
|
||||
<section name="DigitalData.Services.JobRunner.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
<applicationSettings>
|
||||
<DigitalData.Services.JobRunner.My.MySettings>
|
||||
<setting name="SERVICE_NAME" serializeAs="String">
|
||||
<value>DDJobRunner</value>
|
||||
</setting>
|
||||
<setting name="SERVICE_DISPLAY_NAME" serializeAs="String">
|
||||
<value>Digital Data Job Runner</value>
|
||||
</setting>
|
||||
<setting name="JOB_ADSYNC_ENABLED" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="DB_DATASOURCE" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="DB_DATABASE" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="DB_USER" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="DB_PASSWORD" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="JOB_INTERVAL" serializeAs="String">
|
||||
<value>120</value>
|
||||
</setting>
|
||||
<setting name="JOB_ADSYNC_INTERVAL" serializeAs="String">
|
||||
<value>120</value>
|
||||
</setting>
|
||||
<setting name="JOB_ADSYNC_ROOT_PATH" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="DB_CONNECTIONSTRING" serializeAs="String">
|
||||
<setting name="LOG_PATH" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="SQL_CONNECTIONSTRING" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="FIREBIRD_SERVER" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="FIREBIRD_DATABASE" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="FIREBIRD_USER" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="FIREBIRD_PASSWORD" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</DigitalData.Services.JobRunner.My.MySettings>
|
||||
@ -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
|
||||
@ -4,9 +4,9 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{59461E98-A5AF-438C-A651-5021ACAE82AD}</ProjectGuid>
|
||||
<ProjectGuid>{926E6474-5613-4373-BB99-B101158B91EF}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<StartupObject>DigitalData.Services.JobRunner.WindowsService</StartupObject>
|
||||
<StartupObject>DigitalData.Services.JobRunner.JobRunnerService</StartupObject>
|
||||
<RootNamespace>DigitalData.Services.JobRunner</RootNamespace>
|
||||
<AssemblyName>DigitalData.Services.JobRunner</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
@ -46,10 +46,13 @@
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.6.2\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Quartz, Version=3.0.7.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Quartz.3.0.7\lib\net452\Quartz.dll</HintPath>
|
||||
@ -59,14 +62,12 @@
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Remoting" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@ -86,19 +87,15 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="JobRunner.vb" />
|
||||
<Compile Include="JobRunner2.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.vb">
|
||||
<Compile Include="JobRunnerService.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="WindowsService.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="WindowsService.Designer.vb">
|
||||
<DependentUpon>WindowsService.vb</DependentUpon>
|
||||
<Compile Include="JobRunnerService.Designer.vb">
|
||||
<DependentUpon>JobRunnerService.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
@ -111,19 +108,29 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.Designer.vb">
|
||||
<DependentUpon>ProjectInstaller.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="JobRunnerService.resx">
|
||||
<DependentUpon>JobRunnerService.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="WindowsService.resx">
|
||||
<DependentUpon>WindowsService.vb</DependentUpon>
|
||||
<EmbeddedResource Include="ProjectInstaller.resx">
|
||||
<DependentUpon>ProjectInstaller.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\app.manifest" />
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
@ -138,7 +145,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Jobs\Jobs.vbproj">
|
||||
<Project>{39ec839a-3c30-4922-a41e-6b09d1dde5c3}</Project>
|
||||
<Project>{39EC839A-3C30-4922-A41E-6B09D1DDE5C3}</Project>
|
||||
<Name>Jobs</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Database\Database.vbproj">
|
||||
@ -1,11 +1,11 @@
|
||||
Imports System.ServiceProcess
|
||||
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
|
||||
Partial Class WindowsService
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class JobRunnerService
|
||||
Inherits System.ServiceProcess.ServiceBase
|
||||
|
||||
'UserService überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
|
||||
<System.Diagnostics.DebuggerNonUserCode()>
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
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
|
||||
<MTAThread()>
|
||||
<System.Diagnostics.DebuggerNonUserCode()>
|
||||
<MTAThread()> _
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
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.
|
||||
<System.Diagnostics.DebuggerStepThrough()>
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
'
|
||||
'Service1
|
||||
'JobRunnerService
|
||||
'
|
||||
Me.ServiceName = "Service1"
|
||||
Me.CanShutdown = True
|
||||
Me.ServiceName = "DDJobRunner"
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
38
Service.JobRunner/JobRunnerService.vb
Normal file
38
Service.JobRunner/JobRunnerService.vb
Normal file
@ -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
|
||||
@ -8,17 +8,17 @@ Imports System.Runtime.InteropServices
|
||||
|
||||
' Werte der Assemblyattribute überprüfen
|
||||
|
||||
<Assembly: AssemblyTitle("JobRunner")>
|
||||
<Assembly: AssemblyTitle("Service.JobRunner")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("")>
|
||||
<Assembly: AssemblyProduct("JobRunner")>
|
||||
<Assembly: AssemblyProduct("Service.JobRunner")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2019")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
|
||||
<Assembly: Guid("5d2eb259-f8bd-4e9b-a121-afbb3fe90d13")>
|
||||
<Assembly: Guid("01496bb6-b3df-4dca-995c-33fcc0b773e2")>
|
||||
|
||||
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
'
|
||||
@ -54,87 +54,6 @@ Namespace My
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("DDJobRunner")> _
|
||||
Public ReadOnly Property SERVICE_NAME() As String
|
||||
Get
|
||||
Return CType(Me("SERVICE_NAME"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("Digital Data Job Runner")> _
|
||||
Public ReadOnly Property SERVICE_DISPLAY_NAME() As String
|
||||
Get
|
||||
Return CType(Me("SERVICE_DISPLAY_NAME"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("False")> _
|
||||
Public ReadOnly Property JOB_ADSYNC_ENABLED() As Boolean
|
||||
Get
|
||||
Return CType(Me("JOB_ADSYNC_ENABLED"),Boolean)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property DB_DATASOURCE() As String
|
||||
Get
|
||||
Return CType(Me("DB_DATASOURCE"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property DB_DATABASE() As String
|
||||
Get
|
||||
Return CType(Me("DB_DATABASE"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property DB_USER() As String
|
||||
Get
|
||||
Return CType(Me("DB_USER"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property DB_PASSWORD() As String
|
||||
Get
|
||||
Return CType(Me("DB_PASSWORD"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("120")> _
|
||||
Public ReadOnly Property JOB_INTERVAL() As Long
|
||||
Get
|
||||
Return CType(Me("JOB_INTERVAL"),Long)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("120")> _
|
||||
Public ReadOnly Property JOB_ADSYNC_INTERVAL() As Long
|
||||
Get
|
||||
Return CType(Me("JOB_ADSYNC_INTERVAL"),Long)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
@ -147,9 +66,54 @@ Namespace My
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
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
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property SQL_CONNECTIONSTRING() As String
|
||||
Get
|
||||
Return CType(Me("SQL_CONNECTIONSTRING"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property FIREBIRD_SERVER() As String
|
||||
Get
|
||||
Return CType(Me("FIREBIRD_SERVER"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property FIREBIRD_DATABASE() As String
|
||||
Get
|
||||
Return CType(Me("FIREBIRD_DATABASE"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property FIREBIRD_USER() As String
|
||||
Get
|
||||
Return CType(Me("FIREBIRD_USER"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public ReadOnly Property FIREBIRD_PASSWORD() As String
|
||||
Get
|
||||
Return CType(Me("FIREBIRD_PASSWORD"),String)
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
27
Service.JobRunner/My Project/Settings.settings
Normal file
27
Service.JobRunner/My Project/Settings.settings
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<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>
|
||||
<Setting Name="SQL_CONNECTIONSTRING" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="FIREBIRD_SERVER" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="FIREBIRD_DATABASE" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="FIREBIRD_USER" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="FIREBIRD_PASSWORD" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
76
Service.JobRunner/My Project/app.manifest
Normal file
76
Service.JobRunner/My Project/app.manifest
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC-Manifestoptionen
|
||||
Wenn Sie die Ebene der Benutzerkontensteuerung für Windows ändern möchten, ersetzen Sie den
|
||||
Knoten "requestedExecutionLevel" wie folgt.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Durch Angabe des Elements "requestedExecutionLevel" wird die Datei- und Registrierungsvirtualisierung deaktiviert.
|
||||
Entfernen Sie dieses Element, wenn diese Virtualisierung aus Gründen der Abwärtskompatibilität
|
||||
für die Anwendung erforderlich ist.
|
||||
-->
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Eine Liste der Windows-Versionen, unter denen diese Anwendung getestet
|
||||
und für die sie entwickelt wurde. Wenn Sie die Auskommentierung der entsprechenden Elemente aufheben,
|
||||
wird von Windows automatisch die kompatibelste Umgebung ausgewählt. -->
|
||||
|
||||
<!-- Windows Vista -->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
|
||||
|
||||
<!-- Windows 7 -->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
|
||||
|
||||
<!-- Windows 8 -->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
|
||||
|
||||
<!-- Windows 8.1 -->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
|
||||
|
||||
<!-- Windows 10 -->
|
||||
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- Gibt an, dass die Anwendung mit DPI-Werten kompatibel ist und von Windows nicht automatisch auf höhere
|
||||
DPI-Werte skaliert wird. WPF-Anwendungen (Windows Presentation Foundation) sind automatisch mit DPI-Werten kompatibel und müssen sich nicht
|
||||
anmelden. Für Windows Forms-Anwendungen für .NET Framework 4.6, die sich für diese Einstellung anmelden, muss
|
||||
auch die Einstellung "'EnableWindowsFormsHighDpiAutoResizing" in der "app.config" auf "true" festgelegt werden. -->
|
||||
<!--
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
-->
|
||||
|
||||
<!-- Designs für allgemeine Windows-Steuerelemente und -Dialogfelder (Windows XP und höher) aktivieren -->
|
||||
<!--
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
</assembly>
|
||||
47
Service.JobRunner/ProjectInstaller.Designer.vb
generated
Normal file
47
Service.JobRunner/ProjectInstaller.Designer.vb
generated
Normal file
@ -0,0 +1,47 @@
|
||||
<System.ComponentModel.RunInstaller(True)> Partial Class ProjectInstaller
|
||||
Inherits System.Configuration.Install.Installer
|
||||
|
||||
'Installer überschreibt den Löschvorgang zum Bereinigen der Komponentenliste.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
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.
|
||||
<System.Diagnostics.DebuggerStepThrough()>
|
||||
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
|
||||
129
Service.JobRunner/ProjectInstaller.resx
Normal file
129
Service.JobRunner/ProjectInstaller.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ServiceProcessInstaller.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>22, 17</value>
|
||||
</metadata>
|
||||
<metadata name="ServiceInstaller.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>197, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
||||
16
Service.JobRunner/ProjectInstaller.vb
Normal file
16
Service.JobRunner/ProjectInstaller.vb
Normal file
@ -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
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="4.5.11" targetFramework="net461" />
|
||||
<package id="NLog" version="4.6.2" targetFramework="net461" />
|
||||
<package id="Quartz" version="3.0.7" targetFramework="net461" />
|
||||
</packages>
|
||||
Loading…
x
Reference in New Issue
Block a user