ClipboardWatcher: Use connectionId when executing search count command
This commit is contained in:
parent
90015cd7e4
commit
50a158ea5c
@ -114,6 +114,7 @@
|
||||
<Compile Include="ProfileFilter.vb" />
|
||||
<Compile Include="ProfileMatch.vb" />
|
||||
<Compile Include="ProfileSearches.vb" />
|
||||
<Compile Include="ProfileUtils.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="frmMatch.resx">
|
||||
|
||||
@ -361,19 +361,25 @@ Public Class ProfileFilter
|
||||
|
||||
For Each oRow As DataRow In oDTDataSearches.Rows
|
||||
Dim oCountCommand = String.Empty
|
||||
Dim oCountConnectionId = String.Empty
|
||||
Try
|
||||
oCountCommand = NotNull(oRow.Item("COUNT_COMMAND"), String.Empty)
|
||||
oCountConnectionId = NotNull(oRow.Item("CONN_ID"), 0)
|
||||
|
||||
If oCountCommand = String.Empty Then
|
||||
_Logger.Debug("oCountCommand = String.Empty ==> Continue for")
|
||||
_Logger.Debug("oCountCommand = String.Empty ==> Continue for")
|
||||
Continue For
|
||||
End If
|
||||
|
||||
oCountCommand = oPatterns.ReplaceInternalValues(oCountCommand)
|
||||
oCountCommand = oPatterns.ReplaceUserValues(oCountCommand, User)
|
||||
oCountCommand = oPatterns.ReplaceClipboardContents(oCountCommand, ClipboardContents)
|
||||
|
||||
_Logger.Debug($"Count-Command DATA before execute: [{oCountCommand}]")
|
||||
oResultData += NotNull(Of Integer)(Database.GetScalarValue(oCountCommand), 0)
|
||||
|
||||
Dim oConnectionString = ProfileUtils.GetConnectionString(Database, oCountConnectionId)
|
||||
|
||||
oResultData += NotNull(Of Integer)(Database.GetScalarValueWithConnection(oCountCommand, oConnectionString), 0)
|
||||
Catch ex As Exception
|
||||
_Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
|
||||
End Try
|
||||
|
||||
@ -49,7 +49,7 @@ Public Class ProfileSearches
|
||||
oSQL = oPatterns.ReplaceInternalValues(oSQL)
|
||||
oSQL = oPatterns.ReplaceClipboardContents(oSQL, _Params.ClipboardContents)
|
||||
|
||||
Dim oConnectionString = GetConnectionString(oConnectionId)
|
||||
Dim oConnectionString = ProfileUtils.GetConnectionString(_Environment.Database, oConnectionId)
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||
|
||||
If oDatatable Is Nothing Then
|
||||
@ -72,26 +72,6 @@ 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)
|
||||
@ -119,7 +99,7 @@ Public Class ProfileSearches
|
||||
oSQL = oPatterns.ReplaceInternalValues(oSQL)
|
||||
oSQL = oPatterns.ReplaceClipboardContents(oSQL, _Params.ClipboardContents)
|
||||
|
||||
Dim oConnectionString = GetConnectionString(oConnectionId)
|
||||
Dim oConnectionString = ProfileUtils.GetConnectionString(_Environment.Database, oConnectionId)
|
||||
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||
|
||||
If oDatatable Is Nothing Then
|
||||
|
||||
23
GUIs.ClipboardWatcher/ProfileUtils.vb
Normal file
23
GUIs.ClipboardWatcher/ProfileUtils.vb
Normal file
@ -0,0 +1,23 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
|
||||
Public Class ProfileUtils
|
||||
Public Shared Function GetConnectionString(Database As MSSQLServer, ConnectionId As Integer) As String
|
||||
Dim oDatatable As DataTable = 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 = Database.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
|
||||
End Class
|
||||
Loading…
x
Reference in New Issue
Block a user