3 Commits

Author SHA1 Message Date
Jonathan Jenne
33d3af4de8 EDMIService: Reload Config every 5 mins and change tracelogging/debug logging based on debug option in config 2021-04-06 16:39:14 +02:00
Jonathan Jenne
2cbafff539 Config: Version 1.1.0 2021-04-06 16:37:00 +02:00
Jonathan Jenne
686b5bc0ec Config: Add Reload Function 2021-04-06 16:36:15 +02:00
7 changed files with 82 additions and 9 deletions

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,18 @@ Public Class WindowsService
End Try
End Sub
Private Sub UpdateTraceLogging()
' Changing Tracelevels programmatically,
' See: https://wcfpro.wordpress.com/2010/11/21/how-to-add-wcf-traces-programmatically/
Dim oTraceLevel = SourceLevels.Off
If _ConfigManager.Config.Debug Then
oTraceLevel = SourceLevels.Warning
End If
WcfTracesController.Instance.LevelController(oTraceLevel)
End Sub
Private Function StartFirebird() As Firebird
_Logger.Debug("Connecting to Firebird")