Commit vor Firebird entfernen
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user