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:
@@ -2,7 +2,6 @@
|
||||
<configuration>
|
||||
<configSections>
|
||||
<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" />
|
||||
</sectionGroup>
|
||||
<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" />
|
||||
</startup>
|
||||
<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>
|
||||
<setting name="FB_DATABASE" serializeAs="String">
|
||||
<value>172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB</value>
|
||||
@@ -33,17 +24,11 @@
|
||||
</applicationSettings>
|
||||
<userSettings>
|
||||
<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">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="MSSQL_CONNECTIONSTRING" serializeAs="String">
|
||||
<value>Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;TrustServerCertificate=true;</value>
|
||||
<setting name="Test" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</ZUGFeRDTest.MySettings>
|
||||
<ZUGFeRDTest.My.MySettings>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Imports System.Data
|
||||
Imports System.Configuration
|
||||
Imports System.Data
|
||||
Imports System.IO
|
||||
Imports System.Reflection
|
||||
Imports System.Security.Cryptography
|
||||
@@ -9,11 +10,11 @@ Imports DigitalData.Modules.Interfaces
|
||||
Imports DigitalData.Modules.Interfaces.ZUGFeRDInterface
|
||||
Imports DigitalData.Modules.Jobs
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Microsoft.Data
|
||||
|
||||
Public Class Form1
|
||||
Private _logConfig As LogConfig
|
||||
Private _logger As Logger
|
||||
Private _firebird As Firebird
|
||||
Private _mssql As MSSQLServer
|
||||
Private _zugferd As ZUGFeRDInterface
|
||||
Private _GDPictureVersion As String
|
||||
@@ -28,12 +29,24 @@ Public Class Form1
|
||||
.Debug = True
|
||||
}
|
||||
_logger = _logConfig.GetLogger()
|
||||
My.Settings.Save()
|
||||
Dim oCS = My.Settings.MSSQL_CONNECTIONSTRING
|
||||
If Not oCS.Contains("TrustServerCertificate") Then
|
||||
oCS += ";TrustServerCertificate=true"
|
||||
My.Settings.MSSQL_CONNECTIONSTRING = "Server = SDD-VHP04-SQL19\DD_TESTING01;Database=DD_ECM;User Id=sa;Password=123456789dD!;"
|
||||
My.Settings.Save() ' Jetzt wird wirklich gespeichert
|
||||
oCS = My.Settings.MSSQL_CONNECTIONSTRING
|
||||
|
||||
'
|
||||
If Not oCS.EndsWith("TrustServerCertificate") Then
|
||||
oCS += "TrustServerCertificate=true"
|
||||
End If
|
||||
_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"
|
||||
_GDPictureLizenz = ConfigDbFunct.GetProductLicense("GDPICTURE", _GDPictureVersion, _logConfig, My.Settings.MSSQL_CONNECTIONSTRING)
|
||||
|
||||
|
||||
@@ -2,23 +2,11 @@
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="" GeneratedClassName="MySettings" UseMySettingsClassName="true">
|
||||
<Profiles />
|
||||
<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">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="MSSQL_CONNECTIONSTRING" 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>
|
||||
<Setting Name="Test" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -10,17 +10,18 @@
|
||||
<AssemblyName>ZUGFeRDTest</AssemblyName>
|
||||
<Company>Digital Data GmbH</Company>
|
||||
<AssemblyTitle>Provides baseclasses, methods and constants for DD Products</AssemblyTitle>
|
||||
<AssemblyVersion>2.0</AssemblyVersion>
|
||||
<FileVersion>2.0</FileVersion>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
<FileVersion>2.0.0.0</FileVersion>
|
||||
<Title>$(AssemblyName)</Title>
|
||||
<Product>$(AssemblyName)</Product>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="DigitalData.Modules.Config">
|
||||
<HintPath>..\..\DDModules\Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
|
||||
@@ -60,15 +61,8 @@
|
||||
<ItemGroup>
|
||||
<None Update="My Project\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 Update="MyProject\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -2,24 +2,6 @@
|
||||
<configuration>
|
||||
<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>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
|
||||
@@ -388,7 +388,7 @@ Public Class EDMIService
|
||||
|
||||
If oFullPath = String.Empty Then
|
||||
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)
|
||||
End If
|
||||
|
||||
@@ -398,7 +398,7 @@ Public Class EDMIService
|
||||
|
||||
If Not oFileInfo.Exists Then
|
||||
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)
|
||||
End If
|
||||
|
||||
@@ -443,12 +443,12 @@ Public Class EDMIService
|
||||
}
|
||||
_Logger.Debug("End GetFileInfoByObjectId!")
|
||||
Catch ex As FaultException
|
||||
_Logger.Warn("GetFileInfoByObjectId: " & ex.Message)
|
||||
_Logger.Warn("⚠ GetFileInfoByObjectId: " & ex.Message)
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("GetFileInfoByObjectId: " & ex.Message)
|
||||
_Logger.Warn("⚠ GetFileInfoByObjectId: " & ex.Message)
|
||||
_Logger.Error(ex)
|
||||
Throw GetFault(ex)
|
||||
|
||||
@@ -477,14 +477,14 @@ Public Class EDMIService
|
||||
Public Function GetFileList() As DataTable
|
||||
Try
|
||||
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
|
||||
End If
|
||||
|
||||
Dim oTable As DataTable = GlobalState.TableStore.Tables.Item(TBIDB_DOC_INFO)
|
||||
Return oTable
|
||||
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)
|
||||
Return Nothing
|
||||
End Try
|
||||
@@ -534,7 +534,7 @@ Public Class EDMIService
|
||||
Private Function GetFullPathForObjectId(ObjectId As Long) As String
|
||||
Try
|
||||
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
|
||||
End If
|
||||
|
||||
@@ -544,7 +544,7 @@ Public Class EDMIService
|
||||
Dim oFullPath As String
|
||||
|
||||
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
|
||||
Else
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
@@ -553,7 +553,7 @@ Public Class EDMIService
|
||||
|
||||
Return oFullPath
|
||||
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)
|
||||
Return String.Empty
|
||||
End Try
|
||||
@@ -562,7 +562,7 @@ Public Class EDMIService
|
||||
Private Function GetAccessRightForObjectId(UserId As Long, ObjectId As Long) As AccessRight
|
||||
Try
|
||||
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
|
||||
End If
|
||||
|
||||
@@ -575,11 +575,11 @@ Public Class EDMIService
|
||||
_Logger.Debug("Parsing AccessRights for ObjectId [{0}]", ObjectId)
|
||||
|
||||
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
|
||||
Else
|
||||
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
|
||||
|
||||
Dim oRow As DataRow = oRows.First()
|
||||
@@ -593,7 +593,7 @@ Public Class EDMIService
|
||||
Case 4
|
||||
oRight = AccessRight.FULL
|
||||
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
|
||||
End Select
|
||||
End If
|
||||
@@ -603,7 +603,7 @@ Public Class EDMIService
|
||||
|
||||
Return oRight
|
||||
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)
|
||||
Return AccessRight.VIEW_ONLY
|
||||
End Try
|
||||
|
||||
@@ -81,9 +81,6 @@
|
||||
<Reference Include="DigitalData.Modules.Filesystem">
|
||||
<HintPath>..\..\DDModules\Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath>
|
||||
</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">
|
||||
<HintPath>..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
@@ -66,13 +66,13 @@ Public Class GlobalState
|
||||
End Function
|
||||
|
||||
Public Sub LoadDoctypes()
|
||||
_Logger.Info("Loading Doctypes")
|
||||
_Logger.Debug("Loading Doctypes")
|
||||
|
||||
Try
|
||||
Dim oSQL As String = "SELECT * FROM VWIDB_DOCTYPE_HANDLING"
|
||||
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)
|
||||
|
||||
@@ -82,7 +82,7 @@ Public Class GlobalState
|
||||
.FileChangedAction = oRow.Item("CHANGED_HANDLING")
|
||||
}
|
||||
|
||||
_Logger.Info("New Doctype [{0}]", oDoctype.Name)
|
||||
_Logger.Debug("New Doctype [{0}]", oDoctype.Name)
|
||||
oDocTypes.Add(oDoctype)
|
||||
Next
|
||||
|
||||
@@ -94,12 +94,11 @@ Public Class GlobalState
|
||||
|
||||
|
||||
Public Sub LoadObjectStores()
|
||||
_Logger.Info("Loading Object Stores")
|
||||
_Logger.Debug("Loading Object Stores ...")
|
||||
Try
|
||||
Dim oSQL As String = "SELECT * FROM VWIDB_OBJECT_STORE"
|
||||
Dim oTable As DataTable = _MSSQL_IDB.GetDatatable(oSQL)
|
||||
|
||||
_Logger.Info("Found [{0}] Object Stores", oTable.Rows.Count)
|
||||
|
||||
Dim oObjectStores As New List(Of ObjectStore)
|
||||
|
||||
@@ -110,23 +109,24 @@ Public Class GlobalState
|
||||
.Path = oRow.Item("REL_PATH"),
|
||||
.Title = oRow.Item("Objectstore")
|
||||
}
|
||||
_Logger.Info("New Object Store [{0}]", oStore.Title)
|
||||
_Logger.Debug("New Object Store [{0}]", oStore.Title)
|
||||
oObjectStores.Add(oStore)
|
||||
Next
|
||||
|
||||
ObjectStores = oObjectStores
|
||||
_Logger.Info("✔ Found [{0}] Object Stores", oObjectStores.Count)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub LoadConnections()
|
||||
_Logger.Info("Loading Database Connections")
|
||||
_Logger.Debug("Loading Database Connections ...")
|
||||
Try
|
||||
Dim oSQL As String = "SELECT * FROM TBDD_CONNECTION WITH (NOLOCK)"
|
||||
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)
|
||||
|
||||
@@ -141,23 +141,25 @@ Public Class GlobalState
|
||||
.Server = IIf(IsDBNull(oRow.Item("SERVER")), String.Empty, oRow.Item("SERVER")),
|
||||
.Username = IIf(IsDBNull(oRow.Item("USERNAME")), String.Empty, oRow.Item("USERNAME"))
|
||||
}
|
||||
_Logger.Info("New Connection [{0}]", oConnection.Title)
|
||||
oConnections.Add(oConnection)
|
||||
_Logger.Debug("New DB Connection [{0}]", oConnection.Title)
|
||||
Next
|
||||
|
||||
Connections = oConnections
|
||||
_Logger.Info("✔ [{0}] DBConnections configured in service!", oConnections.Count)
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub LoadClientConfig(pConfig As Config)
|
||||
_Logger.Info("Loading Client Config")
|
||||
_Logger.Debug("Loading Client Config")
|
||||
_Logger.Debug("ForceDirectDatabaseAccess: {0}", pConfig.ClientConfig.ForceDirectDatabaseAccess)
|
||||
ClientConfig.ForceDirectDatabaseAccess = pConfig.ClientConfig.ForceDirectDatabaseAccess
|
||||
ClientConfig.DocumentTypes = Doctypes
|
||||
ClientConfig.ConnectionStringECM = _MSSQL_ECM.CurrentConnectionString
|
||||
ClientConfig.ConnectionStringIDB = _MSSQL_IDB.CurrentConnectionString
|
||||
_Logger.Info("✔ Found Client Config")
|
||||
End Sub
|
||||
|
||||
Public Class ObjectStore
|
||||
|
||||
@@ -97,22 +97,21 @@ Public Class DatatableJob
|
||||
oStopWatch.Stop()
|
||||
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)
|
||||
Catch ex As Exception
|
||||
oLogger.Warn("Execute: Error while saving Table: [{0}]", oDatatableName)
|
||||
oLogger.Warn("⚠ Error while saving Table: [{0}]", oDatatableName)
|
||||
oLogger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
|
||||
oLogger.Info("Fetched [{0}] Datatables", oResult.Tables.Count)
|
||||
|
||||
' Das Ergebnis speichern
|
||||
context.Result = oResult
|
||||
oLogger.Info("✔✔ Fetched [{0}] Datatables ✔✔", oResult.Tables.Count)
|
||||
|
||||
Catch ex As Exception
|
||||
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
|
||||
|
||||
Return Task.FromResult(True)
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
Imports System.Threading
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports Quartz
|
||||
Imports Quartz.Listener
|
||||
|
||||
Imports System.Diagnostics
|
||||
Imports System.Data
|
||||
Public Class JobListener
|
||||
Inherits JobListenerSupport
|
||||
|
||||
@@ -121,7 +121,7 @@ Public Class JobListener
|
||||
End If
|
||||
End If
|
||||
|
||||
_Logger.Info("Dataset successfully updated with table [{0}]", oName)
|
||||
_Logger.Info("✔ Dataset successfully updated with table [{0}]", oName)
|
||||
|
||||
Finally
|
||||
' ✅ SCHRITT 3: Write-Lock freigeben (so schnell wie möglich!)
|
||||
@@ -129,7 +129,7 @@ Public Class JobListener
|
||||
oStopWatch.Stop()
|
||||
' ✅ Performance-Warning bei langsamen Updates
|
||||
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
|
||||
_Logger.Debug("[Performance] Table update completed in {0}ms", oStopWatch.ElapsedMilliseconds)
|
||||
End If
|
||||
@@ -142,7 +142,7 @@ Public Class JobListener
|
||||
_MSSQL.ExecuteNonQuery($"INSERT INTO TBAPPSERV_CRON_DETAIL_HISTORY (DETAIL_ID) VALUES ({oDetailId})")
|
||||
|
||||
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)
|
||||
End Try
|
||||
End Sub
|
||||
@@ -256,23 +256,22 @@ Public Class JobListener
|
||||
|
||||
Catch ex As ArgumentNullException
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("ArgumentNullException in AddRelation: {0}", ex.Message)
|
||||
_Logger.Warn("⚠ ArgumentNullException in AddRelation: {0}", ex.Message)
|
||||
|
||||
Catch ex As DuplicateNameException
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("DuplicateNameException in AddRelation: {0}", ex.Message)
|
||||
_Logger.Warn("⚠ DuplicateNameException in AddRelation: {0}", ex.Message)
|
||||
|
||||
Catch ex As InvalidConstraintException
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("InvalidConstraintException in AddRelation: {0}", ex.Message)
|
||||
|
||||
_Logger.Warn("⚠ InvalidConstraintException in AddRelation: {0}", ex.Message)
|
||||
Catch ex As ArgumentException
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("ArgumentException in AddRelation: {0}", ex.Message)
|
||||
_Logger.Warn("⚠ ArgumentException in AddRelation: {0}", ex.Message)
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("Exception in AddRelation: {0}", ex.Message)
|
||||
_Logger.Warn("⚠ Exception in AddRelation: {0}", ex.Message)
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
@@ -103,12 +103,13 @@ Public Class Scheduler
|
||||
|
||||
Logger.Debug("Scheduled a new job for Cron Job [{0}]", oTitle)
|
||||
Next
|
||||
Logger.Info("✔ Scheduler started with {0} cron jobs", oCronjobs.Rows.Count)
|
||||
Else
|
||||
Logger.Warn("CronJobs could not be fetched!")
|
||||
Logger.Warn("⚠ CronJobs could not be fetched!")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
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 Sub
|
||||
Public Async Function GetCronJobs() As Task(Of DataTable)
|
||||
|
||||
@@ -61,34 +61,38 @@ Public Class WindowsService
|
||||
oTimer.Start()
|
||||
|
||||
' 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
|
||||
LogConfigScheduler.Debug = ConfigManager.Config.Debug
|
||||
|
||||
Logger.Info("Connecting to Databases..")
|
||||
Logger.Debug("Connecting to Databases...")
|
||||
Firebird = StartFirebird()
|
||||
MSSQL_ECM = GetMSSQL_ECM(LogConfig)
|
||||
MSSQL_IDB = GetMSSQL_IDB(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)
|
||||
GlobalState = New GlobalState(LogConfig, MSSQL_IDB, MSSQL_ECM)
|
||||
|
||||
Dim oMSSQLServer = GetMSSQL_Config(LogConfigScheduler)
|
||||
Scheduler = New Scheduler(LogConfigScheduler, oMSSQLServer, GlobalState.TableStore, GlobalState)
|
||||
|
||||
Logger.Info("Loading Global Data")
|
||||
Logger.Debug("Loading Global Data ...")
|
||||
GlobalState.LoadObjectStores()
|
||||
GlobalState.LoadConnections()
|
||||
GlobalState.LoadDoctypes()
|
||||
GlobalState.LoadClientConfig(Config)
|
||||
|
||||
Logger.Info("Starting Scheduler")
|
||||
Logger.Debug("Starting Scheduler ...")
|
||||
Scheduler.Start()
|
||||
|
||||
Logger.Info("Preparing WCF ServiceHost")
|
||||
Logger.Debug("Preparing WCF ServiceHost ...")
|
||||
EDMIService.MSSQL_ECM = MSSQL_ECM
|
||||
EDMIService.MSSQL_IDB = MSSQL_IDB
|
||||
EDMIService.Firebird = Firebird
|
||||
@@ -97,11 +101,20 @@ Public Class WindowsService
|
||||
EDMIService.GlobalState = GlobalState
|
||||
EDMIService.Scheduler = Scheduler
|
||||
|
||||
Logger.Info("Starting WCF ServiceHost")
|
||||
Logger.Debug("Starting WCF ServiceHost ...")
|
||||
|
||||
Dim oBaseAddresses() As Uri = {New Uri(SERVICE_BASE_ADDRESS)}
|
||||
ServiceHost = New ServiceHost(Of EDMIService)(oBaseAddresses)
|
||||
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:")
|
||||
For Each oEndpoint In ServiceHost.Description.Endpoints
|
||||
@@ -113,12 +126,20 @@ Public Class WindowsService
|
||||
Next
|
||||
|
||||
Logger.Debug("Starting WFC ServiceHost..")
|
||||
ServiceHost.Open()
|
||||
Logger.Debug("WCF ServiceHost started!")
|
||||
|
||||
Logger.Info("Service {0} successfully started!", SERVICE_DISPLAY_NAME)
|
||||
Try
|
||||
ServiceHost.Open()
|
||||
Logger.Debug("WCF ServiceHost started!")
|
||||
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
|
||||
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)
|
||||
GracefullyStop()
|
||||
End Try
|
||||
@@ -126,7 +147,7 @@ Public Class WindowsService
|
||||
|
||||
Private Sub ReloadTimer_Tick()
|
||||
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
|
||||
|
||||
Config = ConfigManager.Config
|
||||
@@ -153,7 +174,7 @@ Public Class WindowsService
|
||||
Logger.Info("Database connection established.")
|
||||
Return oFirebird
|
||||
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)
|
||||
Return Nothing
|
||||
End Try
|
||||
@@ -162,41 +183,41 @@ Public Class WindowsService
|
||||
Private Function GetMSSQL_ECM(pLogConfig As LogConfig) As MSSQLServer
|
||||
Logger.Debug("Connecting to ECM MSSQL")
|
||||
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")
|
||||
End If
|
||||
|
||||
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
|
||||
End Function
|
||||
|
||||
Private Function GetMSSQL_IDB(pLogConfig As LogConfig) As MSSQLServer
|
||||
Logger.Debug("Connecting to IDB MSSQL")
|
||||
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")
|
||||
End If
|
||||
|
||||
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
|
||||
End Function
|
||||
|
||||
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_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)
|
||||
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")
|
||||
End If
|
||||
End If
|
||||
|
||||
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
|
||||
End Function
|
||||
|
||||
@@ -205,13 +226,28 @@ Public Class WindowsService
|
||||
End Sub
|
||||
|
||||
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
|
||||
ServiceHost.Close()
|
||||
ServiceHost = Nothing
|
||||
Try
|
||||
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
|
||||
|
||||
Scheduler.Stop()
|
||||
If Scheduler IsNot Nothing Then
|
||||
Logger.Info("GracefullyStop - Stopping Scheduler.")
|
||||
Scheduler.Stop()
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user