diff --git a/Controls.LookupGrid/LookupControl2.vb b/Controls.LookupGrid/LookupControl2.vb
index ea3f8de0..b1df6d2e 100644
--- a/Controls.LookupGrid/LookupControl2.vb
+++ b/Controls.LookupGrid/LookupControl2.vb
@@ -21,10 +21,6 @@ Public Class RepositoryItemLookupControl2
Public Const CustomEditName As String = "LookupControl2"
- Public Sub New()
-
- End Sub
-
Public Overrides ReadOnly Property EditorTypeName As String
Get
Return CustomEditName
@@ -59,54 +55,110 @@ Public Class LookupControl2
Public Property PreventDuplicates As Boolean
Public Property DataSource As DataTable
Public Property SelectedValues As List(Of String)
+ Get
+ Return _SelectedValues
+ End Get
+ Set(value As List(Of String))
+ _SelectedValues = value
+ UpdateSelectedValues(value)
+ End Set
+ End Property
+
+ Private LookupFormButton As EditorButton
+ Private DropdownButton As EditorButton
Private Const TAG_BUTTON_LOOKUP_FORM = "openLookupForm"
+
Private Const TEXT_NO_RECORDS = "Keine Datensätze ausgewählt"
+ Private Const TEXT_ONE_RECORD = "Ein Datensatz ausgewählt"
Private Const TEXT_N_RECORDS = "{0} Datensätze ausgewählt"
+ Private _SelectedValues As List(Of String)
+
Shared Sub New()
RepositoryItemLookupControl2.RegisterLookupControl2()
End Sub
Public Sub New()
- Properties.Buttons.Add(New EditorButton() With {
+ MyClass.New(MultiSelect:=False)
+ End Sub
+
+ Public Sub New(MultiSelect As Boolean)
+ LookupFormButton = New EditorButton() With {
.Kind = ButtonPredefines.Ellipsis,
.Tag = TAG_BUTTON_LOOKUP_FORM
- })
+ }
+
+ Properties.Buttons.AddRange({LookupFormButton})
AddHandler ButtonClick, AddressOf HandleButtonClick
AddHandler EditValueChanging, AddressOf HandleEditValueChanging
+ AddHandler QueryPopUp, AddressOf HandleQueryPopup
End Sub
+ '''
+ ''' Prevents popup from opening when multiselect is false
+ '''
+ Private Sub HandleQueryPopup(sender As Object, e As CancelEventArgs)
+ If MultiSelect = False Then
+ e.Cancel = True
+ End If
+ End Sub
+
+ '''
+ ''' Prevents Editvalue changing when multiselect is true
+ '''
Private Sub HandleEditValueChanging(sender As Object, e As ChangingEventArgs)
- e.Cancel = True
+ If MultiSelect Then
+ e.Cancel = True
+ End If
End Sub
+ '''
+ ''' Handles opening frmLookup when ellipsis button is clicked
+ '''
Private Sub HandleButtonClick(sender As Object, e As ButtonPressedEventArgs)
- If e.Button.Tag <> TAG_BUTTON_LOOKUP_FORM Then
- Exit Sub
- End If
+ Select Case e.Button.Tag
+ Case TAG_BUTTON_LOOKUP_FORM
+ Dim oForm As frmLookupGrid = GetLookupForm()
+ Dim oResult = oForm.ShowDialog()
- Dim oForm As frmLookupGrid = GetLookupForm()
- Dim oResult = oForm.ShowDialog()
+ If oResult = Windows.Forms.DialogResult.OK Then
+ Dim oValues = oForm.SelectedValues
- If oResult = Windows.Forms.DialogResult.OK Then
- Dim oValues = oForm.SelectedValues
+ UpdateSelectedValues(oValues)
+ SelectedValues = oValues
+ ElseIf oResult = Windows.Forms.DialogResult.Cancel Then
+ Dim oValues = New List(Of String)
- UpdateSelectedValues(oValues)
+ UpdateSelectedValues(oValues)
+ SelectedValues = oValues
+ End If
- SelectedValues = oValues
- End If
-
- oForm.Dispose()
+ oForm.Dispose()
+ End Select
End Sub
Private Sub UpdateSelectedValues(Values As List(Of String))
+ If Values Is Nothing Then
+ Exit Sub
+ End If
+
If MultiSelect = True Then
Properties.DataSource = Values
- Properties.NullText = IIf(Values.Count = 0, TEXT_NO_RECORDS, String.Format(TEXT_N_RECORDS, Values.Count))
+
+ Select Case Values.Count
+ Case 0
+ Properties.NullText = TEXT_NO_RECORDS
+ Case 1
+ Properties.NullText = TEXT_ONE_RECORD
+ Case Else
+ Properties.NullText = String.Format(TEXT_N_RECORDS, Values.Count)
+ End Select
Else
+ Properties.NullText = Values.FirstOrDefault()
Text = Values.FirstOrDefault()
+ EditValue = Nothing
End If
End Sub
diff --git a/Controls.LookupGrid/My Project/AssemblyInfo.vb b/Controls.LookupGrid/My Project/AssemblyInfo.vb
index a9d9594c..2eb9f91d 100644
--- a/Controls.LookupGrid/My Project/AssemblyInfo.vb
+++ b/Controls.LookupGrid/My Project/AssemblyInfo.vb
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
'
-
+
diff --git a/Controls.LookupGrid/frmLookupGrid.vb b/Controls.LookupGrid/frmLookupGrid.vb
index e0beba62..44517082 100644
--- a/Controls.LookupGrid/frmLookupGrid.vb
+++ b/Controls.LookupGrid/frmLookupGrid.vb
@@ -17,6 +17,7 @@ Public Class frmLookupGrid
view = viewLookup
grid = gridLookup
+
If DataSource Is Nothing Then
Exit Sub
End If
@@ -136,7 +137,7 @@ Public Class frmLookupGrid
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
- SelectedValues.Clear()
+ SelectedValues = New List(Of String)
DialogResult = DialogResult.Cancel
Close()
diff --git a/DDMonorepo.sln b/DDMonorepo.sln
index 0019dc38..bced3c9e 100644
--- a/DDMonorepo.sln
+++ b/DDMonorepo.sln
@@ -69,10 +69,12 @@ 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
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LookupControlGui", "LookupControlGui\LookupControlGui.vbproj", "{B65E24B3-D334-455D-A0BF-B33B8358B013}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -175,10 +177,14 @@ 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
+ {B65E24B3-D334-455D-A0BF-B33B8358B013}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B65E24B3-D334-455D-A0BF-B33B8358B013}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B65E24B3-D334-455D-A0BF-B33B8358B013}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B65E24B3-D334-455D-A0BF-B33B8358B013}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -208,7 +214,8 @@ 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}
+ {B65E24B3-D334-455D-A0BF-B33B8358B013} = {CC368D6A-6AC4-4EB9-A092-14700FABEF7A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286}
diff --git a/EDMI_FILE_OPs/Channel.vb b/EDMI_FILE_OPs/Channel.vb
index c18a7311..aa63c9ac 100644
--- a/EDMI_FILE_OPs/Channel.vb
+++ b/EDMI_FILE_OPs/Channel.vb
@@ -1,4 +1,5 @@
Imports System.ServiceModel
+Imports System.Xml
Public Class Channel
Public Shared Function GetBinding() As NetTcpBinding
@@ -13,7 +14,7 @@ Public Class Channel
.ClientCredentialType = TcpClientCredentialType.Windows
}
},
- .ReaderQuotas = New Xml.XmlDictionaryReaderQuotas() With {
+ .ReaderQuotas = New XmlDictionaryReaderQuotas() With {
.MaxArrayLength = Constants.MAX_ARRAY_LENGTH,
.MaxStringContentLength = Constants.MAX_STRING_CONTENT_LENGTH
}
diff --git a/EDMI_FILE_OPs/Document.vb b/EDMI_FILE_OPs/Document.vb
index bcb4fcab..c0bb55e4 100644
--- a/EDMI_FILE_OPs/Document.vb
+++ b/EDMI_FILE_OPs/Document.vb
@@ -8,6 +8,12 @@ Public Class Document
Private _logConfig As LogConfig
Private _channelFactory As ChannelFactory(Of IEDMServiceChannel)
Private _channel As IEDMServiceChannel
+
+ '''
+ ''' Creates a new EDMIAPI object
+ '''
+ ''' LogConfig object
+ ''' The full service url to connect to
Public Sub New(LogConfig As LogConfig, ServiceAdress As String)
_logger = LogConfig.GetLogger()
_logConfig = LogConfig
@@ -15,30 +21,32 @@ Public Class Document
Try
Dim oBinding = Channel.GetBinding()
Dim oAddress = New EndpointAddress(ServiceAdress)
- _channelFactory = New ChannelFactory(Of IEDMServiceChannel)(oBinding, oAddress)
- Connect2NetService()
+ Dim oFactory = New ChannelFactory(Of IEDMServiceChannel)(oBinding, oAddress)
+
+ _channelFactory = oFactory
Catch ex As Exception
_logger.Error(ex)
End Try
End Sub
- Private Function Connect2NetService()
+ '''
+ ''' Connect to the service
+ '''
+ ''' True if connection was successful, false otherwise
+ Public Function Connect()
Try
- _channel = Nothing
- _channel = _channelFactory.CreateChannel()
- _logger.Info("Successfully connected to EDM_Network Service")
- AddHandler _channel.Faulted, AddressOf Reconnect
+ _channel = GetChannel()
+
+ _logger.Debug("Opening channel..")
_channel.Open()
+
+ _logger.Info("Connection to Service established!")
Return True
Catch ex As Exception
_logger.Error(ex)
- Return True
+ Return False
End Try
End Function
- Private Sub Reconnect()
- _channel.Abort()
- Connect2NetService()
- End Sub
'''
''' Imports a file by filename
@@ -120,59 +128,36 @@ Public Class Document
End Try
End Function
- 'Public Async Function New_EDMI_File(oFILENAME As String, oUserName As String) As Task(Of String)
- ' Try
- ' Dim oFileGUID As DocumentResult = Await CreateDocument(oFILENAME)
- ' Dim oFileRecordID = Nothing
- ' If Not IsNothing(oFileGUID) Then
- ' Dim oSQL = $"SELECT FNEDMI_SET_RECORD(""TBEDMI_ADRESSE"",""{oUserName}"",FALSE,NULL,"""",'{oFileGUID._ContainerId}') FROM rdb$database;"
- ' oFileRecordID = Await New_EDMIFile_CreateDB_Record(oSQL)
- ' End If
- ' Return oFileRecordID
- ' Catch ex As Exception
- ' _logger.Error(ex)
- ' Return Nothing
- ' End Try
- 'End Function
+ '''
+ ''' Aborts the channel and creates a new connection
+ '''
+ Private Sub Reconnect()
+ _logger.Warn("Connection faulted. Trying to reconnect..")
- 'Private Async Function New_EDMIFile_CreateDB_Record(FBCommand As String) As Task(Of String)
- ' Try
- ' Dim oTimeTotal As TimeSpan
- ' Dim oStopwatch As New Stopwatch()
- ' oStopwatch.Start()
- ' Dim oRecord_ID As String
- ' Dim oRequestName = Await _channel.CreateDatabaseRequestAsync("CreateEDMFileRecord", True)
- ' Dim oResult = Await _channel.ReturnScalarAsync(FBCommand)
+ Try
+ _channel.Abort()
+ _channel = GetChannel()
+ _channel.Open()
+ Catch ex As Exception
+ _logger.Error(ex)
+ End Try
+ End Sub
- ' oTimeTotal = oStopwatch.Elapsed
- ' oStopwatch.Reset()
+ '''
+ ''' Creates a channel and adds a Faulted-Handler
+ '''
+ ''' A channel object
+ Private Function GetChannel() As IEDMServiceChannel
+ Try
+ _logger.Debug("Creating channel..")
+ Dim oChannel = _channelFactory.CreateChannel()
- ' Await _channel.CloseDatabaseRequestAsync()
+ AddHandler oChannel.Faulted, AddressOf Reconnect
- ' If Not oResult.OK Then
- ' _logger.Warn($"Unexpected error while executing command: {oResult.ErrorMessage}")
- ' Else
- ' oRecord_ID = oResult.Scalar
- ' _logger.Debug($"SCALAR (SERVICE) {FBCommand} - TIME: {(oTimeTotal.ToString)}")
- ' End If
- ' Return oRecord_ID
- ' Catch ex As Exception
- ' _logger.Error(ex)
- ' Return Nothing
- ' End Try
- 'End Function
- 'Public Async Function Load_EDMIFile_2TempPath(oEDMIFile_GUID As String) As Task(Of String)
- 'Try
- ' Dim oResult As EDMIServiceReference.ContainerResult = Await _channel.GetFileAsync(oEDMIFile_GUID)
- ' Dim oTempPath = Path.Combine(Path.GetTempPath(), "EDMI_FileContainer")
- ' Directory.CreateDirectory(oTempPath)
- ' Dim oFilePath = Path.Combine(oTempPath, $"{oResult.Container.FileId}.{oResult.Container.Extension}")
- ' File.WriteAllBytes(oFilePath, oResult.Container.Contents)
- ' ' Process.Start(oTempPath)
- ' Return oTempPath
- 'Catch ex As Exception
- ' _logger.Error(ex)
- ' Return Nothing
- 'End Try
- 'End Function
+ Return oChannel
+ Catch ex As Exception
+ _logger.Error(ex)
+ Throw ex
+ End Try
+ End Function
End Class
diff --git a/EDMI_FILE_OPs/My Project/AssemblyInfo.vb b/EDMI_FILE_OPs/My Project/AssemblyInfo.vb
index 24a1da3c..f7b314a3 100644
--- a/EDMI_FILE_OPs/My Project/AssemblyInfo.vb
+++ b/EDMI_FILE_OPs/My Project/AssemblyInfo.vb
@@ -8,10 +8,10 @@ Imports System.Runtime.InteropServices
' Werte der Assemblyattribute überprüfen
-
+
-
-
+
+
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
'
-
+
diff --git a/GUIs.ClientSuite/_TEST/frmFileTest.vb b/GUIs.ClientSuite/_TEST/frmFileTest.vb
index 13aaf27c..41c1a49c 100644
--- a/GUIs.ClientSuite/_TEST/frmFileTest.vb
+++ b/GUIs.ClientSuite/_TEST/frmFileTest.vb
@@ -9,7 +9,7 @@ Public Class frmFileTest
Private Sub frmFileTest_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
_fileOp = New Document(My.LogConfig, My.Settings.EDM_NetworkService_Adress)
-
+ _fileOp.Connect()
Catch ex As Exception
Logger.Warn($"Unexpected error in frmFileTest_Load: {ex.Message}")
End Try
@@ -37,7 +37,7 @@ Public Class frmFileTest
listboxLog.Items.Add($"Filename: {oResult.Document.FileName}")
listboxLog.Items.Add($"----------------------------------------------------------")
Catch ex As Exception
- MsgBox(ex.Message)
+ ShowErrorMessage(ex)
Logger.Error(ex)
End Try
End Sub
diff --git a/GUIs.Test.ADSyncTest/Form1.Designer.vb b/GUIs.Test.ADSyncTest/Form1.Designer.vb
index 309bfed9..51609d9d 100644
--- a/GUIs.Test.ADSyncTest/Form1.Designer.vb
+++ b/GUIs.Test.ADSyncTest/Form1.Designer.vb
@@ -27,6 +27,12 @@ Partial Class Form1
Me.ListBox2 = New System.Windows.Forms.ListBox()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
+ Me.txtJobConfigString = New System.Windows.Forms.TextBox()
+ Me.TextBox2 = New System.Windows.Forms.TextBox()
+ Me.TextBox3 = New System.Windows.Forms.TextBox()
+ Me.TextBox4 = New System.Windows.Forms.TextBox()
+ Me.btnParseConfig = New System.Windows.Forms.Button()
+ Me.Label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Button1
@@ -72,11 +78,64 @@ Partial Class Form1
Me.Button3.Text = "List Users for selected Group"
Me.Button3.UseVisualStyleBackColor = True
'
+ 'txtJobConfigString
+ '
+ Me.txtJobConfigString.Location = New System.Drawing.Point(12, 250)
+ Me.txtJobConfigString.Name = "txtJobConfigString"
+ Me.txtJobConfigString.Size = New System.Drawing.Size(227, 20)
+ Me.txtJobConfigString.TabIndex = 5
+ Me.txtJobConfigString.Text = "True|* 0/5 * * * ?|Arg1::Foo,Arg2::Bar"
+ '
+ 'TextBox2
+ '
+ Me.TextBox2.Location = New System.Drawing.Point(12, 321)
+ Me.TextBox2.Name = "TextBox2"
+ Me.TextBox2.Size = New System.Drawing.Size(227, 20)
+ Me.TextBox2.TabIndex = 6
+ '
+ 'TextBox3
+ '
+ Me.TextBox3.Location = New System.Drawing.Point(12, 347)
+ Me.TextBox3.Name = "TextBox3"
+ Me.TextBox3.Size = New System.Drawing.Size(227, 20)
+ Me.TextBox3.TabIndex = 7
+ '
+ 'TextBox4
+ '
+ Me.TextBox4.Location = New System.Drawing.Point(12, 373)
+ Me.TextBox4.Name = "TextBox4"
+ Me.TextBox4.Size = New System.Drawing.Size(227, 20)
+ Me.TextBox4.TabIndex = 8
+ '
+ 'btnParseConfig
+ '
+ Me.btnParseConfig.Location = New System.Drawing.Point(12, 399)
+ Me.btnParseConfig.Name = "btnParseConfig"
+ Me.btnParseConfig.Size = New System.Drawing.Size(227, 33)
+ Me.btnParseConfig.TabIndex = 9
+ Me.btnParseConfig.Text = "Parse Config"
+ Me.btnParseConfig.UseVisualStyleBackColor = True
+ '
+ 'Label1
+ '
+ Me.Label1.AutoSize = True
+ Me.Label1.Location = New System.Drawing.Point(9, 234)
+ Me.Label1.Name = "Label1"
+ Me.Label1.Size = New System.Drawing.Size(67, 13)
+ Me.Label1.TabIndex = 10
+ Me.Label1.Text = "ConfigString:"
+ '
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
+ Me.Controls.Add(Me.Label1)
+ Me.Controls.Add(Me.btnParseConfig)
+ Me.Controls.Add(Me.TextBox4)
+ Me.Controls.Add(Me.TextBox3)
+ Me.Controls.Add(Me.TextBox2)
+ Me.Controls.Add(Me.txtJobConfigString)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.ListBox2)
@@ -85,6 +144,7 @@ Partial Class Form1
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
+ Me.PerformLayout()
End Sub
@@ -93,4 +153,10 @@ Partial Class Form1
Friend WithEvents ListBox2 As ListBox
Friend WithEvents Button2 As Button
Friend WithEvents Button3 As Button
+ Friend WithEvents txtJobConfigString As TextBox
+ Friend WithEvents TextBox2 As TextBox
+ Friend WithEvents TextBox3 As TextBox
+ Friend WithEvents TextBox4 As TextBox
+ Friend WithEvents btnParseConfig As Button
+ Friend WithEvents Label1 As Label
End Class
diff --git a/GUIs.Test.ADSyncTest/Form1.vb b/GUIs.Test.ADSyncTest/Form1.vb
index 8e546f27..79686b2f 100644
--- a/GUIs.Test.ADSyncTest/Form1.vb
+++ b/GUIs.Test.ADSyncTest/Form1.vb
@@ -2,6 +2,7 @@
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Config
+Imports DigitalData.Modules.Jobs
Public Class Form1
Private _sync As ActiveDirectoryInterface
@@ -20,8 +21,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
@@ -70,5 +69,7 @@ Public Class Form1
Return oAttributeMappings
End Function
-
+ Private Sub btnParseConfig_Click(sender As Object, e As EventArgs) Handles btnParseConfig.Click
+ Dim oConfig = JobConfigParser.ParseConfig(txtJobConfigString.Text)
+ End Sub
End Class
diff --git a/GUIs.Test.TestGUI/ConfigTest.vb b/GUIs.Test.TestGUI/ConfigTest.vb
index 8e0dbbc7..356bc62a 100644
--- a/GUIs.Test.TestGUI/ConfigTest.vb
+++ b/GUIs.Test.TestGUI/ConfigTest.vb
@@ -12,7 +12,6 @@ Public Class ConfigTest
End Sub
Public Class Config
-
Public Property StringEntry As String = "TEST"
Public Property BoolEntry As Boolean = True
Public Property IntEntry As Integer = 123
diff --git a/GUIs.Test.TestGUI/Form1.Designer.vb b/GUIs.Test.TestGUI/Form1.Designer.vb
index 8888ec79..e744c1bb 100644
--- a/GUIs.Test.TestGUI/Form1.Designer.vb
+++ b/GUIs.Test.TestGUI/Form1.Designer.vb
@@ -22,7 +22,6 @@ Partial Class Form1
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
Private Sub InitializeComponent()
- Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.Button1 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
@@ -44,8 +43,6 @@ Partial Class Form1
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Label6 = New System.Windows.Forms.Label()
Me.Button4 = New System.Windows.Forms.Button()
- Me.LookupControl1 = New DigitalData.Controls.LookupGrid.LookupControl()
- Me.Button6 = New System.Windows.Forms.Button()
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.GridView1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
@@ -231,34 +228,11 @@ Partial Class Form1
Me.Button4.Text = "Test Background Worker Logging"
Me.Button4.UseVisualStyleBackColor = True
'
- 'LookupControl1
- '
- Me.LookupControl1.AutoSize = True
- Me.LookupControl1.BackColor = System.Drawing.Color.Transparent
- Me.LookupControl1.DataSource = Nothing
- Me.LookupControl1.Location = New System.Drawing.Point(695, 214)
- Me.LookupControl1.MultiSelect = True
- Me.LookupControl1.Name = "LookupControl1"
- Me.LookupControl1.SelectedValues = CType(resources.GetObject("LookupControl1.SelectedValues"), System.Collections.Generic.List(Of String))
- Me.LookupControl1.Size = New System.Drawing.Size(270, 23)
- Me.LookupControl1.TabIndex = 23
- '
- 'Button6
- '
- Me.Button6.Location = New System.Drawing.Point(764, 308)
- Me.Button6.Name = "Button6"
- Me.Button6.Size = New System.Drawing.Size(75, 23)
- Me.Button6.TabIndex = 24
- Me.Button6.Text = "Button6"
- Me.Button6.UseVisualStyleBackColor = True
- '
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1050, 487)
- Me.Controls.Add(Me.Button6)
- Me.Controls.Add(Me.LookupControl1)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.TextBox1)
@@ -310,6 +284,4 @@ Partial Class Form1
Friend WithEvents TextBox1 As TextBox
Friend WithEvents Label6 As Label
Friend WithEvents Button4 As Button
- Friend WithEvents LookupControl1 As DigitalData.Controls.LookupGrid.LookupControl
- Friend WithEvents Button6 As Button
End Class
diff --git a/GUIs.Test.TestGUI/Form1.resx b/GUIs.Test.TestGUI/Form1.resx
index 7a53cff0..1af7de15 100644
--- a/GUIs.Test.TestGUI/Form1.resx
+++ b/GUIs.Test.TestGUI/Form1.resx
@@ -117,13 +117,4 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
- ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
- PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB
- AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0
- ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs=
-
-
\ No newline at end of file
diff --git a/GUIs.Test.TestGUI/Form1.vb b/GUIs.Test.TestGUI/Form1.vb
index 6f8babf9..a41b5a2a 100644
--- a/GUIs.Test.TestGUI/Form1.vb
+++ b/GUIs.Test.TestGUI/Form1.vb
@@ -79,11 +79,6 @@ Public Class Form1
datatable.Rows.Add(dr)
datatable.Rows.Add(dr2)
datatable.Rows.Add(dr3)
-
- LookupControl1.DataSource = datatable
- LookupControl1.SelectedValues = New List(Of String) From {"foo"}
-
-
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles GetValue.Click
diff --git a/GUIs.Test.TestGUI/TestGUI.vbproj b/GUIs.Test.TestGUI/TestGUI.vbproj
index 0387695d..95ee6b2a 100644
--- a/GUIs.Test.TestGUI/TestGUI.vbproj
+++ b/GUIs.Test.TestGUI/TestGUI.vbproj
@@ -176,10 +176,6 @@
{991d0231-4623-496d-8bd0-9ca906029cbc}
Filesystem
-
- {3dcd6d1a-c830-4241-b7e4-27430e7ea483}
- LookupControl
-
{903b2d7d-3b80-4be9-8713-7447b704e1b0}
Logging
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/JobRunner2.vb b/JobRunner/JobRunner2.vb
deleted file mode 100644
index d0fcea3e..00000000
--- a/JobRunner/JobRunner2.vb
+++ /dev/null
@@ -1,113 +0,0 @@
-Imports System.Collections.Specialized
-Imports DigitalData.Modules.Database
-Imports DigitalData.Modules.Jobs
-Imports DigitalData.Modules.Logging
-Imports Quartz
-Imports Quartz.Impl
-Imports Quartz.Logging
-
-Public Class JobRunner2
- Private _LogConfig As LogConfig
- Private _Logger As Modules.Logging.Logger
- Private _firebird As Firebird
- Private _mssql As MSSQLServer
-
- Private _Props As New NameValueCollection From {
- {"quartz.serializer.type", "binary"}
- }
- Private _factory As StdSchedulerFactory
- Private _scheduler As IScheduler
-
- Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer, Firebird As Firebird)
- _LogConfig = LogConfig
- _Logger = LogConfig.GetLogger()
- _firebird = Firebird
- _mssql = MSSQL
- End Sub
-
- Public Async Sub Start()
- Logging.LogProvider.SetCurrentLogProvider(New LogProvider(_Logger))
-
- Dim oProps As New NameValueCollection From {
- {"quartz.serializer.type", "binary"}
- }
- _factory = New StdSchedulerFactory(oProps)
- _scheduler = Await _factory.GetScheduler()
-
- Await _scheduler.Start()
-
- Dim oJobData As New JobDataMap From {
- {"LogConfig", _LogConfig},
- {"Firebird", _firebird},
- {"MSSQL", _mssql},
- {"RootPath", My.Settings.JOB_ADSYNC_ROOT_PATH}
- }
-
- Dim oJobDetail = JobBuilder.Create(Of ADJob)().
- WithIdentity("activedirectory-sync").
- UsingJobData(oJobData).
- Build()
-
- Dim oTrigger = TriggerBuilder.Create().
- WithIdentity("activedirectory-sync-trigger").
- StartNow().
- WithCronSchedule("1 0 * * *").
- Build()
-
- Await _scheduler.ScheduleJob(oJobDetail, oTrigger)
- End Sub
-
- Public Async Sub [Stop]()
- Await _scheduler.Shutdown()
- End Sub
-
- Public Class ADJob
- Implements Quartz.IJob
-
- Public Async 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")
- Dim oMSSQL As MSSQLServer = oJobData.Item("MSSQL")
- Dim oRootPath As String = oJobData.Item("RootPath")
- Dim oADJobArgs = New ADSyncArgs() With {
- .RootPath = oRootPath
- }
-
- Dim oADSyncJob As New ADSyncJob(oLogConfig, oFirebird, oMSSQL)
- oADSyncJob.Start(oADJobArgs)
-
- Await Task.CompletedTask
- End Function
- End Class
-
- Private Class LogProvider
- Implements ILogProvider
-
- Private _Logger As Modules.Logging.Logger
-
- Public Sub New(Logger As 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())
- End If
-
- Return True
- End Function
- End Function
-
- Private Function OpenNestedContext(message As String) As IDisposable Implements ILogProvider.OpenNestedContext
- Throw New NotImplementedException()
- End Function
-
- Private Function OpenMappedContext(key As String, value As String) As IDisposable Implements ILogProvider.OpenMappedContext
- Throw New NotImplementedException()
- End Function
- End Class
-
-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..6245604f 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)
+ ElseIf oSyncedUsers.Count > 0 Then
+ _Logger.Info("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/Jobs/JobConfig.vb b/Jobs/JobConfig.vb
new file mode 100644
index 00000000..9b086bd2
--- /dev/null
+++ b/Jobs/JobConfig.vb
@@ -0,0 +1,7 @@
+Imports System.Collections.Generic
+
+Public Class JobConfig
+ Public Enabled As Boolean
+ Public CronExpression As String
+ Public Arguments As Dictionary(Of String, String)
+End Class
\ No newline at end of file
diff --git a/Jobs/JobConfigParser.vb b/Jobs/JobConfigParser.vb
new file mode 100644
index 00000000..3c6f702c
--- /dev/null
+++ b/Jobs/JobConfigParser.vb
@@ -0,0 +1,62 @@
+Imports System.Collections.Generic
+Imports System.Text.RegularExpressions
+
+Public Class JobConfigParser
+ Private Shared JobOptionsRegex As New Regex("(?True|False)\|(?[\w\d\s,\?*-/]*)(?:\|(?(?:\w*::[^,\n]+,?)*))?")
+ Private Shared JobArgumentsRegex As New Regex("(?:(?:\w+::[^,\n]+,?)?)+")
+ Private Const ARGS_ITEM_DELIMITER As String = ","
+ Private Const ARGS_KEYVALUE_DELIMITER As String = "::"
+ Private Const ARGS_LIST_DELIMITER As String = "|"
+
+ '''
+ ''' Parse a job config string. ex: True|* 0/3 * * * ?|Arg1=Foo
+ '''
+ '''
+ ''' A populated JobConfig object
+ Public Shared Function ParseConfig(ConfigString As String) As JobConfig
+ If JobOptionsRegex.IsMatch(ConfigString) Then
+ Dim oMatches = JobOptionsRegex.Matches(ConfigString)
+ Dim oOptions As New JobConfig
+
+ Dim oSplitOptions As String() = ConfigString.Split(ARGS_LIST_DELIMITER)
+
+ If oSplitOptions.Length = 3 Then
+ oOptions.Enabled = CBool(oSplitOptions(0))
+ oOptions.CronExpression = oSplitOptions(1)
+ oOptions.Arguments = ParseOptionalArguments(oSplitOptions(2))
+ ElseIf oSplitOptions.Length = 2 Then
+ oOptions.Enabled = CBool(oSplitOptions(0))
+ oOptions.CronExpression = oSplitOptions(1)
+ oOptions.Arguments = New Dictionary(Of String, String)
+ Else
+ Throw New ArgumentException("Config Malformed")
+ End If
+
+ Return oOptions
+ Else
+ Throw New ArgumentException("Config Malformed")
+ End If
+ End Function
+
+ Private Shared Function ParseOptionalArguments(ArgsString As String) As Dictionary(Of String, String)
+ Dim oArgsDictionary As New Dictionary(Of String, String)
+
+ If JobArgumentsRegex.IsMatch(ArgsString) Then
+ Dim oArgs As String() = ArgsString.Split(ARGS_ITEM_DELIMITER)
+
+ For Each oArg In oArgs
+ Dim oDelimiter As String() = New String() {ARGS_KEYVALUE_DELIMITER}
+ Dim oArgSplit = oArg.Split(oDelimiter, StringSplitOptions.RemoveEmptyEntries)
+ Regex.Split(oArg, "::")
+
+ If oArgSplit.Length = 2 Then
+ oArgsDictionary.Add(oArgSplit(0), oArgSplit(1))
+ Else
+ Throw New ArgumentException("Config Malformed")
+ End If
+ Next
+ End If
+
+ Return oArgsDictionary
+ End Function
+End Class
diff --git a/Jobs/Jobs.vbproj b/Jobs/Jobs.vbproj
index 59acde28..ba1b63e1 100644
--- a/Jobs/Jobs.vbproj
+++ b/Jobs/Jobs.vbproj
@@ -93,6 +93,8 @@
+
+
True
diff --git a/LookupControlGui/App.config b/LookupControlGui/App.config
new file mode 100644
index 00000000..5534e287
--- /dev/null
+++ b/LookupControlGui/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LookupControlGui/Form1.Designer.vb b/LookupControlGui/Form1.Designer.vb
new file mode 100644
index 00000000..20e29cfc
--- /dev/null
+++ b/LookupControlGui/Form1.Designer.vb
@@ -0,0 +1,89 @@
+
+Partial Class Form1
+ Inherits System.Windows.Forms.Form
+
+ 'Das Formular ü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
+ components.Dispose()
+ End If
+ Finally
+ MyBase.Dispose(disposing)
+ End Try
+ End Sub
+
+ 'Wird vom Windows Form-Designer benötigt.
+ Private components As System.ComponentModel.IContainer
+
+ 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
+ 'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
+ 'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
+
+ Private Sub InitializeComponent()
+ Dim EditorButtonImageOptions1 As DevExpress.XtraEditors.Controls.EditorButtonImageOptions = New DevExpress.XtraEditors.Controls.EditorButtonImageOptions()
+ Dim SerializableAppearanceObject1 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject()
+ Dim SerializableAppearanceObject2 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject()
+ Dim SerializableAppearanceObject3 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject()
+ Dim SerializableAppearanceObject4 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject()
+ Dim EditorButtonImageOptions2 As DevExpress.XtraEditors.Controls.EditorButtonImageOptions = New DevExpress.XtraEditors.Controls.EditorButtonImageOptions()
+ Dim SerializableAppearanceObject5 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject()
+ Dim SerializableAppearanceObject6 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject()
+ Dim SerializableAppearanceObject7 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject()
+ Dim SerializableAppearanceObject8 As DevExpress.Utils.SerializableAppearanceObject = New DevExpress.Utils.SerializableAppearanceObject()
+ Me.Button1 = New System.Windows.Forms.Button()
+ Me.LookupControl = New DigitalData.Controls.LookupGrid.LookupControl2()
+ Me.LookupControl21View = New DevExpress.XtraGrid.Views.Grid.GridView()
+ CType(Me.LookupControl.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
+ CType(Me.LookupControl21View, System.ComponentModel.ISupportInitialize).BeginInit()
+ Me.SuspendLayout()
+ '
+ 'Button1
+ '
+ Me.Button1.Location = New System.Drawing.Point(12, 12)
+ Me.Button1.Name = "Button1"
+ Me.Button1.Size = New System.Drawing.Size(94, 23)
+ Me.Button1.TabIndex = 2
+ Me.Button1.Text = "Get Text"
+ Me.Button1.UseVisualStyleBackColor = True
+ '
+ 'LookupControl
+ '
+ Me.LookupControl.AllowAddNewValues = False
+ Me.LookupControl.DataSource = Nothing
+ Me.LookupControl.Location = New System.Drawing.Point(393, 31)
+ Me.LookupControl.MultiSelect = True
+ Me.LookupControl.Name = "LookupControl"
+ Me.LookupControl.PreventDuplicates = False
+ Me.LookupControl.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo, "", -1, True, True, False, EditorButtonImageOptions1, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject1, SerializableAppearanceObject2, SerializableAppearanceObject3, SerializableAppearanceObject4, "", "openDropdown", Nothing, DevExpress.Utils.ToolTipAnchor.[Default]), New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Ellipsis, "", -1, True, True, False, EditorButtonImageOptions2, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject5, SerializableAppearanceObject6, SerializableAppearanceObject7, SerializableAppearanceObject8, "", "openLookupForm", Nothing, DevExpress.Utils.ToolTipAnchor.[Default])})
+ Me.LookupControl.Properties.PopupView = Me.LookupControl21View
+ Me.LookupControl.SelectedValues = Nothing
+ Me.LookupControl.Size = New System.Drawing.Size(342, 20)
+ Me.LookupControl.TabIndex = 3
+ '
+ 'LookupControl21View
+ '
+ Me.LookupControl21View.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus
+ Me.LookupControl21View.Name = "LookupControl21View"
+ Me.LookupControl21View.OptionsSelection.EnableAppearanceFocusedCell = False
+ Me.LookupControl21View.OptionsView.ShowGroupPanel = False
+ '
+ 'Form1
+ '
+ Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
+ Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
+ Me.ClientSize = New System.Drawing.Size(800, 450)
+ Me.Controls.Add(Me.LookupControl)
+ Me.Controls.Add(Me.Button1)
+ Me.Name = "Form1"
+ Me.Text = "Form1"
+ CType(Me.LookupControl.Properties, System.ComponentModel.ISupportInitialize).EndInit()
+ CType(Me.LookupControl21View, System.ComponentModel.ISupportInitialize).EndInit()
+ Me.ResumeLayout(False)
+
+ End Sub
+ Friend WithEvents Button1 As Button
+ Friend WithEvents LookupControl As DigitalData.Controls.LookupGrid.LookupControl2
+ Friend WithEvents LookupControl21View As DevExpress.XtraGrid.Views.Grid.GridView
+End Class
diff --git a/LookupControlGui/Form1.resx b/LookupControlGui/Form1.resx
new file mode 100644
index 00000000..1af7de15
--- /dev/null
+++ b/LookupControlGui/Form1.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
\ No newline at end of file
diff --git a/LookupControlGui/Form1.vb b/LookupControlGui/Form1.vb
new file mode 100644
index 00000000..fb9958f7
--- /dev/null
+++ b/LookupControlGui/Form1.vb
@@ -0,0 +1,37 @@
+
+
+
+Public Class Form1
+ Private _Datasource As New List(Of String) From {"Foo", "bar", "baz", "quux"}
+
+ Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
+
+ Dim oDatatable = GetDatatable()
+ Dim oSelectedValues = _Datasource.Take(1).ToList()
+
+ LookupControl.DataSource = oDatatable
+ LookupControl.SelectedValues = oSelectedValues
+ End Sub
+
+ Private Function GetDatatable() As DataTable
+ Dim oDatatable As New DataTable
+ Dim oColumns As New List(Of DataColumn) From {
+ New DataColumn("Col1", GetType(String))
+ }
+
+ oDatatable.Columns.AddRange(oColumns.ToArray)
+
+ For Each Item In _Datasource
+ Dim oRow = oDatatable.NewRow()
+ oRow.Item("Col1") = Item
+ oDatatable.Rows.Add(oRow)
+ Next
+
+
+ Return oDatatable
+ End Function
+
+ Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
+ MsgBox(LookupControl.SelectedValues.Count)
+ End Sub
+End Class
diff --git a/LookupControlGui/LookupControlGui.vbproj b/LookupControlGui/LookupControlGui.vbproj
new file mode 100644
index 00000000..e7f8927a
--- /dev/null
+++ b/LookupControlGui/LookupControlGui.vbproj
@@ -0,0 +1,132 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {B65E24B3-D334-455D-A0BF-B33B8358B013}
+ WinExe
+ LookupControlGui.My.MyApplication
+ LookupControlGui
+ LookupControlGui
+ 512
+ WindowsForms
+ v4.6.1
+ true
+
+
+ AnyCPU
+ true
+ full
+ true
+ true
+ bin\Debug\
+ LookupControlGui.xml
+ 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
+
+
+ AnyCPU
+ pdbonly
+ false
+ true
+ true
+ bin\Release\
+ LookupControlGui.xml
+ 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
+
+
+ On
+
+
+ Binary
+
+
+ Off
+
+
+ On
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ Form1.vb
+ Form
+
+
+
+ True
+ Application.myapp
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+ Form1.vb
+
+
+ VbMyResourcesResXFileCodeGenerator
+ Resources.Designer.vb
+ My.Resources
+ Designer
+
+
+
+
+ MyApplicationCodeGenerator
+ Application.Designer.vb
+
+
+ SettingsSingleFileGenerator
+ My
+ Settings.Designer.vb
+
+
+
+
+
+ {3dcd6d1a-c830-4241-b7e4-27430e7ea483}
+ LookupControl
+
+
+
+
\ No newline at end of file
diff --git a/LookupControlGui/My Project/Application.Designer.vb b/LookupControlGui/My Project/Application.Designer.vb
new file mode 100644
index 00000000..50b0d981
--- /dev/null
+++ b/LookupControlGui/My Project/Application.Designer.vb
@@ -0,0 +1,38 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:4.0.30319.42000
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+
+Namespace My
+
+ 'NOTE: This file is auto-generated; do not modify it directly. To make changes,
+ ' or if you encounter build errors in this file, go to the Project Designer
+ ' (go to Project Properties or double-click the My Project node in
+ ' Solution Explorer), and make changes on the Application tab.
+ '
+ Partial Friend Class MyApplication
+
+ _
+ Public Sub New()
+ MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
+ Me.IsSingleInstance = false
+ Me.EnableVisualStyles = true
+ Me.SaveMySettingsOnExit = true
+ Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
+ End Sub
+
+ _
+ Protected Overrides Sub OnCreateMainForm()
+ Me.MainForm = Global.LookupControlGui.Form1
+ End Sub
+ End Class
+End Namespace
diff --git a/LookupControlGui/My Project/Application.myapp b/LookupControlGui/My Project/Application.myapp
new file mode 100644
index 00000000..1243847f
--- /dev/null
+++ b/LookupControlGui/My Project/Application.myapp
@@ -0,0 +1,11 @@
+
+
+ true
+ Form1
+ false
+ 0
+ true
+ 0
+ 0
+ true
+
diff --git a/JobRunner/My Project/AssemblyInfo.vb b/LookupControlGui/My Project/AssemblyInfo.vb
similarity index 87%
rename from JobRunner/My Project/AssemblyInfo.vb
rename to LookupControlGui/My Project/AssemblyInfo.vb
index df2bc85e..66ae7a4b 100644
--- a/JobRunner/My Project/AssemblyInfo.vb
+++ b/LookupControlGui/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/LookupControlGui/My Project/Resources.Designer.vb b/LookupControlGui/My Project/Resources.Designer.vb
new file mode 100644
index 00000000..3cf88756
--- /dev/null
+++ b/LookupControlGui/My Project/Resources.Designer.vb
@@ -0,0 +1,62 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:4.0.30319.42000
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+
+Namespace My.Resources
+
+ 'This class was auto-generated by the StronglyTypedResourceBuilder
+ 'class via a tool like ResGen or Visual Studio.
+ 'To add or remove a member, edit your .ResX file then rerun ResGen
+ 'with the /str option, or rebuild your VS project.
+ '''
+ ''' A strongly-typed resource class, for looking up localized strings, etc.
+ '''
+ _
+ Friend Module Resources
+
+ Private resourceMan As Global.System.Resources.ResourceManager
+
+ Private resourceCulture As Global.System.Globalization.CultureInfo
+
+ '''
+ ''' Returns the cached ResourceManager instance used by this class.
+ '''
+ _
+ Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
+ Get
+ If Object.ReferenceEquals(resourceMan, Nothing) Then
+ Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("LookupControlGui.Resources", GetType(Resources).Assembly)
+ resourceMan = temp
+ End If
+ Return resourceMan
+ End Get
+ End Property
+
+ '''
+ ''' Overrides the current thread's CurrentUICulture property for all
+ ''' resource lookups using this strongly typed resource class.
+ '''
+ _
+ Friend Property Culture() As Global.System.Globalization.CultureInfo
+ Get
+ Return resourceCulture
+ End Get
+ Set(ByVal value As Global.System.Globalization.CultureInfo)
+ resourceCulture = value
+ End Set
+ End Property
+ End Module
+End Namespace
diff --git a/JobRunner/My Project/Resources.resx b/LookupControlGui/My Project/Resources.resx
similarity index 100%
rename from JobRunner/My Project/Resources.resx
rename to LookupControlGui/My Project/Resources.resx
diff --git a/LookupControlGui/My Project/Settings.Designer.vb b/LookupControlGui/My Project/Settings.Designer.vb
new file mode 100644
index 00000000..dcfe7c8c
--- /dev/null
+++ b/LookupControlGui/My Project/Settings.Designer.vb
@@ -0,0 +1,73 @@
+'------------------------------------------------------------------------------
+'
+' This code was generated by a tool.
+' Runtime Version:4.0.30319.42000
+'
+' Changes to this file may cause incorrect behavior and will be lost if
+' the code is regenerated.
+'
+'------------------------------------------------------------------------------
+
+Option Strict On
+Option Explicit On
+
+
+Namespace My
+
+ _
+ Partial Friend NotInheritable Class MySettings
+ Inherits Global.System.Configuration.ApplicationSettingsBase
+
+ Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
+
+#Region "My.Settings Auto-Save Functionality"
+#If _MyType = "WindowsForms" Then
+ Private Shared addedHandler As Boolean
+
+ Private Shared addedHandlerLockObject As New Object
+
+ _
+ Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
+ If My.Application.SaveMySettingsOnExit Then
+ My.Settings.Save()
+ End If
+ End Sub
+#End If
+#End Region
+
+ Public Shared ReadOnly Property [Default]() As MySettings
+ Get
+
+#If _MyType = "WindowsForms" Then
+ If Not addedHandler Then
+ SyncLock addedHandlerLockObject
+ If Not addedHandler Then
+ AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
+ addedHandler = True
+ End If
+ End SyncLock
+ End If
+#End If
+ Return defaultInstance
+ End Get
+ End Property
+ End Class
+End Namespace
+
+Namespace My
+
+ _
+ Friend Module MySettingsProperty
+
+ _
+ Friend ReadOnly Property Settings() As Global.LookupControlGui.My.MySettings
+ Get
+ Return Global.LookupControlGui.My.MySettings.Default
+ End Get
+ End Property
+ End Module
+End Namespace
diff --git a/LookupControlGui/My Project/Settings.settings b/LookupControlGui/My Project/Settings.settings
new file mode 100644
index 00000000..85b890b3
--- /dev/null
+++ b/LookupControlGui/My Project/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/Modules.Database/MSSQLServer.vb b/Modules.Database/MSSQLServer.vb
index cf1b1fbc..aff2870e 100644
--- a/Modules.Database/MSSQLServer.vb
+++ b/Modules.Database/MSSQLServer.vb
@@ -4,73 +4,67 @@ Imports DigitalData.Modules.Logging
Public Class MSSQLServer
Public DBInitialized As Boolean = False
Public CurrentSQLConnectionString As String = ""
- Private CurrentSQLConnection As SqlConnection
Private _Logger As Logger
Public Sub New(LogConfig As LogConfig, ConnectionString As String)
_Logger = LogConfig.GetLogger()
+ CurrentSQLConnectionString = ConnectionString
+
Try
- Dim oSQLconnect As New SqlConnection
- oSQLconnect.ConnectionString = ConnectionString
- oSQLconnect.Open()
- oSQLconnect.Close()
- CurrentSQLConnectionString = ConnectionString
- DBInitialized = True
+ DBInitialized = TestCanConnect()
Catch ex As Exception
DBInitialized = False
_Logger.Error(ex)
End Try
End Sub
- Private Function GetSQLConnection()
+ Private Function TestCanConnect() As Boolean
Try
- If IsNothing(CurrentSQLConnection) Then
- Dim oSQLconnect As New SqlClient.SqlConnection
- oSQLconnect.ConnectionString = CurrentSQLConnectionString
- CurrentSQLConnection = oSQLconnect
- CurrentSQLConnection.Open()
- Else
- If CurrentSQLConnection.State <> ConnectionState.Open Then
- _Logger.Warn($"Actual ConnectionState is: '{CurrentSQLConnection.State.ToString}'")
- Try
- CurrentSQLConnection.Open()
- Return True
- Catch ex As Exception
- _Logger.Warn("Could not reconnect to database!")
- Return False
- End Try
- End If
- End If
+ Dim oConnection As New SqlConnection(CurrentSQLConnectionString)
+ oConnection.Open()
+ oConnection.Close()
Return True
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
End Function
+
+ Private Function GetSQLConnection() As SqlConnection
+ Try
+ Dim oConnection As New SqlConnection(CurrentSQLConnectionString)
+ oConnection.Open()
+ Return oConnection
+ Catch ex As Exception
+ _Logger.Error(ex)
+ Return Nothing
+ End Try
+ End Function
'''
''' Returns a datatable for a sql-statement
'''
''' sqlcommand for datatable (select XYZ from TableORView)
- ''' Optional Timeout
+ ''' Optional Timeout
''' Returns a datatable
'''
- Public Function GetDatatable(sqlcommand As String, Optional commandtimeout As Integer = 120) As DataTable
+ Public Function GetDatatable(sqlcommand As String, Optional Timeout As Integer = 120) As DataTable
Try
- Dim dt As DataTable = New DataTable()
- If GetSQLConnection() = False Then
+ If TestCanConnect() = False Then
Return Nothing
End If
- Dim oSQLCOmmand As SqlCommand
+ Using oConnection = GetSQLConnection()
+ Using oSQLCOmmand = oConnection.CreateCommand()
+ oSQLCOmmand.CommandText = sqlcommand
+ oSQLCOmmand.CommandTimeout = Timeout
- oSQLCOmmand = CurrentSQLConnection.CreateCommand()
- oSQLCOmmand.CommandText = sqlcommand
- oSQLCOmmand.CommandTimeout = commandtimeout
- Dim adapter1 As SqlDataAdapter = New SqlDataAdapter(oSQLCOmmand)
- adapter1.Fill(dt)
-
- Return dt
+ Dim dt As DataTable = New DataTable()
+ Dim oAdapter As SqlDataAdapter = New SqlDataAdapter(oSQLCOmmand)
+ oAdapter.Fill(dt)
+ Return dt
+ End Using
+ End Using
Catch ex As Exception
_Logger.Error(ex)
_Logger.Debug("sqlcommand: " & sqlcommand)
@@ -81,29 +75,58 @@ Public Class MSSQLServer
''' Executes the passed sql-statement
'''
''' the sql statement
- ''' Optional Timeout
+ ''' Optional Timeout
''' Returns true if properly executed, else false
'''
- Public Function NewExecutenonQuery(executeStatement As String, Optional commandtimeout As Integer = 120) As Boolean
+ Public Function NewExecutenonQuery(executeStatement As String, Optional Timeout As Integer = 120) As Boolean
Try
- If GetSQLConnection() = False Then
+ If TestCanConnect() = False Then
Return Nothing
End If
- 'Dim oSQLconnect As New SqlClient.SqlConnection
- Dim oSQLCOmmand As SqlCommand
- oSQLCOmmand = CurrentSQLConnection.CreateCommand()
- oSQLCOmmand.CommandText = executeStatement
- oSQLCOmmand.CommandTimeout = commandtimeout
- oSQLCOmmand.ExecuteNonQuery()
- oSQLCOmmand.Dispose()
- Return True
+ Using oConnection = GetSQLConnection()
+ Using oSQLCOmmand = oConnection.CreateCommand()
+ oSQLCOmmand.CommandText = executeStatement
+ oSQLCOmmand.CommandTimeout = Timeout
+ oSQLCOmmand.ExecuteNonQuery()
+ Return True
+ End Using
+ End Using
Catch ex As Exception
_Logger.Error(ex)
_Logger.Debug("executeStatement: " & executeStatement)
Return False
End Try
End Function
+
+ '''
+ ''' Executes the passed sql-statement as Scalar
+ '''
+ ''' the sql statement
+ ''' Optional Timeout
+ ''' Returns true if properly executed, else false
+ '''
+ Public Function NewExecuteScalar(ScalarSQL As String, Optional Timeout As Integer = 120) As Object
+ Try
+ If TestCanConnect() = False Then
+ Return Nothing
+ End If
+
+ Using oConnection As SqlConnection = GetSQLConnection()
+ Using oSQLCOmmand = oConnection.CreateCommand()
+ oSQLCOmmand.CommandText = ScalarSQL
+ oSQLCOmmand.CommandTimeout = Timeout
+ Dim oResult As Object = oSQLCOmmand.ExecuteScalar()
+ Return oResult
+ End Using
+ End Using
+ Catch ex As Exception
+ _Logger.Error(ex)
+ _Logger.Debug("executeStatement: " & ScalarSQL)
+ Return Nothing
+ End Try
+ End Function
+
'''
''' Executes the passed sql-statement in asyncmode
'''
@@ -111,18 +134,20 @@ Public Class MSSQLServer
''' Optional Timeout
'''
Public Sub NewExecuteNonQueryAsync(executeStatement As String, Optional commandtimeout As Integer = 120)
- If GetSQLConnection() = False Then
+ If TestCanConnect() = False Then
Exit Sub
End If
- Dim oSQLCOmmand As SqlCommand
- Dim callback As New AsyncCallback(AddressOf NewExecuteNonQueryAsync_Callback)
Try
- oSQLCOmmand = CurrentSQLConnection.CreateCommand()
- oSQLCOmmand.CommandText = executeStatement
- oSQLCOmmand.CommandTimeout = commandtimeout
- oSQLCOmmand.BeginExecuteNonQuery(callback, oSQLCOmmand)
- oSQLCOmmand.Dispose()
+ Dim oCallback As New AsyncCallback(AddressOf NewExecuteNonQueryAsync_Callback)
+
+ Using oConnection As SqlConnection = GetSQLConnection()
+ Using oSQLCOmmand = oConnection.CreateCommand()
+ oSQLCOmmand.CommandText = executeStatement
+ oSQLCOmmand.CommandTimeout = commandtimeout
+ oSQLCOmmand.BeginExecuteNonQuery(oCallback, oSQLCOmmand)
+ End Using
+ End Using
Catch ex As Exception
_Logger.Error(ex)
_Logger.Debug("executeStatement: " & executeStatement)
@@ -132,33 +157,6 @@ Public Class MSSQLServer
Private Sub NewExecuteNonQueryAsync_Callback(ByVal result As IAsyncResult)
Dim command As SqlCommand = CType(result.AsyncState, SqlCommand)
Dim res = command.EndExecuteNonQuery(result)
- _Logger.Info(String.Format("Finished executing Async database operation: {0}", command.CommandText))
+ _Logger.Info("Finished executing Async database operation: {0}", command.CommandText)
End Sub
- '''
- ''' Executes the passed sql-statement as Scalar
- '''
- ''' the sql statement
- ''' Optional Timeout
- ''' Returns true if properly executed, else false
- '''
- Public Function NewExecuteScalar(executeStatement As String, Optional commandtimeout As Integer = 120)
- Dim result
- Try
- If GetSQLConnection() = False Then
- Return Nothing
- End If
-
- Dim oSQLCOmmand As SqlClient.SqlCommand
- oSQLCOmmand = CurrentSQLConnection.CreateCommand()
- oSQLCOmmand.CommandText = executeStatement
- oSQLCOmmand.CommandTimeout = commandtimeout
- result = oSQLCOmmand.ExecuteScalar()
- oSQLCOmmand.Dispose()
- Return result
- Catch ex As Exception
- _Logger.Error(ex)
- _Logger.Debug("executeStatement: " & executeStatement)
- Return Nothing
- End Try
- End Function
End Class
diff --git a/Modules.Interfaces/ActiveDirectoryInterface.vb b/Modules.Interfaces/ActiveDirectoryInterface.vb
index d3e8d8df..bd12e115 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)
@@ -45,8 +52,8 @@ Public Class ActiveDirectoryInterface
Dim oSyncedUsers As New List(Of ADUser)
Dim oGroupId As Int64 = Nothing
- Dim oFirebirdSync As New SyncUsers.Firebird(_logConfig, _firebird)
- Dim oSQLSync As New SyncUsers.MSSQL(_logConfig, _mssql)
+ Dim oFirebirdSync As New SyncUsers.SyncUsersFirebird(_logConfig, _firebird)
+ Dim oSQLSync As New SyncUsers.SyncUsersMSSQL(_logConfig, _mssql)
Dim oSyncedUsersFirebird, oSyncedUsersMSSQL As List(Of ADUser)
Try
@@ -66,13 +73,17 @@ Public Class ActiveDirectoryInterface
' Do the actual sync into firebird
If _firebird IsNot Nothing Then
oSyncedUsersFirebird = oFirebirdSync.SyncUsers(GroupName, oUsers, AttributeMappings)
- _logger.Info("Synced {0} users to Firebird", oSyncedUsersFirebird.Count)
+ If oSyncedUsersFirebird.Count > 0 Then
+ _logger.Info("Synced {0} users to Firebird", oSyncedUsersFirebird.Count)
+ End If
End If
' Do the actual sync into MSSQL
If _mssql IsNot Nothing Then
oSyncedUsersMSSQL = oSQLSync.SyncUsers(GroupName, oUsers, AttributeMappings)
- _logger.Info("Synced {0} users to MSSQLServer", oSyncedUsersMSSQL.Count)
+ If oSyncedUsersMSSQL.Count > 0 Then
+ _logger.Info("Synced {0} users to MSSQLServer", oSyncedUsersMSSQL.Count)
+ End If
End If
Return oUsers
@@ -139,43 +150,57 @@ Public Class ActiveDirectoryInterface
Using oContext As New PrincipalContext(ContextType.Domain)
Using oGroupPrincipal As GroupPrincipal = GroupPrincipal.FindByIdentity(oContext, IdentityType.Name, GroupName)
If oGroupPrincipal Is Nothing Then
- _logger.Warn("Group {0} does not exist.", GroupName)
+ _logger.Debug("Group {0} does not exist.", GroupName)
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.Debug("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.Debug("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 +209,7 @@ Public Class ActiveDirectoryInterface
Return oUsers
Catch ex As Exception
_logger.Error(ex)
- Throw ex
+ Return oUsers
End Try
End Function
@@ -229,7 +254,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/Modules.Interfaces/ActiveDirectoryInterface/SyncUsers.Firebird.vb b/Modules.Interfaces/ActiveDirectoryInterface/SyncUsers.Firebird.vb
index 00d842d0..c772db48 100644
--- a/Modules.Interfaces/ActiveDirectoryInterface/SyncUsers.Firebird.vb
+++ b/Modules.Interfaces/ActiveDirectoryInterface/SyncUsers.Firebird.vb
@@ -3,7 +3,7 @@ Imports DigitalData.Modules.Interfaces
Imports DigitalData.Modules.Logging
Namespace SyncUsers
- Public Class Firebird
+ Public Class SyncUsersFirebird
Implements ISyncUsers
Private ReadOnly _logConfig As LogConfig
@@ -25,7 +25,7 @@ Namespace SyncUsers
oGroupId = GetGroupId(GroupName)
If oGroupId = 0 Then
- _logger.Warn("Group {0} does not exist in database. Exiting", GroupName)
+ _logger.Debug("Group {0} does not exist in database or is not enabled for sync.", GroupName)
Return oSyncedUsers
End If
diff --git a/Modules.Interfaces/ActiveDirectoryInterface/SyncUsers.MSSQL.vb b/Modules.Interfaces/ActiveDirectoryInterface/SyncUsers.MSSQL.vb
index 6dcd32e9..032a7dfc 100644
--- a/Modules.Interfaces/ActiveDirectoryInterface/SyncUsers.MSSQL.vb
+++ b/Modules.Interfaces/ActiveDirectoryInterface/SyncUsers.MSSQL.vb
@@ -2,14 +2,16 @@
Imports DigitalData.Modules.Logging
Namespace SyncUsers
- Public Class MSSQL
+ Public Class SyncUsersMSSQL
Implements ISyncUsers
Private _logConfig As LogConfig
Private _logger As Logger
Private _mssql As MSSQLServer
- Public Sub New(LogConfig As LogConfig, MSSQL As Database.MSSQLServer)
+ Private Const ADDED_WHO = "Active Directory Sync"
+
+ Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer)
_logConfig = LogConfig
_logger = LogConfig.GetLogger()
_mssql = MSSQL
@@ -24,7 +26,7 @@ Namespace SyncUsers
oGroupId = GetGroupId(GroupName)
If oGroupId = 0 Then
- _logger.Warn("Group {0} does not exist in database. Exiting", GroupName)
+ _logger.Debug("Group {0} does not exist in database. Exiting.", GroupName)
Return oSyncedUsers
End If
@@ -43,10 +45,10 @@ Namespace SyncUsers
_logger.Debug("Checking if user {0} exists", oUser)
oUserId = GetUserId(oUser.samAccountName)
oUserExists = oUserId > 0
- _logger.Debug("User {0} exists in database: ", oUser, oUserExists)
+ _logger.Debug("User {0} exists in database: {1}", oUser, oUserExists)
Catch ex As Exception
_logger.Error(ex)
- _logger.Warn("Could not get UserId for user. Skipping")
+ _logger.Warn("Could not get UserId for user. Skipping.")
Continue For
End Try
@@ -59,7 +61,7 @@ Namespace SyncUsers
End If
Catch ex As Exception
_logger.Error(ex)
- _logger.Warn("Could not create user. Skipping")
+ _logger.Warn("Could not create user. Skipping.")
Continue For
End Try
@@ -68,7 +70,7 @@ Namespace SyncUsers
AddCustomAttributesToUser(oUser, oUserId)
Catch ex As Exception
_logger.Error(ex)
- _logger.Warn("Could not add custom attributes to user {0}. Continuing", oUser)
+ _logger.Debug("Could not add custom attributes to user {0}. Continuing.", oUser)
End Try
' Add the user to group
@@ -76,7 +78,7 @@ Namespace SyncUsers
AddUserToGroup(oUserId, oGroupId)
Catch ex As Exception
_logger.Error(ex)
- _logger.Warn("Could not add user {0} to group {1}. Skipping", oUser, GroupName)
+ _logger.Warn("Could not add user {0} to group {1}. Skipping.", oUser, GroupName)
Continue For
End Try
@@ -88,7 +90,7 @@ Namespace SyncUsers
Private Sub AddUserToGroup(UserId As Integer, GroupId As Integer) Implements ISyncUsers.AddUserToGroup
Try
- Dim oSQL As String = $"INSERT INTO TBDD_GROUPS_USER (USER_ID, GROUP_ID) VALUES ({UserId}, {GroupId})"
+ Dim oSQL As String = $"INSERT INTO TBDD_GROUPS_USER (USER_ID, GROUP_ID, ADDED_WHO) VALUES ({UserId}, {GroupId}, '{ADDED_WHO}')"
Dim oResult = _mssql.NewExecutenonQuery(oSQL)
If oResult = False Then
@@ -102,11 +104,11 @@ Namespace SyncUsers
Private Function GetGroupId(GroupName As String) As Integer Implements ISyncUsers.GetGroupId
Try
- Dim oSQL As String = $"SELECT GUID FROM TBDD_GROUPS WHERE NAME = '{GroupName}'"
+ Dim oSQL As String = $"SELECT GUID FROM TBDD_GROUPS WHERE NAME = '{GroupName}' AND AD_SYNC = 1 AND ACTIVE = 1"
Dim oGroupId = _mssql.NewExecuteScalar(oSQL)
If IsDBNull(oGroupId) OrElse oGroupId = 0 Then
- _logger.Debug("Group {0} not found in database", GroupName)
+ _logger.Debug("Group {0} not found in database.", GroupName)
Return 0
End If
@@ -135,7 +137,7 @@ Namespace SyncUsers
Private Function CreateUser(User As ADUser) As Integer Implements ISyncUsers.CreateUser
Try
- Dim oSQL As String = $"INSERT INTO TBDD_USER (PRENAME, NAME, USERNAME, EMAIL) VALUES ('{User.GivenName}', '{User.Surname}', '{User.samAccountName}', '{User.Email}')"
+ Dim oSQL As String = $"INSERT INTO TBDD_USER (PRENAME, NAME, USERNAME, EMAIL, ADDED_WHO) VALUES ('{User.GivenName}', '{User.Surname}', '{User.samAccountName}', '{User.Email}', '{ADDED_WHO}')"
Dim oResult = _mssql.NewExecutenonQuery(oSQL)
If oResult = True Then
@@ -154,11 +156,11 @@ Namespace SyncUsers
Dim oCustomAttributes = User.CustomAttributes
For Each oAttribute In oCustomAttributes
- Dim oSQL As String = $"UPDATE TBDD_USER SET {oAttribute.MSSQLColumn} = '{oAttribute.Value}' WHERE GUID = {UserId}"
+ Dim oSQL As String = $"UPDATE TBDD_USER SET {oAttribute.MSSQLColumn} = '{oAttribute.Value}', CHANGED_WHO = '{ADDED_WHO}' WHERE GUID = {UserId}"
Dim oResult = _mssql.NewExecutenonQuery(oSQL)
If oResult = False Then
- _logger.Warn("Custom Attribute {0} could not be added to user {1}", oAttribute.Name, User.samAccountName)
+ _logger.Debug("Custom Attribute {0} could not be added to user {1}", oAttribute.Name, User.samAccountName)
Continue For
End If
Next
diff --git a/JobRunner/App.config b/Service.JobRunner/App.config
similarity index 51%
rename from JobRunner/App.config
rename to Service.JobRunner/App.config
index 3249a680..7f837fee 100644
--- a/JobRunner/App.config
+++ b/Service.JobRunner/App.config
@@ -5,43 +5,34 @@
-
-
-
-
- DDJobRunner
+
+
-
- Digital Data Job Runner
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
False
-
+
-
-
-
-
-
-
-
-
-
-
- 120
-
-
- 120
-
-
-
-
-
-
+
+ False|10/0 * * * * ?|Foo:Bar
diff --git a/Service.JobRunner/JobRunner.vb b/Service.JobRunner/JobRunner.vb
new file mode 100644
index 00000000..aa378bb4
--- /dev/null
+++ b/Service.JobRunner/JobRunner.vb
@@ -0,0 +1,169 @@
+Imports System.Collections.Specialized
+Imports System.Text.RegularExpressions
+Imports DigitalData.Modules.Database
+Imports DigitalData.Modules.Jobs
+Imports DigitalData.Modules.Logging
+Imports Quartz
+Imports Quartz.Impl
+Imports Quartz.Logging
+
+Public Class JobRunner
+ Private _LogConfig As LogConfig
+ Private _Logger As DigitalData.Modules.Logging.Logger
+ Private _firebird As Firebird
+ Private _mssql As MSSQLServer
+
+ Private _Props As New NameValueCollection From {
+ {"quartz.serializer.type", "binary"},
+ {"quartz.threadPool.threadCount", 10}
+ }
+ Private _factory As StdSchedulerFactory
+ Private _scheduler As IScheduler
+
+ Public Sub New(LogConfig As LogConfig, MSSQL As MSSQLServer, Firebird As Firebird)
+ _LogConfig = LogConfig
+ _Logger = LogConfig.GetLogger()
+ _firebird = Firebird
+ _mssql = MSSQL
+ End Sub
+
+ Public Async Sub Start()
+ Try
+ Logging.LogProvider.SetCurrentLogProvider(New LogProvider(_Logger))
+
+ _Logger.Info("Starting JobRunner")
+
+ Dim oProps As New NameValueCollection From {
+ {"quartz.serializer.type", "binary"}
+ }
+ _factory = New StdSchedulerFactory(oProps)
+ _scheduler = Await _factory.GetScheduler()
+
+ _Logger.Info("Starting Scheduler..")
+ Await _scheduler.Start()
+
+ ' [START] Job Scheduling
+ ' ADSync
+ Await ScheduleJob(Of ADJob)("ADSync", My.Settings.ADSYNC_CONFIG)
+ ' Test Job
+ Await ScheduleJob(Of TestJob)("TestJob", My.Settings.TEST_CONFIG)
+ ' [END] Job Scheduling
+
+ Catch ex As Exception
+ _Logger.Warn("Job Failed.")
+ _Logger.Error(ex)
+ End Try
+ End Sub
+
+ Public Async Function ScheduleJob(Of T As Quartz.IJob)(JobName As String, JobConfigString As String) As Task
+ Dim oJobIdentity As String = JobName
+ Dim oTriggerIdentity As String = JobName & "-Trigger"
+ Dim oJobConfig As JobConfig = JobConfigParser.ParseConfig(JobConfigString)
+ Dim oJobData As New JobDataMap From {
+ {"LogConfig", _LogConfig},
+ {"Firebird", _firebird},
+ {"MSSQL", _mssql},
+ {"Args", oJobConfig.Arguments}
+ }
+
+ Dim oJobDetail = JobBuilder.Create(Of T)().
+ WithIdentity(oJobIdentity).
+ UsingJobData(oJobData).
+ Build()
+
+ Dim oTrigger = TriggerBuilder.Create().
+ WithIdentity(oTriggerIdentity).
+ StartNow().
+ WithCronSchedule(oJobConfig.CronExpression).
+ Build()
+
+ If oJobConfig.Enabled Then
+ Await _scheduler.ScheduleJob(oJobDetail, oTrigger)
+ _Logger.Info("Job {0} started.", JobName)
+ Else
+ _Logger.Info("Job {0} is disabled.", JobName)
+ End If
+ End Function
+
+ Public Async Sub [Stop]()
+ _Logger.Info("Stopping JobRunner")
+ Await _scheduler.Shutdown()
+ End Sub
+
+ Public Class ADJob
+ Implements Quartz.IJob
+
+ Public Function Execute(context As IJobExecutionContext) As Task Implements Quartz.IJob.Execute
+ Dim oJobData = context.MergedJobDataMap
+ Dim oLogConfig As LogConfig = oJobData.Item("LogConfig")
+ Dim oFirebird As Firebird = oJobData.Item("Firebird")
+ Dim oMSSQL As MSSQLServer = oJobData.Item("MSSQL")
+ Dim oArgs As Dictionary(Of String, String) = oJobData.Item("Args")
+ Dim oADJobArgs = New ADSyncArgs()
+
+ If oArgs.ContainsKey("RootPath") Then
+ oADJobArgs.RootPath = oArgs.Item("RootPath")
+ End If
+
+ Dim oADSyncJob As New ADSyncJob(oLogConfig, oFirebird, oMSSQL)
+ oADSyncJob.Start(oADJobArgs)
+
+ Return Task.FromResult(True)
+ End Function
+ End Class
+ Public Class TestJob
+ Implements Quartz.IJob
+
+ Public Function Execute(context As IJobExecutionContext) As Task Implements Quartz.IJob.Execute
+ Dim oJobData = context.MergedJobDataMap
+ Dim oLogConfig As LogConfig = oJobData.Item("LogConfig")
+ Dim oLogger = oLogConfig.GetLogger()
+
+ Dim oArgs As Dictionary(Of String, String) = oJobData.Item("Args")
+
+ If oArgs.ContainsKey("Arg1") Then
+ Dim oArg1 As String = oArgs.Item("Arg1")
+ oLogger.Info("Running Test Job With Arg1: {0}", oArg1)
+ Else
+ oLogger.Warn("Running Test Job With missing Arg1 :/")
+ End If
+
+ Return Task.FromResult(True)
+ End Function
+ End Class
+
+ Private Class LogProvider
+ Implements ILogProvider
+
+ Private _Logger As DigitalData.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 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
+ End Function
+ 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
+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..24106e2a
--- /dev/null
+++ b/Service.JobRunner/JobRunnerService.vb
@@ -0,0 +1,39 @@
+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) With {
+ .Debug = My.Settings.LOG_DEBUG
+ }
+ _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/Service.JobRunner/My Project/AssemblyInfo.vb b/Service.JobRunner/My Project/AssemblyInfo.vb
new file mode 100644
index 00000000..9c9ed951
--- /dev/null
+++ b/Service.JobRunner/My Project/AssemblyInfo.vb
@@ -0,0 +1,35 @@
+Imports System
+Imports System.Reflection
+Imports System.Runtime.InteropServices
+
+' Allgemeine Informationen über eine Assembly werden über die folgenden
+' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+' die einer Assembly zugeordnet sind.
+
+' 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:
+'
+' Hauptversion
+' Nebenversion
+' Buildnummer
+' Revision
+'
+' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
+' übernehmen, indem Sie "*" eingeben:
+'
+
+
+
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/Service.JobRunner/My Project/Resources.resx b/Service.JobRunner/My Project/Resources.resx
new file mode 100644
index 00000000..af7dbebb
--- /dev/null
+++ b/Service.JobRunner/My Project/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/JobRunner/My Project/Settings.Designer.vb b/Service.JobRunner/My Project/Settings.Designer.vb
similarity index 74%
rename from JobRunner/My Project/Settings.Designer.vb
rename to Service.JobRunner/My Project/Settings.Designer.vb
index 5416b196..da4d8c38 100644
--- a/JobRunner/My Project/Settings.Designer.vb
+++ b/Service.JobRunner/My Project/Settings.Designer.vb
@@ -56,100 +56,82 @@ Namespace My
_
- Public ReadOnly Property SERVICE_NAME() As String
+ Global.System.Configuration.DefaultSettingValueAttribute("")> _
+ Public ReadOnly Property LOG_PATH() As String
Get
- Return CType(Me("SERVICE_NAME"),String)
+ Return CType(Me("LOG_PATH"),String)
End Get
End Property
_
- Public ReadOnly Property SERVICE_DISPLAY_NAME() As String
+ Global.System.Configuration.DefaultSettingValueAttribute("")> _
+ Public ReadOnly Property SQL_CONNECTIONSTRING() As String
Get
- Return CType(Me("SERVICE_DISPLAY_NAME"),String)
+ 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
_
- Public ReadOnly Property JOB_ADSYNC_ENABLED() As Boolean
+ Public ReadOnly Property LOG_DEBUG() As Boolean
Get
- Return CType(Me("JOB_ADSYNC_ENABLED"),Boolean)
+ Return CType(Me("LOG_DEBUG"),Boolean)
End Get
End Property
_
- Public ReadOnly Property DB_DATASOURCE() As String
+ Public ReadOnly Property ADSYNC_CONFIG() As String
Get
- Return CType(Me("DB_DATASOURCE"),String)
+ Return CType(Me("ADSYNC_CONFIG"),String)
End Get
End Property
_
- Public ReadOnly Property DB_DATABASE() As String
+ Global.System.Configuration.DefaultSettingValueAttribute("False|10/0 * * * * ?|Foo:Bar")> _
+ Public ReadOnly Property TEST_CONFIG() 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
-
- _
- Public ReadOnly Property JOB_ADSYNC_ROOT_PATH() As String
- Get
- Return CType(Me("JOB_ADSYNC_ROOT_PATH"),String)
- End Get
- End Property
-
- _
- Public ReadOnly Property DB_CONNECTIONSTRING() As String
- Get
- Return CType(Me("DB_CONNECTIONSTRING"),String)
+ Return CType(Me("TEST_CONFIG"),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..61a6220d
--- /dev/null
+++ b/Service.JobRunner/My Project/Settings.settings
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+
+ False|10/0 * * * * ?|Foo:Bar
+
+
+
\ 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