Verbesserung der Protokollierung und Konfigurationsbereinigung

Die Änderungen umfassen:

- Anpassung der `App.config`: Entfernen veralteter Einstellungen (`FB_DATABASE`, `FB_USER`, etc.) und Hinzufügen neuer Platzhalter (`Test`).
- Verbesserte Fehlerbehandlung und Protokollierung in `Form1.vb`, `WindowsService.vb` und anderen Klassen.
- Konsistente Verwendung von Symbolen (✔, ⚠) zur Hervorhebung von Erfolgen und Warnungen.
- Aktualisierung der `Settings.settings` und Bereinigung nicht mehr benötigter Konfigurationswerte.
- Downgrade von `Microsoft.Data.SqlClient` von Version 7.0.1 auf 5.2.2.
- Entfernung redundanter Module und Codeabschnitte zur Verbesserung der Wartbarkeit.
- Verbesserte Fehlerbehandlung beim Starten und Stoppen des ServiceHosts.
- Optimierung der Protokollmeldungen für Debugging und Performance-Analysen.
This commit is contained in:
Developer01
2026-09-22 16:42:07 +02:00
parent 0f9e7c55ec
commit 9901b48b80
12 changed files with 136 additions and 140 deletions

View File

@@ -2,7 +2,6 @@
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ZUGFeRDTest.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="ZUGFeRDTest.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> <section name="ZUGFeRDTest.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup> </sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@@ -14,14 +13,6 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup> </startup>
<applicationSettings> <applicationSettings>
<ZUGFeRDTest.MySettings>
<setting name="FB_DATABASE" serializeAs="String">
<value>172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB</value>
</setting>
<setting name="FB_DATASOURCE" serializeAs="String">
<value>172.24.12.50</value>
</setting>
</ZUGFeRDTest.MySettings>
<ZUGFeRDTest.My.MySettings> <ZUGFeRDTest.My.MySettings>
<setting name="FB_DATABASE" serializeAs="String"> <setting name="FB_DATABASE" serializeAs="String">
<value>172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB</value> <value>172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB</value>
@@ -33,17 +24,11 @@
</applicationSettings> </applicationSettings>
<userSettings> <userSettings>
<ZUGFeRDTest.MySettings> <ZUGFeRDTest.MySettings>
<setting name="FB_USER" serializeAs="String">
<value>sysdba</value>
</setting>
<setting name="FB_PASS" serializeAs="String">
<value>dd</value>
</setting>
<setting name="MD5Cheksum" serializeAs="String"> <setting name="MD5Cheksum" serializeAs="String">
<value /> <value />
</setting> </setting>
<setting name="MSSQL_CONNECTIONSTRING" serializeAs="String"> <setting name="Test" serializeAs="String">
<value>Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;TrustServerCertificate=true;</value> <value />
</setting> </setting>
</ZUGFeRDTest.MySettings> </ZUGFeRDTest.MySettings>
<ZUGFeRDTest.My.MySettings> <ZUGFeRDTest.My.MySettings>

View File

@@ -1,4 +1,5 @@
Imports System.Data Imports System.Configuration
Imports System.Data
Imports System.IO Imports System.IO
Imports System.Reflection Imports System.Reflection
Imports System.Security.Cryptography Imports System.Security.Cryptography
@@ -9,11 +10,11 @@ Imports DigitalData.Modules.Interfaces
Imports DigitalData.Modules.Interfaces.ZUGFeRDInterface Imports DigitalData.Modules.Interfaces.ZUGFeRDInterface
Imports DigitalData.Modules.Jobs Imports DigitalData.Modules.Jobs
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports Microsoft.Data
Public Class Form1 Public Class Form1
Private _logConfig As LogConfig Private _logConfig As LogConfig
Private _logger As Logger Private _logger As Logger
Private _firebird As Firebird
Private _mssql As MSSQLServer Private _mssql As MSSQLServer
Private _zugferd As ZUGFeRDInterface Private _zugferd As ZUGFeRDInterface
Private _GDPictureVersion As String Private _GDPictureVersion As String
@@ -28,12 +29,24 @@ Public Class Form1
.Debug = True .Debug = True
} }
_logger = _logConfig.GetLogger() _logger = _logConfig.GetLogger()
My.Settings.Save()
Dim oCS = My.Settings.MSSQL_CONNECTIONSTRING Dim oCS = My.Settings.MSSQL_CONNECTIONSTRING
If Not oCS.Contains("TrustServerCertificate") Then My.Settings.MSSQL_CONNECTIONSTRING = "Server = SDD-VHP04-SQL19\DD_TESTING01;Database=DD_ECM;User Id=sa;Password=123456789dD!;"
oCS += ";TrustServerCertificate=true" My.Settings.Save() ' Jetzt wird wirklich gespeichert
oCS = My.Settings.MSSQL_CONNECTIONSTRING
'
If Not oCS.EndsWith("TrustServerCertificate") Then
oCS += "TrustServerCertificate=true"
End If End If
_mssql = New MSSQLServer(_logConfig, oCS) _mssql = New MSSQLServer(_logConfig, oCS)
If _mssql Is Nothing Then
MsgBox("Could not connect to MSSQL Server. Please check the connection string in the application settings.", MsgBoxStyle.Critical, "Database Connection Error")
Else
If Not _mssql.DBInitialized Then
MsgBox("Could not connect to MSSQL Server. Please check the connection string in the application settings.", MsgBoxStyle.Critical, "Database Connection Error")
End If
End If
_GDPictureVersion = "11.2024" _GDPictureVersion = "11.2024"
_GDPictureLizenz = ConfigDbFunct.GetProductLicense("GDPICTURE", _GDPictureVersion, _logConfig, My.Settings.MSSQL_CONNECTIONSTRING) _GDPictureLizenz = ConfigDbFunct.GetProductLicense("GDPICTURE", _GDPictureVersion, _logConfig, My.Settings.MSSQL_CONNECTIONSTRING)

View File

@@ -2,23 +2,11 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="" GeneratedClassName="MySettings" UseMySettingsClassName="true"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="" GeneratedClassName="MySettings" UseMySettingsClassName="true">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="FB_DATABASE" Type="System.String" Scope="Application">
<Value Profile="(Default)">172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB</Value>
</Setting>
<Setting Name="FB_DATASOURCE" Type="System.String" Scope="Application">
<Value Profile="(Default)">172.24.12.50</Value>
</Setting>
<Setting Name="FB_USER" Type="System.String" Scope="User">
<Value Profile="(Default)">sysdba</Value>
</Setting>
<Setting Name="FB_PASS" Type="System.String" Scope="User">
<Value Profile="(Default)">dd</Value>
</Setting>
<Setting Name="MD5Cheksum" Type="System.String" Scope="User"> <Setting Name="MD5Cheksum" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="MSSQL_CONNECTIONSTRING" Type="System.String" Scope="User"> <Setting Name="Test" Type="System.String" Scope="User">
<Value Profile="(Default)">Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;TrustServerCertificate=true;</Value> <Value Profile="(Default)" />
</Setting> </Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@@ -10,17 +10,18 @@
<AssemblyName>ZUGFeRDTest</AssemblyName> <AssemblyName>ZUGFeRDTest</AssemblyName>
<Company>Digital Data GmbH</Company> <Company>Digital Data GmbH</Company>
<AssemblyTitle>Provides baseclasses, methods and constants for DD Products</AssemblyTitle> <AssemblyTitle>Provides baseclasses, methods and constants for DD Products</AssemblyTitle>
<AssemblyVersion>2.0</AssemblyVersion> <AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0</FileVersion> <FileVersion>2.0.0.0</FileVersion>
<Title>$(AssemblyName)</Title> <Title>$(AssemblyName)</Title>
<Product>$(AssemblyName)</Product> <Product>$(AssemblyName)</Product>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="GdPicture" Version="14.4.4" /> <PackageReference Include="GdPicture" Version="14.4.4" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="7.0.1" /> <PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="NLog" Version="5.0.5" /> <PackageReference Include="NLog" Version="5.0.5" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="DigitalData.Modules.Config"> <Reference Include="DigitalData.Modules.Config">
<HintPath>..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath> <HintPath>..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
@@ -60,15 +61,8 @@
<ItemGroup> <ItemGroup>
<None Update="My Project\Settings.settings"> <None Update="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
</None> <LastGenOutput>Settings.Designer.vb</LastGenOutput>
<None Update="MyProject\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
</None>
<None Update="MyProject\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
</None>
<None Update="MyProject\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
</None> </None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -2,24 +2,6 @@
<configuration> <configuration>
<configSections> <configSections>
</configSections> </configSections>
<system.diagnostics>
<sources>
<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>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" initializeData="C:\logs\TracingAndLogging-service.svclog" type="System.Diagnostics.XmlWriterTraceListener" />
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly> <dependentAssembly>
@@ -35,4 +17,4 @@
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup> </startup>
</configuration> </configuration>

View File

@@ -388,7 +388,7 @@ Public Class EDMIService
If oFullPath = String.Empty Then If oFullPath = String.Empty Then
Dim oDetails As New ObjectDoesNotExistFault(Data.ObjectId) Dim oDetails As New ObjectDoesNotExistFault(Data.ObjectId)
_Logger.Warn("GetFileByObjectId: " & oDetails.ErrorMessage) _Logger.Warn("⚠ GetFileByObjectId: " & oDetails.ErrorMessage)
Throw New FaultException(Of ObjectDoesNotExistFault)(oDetails, oDetails.ErrorMessage) Throw New FaultException(Of ObjectDoesNotExistFault)(oDetails, oDetails.ErrorMessage)
End If End If
@@ -398,7 +398,7 @@ Public Class EDMIService
If Not oFileInfo.Exists Then If Not oFileInfo.Exists Then
Dim oDetails As New ObjectDoesNotExistFault(Data.ObjectId) Dim oDetails As New ObjectDoesNotExistFault(Data.ObjectId)
_Logger.Warn("GetFileByObjectId: " & oDetails.ErrorMessage) _Logger.Warn("⚠ GetFileByObjectId: " & oDetails.ErrorMessage)
Throw New FaultException(Of ObjectDoesNotExistFault)(oDetails, oDetails.ErrorMessage) Throw New FaultException(Of ObjectDoesNotExistFault)(oDetails, oDetails.ErrorMessage)
End If End If
@@ -443,12 +443,12 @@ Public Class EDMIService
} }
_Logger.Debug("End GetFileInfoByObjectId!") _Logger.Debug("End GetFileInfoByObjectId!")
Catch ex As FaultException Catch ex As FaultException
_Logger.Warn("GetFileInfoByObjectId: " & ex.Message) _Logger.Warn("⚠ GetFileInfoByObjectId: " & ex.Message)
_Logger.Error(ex) _Logger.Error(ex)
Throw ex Throw ex
Catch ex As Exception Catch ex As Exception
_Logger.Warn("GetFileInfoByObjectId: " & ex.Message) _Logger.Warn("⚠ GetFileInfoByObjectId: " & ex.Message)
_Logger.Error(ex) _Logger.Error(ex)
Throw GetFault(ex) Throw GetFault(ex)
@@ -477,14 +477,14 @@ Public Class EDMIService
Public Function GetFileList() As DataTable Public Function GetFileList() As DataTable
Try Try
If Not GlobalState.TableStore.Tables.Contains(TBIDB_DOC_INFO) Then If Not GlobalState.TableStore.Tables.Contains(TBIDB_DOC_INFO) Then
_Logger.Warn("GetFileList: Document info table does not exist!") _Logger.Warn("⚠ GetFileList: Document info table does not exist!")
Return Nothing Return Nothing
End If End If
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_DOC_INFO) Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_DOC_INFO)
Return oTable Return oTable
Catch ex As Exception Catch ex As Exception
_Logger.Warn("GetFileList: Unexpected Error while getting file list.") _Logger.Warn("⚠ GetFileList: Unexpected Error while getting file list.")
_Logger.Error(ex) _Logger.Error(ex)
Return Nothing Return Nothing
End Try End Try
@@ -534,7 +534,7 @@ Public Class EDMIService
Private Function GetFullPathForObjectId(ObjectId As Long) As String Private Function GetFullPathForObjectId(ObjectId As Long) As String
Try Try
If Not GlobalState.TableStore.Tables.Contains(TBIDB_DOC_INFO) Then If Not GlobalState.TableStore.Tables.Contains(TBIDB_DOC_INFO) Then
_Logger.Warn("GetFullPathForObjectId: Document info table does not exist!") _Logger.Warn("⚠ GetFullPathForObjectId: Document info table does not exist!")
Return String.Empty Return String.Empty
End If End If
@@ -544,7 +544,7 @@ Public Class EDMIService
Dim oFullPath As String Dim oFullPath As String
If oRows.Count = 0 Then If oRows.Count = 0 Then
_Logger.Warn("GetFullPathForObjectId: Full path does not exist for object [{0}]", ObjectId) _Logger.Warn("⚠ GetFullPathForObjectId: Full path does not exist for object [{0}]", ObjectId)
oFullPath = String.Empty oFullPath = String.Empty
Else Else
Dim oRow As DataRow = oRows.First() Dim oRow As DataRow = oRows.First()
@@ -553,7 +553,7 @@ Public Class EDMIService
Return oFullPath Return oFullPath
Catch ex As Exception Catch ex As Exception
_Logger.Warn("GetFullPathForObjectId: Unexpected Error while getting full path for object [{0}].", ObjectId) _Logger.Warn("⚠ GetFullPathForObjectId: Unexpected Error while getting full path for object [{0}].", ObjectId)
_Logger.Error(ex) _Logger.Error(ex)
Return String.Empty Return String.Empty
End Try End Try
@@ -562,7 +562,7 @@ Public Class EDMIService
Private Function GetAccessRightForObjectId(UserId As Long, ObjectId As Long) As AccessRight Private Function GetAccessRightForObjectId(UserId As Long, ObjectId As Long) As AccessRight
Try Try
If Not GlobalState.TableStore.Tables.Contains(TBIDB_ACCESSRIGHT) Then If Not GlobalState.TableStore.Tables.Contains(TBIDB_ACCESSRIGHT) Then
_Logger.Warn("GetAccessRightForObjectId: Access right table does not exist!") _Logger.Warn("⚠ GetAccessRightForObjectId: Access right table does not exist!")
Return AccessRight.VIEW_ONLY Return AccessRight.VIEW_ONLY
End If End If
@@ -575,11 +575,11 @@ Public Class EDMIService
_Logger.Debug("Parsing AccessRights for ObjectId [{0}]", ObjectId) _Logger.Debug("Parsing AccessRights for ObjectId [{0}]", ObjectId)
If oRows.Count = 0 Then If oRows.Count = 0 Then
_Logger.Warn("GetAccessRightForObjectId: Access right assignment does not exist for user [{0}] on object [{1}]", UserId, ObjectId) _Logger.Warn("⚠ GetAccessRightForObjectId: Access right assignment does not exist for user [{0}] on object [{1}]", UserId, ObjectId)
Return AccessRight.VIEW_ONLY Return AccessRight.VIEW_ONLY
Else Else
If oRows.Count > 1 Then If oRows.Count > 1 Then
_Logger.Warn("GetAccessRightForObjectId: More than one access right assignment found for user [{0}] on object [{1}]", UserId, ObjectId) _Logger.Warn("⚠ GetAccessRightForObjectId: More than one access right assignment found for user [{0}] on object [{1}]", UserId, ObjectId)
End If End If
Dim oRow As DataRow = oRows.First() Dim oRow As DataRow = oRows.First()
@@ -593,7 +593,7 @@ Public Class EDMIService
Case 4 Case 4
oRight = AccessRight.FULL oRight = AccessRight.FULL
Case Else Case Else
_Logger.Warn("GetAccessRightForObjectId: Unknown access right [{0}] for user [{1}] on object [{2}]", oRightAsInt, UserId, ObjectId) _Logger.Warn("⚠ GetAccessRightForObjectId: Unknown access right [{0}] for user [{1}] on object [{2}]", oRightAsInt, UserId, ObjectId)
oRight = AccessRight.VIEW_ONLY oRight = AccessRight.VIEW_ONLY
End Select End Select
End If End If
@@ -603,7 +603,7 @@ Public Class EDMIService
Return oRight Return oRight
Catch ex As Exception Catch ex As Exception
_Logger.Warn("GetAccessRightForObjectId: Unexpected Error while getting access right for object [{0}].", ObjectId) _Logger.Warn("⚠ GetAccessRightForObjectId: Unexpected Error while getting access right for object [{0}].", ObjectId)
_Logger.Error(ex) _Logger.Error(ex)
Return AccessRight.VIEW_ONLY Return AccessRight.VIEW_ONLY
End Try End Try

View File

@@ -81,9 +81,6 @@
<Reference Include="DigitalData.Modules.Filesystem"> <Reference Include="DigitalData.Modules.Filesystem">
<HintPath>..\..\DDModules\Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath> <HintPath>..\..\DDModules\Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Language">
<HintPath>P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\Digital Data\DigitalData.Modules.Language.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Logging"> <Reference Include="DigitalData.Modules.Logging">
<HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath> <HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
</Reference> </Reference>

View File

@@ -66,13 +66,13 @@ Public Class GlobalState
End Function End Function
Public Sub LoadDoctypes() Public Sub LoadDoctypes()
_Logger.Info("Loading Doctypes") _Logger.Debug("Loading Doctypes")
Try Try
Dim oSQL As String = "SELECT * FROM VWIDB_DOCTYPE_HANDLING" Dim oSQL As String = "SELECT * FROM VWIDB_DOCTYPE_HANDLING"
Dim oTable As DataTable = _MSSQL_IDB.GetDatatable(oSQL) Dim oTable As DataTable = _MSSQL_IDB.GetDatatable(oSQL)
_Logger.Info("Found [{0}] Document Types", oTable.Rows.Count) _Logger.Info("✔ Found [{0}] Document Types", oTable.Rows.Count)
Dim oDocTypes As New List(Of Doctype) Dim oDocTypes As New List(Of Doctype)
@@ -82,7 +82,7 @@ Public Class GlobalState
.FileChangedAction = oRow.Item("CHANGED_HANDLING") .FileChangedAction = oRow.Item("CHANGED_HANDLING")
} }
_Logger.Info("New Doctype [{0}]", oDoctype.Name) _Logger.Debug("New Doctype [{0}]", oDoctype.Name)
oDocTypes.Add(oDoctype) oDocTypes.Add(oDoctype)
Next Next
@@ -94,13 +94,12 @@ Public Class GlobalState
Public Sub LoadObjectStores() Public Sub LoadObjectStores()
_Logger.Info("Loading Object Stores") _Logger.Debug("Loading Object Stores ...")
Try Try
Dim oSQL As String = "SELECT * FROM VWIDB_OBJECT_STORE" Dim oSQL As String = "SELECT * FROM VWIDB_OBJECT_STORE"
Dim oTable As DataTable = _MSSQL_IDB.GetDatatable(oSQL) Dim oTable As DataTable = _MSSQL_IDB.GetDatatable(oSQL)
_Logger.Info("Found [{0}] Object Stores", oTable.Rows.Count)
Dim oObjectStores As New List(Of ObjectStore) Dim oObjectStores As New List(Of ObjectStore)
For Each oRow As DataRow In oTable.Rows For Each oRow As DataRow In oTable.Rows
@@ -110,23 +109,24 @@ Public Class GlobalState
.Path = oRow.Item("REL_PATH"), .Path = oRow.Item("REL_PATH"),
.Title = oRow.Item("Objectstore") .Title = oRow.Item("Objectstore")
} }
_Logger.Info("New Object Store [{0}]", oStore.Title) _Logger.Debug("New Object Store [{0}]", oStore.Title)
oObjectStores.Add(oStore) oObjectStores.Add(oStore)
Next Next
ObjectStores = oObjectStores ObjectStores = oObjectStores
_Logger.Info("✔ Found [{0}] Object Stores", oObjectStores.Count)
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
End Try End Try
End Sub End Sub
Public Sub LoadConnections() Public Sub LoadConnections()
_Logger.Info("Loading Database Connections") _Logger.Debug("Loading Database Connections ...")
Try Try
Dim oSQL As String = "SELECT * FROM TBDD_CONNECTION WITH (NOLOCK)" Dim oSQL As String = "SELECT * FROM TBDD_CONNECTION WITH (NOLOCK)"
Dim oTable As DataTable = _MSSQL_ECM.GetDatatable(oSQL) Dim oTable As DataTable = _MSSQL_ECM.GetDatatable(oSQL)
_Logger.Info("Found [{0}] Connections", oTable.Rows.Count) _Logger.Debug("Found [{0}] Connections!", oTable.Rows.Count)
Dim oConnections As New List(Of DatabaseConnection) Dim oConnections As New List(Of DatabaseConnection)
@@ -141,23 +141,25 @@ Public Class GlobalState
.Server = IIf(IsDBNull(oRow.Item("SERVER")), String.Empty, oRow.Item("SERVER")), .Server = IIf(IsDBNull(oRow.Item("SERVER")), String.Empty, oRow.Item("SERVER")),
.Username = IIf(IsDBNull(oRow.Item("USERNAME")), String.Empty, oRow.Item("USERNAME")) .Username = IIf(IsDBNull(oRow.Item("USERNAME")), String.Empty, oRow.Item("USERNAME"))
} }
_Logger.Info("New Connection [{0}]", oConnection.Title)
oConnections.Add(oConnection) oConnections.Add(oConnection)
_Logger.Debug("New DB Connection [{0}]", oConnection.Title)
Next Next
Connections = oConnections Connections = oConnections
_Logger.Info("✔ [{0}] DBConnections configured in service!", oConnections.Count)
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
End Try End Try
End Sub End Sub
Public Sub LoadClientConfig(pConfig As Config) Public Sub LoadClientConfig(pConfig As Config)
_Logger.Info("Loading Client Config") _Logger.Debug("Loading Client Config")
_Logger.Debug("ForceDirectDatabaseAccess: {0}", pConfig.ClientConfig.ForceDirectDatabaseAccess) _Logger.Debug("ForceDirectDatabaseAccess: {0}", pConfig.ClientConfig.ForceDirectDatabaseAccess)
ClientConfig.ForceDirectDatabaseAccess = pConfig.ClientConfig.ForceDirectDatabaseAccess ClientConfig.ForceDirectDatabaseAccess = pConfig.ClientConfig.ForceDirectDatabaseAccess
ClientConfig.DocumentTypes = Doctypes ClientConfig.DocumentTypes = Doctypes
ClientConfig.ConnectionStringECM = _MSSQL_ECM.CurrentConnectionString ClientConfig.ConnectionStringECM = _MSSQL_ECM.CurrentConnectionString
ClientConfig.ConnectionStringIDB = _MSSQL_IDB.CurrentConnectionString ClientConfig.ConnectionStringIDB = _MSSQL_IDB.CurrentConnectionString
_Logger.Info("✔ Found Client Config")
End Sub End Sub
Public Class ObjectStore Public Class ObjectStore

View File

@@ -97,22 +97,21 @@ Public Class DatatableJob
oStopWatch.Stop() oStopWatch.Stop()
oLogger.Debug("[Time] Adding Relations: {0}ms", oStopWatch.ElapsedMilliseconds) oLogger.Debug("[Time] Adding Relations: {0}ms", oStopWatch.ElapsedMilliseconds)
oLogger.Info("Fetched Datatable [{0}]", oDatatableName) oLogger.Info("✔ Fetched Datatable [{0}]", oDatatableName)
oResult.Tables.Add(oResultTable) oResult.Tables.Add(oResultTable)
Catch ex As Exception Catch ex As Exception
oLogger.Warn("Execute: Error while saving Table: [{0}]", oDatatableName) oLogger.Warn("⚠ Error while saving Table: [{0}]", oDatatableName)
oLogger.Error(ex) oLogger.Error(ex)
End Try End Try
Next Next
oLogger.Info("Fetched [{0}] Datatables", oResult.Tables.Count)
' Das Ergebnis speichern ' Das Ergebnis speichern
context.Result = oResult context.Result = oResult
oLogger.Info("✔✔ Fetched [{0}] Datatables ✔✔", oResult.Tables.Count)
Catch ex As Exception Catch ex As Exception
oLogger.Error(ex) oLogger.Error(ex)
oLogger.Warn("Execute: Unhandled exception while executing SQL for Datatable {0}", oCronJobTitle) oLogger.Warn("⚠ Unhandled exception while executing SQL for Datatable {0}", oCronJobTitle)
End Try End Try
Return Task.FromResult(True) Return Task.FromResult(True)

View File

@@ -2,11 +2,11 @@
Imports System.Threading Imports System.Threading
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports Quartz Imports Quartz
Imports Quartz.Listener Imports Quartz.Listener
Imports System.Diagnostics
Imports System.Data
Public Class JobListener Public Class JobListener
Inherits JobListenerSupport Inherits JobListenerSupport
@@ -121,7 +121,7 @@ Public Class JobListener
End If End If
End If End If
_Logger.Info("Dataset successfully updated with table [{0}]", oName) _Logger.Info("✔ Dataset successfully updated with table [{0}]", oName)
Finally Finally
' ✅ SCHRITT 3: Write-Lock freigeben (so schnell wie möglich!) ' ✅ SCHRITT 3: Write-Lock freigeben (so schnell wie möglich!)
@@ -129,7 +129,7 @@ Public Class JobListener
oStopWatch.Stop() oStopWatch.Stop()
' ✅ Performance-Warning bei langsamen Updates ' ✅ Performance-Warning bei langsamen Updates
If oStopWatch.ElapsedMilliseconds > 500 Then If oStopWatch.ElapsedMilliseconds > 500 Then
_Logger.Warn("[Performance] Table update took {0}ms (> 500ms threshold)", oStopWatch.ElapsedMilliseconds) _Logger.Warn("⚠ [Performance] Table update took {0}ms (> 500ms threshold)", oStopWatch.ElapsedMilliseconds)
Else Else
_Logger.Debug("[Performance] Table update completed in {0}ms", oStopWatch.ElapsedMilliseconds) _Logger.Debug("[Performance] Table update completed in {0}ms", oStopWatch.ElapsedMilliseconds)
End If End If
@@ -142,7 +142,7 @@ Public Class JobListener
_MSSQL.ExecuteNonQuery($"INSERT INTO TBAPPSERV_CRON_DETAIL_HISTORY (DETAIL_ID) VALUES ({oDetailId})") _MSSQL.ExecuteNonQuery($"INSERT INTO TBAPPSERV_CRON_DETAIL_HISTORY (DETAIL_ID) VALUES ({oDetailId})")
Catch ex As Exception Catch ex As Exception
_Logger.Warn("Unexpected error in SaveDataTables: {0}", ex.Message) _Logger.Warn("⚠ Unexpected error in SaveDataTables: {0}", ex.Message)
_Logger.Error(ex) _Logger.Error(ex)
End Try End Try
End Sub End Sub
@@ -256,23 +256,22 @@ Public Class JobListener
Catch ex As ArgumentNullException Catch ex As ArgumentNullException
_Logger.Error(ex) _Logger.Error(ex)
_Logger.Warn("ArgumentNullException in AddRelation: {0}", ex.Message) _Logger.Warn("⚠ ArgumentNullException in AddRelation: {0}", ex.Message)
Catch ex As DuplicateNameException Catch ex As DuplicateNameException
_Logger.Error(ex) _Logger.Error(ex)
_Logger.Warn("DuplicateNameException in AddRelation: {0}", ex.Message) _Logger.Warn("⚠ DuplicateNameException in AddRelation: {0}", ex.Message)
Catch ex As InvalidConstraintException Catch ex As InvalidConstraintException
_Logger.Error(ex) _Logger.Error(ex)
_Logger.Warn("InvalidConstraintException in AddRelation: {0}", ex.Message) _Logger.Warn("⚠ InvalidConstraintException in AddRelation: {0}", ex.Message)
Catch ex As ArgumentException Catch ex As ArgumentException
_Logger.Error(ex) _Logger.Error(ex)
_Logger.Warn("ArgumentException in AddRelation: {0}", ex.Message) _Logger.Warn("⚠ ArgumentException in AddRelation: {0}", ex.Message)
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
_Logger.Warn("Exception in AddRelation: {0}", ex.Message) _Logger.Warn("⚠ Exception in AddRelation: {0}", ex.Message)
End Try End Try
End Sub End Sub

View File

@@ -103,12 +103,13 @@ Public Class Scheduler
Logger.Debug("Scheduled a new job for Cron Job [{0}]", oTitle) Logger.Debug("Scheduled a new job for Cron Job [{0}]", oTitle)
Next Next
Logger.Info("✔ Scheduler started with {0} cron jobs", oCronjobs.Rows.Count)
Else Else
Logger.Warn("CronJobs could not be fetched!") Logger.Warn("⚠ CronJobs could not be fetched!")
End If End If
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Logger.Warn("Unexpected Error while setting up scheduler: " & ex.Message) Logger.Warn("⚠ Unexpected Error while setting up scheduler: " & ex.Message)
End Try End Try
End Sub End Sub
Public Async Function GetCronJobs() As Task(Of DataTable) Public Async Function GetCronJobs() As Task(Of DataTable)

View File

@@ -61,34 +61,38 @@ Public Class WindowsService
oTimer.Start() oTimer.Start()
' Setting Debug Flag ' Setting Debug Flag
Logger.Info("Setting DEBUG Flag to [{0}]", ConfigManager.Config.Debug) If ConfigManager.Config.Debug Then
Logger.Info("Debug Flag is set to TRUE. Logging will be more verbose.")
Else
Logger.Info("Debug Flag is set to FALSE. Logging will be less verbose.")
End If
LogConfig.Debug = ConfigManager.Config.Debug LogConfig.Debug = ConfigManager.Config.Debug
LogConfigScheduler.Debug = ConfigManager.Config.Debug LogConfigScheduler.Debug = ConfigManager.Config.Debug
Logger.Info("Connecting to Databases..") Logger.Debug("Connecting to Databases...")
Firebird = StartFirebird() Firebird = StartFirebird()
MSSQL_ECM = GetMSSQL_ECM(LogConfig) MSSQL_ECM = GetMSSQL_ECM(LogConfig)
MSSQL_IDB = GetMSSQL_IDB(LogConfig) MSSQL_IDB = GetMSSQL_IDB(LogConfig)
MSSQL_Config = GetMSSQL_Config(LogConfig) MSSQL_Config = GetMSSQL_Config(LogConfig)
Logger.Info("Connection to Databases established!") Logger.Debug("Connection to Databases established!")
Logger.Debug("Initializing EDMI Functions") Logger.Debug("Initializing EDMI Functions...")
Filesystem = New Filesystem.File(LogConfig) Filesystem = New Filesystem.File(LogConfig)
GlobalState = New GlobalState(LogConfig, MSSQL_IDB, MSSQL_ECM) GlobalState = New GlobalState(LogConfig, MSSQL_IDB, MSSQL_ECM)
Dim oMSSQLServer = GetMSSQL_Config(LogConfigScheduler) Dim oMSSQLServer = GetMSSQL_Config(LogConfigScheduler)
Scheduler = New Scheduler(LogConfigScheduler, oMSSQLServer, GlobalState.TableStore, GlobalState) Scheduler = New Scheduler(LogConfigScheduler, oMSSQLServer, GlobalState.TableStore, GlobalState)
Logger.Info("Loading Global Data") Logger.Debug("Loading Global Data ...")
GlobalState.LoadObjectStores() GlobalState.LoadObjectStores()
GlobalState.LoadConnections() GlobalState.LoadConnections()
GlobalState.LoadDoctypes() GlobalState.LoadDoctypes()
GlobalState.LoadClientConfig(Config) GlobalState.LoadClientConfig(Config)
Logger.Info("Starting Scheduler") Logger.Debug("Starting Scheduler ...")
Scheduler.Start() Scheduler.Start()
Logger.Info("Preparing WCF ServiceHost") Logger.Debug("Preparing WCF ServiceHost ...")
EDMIService.MSSQL_ECM = MSSQL_ECM EDMIService.MSSQL_ECM = MSSQL_ECM
EDMIService.MSSQL_IDB = MSSQL_IDB EDMIService.MSSQL_IDB = MSSQL_IDB
EDMIService.Firebird = Firebird EDMIService.Firebird = Firebird
@@ -97,11 +101,20 @@ Public Class WindowsService
EDMIService.GlobalState = GlobalState EDMIService.GlobalState = GlobalState
EDMIService.Scheduler = Scheduler EDMIService.Scheduler = Scheduler
Logger.Info("Starting WCF ServiceHost") Logger.Debug("Starting WCF ServiceHost ...")
Dim oBaseAddresses() As Uri = {New Uri(SERVICE_BASE_ADDRESS)} Dim oBaseAddresses() As Uri = {New Uri(SERVICE_BASE_ADDRESS)}
ServiceHost = New ServiceHost(Of EDMIService)(oBaseAddresses) ServiceHost = New ServiceHost(Of EDMIService)(oBaseAddresses)
ServiceHost.EnableMetadataExchange(False) ServiceHost.EnableMetadataExchange(False)
' MEX-Endpoints explizit entfernen, da sie Port-Konflikte verursachen
Dim oMexEndpoints = ServiceHost.Description.Endpoints _
.Where(Function(e) e.Contract.ContractType = GetType(IMetadataExchange)) _
.ToList()
For Each oEndpoint In oMexEndpoints
ServiceHost.Description.Endpoints.Remove(oEndpoint)
Logger.Debug("OnStart -> Removed MEX endpoint: {0}", oEndpoint.Address.ToString)
Next
Logger.Debug("Listing Endpoints:") Logger.Debug("Listing Endpoints:")
For Each oEndpoint In ServiceHost.Description.Endpoints For Each oEndpoint In ServiceHost.Description.Endpoints
@@ -113,12 +126,20 @@ Public Class WindowsService
Next Next
Logger.Debug("Starting WFC ServiceHost..") Logger.Debug("Starting WFC ServiceHost..")
ServiceHost.Open() Try
Logger.Debug("WCF ServiceHost started!") ServiceHost.Open()
Logger.Debug("WCF ServiceHost started!")
Logger.Info("Service {0} successfully started!", SERVICE_DISPLAY_NAME) Catch ex As System.ServiceModel.AddressAlreadyInUseException
Logger.Error("Port is already in use! Check if another instance is running. Details: {0}", ex.Message)
GracefullyStop()
Catch ex As Exception
Logger.Warn("⚠ Unexpected error while opening ServiceHost: {0}", ex.Message)
Logger.Error(ex)
GracefullyStop()
End Try
Logger.Info("✔ Service [{0}] started successfully!", SERVICE_DISPLAY_NAME)
Catch ex As Exception Catch ex As Exception
Logger.Warn("Unexpected Error while starting the service: {0}", ex.Message) Logger.Warn("⚠ Unexpected Error while starting the service: {0}", ex.Message)
Logger.Error(ex) Logger.Error(ex)
GracefullyStop() GracefullyStop()
End Try End Try
@@ -126,7 +147,7 @@ Public Class WindowsService
Private Sub ReloadTimer_Tick() Private Sub ReloadTimer_Tick()
If ConfigManager.Reload() = False Then If ConfigManager.Reload() = False Then
Logger.Warn("Could not reload config, check the service and config file.") Logger.Warn("⚠ Could not reload config, check the service and config file.")
End If End If
Config = ConfigManager.Config Config = ConfigManager.Config
@@ -153,7 +174,7 @@ Public Class WindowsService
Logger.Info("Database connection established.") Logger.Info("Database connection established.")
Return oFirebird Return oFirebird
Catch ex As Exception Catch ex As Exception
Logger.Warn("StartFirebird: Could not connect to firebird database.") Logger.Warn("⚠ StartFirebird: Could not connect to firebird database.")
Logger.Error(ex) Logger.Error(ex)
Return Nothing Return Nothing
End Try End Try
@@ -162,41 +183,41 @@ Public Class WindowsService
Private Function GetMSSQL_ECM(pLogConfig As LogConfig) As MSSQLServer Private Function GetMSSQL_ECM(pLogConfig As LogConfig) As MSSQLServer
Logger.Debug("Connecting to ECM MSSQL") Logger.Debug("Connecting to ECM MSSQL")
If Config.ConnectionString_ECM = String.Empty Then If Config.ConnectionString_ECM = String.Empty Then
Logger.Warn("Configuration for ConnectionString_ECM is missing.") Logger.Warn("⚠ Configuration for ConnectionString_ECM is missing.")
Throw New ArgumentNullException("ConnectionString_ECM") Throw New ArgumentNullException("ConnectionString_ECM")
End If End If
Dim oMSSQL = New MSSQLServer(pLogConfig, Config.ConnectionString_ECM) Dim oMSSQL = New MSSQLServer(pLogConfig, Config.ConnectionString_ECM)
Logger.Info("Database connection to ECM Database established.") Logger.Info("✔ Database connection to ECM Database established.")
Return oMSSQL Return oMSSQL
End Function End Function
Private Function GetMSSQL_IDB(pLogConfig As LogConfig) As MSSQLServer Private Function GetMSSQL_IDB(pLogConfig As LogConfig) As MSSQLServer
Logger.Debug("Connecting to IDB MSSQL") Logger.Debug("Connecting to IDB MSSQL")
If Config.ConnectionString_IDB = String.Empty Then If Config.ConnectionString_IDB = String.Empty Then
Logger.Warn("Configuration for ConnectionString_IDB is missing.") Logger.Warn("⚠ Configuration for ConnectionString_IDB is missing.")
Throw New ArgumentNullException("ConnectionString_IDB") Throw New ArgumentNullException("ConnectionString_IDB")
End If End If
Dim oMSSQL = New MSSQLServer(pLogConfig, Config.ConnectionString_IDB) Dim oMSSQL = New MSSQLServer(pLogConfig, Config.ConnectionString_IDB)
Logger.Info("Database connection to IDB Database established.") Logger.Info("✔ Database connection to IDB Database established.")
Return oMSSQL Return oMSSQL
End Function End Function
Private Function GetMSSQL_Config(pLogConfig As LogConfig) As MSSQLServer Private Function GetMSSQL_Config(pLogConfig As LogConfig) As MSSQLServer
Logger.Debug("Connecting to Config MSSQL") Logger.Debug("Connecting to Config MSSQL...")
If Config.ConnectionString_Config = String.Empty Then If Config.ConnectionString_Config = String.Empty Then
If Config.ConnectionString_ECM <> String.Empty Then If Config.ConnectionString_ECM <> String.Empty Then
Logger.Info("Using ConnectionString_ECM for Config Database connection.") Logger.Debug("Using ConnectionString_ECM for Config Database connection!")
Return GetMSSQL_ECM(pLogConfig) Return GetMSSQL_ECM(pLogConfig)
Else Else
Logger.Warn("Configuration for ConnectionString_Config is missing and ConnectionString_ECM is also missing.") Logger.Warn("⚠ Configuration for ConnectionString_Config is missing and ConnectionString_ECM is also missing.")
Throw New ArgumentNullException("ConnectionString_Config") Throw New ArgumentNullException("ConnectionString_Config")
End If End If
End If End If
Dim oMSSQL = New MSSQLServer(pLogConfig, Config.ConnectionString_Config) Dim oMSSQL = New MSSQLServer(pLogConfig, Config.ConnectionString_Config)
Logger.Info("Database connection to Config Database established.") Logger.Info("✔ Database connection to Config Database established.")
Return oMSSQL Return oMSSQL
End Function End Function
@@ -205,13 +226,28 @@ Public Class WindowsService
End Sub End Sub
Private Sub GracefullyStop() Private Sub GracefullyStop()
Logger.Info("Service {0} is stopping!", SERVICE_DISPLAY_NAME) Logger.Info("GracefullyStop - Service {0} is stopping!", SERVICE_DISPLAY_NAME)
If ServiceHost IsNot Nothing Then If ServiceHost IsNot Nothing Then
ServiceHost.Close() Try
ServiceHost = Nothing If ServiceHost.State = CommunicationState.Faulted Then
Logger.Warn("⚠ GracefullyStop - ServiceHost is in Faulted state. Using Abort() instead of Close().")
ServiceHost.Abort()
Else
ServiceHost.Close()
End If
Catch ex As Exception
Logger.Warn("⚠ GracefullyStop - Error while closing ServiceHost: {0}", ex.Message)
Logger.Error(ex)
ServiceHost.Abort()
Finally
ServiceHost = Nothing
End Try
End If End If
Scheduler.Stop() If Scheduler IsNot Nothing Then
Logger.Info("GracefullyStop - Stopping Scheduler.")
Scheduler.Stop()
End If
End Sub End Sub
End Class End Class