Compare commits
3 Commits
ec151f9ee3
...
upgrade-to
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ee84a5ccd | ||
|
|
1b7c7814bc | ||
|
|
a4dc5c5cd3 |
@@ -1,351 +0,0 @@
|
|||||||
Imports FirebirdSql.Data.FirebirdClient
|
|
||||||
Imports System.Text.RegularExpressions
|
|
||||||
Imports DigitalData.Modules.Logging
|
|
||||||
Imports System.ComponentModel
|
|
||||||
Imports System.Data
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' MODULE: Firebird
|
|
||||||
'''
|
|
||||||
''' VERSION: 0.0.0.4
|
|
||||||
'''
|
|
||||||
''' DATE: 18.12.2018
|
|
||||||
'''
|
|
||||||
''' DESCRIPTION:
|
|
||||||
'''
|
|
||||||
''' DEPENDENCIES: NLog, >= 4.5.10
|
|
||||||
'''
|
|
||||||
''' EntityFramework.Firebird, >= 6.4.0
|
|
||||||
'''
|
|
||||||
''' FirebirdSql.Data.FirebirdClient, >= 6.4.0
|
|
||||||
'''
|
|
||||||
''' PARAMETERS: LogConfig, DigitalData.Modules.Logging.LogConfig
|
|
||||||
''' The LogFactory containing the current log config. Used to instanciate the class logger for this and any dependent class
|
|
||||||
'''
|
|
||||||
''' DataSource, String
|
|
||||||
''' The server where the database lives, for example 127.0.0.1 or dd-vmx09-vm03
|
|
||||||
'''
|
|
||||||
''' Database, String
|
|
||||||
''' The location of the Database in the format `127.0.0.1:E:\Path\To\Database.FDB`
|
|
||||||
'''
|
|
||||||
''' User, String
|
|
||||||
''' The user name to connect as
|
|
||||||
'''
|
|
||||||
''' Password, String
|
|
||||||
''' The user's password
|
|
||||||
'''
|
|
||||||
''' PROPERTIES: ConnectionEstablished, Boolean
|
|
||||||
''' If the last opened connection was successful
|
|
||||||
'''
|
|
||||||
''' ConnectionFailed, Boolean
|
|
||||||
''' If the last opened connection failed
|
|
||||||
'''
|
|
||||||
''' ConnectionString, String
|
|
||||||
''' The used connectionstring
|
|
||||||
'''
|
|
||||||
''' EXAMPLES:
|
|
||||||
'''
|
|
||||||
''' REMARKS: If the connection fails due to "wrong username or password", the cause might be that the server harddrive is full..
|
|
||||||
''' </summary>
|
|
||||||
Public Class Firebird
|
|
||||||
Private _Logger As Logger
|
|
||||||
Private _LogConfig As LogConfig
|
|
||||||
Private _connectionServer As String
|
|
||||||
Private _connectionDatabase As String
|
|
||||||
Private _connectionUsername As String
|
|
||||||
Private _connectionPassword As String
|
|
||||||
Private _connectionString As String
|
|
||||||
Public _DBInitialized As Boolean = False
|
|
||||||
|
|
||||||
Public Const MAX_POOL_SIZE = 1000
|
|
||||||
|
|
||||||
Public Enum TransactionMode
|
|
||||||
<Description("Use no transaction, neither internal nor external")>
|
|
||||||
NoTransaction
|
|
||||||
<Description("Use the transaction supplied in the Transaction Parameter")>
|
|
||||||
ExternalTransaction
|
|
||||||
<Description("Create an internal transaction on the fly")>
|
|
||||||
WithTransaction
|
|
||||||
End Enum
|
|
||||||
|
|
||||||
Public ReadOnly Property ConnectionString As String
|
|
||||||
Get
|
|
||||||
Return _connectionString
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
Public ReadOnly Property DatabaseName As String
|
|
||||||
Get
|
|
||||||
Dim oRegex As New Regex("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:")
|
|
||||||
Dim oPath As String = oRegex.Replace(_connectionDatabase, "")
|
|
||||||
Dim oFileInfo As New IO.FileInfo(oPath)
|
|
||||||
Return oFileInfo.Name
|
|
||||||
End Get
|
|
||||||
End Property
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
'''
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="LogConfig">The LogFactory containing the current log config. Used to instanciate the class logger for this and any dependent class</param>
|
|
||||||
''' <param name="Datasource">The server where the database lives, for example 127.0.0.1 or dd-vmx09-vm03</param>
|
|
||||||
''' <param name="Database">The location of the Database in the format `127.0.0.1:E:\Path\To\Database.FDB`</param>
|
|
||||||
''' <param name="User">The user name to connect as</param>
|
|
||||||
''' <param name="Password">The user's password</param>
|
|
||||||
''' <exception cref="Exceptions.DatabaseException"></exception>
|
|
||||||
Public Sub New(LogConfig As LogConfig, Datasource As String, Database As String, User As String, Password As String)
|
|
||||||
Try
|
|
||||||
_LogConfig = LogConfig
|
|
||||||
_Logger = _LogConfig.GetLogger()
|
|
||||||
Dim oConnectionString = GetConnectionString(Datasource, Database, User, Password)
|
|
||||||
|
|
||||||
_connectionServer = Datasource
|
|
||||||
_connectionDatabase = Database
|
|
||||||
_connectionUsername = User
|
|
||||||
_connectionPassword = Password
|
|
||||||
_connectionString = oConnectionString
|
|
||||||
|
|
||||||
_Logger.Debug("Connecting to database..")
|
|
||||||
|
|
||||||
' Test the connection
|
|
||||||
Dim oConnection = GetConnection()
|
|
||||||
' If initial connection was successfully, close it
|
|
||||||
oConnection.Close()
|
|
||||||
|
|
||||||
If oConnection Is Nothing Then
|
|
||||||
Throw New Exceptions.DatabaseException()
|
|
||||||
Else
|
|
||||||
_DBInitialized = True
|
|
||||||
End If
|
|
||||||
|
|
||||||
_Logger.Debug("Connection sucessfully established!")
|
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Error(ex)
|
|
||||||
End Try
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Public Function GetConnection() As FbConnection
|
|
||||||
Try
|
|
||||||
Dim oConnection = New FbConnection(_connectionString)
|
|
||||||
oConnection.Open()
|
|
||||||
|
|
||||||
Return oConnection
|
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Error(ex)
|
|
||||||
Return Nothing
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' Builds a connectionstring from the provided arguments.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="DataSource">The database server where to connect to</param>
|
|
||||||
''' <param name="Database">The datasource, eg. the path of the FDB-file</param>
|
|
||||||
''' <param name="User">The user used to connect to the database</param>
|
|
||||||
''' <param name="Password">The password of the connecting user</param>
|
|
||||||
''' <returns>A connectionstring</returns>
|
|
||||||
Private Function GetConnectionString(DataSource As String, Database As String, User As String, Password As String) As String
|
|
||||||
Return New FbConnectionStringBuilder With {
|
|
||||||
.DataSource = DataSource,
|
|
||||||
.Database = Database,
|
|
||||||
.UserID = User,
|
|
||||||
.Password = Password,
|
|
||||||
.Charset = "UTF8",
|
|
||||||
.MaxPoolSize = MAX_POOL_SIZE
|
|
||||||
}.ToString()
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Private Function MaybeGetTransaction(Connection As FbConnection, Mode As TransactionMode, Transaction As FbTransaction) As FbTransaction
|
|
||||||
If Mode = TransactionMode.NoTransaction Then
|
|
||||||
Return Nothing
|
|
||||||
ElseIf Mode = TransactionMode.ExternalTransaction Then
|
|
||||||
Return Transaction
|
|
||||||
Else
|
|
||||||
Return Connection.BeginTransaction()
|
|
||||||
End If
|
|
||||||
End Function
|
|
||||||
|
|
||||||
Private Function MaybeCommitTransaction(Transaction As FbTransaction, TransactionMode As TransactionMode) As Boolean
|
|
||||||
Select Case TransactionMode
|
|
||||||
Case TransactionMode.NoTransaction
|
|
||||||
Return True
|
|
||||||
Case TransactionMode.ExternalTransaction
|
|
||||||
Return True
|
|
||||||
Case TransactionMode.WithTransaction
|
|
||||||
Try
|
|
||||||
Transaction.Commit()
|
|
||||||
Return True
|
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Error(ex)
|
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
Case Else
|
|
||||||
Return True
|
|
||||||
End Select
|
|
||||||
End Function
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' Executes a non-query command.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="SqlCommand">The command to execute</param>
|
|
||||||
''' <param name="Connection">The Firebird connection to use</param>
|
|
||||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
|
||||||
Public Function ExecuteNonQueryWithConnection(SqlCommand As String, Connection As FbConnection, Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction, Optional Transaction As FbTransaction = Nothing) As Boolean
|
|
||||||
_Logger.Debug("Executing Non-Query: {0}", SqlCommand)
|
|
||||||
|
|
||||||
If Connection Is Nothing Then
|
|
||||||
_Logger.Warn("Connection is nothing!")
|
|
||||||
Return Nothing
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim oTransaction = MaybeGetTransaction(Connection, TransactionMode, Transaction)
|
|
||||||
|
|
||||||
Try
|
|
||||||
Dim oCommand As New FbCommand With {
|
|
||||||
.CommandText = SqlCommand,
|
|
||||||
.Connection = Connection
|
|
||||||
}
|
|
||||||
|
|
||||||
If Not IsNothing(oTransaction) Then
|
|
||||||
oCommand.Transaction = oTransaction
|
|
||||||
End If
|
|
||||||
|
|
||||||
oCommand.ExecuteNonQuery()
|
|
||||||
_Logger.Debug("Command executed!")
|
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Error(ex, $"Error in ExecuteNonQuery while executing command: [{SqlCommand}]")
|
|
||||||
_Logger.Warn($"Unexpected error in ExecuteNonQueryWithConnection: [{SqlCommand}]")
|
|
||||||
Throw ex
|
|
||||||
Finally
|
|
||||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Return True
|
|
||||||
End Function
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' Executes a non-query command.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="SqlCommand">The command to execute</param>
|
|
||||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
|
||||||
Public Function ExecuteNonQuery(SqlCommand As String) As Boolean
|
|
||||||
Using oConnection As FbConnection = GetConnection()
|
|
||||||
Return ExecuteNonQueryWithConnection(SqlCommand, oConnection)
|
|
||||||
End Using
|
|
||||||
End Function
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' Executes a non-query command inside the specified transaction.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="SqlCommand">The command to execute</param>
|
|
||||||
''' <returns>True, if command was executed sucessfully. Otherwise false.</returns>
|
|
||||||
Public Function ExecuteNonQuery(SqlCommand As String, Transaction As FbTransaction) As Boolean
|
|
||||||
Using oConnection As FbConnection = GetConnection()
|
|
||||||
Return ExecuteNonQueryWithConnection(SqlCommand, oConnection, TransactionMode.ExternalTransaction, Transaction)
|
|
||||||
End Using
|
|
||||||
End Function
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' Executes a sql query resulting in a scalar value.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="SqlQuery">The query to execute</param>
|
|
||||||
''' <param name="Connection">The Firebird connection to use</param>
|
|
||||||
''' <returns>The scalar value if the command was executed successfully. Nothing otherwise.</returns>
|
|
||||||
Public Function GetScalarValueWithConnection(SqlQuery As String, Connection As FbConnection, Optional TransactionMode As TransactionMode = TransactionMode.WithTransaction, Optional Transaction As FbTransaction = Nothing) As Object
|
|
||||||
_Logger.Debug("Fetching Scalar-Value: {0}", SqlQuery)
|
|
||||||
|
|
||||||
If Connection Is Nothing Then
|
|
||||||
_Logger.Warn("Connection is nothing!")
|
|
||||||
Return Nothing
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim oTransaction = MaybeGetTransaction(Connection, TransactionMode, Transaction)
|
|
||||||
Dim oResult As Object
|
|
||||||
|
|
||||||
Try
|
|
||||||
Dim oCommand As New FbCommand With {
|
|
||||||
.CommandText = SqlQuery,
|
|
||||||
.Connection = Connection,
|
|
||||||
.Transaction = oTransaction
|
|
||||||
}
|
|
||||||
oResult = oCommand.ExecuteScalar()
|
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Error(ex, $"Error in ReturnScalar while executing command: [{SqlQuery}]")
|
|
||||||
Throw ex
|
|
||||||
Finally
|
|
||||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Return oResult
|
|
||||||
End Function
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' Executes a sql query resulting in a scalar value.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="SqlQuery">The query to execute</param>
|
|
||||||
''' <returns>The scalar value if the command was executed successfully. Nothing otherwise.</returns>
|
|
||||||
Public Function GetScalarValue(SqlQuery As String) As Object
|
|
||||||
Dim oConnection As FbConnection = GetConnection()
|
|
||||||
Dim oScalarValue As Object = GetScalarValueWithConnection(SqlQuery, oConnection)
|
|
||||||
oConnection.Close()
|
|
||||||
|
|
||||||
Return oScalarValue
|
|
||||||
End Function
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' Executes a sql query resulting in a table of values.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="SqlQuery">The query to execute</param>
|
|
||||||
''' <param name="Connection">The Firebird connection to use</param>
|
|
||||||
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
|
|
||||||
Public Function GetDatatableWithConnection(SqlQuery As String, Connection As FbConnection, Optional TransactionMode As TransactionMode = TransactionMode.NoTransaction, Optional Transaction As FbTransaction = Nothing) As DataTable
|
|
||||||
_Logger.Debug("Fetching Datatable: {0}", SqlQuery)
|
|
||||||
|
|
||||||
If Connection Is Nothing Then
|
|
||||||
_Logger.Warn("Connection is nothing!")
|
|
||||||
Return Nothing
|
|
||||||
End If
|
|
||||||
|
|
||||||
Dim oTransaction = MaybeGetTransaction(Connection, TransactionMode, Transaction)
|
|
||||||
Dim oDatatable As New DataTable() With {
|
|
||||||
.TableName = "DDRESULT"
|
|
||||||
}
|
|
||||||
|
|
||||||
Try
|
|
||||||
Dim oAdapter As New FbDataAdapter(New FbCommand With {
|
|
||||||
.CommandText = SqlQuery,
|
|
||||||
.Connection = Connection,
|
|
||||||
.Transaction = oTransaction
|
|
||||||
})
|
|
||||||
|
|
||||||
oAdapter.Fill(oDatatable)
|
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Error(ex)
|
|
||||||
_Logger.Warn("Error in GetDatatableWithConnection while executing command: [{0}]", SqlQuery)
|
|
||||||
Throw ex
|
|
||||||
Finally
|
|
||||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
|
||||||
End Try
|
|
||||||
|
|
||||||
Return oDatatable
|
|
||||||
End Function
|
|
||||||
|
|
||||||
''' <summary>
|
|
||||||
''' Executes a sql query resulting in a table of values.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="SqlQuery">The query to execute</param>
|
|
||||||
''' <returns>A datatable containing the results if the command was executed successfully. Nothing otherwise.</returns>
|
|
||||||
Public Function GetDatatable(SqlQuery As String, Optional TransactionMode As TransactionMode = TransactionMode.NoTransaction, Optional Transaction As FbTransaction = Nothing) As DataTable
|
|
||||||
Try
|
|
||||||
Dim oConnection As FbConnection = GetConnection()
|
|
||||||
Dim oDatatable As DataTable = GetDatatableWithConnection(SqlQuery, oConnection, TransactionMode, Transaction)
|
|
||||||
oConnection.Close()
|
|
||||||
|
|
||||||
Return oDatatable
|
|
||||||
Catch ex As Exception
|
|
||||||
_Logger.Error(ex)
|
|
||||||
_Logger.Warn("Error in GetDatatable while executing command: '{0}'", SqlQuery)
|
|
||||||
Throw ex
|
|
||||||
End Try
|
|
||||||
End Function
|
|
||||||
End Class
|
|
||||||
@@ -75,7 +75,7 @@ Public Class MSSQLServer
|
|||||||
''' <summary>
|
''' <summary>
|
||||||
''' Decrypts a connection string password.
|
''' Decrypts a connection string password.
|
||||||
''' </summary>
|
''' </summary>
|
||||||
''' <param name="pConnectionString">A connection string with a encrypted password</param>
|
''' <param name="pConnectionString">A connection string with an encrypted password</param>
|
||||||
''' <returns>The connection string with the password decrypted.</returns>
|
''' <returns>The connection string with the password decrypted.</returns>
|
||||||
<DebuggerStepThrough()>
|
<DebuggerStepThrough()>
|
||||||
Public Shared Function DecryptConnectionString(pConnectionString As String) As String
|
Public Shared Function DecryptConnectionString(pConnectionString As String) As String
|
||||||
@@ -87,6 +87,11 @@ Public Class MSSQLServer
|
|||||||
Return oBuilder.ToString()
|
Return oBuilder.ToString()
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
<DebuggerStepThrough()>
|
||||||
|
Private Function IDatabase_DecryptConnectionString(pConnectionString As String) As String Implements IDatabase.DecryptConnectionString
|
||||||
|
Return DecryptConnectionString(pConnectionString)
|
||||||
|
End Function
|
||||||
|
|
||||||
<DebuggerStepThrough()>
|
<DebuggerStepThrough()>
|
||||||
Public Function GetConnectionString(Server As String, Database As String, UserId As String, Password As String) As String
|
Public Function GetConnectionString(Server As String, Database As String, UserId As String, Password As String) As String
|
||||||
Dim oConnectionStringBuilder As New SqlConnectionStringBuilder() With {
|
Dim oConnectionStringBuilder As New SqlConnectionStringBuilder() With {
|
||||||
@@ -146,7 +151,7 @@ Public Class MSSQLServer
|
|||||||
End Select
|
End Select
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function GetConnectionStringForId(pConnectionId As Integer) As String
|
Public Function GetConnectionStringForId(pConnectionId As Integer) As String Implements IDatabase.GetConnectionStringForId
|
||||||
Return Get_ConnectionStringforID(pConnectionId)
|
Return Get_ConnectionStringforID(pConnectionId)
|
||||||
End Function
|
End Function
|
||||||
Public Function GetGDPictureString() As String
|
Public Function GetGDPictureString() As String
|
||||||
@@ -194,14 +199,6 @@ Public Class MSSQLServer
|
|||||||
Else
|
Else
|
||||||
oConnectionString = $"Server={oServer};Database={oDatabase};User Id={oUser};Password={oPassword};"
|
oConnectionString = $"Server={oServer};Database={oDatabase};User Id={oUser};Password={oPassword};"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Case "ORACLE"
|
|
||||||
If oRow.Item("BEMERKUNG").ToString.Contains("without tnsnames") Then
|
|
||||||
oConnectionString = $"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={oServer})(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME={oDatabase})));User Id={oUser};Password={oPassword};"
|
|
||||||
Else
|
|
||||||
oConnectionString = $"Data Source={oServer};Persist Security Info=True;User Id={oUser};Password={oPassword};Unicode=True"
|
|
||||||
End If
|
|
||||||
|
|
||||||
Case Else
|
Case Else
|
||||||
Logger.Warn("Provider [{0}] not supported!", oProvider)
|
Logger.Warn("Provider [{0}] not supported!", oProvider)
|
||||||
|
|
||||||
@@ -213,7 +210,7 @@ Public Class MSSQLServer
|
|||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Logger.Error(ex)
|
Logger.Error(ex)
|
||||||
Logger.Warn("Error in Get_ConnectionStringforID")
|
Logger.Warn("Error in Get_ConnectionStringforID (MSSQLServer.VB)")
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
Return DecryptConnectionString(oConnectionString)
|
Return DecryptConnectionString(oConnectionString)
|
||||||
|
|||||||
@@ -10,7 +10,53 @@ Public Class Oracle
|
|||||||
|
|
||||||
Private ReadOnly _Timeout As Integer
|
Private ReadOnly _Timeout As Integer
|
||||||
Private ReadOnly _Logger As Logger
|
Private ReadOnly _Logger As Logger
|
||||||
|
Public Function GetConnectionStringForId(pConnectionId As Integer) As String Implements IDatabase.GetConnectionStringForId
|
||||||
|
Return Get_ConnectionStringforID(pConnectionId)
|
||||||
|
End Function
|
||||||
|
Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String
|
||||||
|
Dim oConnectionString As String = String.Empty
|
||||||
|
|
||||||
|
_Logger.Debug("Getting ConnectionString for ConnectionId [{0}]", pConnectionId)
|
||||||
|
|
||||||
|
If pConnectionId = 0 Then
|
||||||
|
_Logger.Warn("ConnectionId was 0. Falling back to default connection.")
|
||||||
|
Return String.Empty
|
||||||
|
End If
|
||||||
|
|
||||||
|
Try
|
||||||
|
Dim oTable As DataTable = GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {pConnectionId}")
|
||||||
|
If oTable.Rows.Count = 1 Then
|
||||||
|
Dim oRow As DataRow = oTable.Rows(0)
|
||||||
|
Dim oProvider = oRow.Item("SQL_PROVIDER").ToString.ToUpper
|
||||||
|
Dim oServer = oRow.Item("SERVER")
|
||||||
|
Dim oDatabase = oRow.Item("DATENBANK")
|
||||||
|
Dim oUser = oRow.Item("USERNAME")
|
||||||
|
Dim oPassword = oRow.Item("PASSWORD")
|
||||||
|
|
||||||
|
Select Case oProvider
|
||||||
|
Case "ORACLE"
|
||||||
|
If oRow.Item("BEMERKUNG").ToString.Contains("without tnsnames") Then
|
||||||
|
oConnectionString = $"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={oServer})(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME={oDatabase})));User Id={oUser};Password={oPassword};"
|
||||||
|
Else
|
||||||
|
oConnectionString = $"Data Source={oServer};Persist Security Info=True;User Id={oUser};Password={oPassword};Unicode=True"
|
||||||
|
End If
|
||||||
|
|
||||||
|
Case Else
|
||||||
|
_Logger.Warn("Provider [{0}] not supported!", oProvider)
|
||||||
|
|
||||||
|
End Select
|
||||||
|
|
||||||
|
Else
|
||||||
|
_Logger.Warn("No entry for Connection-ID: [{0}] ", pConnectionId.ToString)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
_Logger.Error(ex)
|
||||||
|
_Logger.Warn("Error in Get_ConnectionStringforID (Oracle.VB)")
|
||||||
|
End Try
|
||||||
|
|
||||||
|
Return DecryptConnectionString(oConnectionString)
|
||||||
|
End Function
|
||||||
Public Sub New(LogConfig As LogConfig, ConnectionString As String, Optional Timeout As Integer = 120)
|
Public Sub New(LogConfig As LogConfig, ConnectionString As String, Optional Timeout As Integer = 120)
|
||||||
_Timeout = Timeout
|
_Timeout = Timeout
|
||||||
_Logger = LogConfig.GetLogger()
|
_Logger = LogConfig.GetLogger()
|
||||||
@@ -66,7 +112,7 @@ Public Class Oracle
|
|||||||
''' <param name="ConnectionString">A connection string with a encrypted password</param>
|
''' <param name="ConnectionString">A connection string with a encrypted password</param>
|
||||||
''' <returns>The connection string with the password decrypted.</returns>
|
''' <returns>The connection string with the password decrypted.</returns>
|
||||||
<DebuggerStepThrough()>
|
<DebuggerStepThrough()>
|
||||||
Public Shared Function DecryptConnectionString(ConnectionString As String) As String
|
Public Function DecryptConnectionString(ConnectionString As String) As String Implements IDatabase.DecryptConnectionString
|
||||||
Dim oEncryption As New EncryptionLegacy()
|
Dim oEncryption As New EncryptionLegacy()
|
||||||
Dim oBuilder As New OracleConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
Dim oBuilder As New OracleConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||||
Dim oDecryptedPassword = oEncryption.DecryptData(oBuilder.Password)
|
Dim oDecryptedPassword = oEncryption.DecryptData(oBuilder.Password)
|
||||||
|
|||||||
@@ -150,10 +150,6 @@ Public Class Dispatcher
|
|||||||
Case ConnectionType.Oracle
|
Case ConnectionType.Oracle
|
||||||
Return New Oracle(LogConfig, oConnection.ConnectionString, Constants.DEFAULT_TIMEOUT)
|
Return New Oracle(LogConfig, oConnection.ConnectionString, Constants.DEFAULT_TIMEOUT)
|
||||||
|
|
||||||
Case ConnectionType.Firebird
|
|
||||||
Dim oBuilder As New FirebirdSql.Data.FirebirdClient.FbConnectionStringBuilder(oConnection.ConnectionString)
|
|
||||||
Return New Firebird(LogConfig, oBuilder.DataSource, oBuilder.Database, oBuilder.UserID, oBuilder.Password)
|
|
||||||
|
|
||||||
Case ConnectionType.ODBC
|
Case ConnectionType.ODBC
|
||||||
'Dim oBuilder As New Data.Odbc.OdbcConnectionStringBuilder(pConnection.ConnectionString)
|
'Dim oBuilder As New Data.Odbc.OdbcConnectionStringBuilder(pConnection.ConnectionString)
|
||||||
'Return New ODBC(LogConfig)
|
'Return New ODBC(LogConfig)
|
||||||
|
|||||||
@@ -17,4 +17,7 @@ Public Interface IDatabase
|
|||||||
|
|
||||||
Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object
|
Function GetScalarValue(SQLQuery As String, Timeout As Integer) As Object
|
||||||
Function GetScalarValue(SQLQuery As String) As Object
|
Function GetScalarValue(SQLQuery As String) As Object
|
||||||
|
|
||||||
|
Function GetConnectionStringForId(ConnectionId As Integer) As String
|
||||||
|
Function DecryptConnectionString(pConnectionString As String) As String
|
||||||
End Interface
|
End Interface
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0-windows7.0</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<RootNamespace>DigitalData.Modules.Jobs</RootNamespace>
|
<RootNamespace>DigitalData.Modules.Jobs</RootNamespace>
|
||||||
<AssemblyName>DigitalData.Modules.Jobs</AssemblyName>
|
<AssemblyName>DigitalData.Modules.Jobs</AssemblyName>
|
||||||
|
|||||||
@@ -298,4 +298,5 @@ Public Class Helpers
|
|||||||
Friend Shared Function IsVectorIndex(indexType As Integer)
|
Friend Shared Function IsVectorIndex(indexType As Integer)
|
||||||
Return VectorIndicies.Contains(indexType)
|
Return VectorIndicies.Contains(indexType)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ Imports System.Text.RegularExpressions
|
|||||||
Imports System.Data
|
Imports System.Data
|
||||||
Imports DigitalData.Modules.Base
|
Imports DigitalData.Modules.Base
|
||||||
Imports DigitalData.Modules.Logging
|
Imports DigitalData.Modules.Logging
|
||||||
|
|
||||||
|
|
||||||
Imports WINDREAMLib
|
Imports WINDREAMLib
|
||||||
Imports WINDREAMLib.WMObjectEditMode
|
Imports WINDREAMLib.WMObjectEditMode
|
||||||
Imports WMOBRWSLib
|
Imports WMOBRWSLib
|
||||||
@@ -1560,6 +1558,29 @@ Public Class Windream
|
|||||||
Dim oIndexType As Integer = GetIndexType(IndexName)
|
Dim oIndexType As Integer = GetIndexType(IndexName)
|
||||||
Return Helpers.IsVectorIndex(oIndexType)
|
Return Helpers.IsVectorIndex(oIndexType)
|
||||||
End Function
|
End Function
|
||||||
|
Public Function Start_WMCC_andCo()
|
||||||
|
Try
|
||||||
|
' 04.10.18: Überprüft, ob der Benutzer Mitglied der SERVER_USER Gruppe ist
|
||||||
|
' Dim sql = "SELECT T.GUID FROM TBDD_GROUPS_USER T INNER JOIN TBDD_GROUPS T1 on T1.GUID = T.GROUP_ID WHERE T1.NAME = 'SERVER_USER' AND T.USER_ID = " & USER_ID
|
||||||
|
'Dim userExistsInServerUserGroup = DatabaseFallback.GetScalarValueECM(sql) ', CONNECTION_STRING_ECM, "StartWMCC-userExistsInServerUserGroup")
|
||||||
|
|
||||||
|
' If WMSESSION_STARTSTOP_STARTUP = True Then
|
||||||
|
'And userExistsInServerUserGroup Is Nothing
|
||||||
|
_logger.Info(">> WINDREAM-Start on ApplicationStart is active!")
|
||||||
|
|
||||||
|
Dim owindreamControlCenter = CreateObject("Wmcc.ControlCenter")
|
||||||
|
Dim owindreamIndexService = CreateObject("WMIndexServer.WMIdxSvControl")
|
||||||
|
owindreamControlCenter.StartVFSService(1)
|
||||||
|
System.Threading.Thread.Sleep(1000)
|
||||||
|
owindreamIndexService.Start()
|
||||||
|
System.Threading.Thread.Sleep(1500)
|
||||||
|
' End If
|
||||||
|
' Create_Session()
|
||||||
|
Catch ex As Exception
|
||||||
|
_logger.Error(ex)
|
||||||
|
_logger.Info("Error while starting up WMCC and IndexService: " & ex.Message, True)
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
#Region "Private Methods"
|
#Region "Private Methods"
|
||||||
|
|||||||
Reference in New Issue
Block a user