This commit is contained in:
SchreiberM 2021-04-08 16:19:27 +02:00
commit 1a3b9862f9
12 changed files with 152 additions and 30 deletions

View File

@ -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)

View File

@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.0.1.0")>
<Assembly: AssemblyFileVersion("3.0.1.0")>
<Assembly: AssemblyVersion("3.0.3.0")>
<Assembly: AssemblyFileVersion("3.0.3.0")>

View File

@ -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

View File

@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' indem Sie "*" wie unten gezeigt eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: AssemblyVersion("1.0.1.0")>
<Assembly: AssemblyFileVersion("1.0.1.0")>

View File

@ -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

View File

@ -118,7 +118,7 @@ Public Class ConfigManager(Of T)
_WriteAllValuesToUserConfig = ForceUserConfig
Config = LoadConfig()
_Config = LoadConfig()
End Sub
''' <summary>
@ -145,6 +145,20 @@ Public Class ConfigManager(Of T)
End Try
End Function
''' <summary>
''' Reloads the config object from file.
''' </summary>
''' <returns>True if reload was successful, False otherwise</returns>
Public Function Reload() As Boolean
Try
_Config = LoadConfig()
Return True
Catch ex As Exception
_Logger.Error(ex)
Return False
End Try
End Function
''' <summary>
''' Copies all properties from Source to Target, except those who have an attribute
''' listed in ExcludedAttributeTypes

View File

@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("Modules.Config")>
<Assembly: AssemblyCopyright("Copyright © 2019")>
<Assembly: AssemblyCopyright("Copyright © 2021")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.11.0")>
<Assembly: AssemblyFileVersion("1.0.11.0")>
<Assembly: AssemblyVersion("1.1.0.0")>
<Assembly: AssemblyFileVersion("1.1.0.0")>

View File

@ -4,7 +4,10 @@
</configSections>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information,ActivityTracing" propagateActivity="true">
<source name="System.ServiceModel"
switchValue="Warning"
switchType="DigitalData.Services.EDMIService.TraceSwitch, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>

View File

@ -133,6 +133,7 @@
<Compile Include="Helpers\Exceptions.vb" />
<Compile Include="Helpers\DatabaseResult.vb" />
<Compile Include="EDMIService.vb" />
<Compile Include="Helpers\TraceSwitch.vb" />
<Compile Include="Scheduler\Scheduler.vb" />
<Compile Include="Scheduler\DatatableJob.vb" />
<Compile Include="Scheduler\JobListener.vb" />

View File

@ -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

View File

@ -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

View File

@ -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")