Compare commits
5 Commits
b7c17250eb
...
41879e3999
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41879e3999 | ||
|
|
50a158ea5c | ||
|
|
90015cd7e4 | ||
|
|
c0e2cf5bc3 | ||
|
|
d57be5ab39 |
@@ -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">
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.2")>
|
||||
<Assembly: AssemblyVersion("1.0.0.3")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
@@ -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
|
||||
@@ -101,6 +101,14 @@ Public Class frmDataResultList
|
||||
|
||||
' Hide Grids depending on Result count
|
||||
Select Case _ResultLists.Count
|
||||
Case 0
|
||||
SplitContainerControl1.SetPanelCollapsed(True)
|
||||
SplitContainerControl2.SetPanelCollapsed(True)
|
||||
|
||||
SwitchMainContainerHorizontal.Enabled = False
|
||||
SwitchDetailContainerHorizontal.Enabled = False
|
||||
|
||||
MessageBox.Show("Es ist ein Fehler beim Ausführen der Suchen aufgetreten oder es wurden keine Suchen gefunden!", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Case 1
|
||||
SplitContainerControl1.SetPanelCollapsed(True)
|
||||
SplitContainerControl2.SetPanelCollapsed(True)
|
||||
|
||||
@@ -116,7 +116,7 @@ Public Class frmDocumentResultList
|
||||
SwitchMainContainerHorizontal.Enabled = False
|
||||
SwitchDetailContainerHorizontal.Enabled = False
|
||||
|
||||
MessageBox.Show("No Searches found.", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
MessageBox.Show("Es ist ein Fehler beim Ausführen der Suchen aufgetreten oder es wurden keine Suchen gefunden!", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
|
||||
Case 1
|
||||
SplitContainerControl1.SetPanelCollapsed(True)
|
||||
SplitContainerControl2.SetPanelCollapsed(True)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
DevExpress.XtraBars.Ribbon.RibbonControl, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
|
||||
|
||||
@@ -72,15 +72,11 @@ Public Class MSSQLServer
|
||||
|
||||
Private Function GetSQLConnection(ConnectionString As String) As SqlConnection
|
||||
Try
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||
Dim oConnection As New SqlConnection(ConnectionString)
|
||||
oConnection.Open()
|
||||
|
||||
Try
|
||||
Dim oConnectionString = ConnectionString.Replace(oBuilder.Password, "XXXXX")
|
||||
_Logger.Debug($"Following Connectionstring is open: {oConnectionString}")
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
Dim oMaskedConnectionString = MaskConnectionString(ConnectionString)
|
||||
_Logger.Debug("The Following Connection is open: {0}", oMaskedConnectionString)
|
||||
|
||||
Return oConnection
|
||||
Catch ex As Exception
|
||||
@@ -90,6 +86,17 @@ Public Class MSSQLServer
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function MaskConnectionString(ConnectionString As String) As String
|
||||
Try
|
||||
Dim oBuilder As New SqlConnectionStringBuilder() With {.ConnectionString = ConnectionString}
|
||||
Dim oConnectionString = ConnectionString.Replace(oBuilder.Password, "XXXXX")
|
||||
Return oConnectionString
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Return "Invalid ConnectionString"
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Returns a datatable for a sql-statement
|
||||
''' </summary>
|
||||
@@ -146,7 +153,9 @@ Public Class MSSQLServer
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("sqlcommand: " & SqlCommand)
|
||||
_Logger.Warn("GetDatatableWithConnection failed with:")
|
||||
_Logger.Warn("ConnectionString: ")
|
||||
_Logger.Warn("SQL Query: " & SqlCommand)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
@@ -168,7 +177,7 @@ Public Class MSSQLServer
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
_Logger.Debug("Running Query: {0}", SQLCommand)
|
||||
_Logger.Debug("ExecuteNonQuery: Running Query [{0}]", SQLCommand)
|
||||
|
||||
Using oConnection = GetSQLConnection()
|
||||
Using oSQLCOmmand = oConnection.CreateCommand()
|
||||
@@ -227,7 +236,7 @@ Public Class MSSQLServer
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
_Logger.Debug("Running Query: {0}", SQLCommand)
|
||||
_Logger.Debug("GetScalarValue: Running Query [{0}]", SQLCommand)
|
||||
|
||||
Using oConnection As SqlConnection = GetSQLConnection()
|
||||
Using oSQLCOmmand = oConnection.CreateCommand()
|
||||
@@ -248,6 +257,29 @@ Public Class MSSQLServer
|
||||
Return GetScalarValue(SQLQuery, _Timeout)
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValueWithConnection(SQLCommand As String, ConnectionString As String) As Object
|
||||
Try
|
||||
If TestCanConnect(ConnectionString) = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
_Logger.Debug("GetScalarValue: Running Query [{0}]", SQLCommand)
|
||||
|
||||
Using oConnection As SqlConnection = GetSQLConnection()
|
||||
Using oSQLCOmmand = oConnection.CreateCommand()
|
||||
oSQLCOmmand.CommandText = SQLCommand
|
||||
oSQLCOmmand.CommandTimeout = _Timeout
|
||||
Dim oResult As Object = oSQLCOmmand.ExecuteScalar()
|
||||
Return oResult
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
_Logger.Warn("SQLQuery: " & SQLCommand)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetScalarValue(SQLCommand As SqlCommand, OutputParameter As String, Timeout As Integer) As Object
|
||||
Try
|
||||
If TestCanConnect() = False Then
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.7")>
|
||||
<Assembly: AssemblyVersion("1.0.0.8")>
|
||||
<Assembly: AssemblyFileVersion("1.1.0.0")>
|
||||
|
||||
Reference in New Issue
Block a user