EDMI: Include Doctypes in ClientConfig

This commit is contained in:
Jonathan Jenne
2022-02-04 16:49:05 +01:00
parent d8b1b7e2b7
commit 67852d4572
19 changed files with 1564 additions and 1357 deletions

View File

@@ -1,4 +1,5 @@
Imports System.Data.SqlClient
Imports System.Runtime.Serialization
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Logging
@@ -11,7 +12,9 @@ Public Class GlobalState
Public Property ObjectStores As New List(Of ObjectStore)
Public Property Connections As New List(Of DatabaseConnection)
Public Property ClientConfig As New Config.ClientConfiguration
Public Property Doctypes As New List(Of Doctype)
Public Property ClientConfig As New ClientConfiguration
Public Property TableStore As New DataSet
@@ -62,18 +65,45 @@ Public Class GlobalState
Return MSSQLServer.DecryptConnectionString(oBuilder.ToString)
End Function
Public Sub LoadDoctypes()
_Logger.Info("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)
Dim oDocTypes As New List(Of Doctype)
For Each oRow As DataRow In oTable.Rows
Dim oDoctype As New Doctype With {
.Name = oRow.Item("DOCTYPE"),
.FileChangedAction = oRow.Item("CHANGED_HANDLING")
}
_Logger.Info("New Doctype [{0}]", oDoctype.Name)
oDocTypes.Add(oDoctype)
Next
Doctypes = oDocTypes
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Public Sub LoadObjectStores()
_Logger.Info("Loading Object Stores")
Try
Dim oSQL As String = "SELECT * FROM VWIDB_OBJECTSTORE"
Dim oDatatable As DataTable = _MSSQL_IDB.GetDatatable(oSQL)
Dim oTable As DataTable = _MSSQL_IDB.GetDatatable(oSQL)
ObjectStores.Clear()
_Logger.Info("Found [{0}] Object Stores", oTable.Rows.Count)
_Logger.Info("Found [{0}] Object Stores", oDatatable.Rows.Count)
Dim oObjectStores As New List(Of ObjectStore)
For Each oRow As DataRow In oDatatable.Rows
For Each oRow As DataRow In oTable.Rows
Dim oStore As New ObjectStore() With {
.Id = oRow.Item("OST_ID"),
.IsArchive = oRow.Item("OS_IS_ARCHIVE"),
@@ -81,8 +111,10 @@ Public Class GlobalState
.Title = oRow.Item("OS_TITLE")
}
_Logger.Info("New Object Store [{0}]", oStore.Title)
ObjectStores.Add(oStore)
oObjectStores.Add(oStore)
Next
ObjectStores = oObjectStores
Catch ex As Exception
_Logger.Error(ex)
End Try
@@ -92,13 +124,13 @@ Public Class GlobalState
_Logger.Info("Loading Database Connections")
Try
Dim oSQL As String = "SELECT * FROM TBDD_CONNECTION"
Dim oDatatable As DataTable = _MSSQL_ECM.GetDatatable(oSQL)
Dim oTable As DataTable = _MSSQL_ECM.GetDatatable(oSQL)
Connections.Clear()
_Logger.Info("Found [{0}] Connections", oTable.Rows.Count)
_Logger.Info("Found [{0}] Connections", oDatatable.Rows.Count)
Dim oConnections As New List(Of DatabaseConnection)
For Each oRow As DataRow In oDatatable.Rows
For Each oRow As DataRow In oTable.Rows
Dim oConnection As New DatabaseConnection() With {
.Id = oRow.ItemEx(Of Integer)("GUID"),
.Active = oRow.ItemEx(Of Boolean)("AKTIV"),
@@ -110,21 +142,30 @@ Public Class GlobalState
.Username = oRow.ItemEx(Of String)("USERNAME")
}
_Logger.Info("New Connection [{0}]", oConnection.Title)
Connections.Add(oConnection)
oConnections.Add(oConnection)
Next
Connections = oConnections
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Class ObjectStore
Public Sub LoadClientConfig(pConfig As Config)
_Logger.Info("Loading Client Config")
_Logger.Debug("ForceDirectDatabaseAccess: {0}", pConfig.ClientConfig.ForceDirectDatabaseAccess)
ClientConfig.ForceDirectDatabaseAccess = pConfig.ClientConfig.ForceDirectDatabaseAccess
ClientConfig.DocumentTypes = Doctypes
End Sub
Public Class ObjectStore
Public Id As Long
Public Title As String
Public IsArchive As Boolean
Public Path As String
End Class
Class DatabaseConnection
Public Class DatabaseConnection
Public Id As Long
Public Title As String
Public Provider As String
@@ -134,4 +175,19 @@ Public Class GlobalState
Public Password As String
Public Active As Boolean
End Class
Public Class ClientConfiguration
Public Property ForceDirectDatabaseAccess As Boolean = False
Public Property DocumentTypes As New List(Of Doctype)
End Class
<DataContract>
Public Class Doctype
<DataMember>
Public Property Name As String
<DataMember>
Public Property FileChangedAction As String
End Class
End Class

View File

@@ -4,13 +4,14 @@ Namespace Methods.Base.GetClientConfig
<Serializable>
<DataContract>
<KnownType(GetType(GlobalState.Doctype))>
Public Class GetClientConfigResponse
Inherits Messages.BaseResponse
<DataMember>
Public Property ClientConfig As Config.ClientConfiguration
Public Property ClientConfig As GlobalState.ClientConfiguration
Public Sub New(pConfig As Config.ClientConfiguration)
Public Sub New(pConfig As GlobalState.ClientConfiguration)
MyBase.New()
ClientConfig = pConfig
End Sub

View File

@@ -34,7 +34,7 @@ Public Class WindowsService
Run(New WindowsService())
End Sub
Protected Overrides Sub OnStart(ByVal args As String())
Protected Overrides Sub OnStart(args As String())
Try
' Init
Dim oServicePath As String = AppDomain.CurrentDomain.BaseDirectory
@@ -65,11 +65,11 @@ Public Class WindowsService
LogConfig.Debug = ConfigManager.Config.Debug
LogConfigScheduler.Debug = ConfigManager.Config.Debug
Logger.Debug("Connecting to Databases")
Logger.Info("Connecting to Databases..")
Firebird = StartFirebird()
MSSQL_ECM = GetMSSQL_ECM(LogConfig)
MSSQL_IDB = GetMSSQL_IDB(LogConfig)
Logger.Info("Connection to Databases established!")
Logger.Debug("Initializing EDMI Functions")
Archive = New EDMI.File.Archive(LogConfig)
@@ -79,18 +79,16 @@ Public Class WindowsService
Dim oMSSQLServer = GetMSSQL_ECM(LogConfigScheduler)
Scheduler = New Scheduler(LogConfigScheduler, oMSSQLServer, GlobalState.TableStore)
Logger.Debug("Loading Global Data")
Logger.Info("Loading Global Data")
GlobalState.LoadObjectStores()
GlobalState.LoadConnections()
GlobalState.LoadDoctypes()
GlobalState.LoadClientConfig(Config)
Logger.Debug("Loading Client Config")
Logger.Debug("ForceDirectDatabaseAccess: {0}", Config.ClientConfig.ForceDirectDatabaseAccess)
GlobalState.ClientConfig = Config.ClientConfig
Logger.Debug("Starting Scheduler")
Logger.Info("Starting Scheduler")
Scheduler.Start()
Logger.Debug("Preparing WCF ServiceHost")
Logger.Info("Preparing WCF ServiceHost")
EDMIService.MSSQL_ECM = MSSQL_ECM
EDMIService.MSSQL_IDB = MSSQL_IDB
EDMIService.Firebird = Firebird
@@ -101,7 +99,7 @@ Public Class WindowsService
EDMIService.GlobalState = GlobalState
EDMIService.Scheduler = Scheduler
Logger.Debug("Starting WCF ServiceHost")
Logger.Info("Starting WCF ServiceHost")
Dim oBaseAddresses() As Uri = {New Uri(SERVICE_BASE_ADDRESS)}
ServiceHost = New ServiceHost(Of EDMIService)(oBaseAddresses)
@@ -116,10 +114,11 @@ Public Class WindowsService
Logger.Debug("Contract: {0}", oEndpoint.Contract.Name)
Next
Logger.Debug("Starting WFC ServiceHost..")
ServiceHost.Open()
Logger.Debug("WCF ServiceHost started!")
Logger.Info("WCF ServiceHost started")
Logger.Info("Service {0} successfully started", SERVICE_DISPLAY_NAME)
Logger.Info("Service {0} successfully started!", SERVICE_DISPLAY_NAME)
Catch ex As Exception
Logger.Warn("Unexpected Error while starting the service: {0}", ex.Message)
Logger.Error(ex)