diff --git a/Controls.LookupGrid/LookupControl3.vb b/Controls.LookupGrid/LookupControl3.vb index e44244b0..cee08f3c 100644 --- a/Controls.LookupGrid/LookupControl3.vb +++ b/Controls.LookupGrid/LookupControl3.vb @@ -49,6 +49,7 @@ Public Class RepositoryItemLookupControl3 SetDropdownButtonEnabled(_MultiSelect) End Sub + Private Const NAME_DATATABLE_INTERNAL = "__INTERNAL_DATATABLE__" Private Const TAG_DROPDOWN = "openDropdown" Private Const TAG_BUTTON_LOOKUP_FORM = "openLookupForm" @@ -165,8 +166,12 @@ Public Class RepositoryItemLookupControl3 NullText = Values.FirstOrDefault() End If - If DataSource Is Nothing Then - Dim oDataTable As New DataTable() + ' If No external Datasource is supplied, create one containing the currently selected values + ' If the current datasource is the internal one, update it + If DataSource Is Nothing OrElse (TypeOf DataSource Is DataTable AndAlso DirectCast(DataSource, DataTable).TableName = NAME_DATATABLE_INTERNAL) Then + Dim oDataTable As New DataTable() With { + .TableName = NAME_DATATABLE_INTERNAL + } oDataTable.Columns.Add(New DataColumn("Data", GetType(String))) For Each oValue In Values @@ -224,6 +229,18 @@ Public Class RepositoryItemLookupControl3 If oResult = Windows.Forms.DialogResult.OK Then Dim oValues = oForm.SelectedValues UpdateSelectedValues(oValues) + + If oForm.NewValues.Count > 0 AndAlso TypeOf DataSource Is DataTable Then + Dim oTable As DataTable = DirectCast(DataSource, DataTable) + + If oTable.TableName <> NAME_DATATABLE_INTERNAL Then + For Each oValue In oForm.NewValues + Dim oRow = oTable.NewRow() + oRow.Item(0) = oValue + oTable.Rows.Add(oRow) + Next + End If + End If End If End Using End If @@ -248,9 +265,9 @@ Public Class RepositoryItemLookupControl3 If DataSource IsNot Nothing AndAlso DataSource.Columns.Count > 0 Then Dim oFirstColumn As String = DataSource.Columns.Item(0).ColumnName - Dim oWrapped = SelectedValues.Select(Function(v As String) - Return $"'{v}'" - End Function).ToArray() + Dim oWrapped = SelectedValues. + Select(Function(v As String) $"'{v}'"). + ToArray() Dim oValueString As String = String.Join(",", oWrapped) Dim oCriterium As String = $"[{oFirstColumn}] IN ({oValueString})" View.ActiveFilterCriteria = DevExpress.Data.Filtering.CriteriaOperator.Parse(oCriterium) diff --git a/Controls.LookupGrid/My Project/AssemblyInfo.vb b/Controls.LookupGrid/My Project/AssemblyInfo.vb index ff9ace7c..1ba7bcc3 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 c770f47d..a25db847 100644 --- a/Controls.LookupGrid/frmLookupGrid.vb +++ b/Controls.LookupGrid/frmLookupGrid.vb @@ -9,6 +9,9 @@ Public Class frmLookupGrid Public Property PreventDuplicates As Boolean Public Property DataSource As DataTable Public Property SelectedValues As List(Of String) + Public Property NewValues As New HashSet(Of String) + + Public Const COLUMN_SELECTED = "SELECTED" Private _DataColumn As Integer Private _DataSourceTemp As DataTable @@ -29,7 +32,7 @@ Public Class frmLookupGrid End If If MultiSelect Then - If Not _DataSourceTemp.Columns.Contains("SELECTED") Then + If Not _DataSourceTemp.Columns.Contains(COLUMN_SELECTED) Then Dim selectedColumn = New DataColumn() With { .ColumnName = "SELECTED", .DataType = GetType(Boolean), @@ -96,7 +99,7 @@ Public Class frmLookupGrid For oIndex = 0 To viewLookup.DataRowCount - 1 Dim oRow As DataRow = _View.GetDataRow(oIndex) Dim oSelected As Boolean = oRow.Item(0) - Dim oValue As Object = oRow.Item(1) + Dim oValue As Object = GetValueFromRow(oRow) If oSelected Then oValues.Add(oValue) @@ -115,7 +118,7 @@ Public Class frmLookupGrid Dim oValues As New List(Of String) If oRow IsNot Nothing Then - Dim oValue = oRow.Item(0) + Dim oValue = GetValueFromRow(oRow) oValues.Add(oValue) End If @@ -123,6 +126,13 @@ Public Class frmLookupGrid End If End Sub + Private Function GetValueFromRow(pRow As DataRow) As String + If MultiSelect Then + Return pRow.Item(1) + Else + Return pRow.Item(0) + End If + End Function Private Sub SyncItemsWithView(view As GridView) ' Wenn Vorbelegungen existieren, werden diese angehakt @@ -145,8 +155,6 @@ Public Class frmLookupGrid End If End If End If - - Next End If End Sub @@ -235,9 +243,15 @@ Public Class frmLookupGrid End Sub Private Sub viewLookup_ValidateRow(sender As Object, e As ValidateRowEventArgs) Handles viewLookup.ValidateRow - If MultiSelect And e.RowHandle = GridControl.NewItemRowHandle Then - Dim oRow As DataRowView = viewLookup.GetRow(e.RowHandle) - oRow.Row.Item("SELECTED") = True + If e.RowHandle = GridControl.NewItemRowHandle Then + Dim oRowView As DataRowView = viewLookup.GetRow(e.RowHandle) + Dim oValue = GetValueFromRow(oRowView.Row) + NewValues.Add(oValue) + + ' Automatically select newly added row when MultiSelect is enabled + If MultiSelect Then + oRowView.Row.Item(COLUMN_SELECTED) = True + End If End If End Sub End Class \ No newline at end of file diff --git a/GUIs.GlobalIndexer/My Project/AssemblyInfo.vb b/GUIs.GlobalIndexer/My Project/AssemblyInfo.vb index c0b3cbdf..5e67d672 100644 --- a/GUIs.GlobalIndexer/My Project/AssemblyInfo.vb +++ b/GUIs.GlobalIndexer/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' indem Sie "*" wie unten gezeigt eingeben: ' - - + + diff --git a/GUIs.Test.TestGUI/frmLookup.vb b/GUIs.Test.TestGUI/frmLookup.vb index bca26cb3..7721fa3d 100644 --- a/GUIs.Test.TestGUI/frmLookup.vb +++ b/GUIs.Test.TestGUI/frmLookup.vb @@ -9,18 +9,22 @@ Public Class frmLookup Dim LookupControl31 As New LookupControl3 With { .Location = New Point(10, 10), - .Size = New Drawing.Size(100, 27) + .Size = New Size(300, 27) } Dim LookupControl32 As New LookupControl3 With { .Location = New Point(10, 60), - .Size = New Drawing.Size(100, 27) + .Size = New Size(300, 27) } Dim LookupControl33 As New LookupControl3 With { .Location = New Point(10, 110), - .Size = New Drawing.Size(100, 27) + .Size = New Size(300, 27) + } + Dim LookupControl34 As New LookupControl3 With { + .Location = New Point(10, 160), + .Size = New Size(300, 27) } - Controls.AddRange({LookupControl31, LookupControl32, LookupControl33}) + Controls.AddRange({LookupControl31, LookupControl32, LookupControl33, LookupControl34}) LookupControl31.Properties.DataSource = oTable @@ -31,6 +35,10 @@ Public Class frmLookup LookupControl33.Properties.AllowAddNewValues = True LookupControl33.Properties.MultiSelect = True + LookupControl33.Properties.DataSource = oTable + + LookupControl34.Properties.AllowAddNewValues = True + LookupControl34.Properties.MultiSelect = True End Sub Private Function GetDatatable(Limit As Integer) As DataTable diff --git a/Modules.Config/ConfigManager.vb b/Modules.Config/ConfigManager.vb index dad9c96e..cb9754cf 100644 --- a/Modules.Config/ConfigManager.vb +++ b/Modules.Config/ConfigManager.vb @@ -118,7 +118,7 @@ Public Class ConfigManager(Of T) _WriteAllValuesToUserConfig = ForceUserConfig - Config = LoadConfig() + _Config = LoadConfig() End Sub ''' @@ -145,6 +145,20 @@ Public Class ConfigManager(Of T) End Try End Function + ''' + ''' Reloads the config object from file. + ''' + ''' True if reload was successful, False otherwise + Public Function Reload() As Boolean + Try + _Config = LoadConfig() + Return True + Catch ex As Exception + _Logger.Error(ex) + Return False + End Try + End Function + ''' ''' Copies all properties from Source to Target, except those who have an attribute ''' listed in ExcludedAttributeTypes diff --git a/Modules.Config/My Project/AssemblyInfo.vb b/Modules.Config/My Project/AssemblyInfo.vb index c7717a79..74781c84 100644 --- a/Modules.Config/My Project/AssemblyInfo.vb +++ b/Modules.Config/My Project/AssemblyInfo.vb @@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Service.EDMIService/App.config b/Service.EDMIService/App.config index 4d9ba156..90304c22 100644 --- a/Service.EDMIService/App.config +++ b/Service.EDMIService/App.config @@ -4,7 +4,10 @@ - + diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj index 74fd818f..17da2e73 100644 --- a/Service.EDMIService/EDMIService.vbproj +++ b/Service.EDMIService/EDMIService.vbproj @@ -133,6 +133,7 @@ + diff --git a/Service.EDMIService/Helpers/TraceSwitch.vb b/Service.EDMIService/Helpers/TraceSwitch.vb new file mode 100644 index 00000000..f34db423 --- /dev/null +++ b/Service.EDMIService/Helpers/TraceSwitch.vb @@ -0,0 +1,34 @@ +Public Class TraceSwitch + Inherits SourceSwitch + + Public Sub New(Name As String) + MyBase.New("System.ServiceModel") + Level = SourceLevels.Information + WcfTracesController.Instance.LevelController = AddressOf WcfTracesLevelController + End Sub + + Public Sub WcfTracesLevelController(ByVal level As SourceLevels) + Me.Level = level + End Sub +End Class + +Public Class WcfTracesController + Private Shared Controller As WcfTracesController = Nothing + + Private Sub New() + End Sub + + Public Delegate Sub TraceLevelController(ByVal level As SourceLevels) + Public LevelController As TraceLevelController + + Public Shared ReadOnly Property Instance As WcfTracesController + Get + + If Controller Is Nothing Then + Controller = New WcfTracesController() + End If + + Return Controller + End Get + End Property +End Class diff --git a/Service.EDMIService/ServiceHost.vb b/Service.EDMIService/ServiceHost.vb index e24905d0..9680df2e 100644 --- a/Service.EDMIService/ServiceHost.vb +++ b/Service.EDMIService/ServiceHost.vb @@ -9,15 +9,11 @@ Public Class ServiceHost(Of T) MyBase.New(GetType(T), baseAddresses) End Sub - - Public Sub EnableMetadataExchange(ByVal Optional EnableHttpGet As Boolean = True) If State = CommunicationState.Opened Then Throw New InvalidOperationException("Host is already opened") End If - - Dim oMetadataBehavior As ServiceMetadataBehavior = Description.Behaviors.Find(Of ServiceMetadataBehavior)() If oMetadataBehavior Is Nothing Then diff --git a/Service.EDMIService/WindowsService.vb b/Service.EDMIService/WindowsService.vb index 0a6d78e8..26bb05b8 100644 --- a/Service.EDMIService/WindowsService.vb +++ b/Service.EDMIService/WindowsService.vb @@ -63,6 +63,19 @@ Public Class WindowsService _Config = _ConfigManager.Config _LogConfig.Debug = _ConfigManager.Config.Debug + UpdateTraceLogging() + + Dim oTimer As New Timers.Timer(60000) + AddHandler oTimer.Elapsed, Sub() + _Logger.Debug("Reloading config..") + _ConfigManager.Reload() + _Config = _ConfigManager.Config + _LogConfig.Debug = _ConfigManager.Config.Debug + + UpdateTraceLogging() + End Sub + oTimer.Start() + _Logger.Debug("Connecting to Databases") _Firebird = StartFirebird() @@ -119,6 +132,28 @@ Public Class WindowsService End Try End Sub + Private Sub UpdateTraceLogging() + Try + ' Changing Tracelevels programmatically, + ' See: https://wcfpro.wordpress.com/2010/11/21/how-to-add-wcf-traces-programmatically/ + _Logger.Debug("UpdateTraceLogging running..") + _Logger.Debug("SourceLevels is off by default") + + Dim oTraceLevel = SourceLevels.Off + + _Logger.Debug("Debug is currently set to {0}", _ConfigManager.Config.Debug) + If _ConfigManager.Config.Debug Then + oTraceLevel = SourceLevels.Warning + End If + + _Logger.Debug("Setting TraceLevel to {0}", oTraceLevel) + WcfTracesController.Instance.LevelController(oTraceLevel) + Catch ex As Exception + _Logger.Warn("TraceLogging could not be updated!") + _Logger.Error(ex) + End Try + End Sub + Private Function StartFirebird() As Firebird _Logger.Debug("Connecting to Firebird")