ClipboardWatcher: Actually use configured connection strings
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
Imports DigitalData.Modules.Patterns
|
||||
|
||||
Public Class ProfileSearches
|
||||
Private _LogConfig As LogConfig
|
||||
@@ -34,7 +36,7 @@ Public Class ProfileSearches
|
||||
Dim oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
|
||||
Dim oDocSearches As New List(Of Search)
|
||||
Dim oCounter As Integer = 0
|
||||
Dim oPatterns As New Patterns.ClassPatterns(_LogConfig)
|
||||
Dim oPatterns As New ClassPatterns(_LogConfig)
|
||||
|
||||
For Each oRow As DataRow In oSearchesDataTable.Rows
|
||||
Dim oProfileId As Integer = oRow.Item("PROFILE_ID")
|
||||
@@ -47,7 +49,8 @@ Public Class ProfileSearches
|
||||
oSQL = oPatterns.ReplaceInternalValues(oSQL)
|
||||
oSQL = oPatterns.ReplaceClipboardContents(oSQL, _Params.ClipboardContents)
|
||||
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatable(oSQL, oConnectionId)
|
||||
Dim oConnectionString = GetConnectionString(oConnectionId)
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||
|
||||
If oDatatable Is Nothing Then
|
||||
_Logger.Warn("Error in SQL-Query '{0}'", oSQL)
|
||||
@@ -69,6 +72,26 @@ Public Class ProfileSearches
|
||||
Return oDocSearches
|
||||
End Function
|
||||
|
||||
Private Function GetConnectionString(ConnectionId As Integer) As String
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {ConnectionId}")
|
||||
|
||||
If oDatatable.Rows.Count > 0 Then
|
||||
Dim oRow As DataRow = oDatatable.Rows.Item(0)
|
||||
|
||||
Select Case oRow.Item("SQL_PROVIDER")
|
||||
Case "MS-SQL"
|
||||
Dim oConnectionString = MSSQLServer.GetConnectionString(oRow.Item("SERVER"), oRow.Item("DATENBANK"), oRow.Item("USERNAME"), oRow.Item("PASSWORD"))
|
||||
Return oConnectionString
|
||||
|
||||
Case Else
|
||||
Return Nothing
|
||||
|
||||
End Select
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Async Function LoadDataSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search))
|
||||
Return Await Task.Run(Function()
|
||||
Return DoLoadDataSearches(ProfileId)
|
||||
@@ -83,7 +106,7 @@ Public Class ProfileSearches
|
||||
Dim oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
|
||||
|
||||
Dim oCounter As Integer = 0
|
||||
Dim oPatterns As New Patterns.ClassPatterns(_LogConfig)
|
||||
Dim oPatterns As New ClassPatterns(_LogConfig)
|
||||
|
||||
For Each oRow As DataRow In oSearchesDataTable.Rows
|
||||
Try
|
||||
@@ -95,7 +118,8 @@ Public Class ProfileSearches
|
||||
oSQL = oPatterns.ReplaceUserValues(oSQL, _Environment.User)
|
||||
oSQL = oPatterns.ReplaceInternalValues(oSQL)
|
||||
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatable(oSQL, oConnectionId)
|
||||
Dim oConnectionString = GetConnectionString(oConnectionId)
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||
|
||||
If oDatatable Is Nothing Then
|
||||
_Logger.Warn("Error in SQL-Query '{0}'", oSQL)
|
||||
|
||||
Reference in New Issue
Block a user