This commit is contained in:
Jonathan Jenne 2019-11-05 11:18:58 +01:00
commit 5ebf847b73
3 changed files with 59 additions and 28 deletions

View File

@ -89,7 +89,7 @@ Public Class ProfileFilter
Dim oMatch = oRegex.Match(ClipboardContents)
If oMatch.Success Then
_Logger.Debug("FilterProfilesByClipboardRegex: Clipboard Regex Matched: {0}", ClipboardContents)
_Logger.Info("Profile {0} matched!", oProfile.Name)
_Logger.Info("FilterProfilesByClipboardRegex: Profile {0} matched!", oProfile.Name)
oFilteredProfiles.Add(oProfile)
oProfile.IsMatched = True
@ -128,7 +128,7 @@ Public Class ProfileFilter
_Logger.Debug($"Processname Matched: {oProcess.ProcessName}")
oFilteredProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
_Logger.Info("FilterProfilesByProcess: Profile {0} matched!", oProfile.Name)
oProfile.MatchedProcessID = oProcess.Guid
oProcess.IsMatched = True
@ -195,6 +195,8 @@ Public Class ProfileFilter
oProfile.MatchedWindowID = oWindowDef.Guid
oWindowDef.IsMatched = True
oWindows.Add(oWindowDef)
Else
_Logger.Debug("NO MATCH on WindowTitle: {0} - REGEX: {2}", WindowTitle, oWindowDef.Regex)
End If
Dim oParent = _ProfileMatch.FindNodeByTag(_TreeView.Nodes, oWindowDef.WindowProcessID & "-PROCESS")
@ -215,7 +217,7 @@ Public Class ProfileFilter
oProfile.IsMatched = True
oProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
_Logger.Info("FilterWindowsByWindowTitleRegex: Profile {0} matched!", oProfile.Name)
End If
Next
@ -323,7 +325,7 @@ Public Class ProfileFilter
oProfile.Controls = oMatchingControls
oFilteredProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
_Logger.Info("FilterProfilesByFocusedControl: Profile {0} matched!", oProfile.Name)
End If
Next
@ -334,48 +336,50 @@ Public Class ProfileFilter
Dim oProfiles As New List(Of ProfileData)
For Each oProfile In Profiles
_Logger.Debug($"Checking SearchResults on ProfileID: {oProfile.Guid}")
Dim oResultDocs As Integer = 0
Dim oResultData As Integer = 0
Dim oPatterns As New ClassPatterns(_LogConfig)
Dim oDataSearches As DataTable
Dim oDocSearches As DataTable
Dim oDTDataSearches As DataTable
Dim oDTDocSearches As DataTable
Try
oDataSearches = Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}")
oDTDataSearches = Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}")
Catch ex As Exception
_Logger.Error(ex)
Continue For
End Try
Try
oDocSearches = Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}")
oDTDocSearches = Database.GetDatatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {oProfile.Guid}")
Catch ex As Exception
_Logger.Error(ex)
Continue For
End Try
For Each oRow As DataRow In oDataSearches.Rows
For Each oRow As DataRow In oDTDataSearches.Rows
Dim oCountCommand = String.Empty
Try
oCountCommand = NotNull(oRow.Item("COUNT_COMMAND"), String.Empty)
If oCountCommand = String.Empty Then
_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)
Catch ex As Exception
_Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
End Try
Next
For Each oRow As DataRow In oDocSearches.Rows
For Each oRow As DataRow In oDTDocSearches.Rows
Dim oCountCommand = String.Empty
Try
oCountCommand = NotNull(oRow.Item("COUNT_COMMAND"), String.Empty)
@ -383,12 +387,15 @@ Public Class ProfileFilter
If oCountCommand = String.Empty Then
Continue For
End If
_Logger.Debug($"Count-Command DOCS BEFORE Replace: {oCountCommand}")
oCountCommand = oPatterns.ReplaceInternalValues(oCountCommand)
' _Logger.Debug($"Count-Command DOCS AFTER ReplaceInternalValues: {oCountCommand}")
oCountCommand = oPatterns.ReplaceUserValues(oCountCommand, User)
' _Logger.Debug($"Count-Command DOCS AFTER ReplaceUserValues: {oCountCommand}")
oCountCommand = oPatterns.ReplaceClipboardContents(oCountCommand, ClipboardContents)
_Logger.Debug($"Count-Command DOCS BEFORE execute: {oCountCommand}")
oResultDocs += NotNull(Of Integer)(Database.GetScalarValue(oCountCommand), 0)
_Logger.Debug($"oResultDocs: {oResultDocs}")
Catch ex As Exception
_Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oCountCommand)
End Try
@ -401,7 +408,7 @@ Public Class ProfileFilter
For Each oProfile In Profiles
If oProfile.CountData > 0 Or oProfile.CountDocs > 0 Then
oProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
_Logger.Info("Profile {0} matched in FilterProfilesBySearchResults!", oProfile.Name)
End If
Next
@ -447,7 +454,7 @@ Public Class ProfileFilter
oProfile.Windows = oWindows
oProfiles.Add(oProfile)
_Logger.Info("Profile {0} matched!", oProfile.Name)
_Logger.Info("FilterWindowsByWindowClipboardRegex: Profile {0} matched!", oProfile.Name)
End If
Next

View File

@ -70,27 +70,31 @@ Public Class frmMatch
End If
If oCreatedTiles = 0 Then
_Logger.Warn("No Results found for ""{0}""", _Params.ClipboardContents)
_Logger.Warn("No Tiles Created: No Results found for ""{0}""", _Params.ClipboardContents)
Close()
End If
Dim oMatchString = IIf(oCreatedTiles = 1, "1 Profil", $"{oCreatedTiles} Profile")
Label1.Text = String.Format(Label1.Text, oMatchString, _Params.ClipboardContents)
_Logger.Debug($"Created Tiles: {oCreatedTiles} ")
If oCreatedTiles = 1 Then
Dim oProfile As ProfileData = _Params.MatchingProfiles.First()
Dim oProfileSearch As New ProfileSearches(_LogConfig, _Environment, _Params)
If oProfile.CountData > 0 Then
Dim oSearches = Await oProfileSearch.LoadDataSearchesAsync(oProfile.Guid)
OpenDataResults(oProfile, oSearches)
Hide()
ElseIf oProfile.CountDocs > 0 Then
If oProfile.CountDocs > 0 And oProfile.CountData = 0 Then
_Logger.Debug($"ONLY Docs")
'ONLY DOCS AND DATA
Dim oSearches = Await oProfileSearch.LoadDocumentSearchesAsync(oProfile.Guid)
OpenDocumentResults(oProfile, oSearches)
Hide()
ElseIf oProfile.CountDocs > 0 And oProfile.CountData > 0 Then
_Logger.Debug($"Docs AND Data")
ElseIf oProfile.CountDocs = 0 And oProfile.CountData > 0 Then
_Logger.Debug($"ONLY Data")
Dim oSearches = Await oProfileSearch.LoadDataSearchesAsync(oProfile.Guid)
OpenDataResults(oProfile, oSearches)
Hide()
End If
End If
End Sub
@ -121,10 +125,13 @@ Public Class frmMatch
'End If
If oProfile.ProfileType = ProfileType.ANY Or oProfile.ProfileType = ProfileType.DOCS_ONLY Then
_Logger.Debug("Docs only or ProfileTypeAny")
If oProfile.CountDocs > 0 Then
Dim oItem = CreateTile(oProfile, $"{oProfile.CountDocs} Dokumente")
Dim oItem = CreateTile(oProfile, $"{oProfile.CountDocs} Dateien")
oDocumentGroup.Items.Add(oItem)
oCreatedTiles += 1
Else
_Logger.Debug("NO Doc-Results!")
End If
End If
@ -133,6 +140,8 @@ Public Class frmMatch
Dim oItem = CreateTile(oProfile, $"{oProfile.CountData} Datensätze")
oDataGroup.Items.Add(oItem)
oCreatedTiles += 1
Else
_Logger.Debug("NO Data-Results!")
End If
End If
Next

View File

@ -63,9 +63,23 @@ Public Class MSSQLServer
Try
Dim oConnection As New SqlConnection(CurrentSQLConnectionString)
oConnection.Open()
Dim OMyConnection As New SqlClient.SqlConnection(CurrentSQLConnectionString) 'csb.ConnectionString)
Dim csb As New SqlClient.SqlConnectionStringBuilder
csb.ConnectionString = CurrentSQLConnectionString
Dim constr = OMyConnection.ConnectionString
Try
constr = constr.Replace(csb.Password, "XXXXX")
Catch ex As Exception
End Try
'If constr.Contains("Trusted_Connection=True") = False Then
' constr = constr.Replace(csb.Password, "XXXXX")
'End If
_Logger.Debug($"Following Connectionstring is open: {constr}")
Return oConnection
Catch ex As Exception
_Logger.Error(ex)
Return Nothing
End Try
End Function
@ -94,7 +108,7 @@ Public Class MSSQLServer
End Using
Catch ex As Exception
_Logger.Error(ex)
_Logger.Debug("sqlcommand: " & SqlCommand)
_Logger.Warn("sqlcommand: " & SqlCommand)
Return Nothing
End Try
End Function
@ -130,7 +144,7 @@ Public Class MSSQLServer
End Using
Catch ex As Exception
_Logger.Error(ex)
_Logger.Debug("executeStatement: " & SQLCommand)
_Logger.Warn("executeStatement: " & SQLCommand)
Return False
End Try
End Function
@ -165,6 +179,7 @@ Public Class MSSQLServer
End Using
Catch ex As Exception
_Logger.Error(ex)
_Logger.Warn("SQLQuery: " & SQLQuery)
Return Nothing
End Try
End Function
@ -196,7 +211,7 @@ Public Class MSSQLServer
End Using
Catch ex As Exception
_Logger.Error(ex)
_Logger.Debug("executeStatement: " & executeStatement)
_Logger.Warn("executeStatement: " & executeStatement)
End Try
End Sub