EDMIService: Automatic indexing, more consolidation of globix logic

This commit is contained in:
Jonathan Jenne
2021-12-06 15:01:14 +01:00
parent 34517ce209
commit 785b138c57
35 changed files with 1259 additions and 255 deletions

View File

@@ -1,4 +1,6 @@
Imports DigitalData.Modules.Database
Imports System.Data.SqlClient
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Logging
Public Class GlobalState
@@ -8,6 +10,7 @@ Public Class GlobalState
Private ReadOnly _MSSQL_ECM As MSSQLServer
Public Property ObjectStores As New List(Of ObjectStore)
Public Property Connections As New List(Of DatabaseConnection)
Public Property TableStore As New DataSet
@@ -18,8 +21,33 @@ Public Class GlobalState
_MSSQL_ECM = MSSQL_ECM
End Sub
Public Function GetObjectStore(pName As String) As ObjectStore
Return ObjectStores.
Where(Function(store) store.Title.ToUpper = pName.ToUpper).
FirstOrDefault()
End Function
Public Function GetConnection(pConnectionId As Long) As DatabaseConnection
Return Connections.
Where(Function(conn) conn.Id = pConnectionId).
FirstOrDefault()
End Function
Public Function GetConnectionString(pConnectionId As Long) As String
Dim oConnection = GetConnection(pConnectionId)
Dim oBuilder As New SqlConnectionStringBuilder With {
.DataSource = oConnection.Server,
.InitialCatalog = oConnection.Database,
.UserID = oConnection.Username,
.Password = MSSQLServer.DecryptConnectionString(oConnection.Password)
}
Return oBuilder.ToString
End Function
Public Sub LoadObjectStores()
_Logger.Debug("Loading Object Stores")
_Logger.Info("Loading Object Stores")
Try
Dim oSQL As String = "SELECT * FROM VWIDB_OBJECTSTORE"
Dim oDatatable As DataTable = _MSSQL_IDB.GetDatatable(oSQL)
@@ -43,11 +71,34 @@ Public Class GlobalState
End Try
End Sub
Public Function GetObjectStore(Name As String) As ObjectStore
Return ObjectStores.
Where(Function(o) o.Title.ToUpper = Name.ToUpper).
FirstOrDefault()
End Function
Public Sub LoadConnections()
_Logger.Info("Loading Database Connections")
Try
Dim oSQL As String = "SELECT * FROM TBDD_CONNECTION"
Dim oDatatable As DataTable = _MSSQL_ECM.GetDatatable(oSQL)
Connections.Clear()
_Logger.Info("Found [{0}] Connections", oDatatable.Rows.Count)
For Each oRow As DataRow In oDatatable.Rows
Dim oConnection As New DatabaseConnection() With {
.Id = oRow.ItemEx(Of Integer)("GUID"),
.Active = oRow.ItemEx(Of Boolean)("AKTIV"),
.Database = oRow.ItemEx(Of String)("DATENBANK"),
.Title = oRow.ItemEx(Of String)("BEZEICHNUNG"),
.Password = oRow.ItemEx(Of String)("PASSWORD"),
.Provider = oRow.ItemEx(Of String)("SQL_PROVIDER"),
.Server = oRow.ItemEx(Of String)("SERVER"),
.Username = oRow.ItemEx(Of String)("USERNAME")
}
_Logger.Info("New Connection [{0}]", oConnection.Title)
Connections.Add(oConnection)
Next
Catch ex As Exception
_Logger.Error(ex)
End Try
End Sub
Class ObjectStore
Public Id As Long
@@ -55,4 +106,15 @@ Public Class GlobalState
Public IsArchive As Boolean
Public Path As String
End Class
Class DatabaseConnection
Public Id As Long
Public Title As String
Public Provider As String
Public Server As String
Public Database As String
Public Username As String
Public Password As String
Public Active As Boolean
End Class
End Class