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="ProfileFilter.vb" />
|
||||||
<Compile Include="ProfileMatch.vb" />
|
<Compile Include="ProfileMatch.vb" />
|
||||||
<Compile Include="ProfileSearches.vb" />
|
<Compile Include="ProfileSearches.vb" />
|
||||||
|
<Compile Include="ProfileUtils.vb" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="frmMatch.resx">
|
<EmbeddedResource Include="frmMatch.resx">
|
||||||
|
|||||||
@ -361,8 +361,10 @@ Public Class ProfileFilter
|
|||||||
|
|
||||||
For Each oRow As DataRow In oDTDataSearches.Rows
|
For Each oRow As DataRow In oDTDataSearches.Rows
|
||||||
Dim oCountCommand = String.Empty
|
Dim oCountCommand = String.Empty
|
||||||
|
Dim oCountConnectionId = String.Empty
|
||||||
Try
|
Try
|
||||||
oCountCommand = NotNull(oRow.Item("COUNT_COMMAND"), String.Empty)
|
oCountCommand = NotNull(oRow.Item("COUNT_COMMAND"), String.Empty)
|
||||||
|
oCountConnectionId = NotNull(oRow.Item("CONN_ID"), 0)
|
||||||
|
|
||||||
If oCountCommand = String.Empty Then
|
If oCountCommand = String.Empty Then
|
||||||
_Logger.Debug("oCountCommand = String.Empty ==> Continue for")
|
_Logger.Debug("oCountCommand = String.Empty ==> Continue for")
|
||||||
@ -372,8 +374,12 @@ Public Class ProfileFilter
|
|||||||
oCountCommand = oPatterns.ReplaceInternalValues(oCountCommand)
|
oCountCommand = oPatterns.ReplaceInternalValues(oCountCommand)
|
||||||
oCountCommand = oPatterns.ReplaceUserValues(oCountCommand, User)
|
oCountCommand = oPatterns.ReplaceUserValues(oCountCommand, User)
|
||||||
oCountCommand = oPatterns.ReplaceClipboardContents(oCountCommand, ClipboardContents)
|
oCountCommand = oPatterns.ReplaceClipboardContents(oCountCommand, ClipboardContents)
|
||||||
|
|
||||||
_Logger.Debug($"Count-Command DATA before execute: [{oCountCommand}]")
|
_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
|
Catch ex As Exception
|
||||||
_Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
|
_Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
|
||||||
End Try
|
End Try
|
||||||
|
|||||||
@ -49,7 +49,7 @@ Public Class ProfileSearches
|
|||||||
oSQL = oPatterns.ReplaceInternalValues(oSQL)
|
oSQL = oPatterns.ReplaceInternalValues(oSQL)
|
||||||
oSQL = oPatterns.ReplaceClipboardContents(oSQL, _Params.ClipboardContents)
|
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)
|
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||||
|
|
||||||
If oDatatable Is Nothing Then
|
If oDatatable Is Nothing Then
|
||||||
@ -72,26 +72,6 @@ Public Class ProfileSearches
|
|||||||
Return oDocSearches
|
Return oDocSearches
|
||||||
End Function
|
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))
|
Public Async Function LoadDataSearchesAsync(ProfileId As Integer) As Task(Of List(Of Search))
|
||||||
Return Await Task.Run(Function()
|
Return Await Task.Run(Function()
|
||||||
Return DoLoadDataSearches(ProfileId)
|
Return DoLoadDataSearches(ProfileId)
|
||||||
@ -119,7 +99,7 @@ Public Class ProfileSearches
|
|||||||
oSQL = oPatterns.ReplaceInternalValues(oSQL)
|
oSQL = oPatterns.ReplaceInternalValues(oSQL)
|
||||||
oSQL = oPatterns.ReplaceClipboardContents(oSQL, _Params.ClipboardContents)
|
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)
|
Dim oDatatable As DataTable = _Environment.Database.GetDatatableWithConnection(oSQL, oConnectionString)
|
||||||
|
|
||||||
If oDatatable Is Nothing Then
|
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