prepare for new profilematch version, clean up, fix bugs
This commit is contained in:
@@ -12,8 +12,10 @@ Public Class ClassProfileFilter
|
||||
Public ProcessName As String
|
||||
Public Name As String
|
||||
Public Comment As String
|
||||
Public CountSQL As String
|
||||
Public Count As Integer = 0
|
||||
Public SQLCountDocs As String
|
||||
Public SQLCountData As String
|
||||
Public CountDocs As Integer = 0
|
||||
Public CountData As Integer = 0
|
||||
Public Windows As List(Of WindowData)
|
||||
End Class
|
||||
|
||||
@@ -157,7 +159,8 @@ Public Class ClassProfileFilter
|
||||
.Regex = oRow.Item("REGEX_EXPRESSION"),
|
||||
.Name = oRow.Item("NAME"),
|
||||
.Comment = oRow.Item("COMMENT"),
|
||||
.CountSQL = oRow.Item("SQL_COUNT_RESULT"),
|
||||
.SQLCountDocs = oRow.Item("SQL_COUNT_DOCS"),
|
||||
.SQLCountData = oRow.Item("SQL_COUNT_DATA"),
|
||||
.Windows = oWindowList
|
||||
})
|
||||
Next
|
||||
|
||||
@@ -48,12 +48,12 @@ Public Class frmProfileMatch
|
||||
oCountElement.TextAlignment = TileItemContentAlignment.BottomRight
|
||||
oCountElement.Appearance.Normal.Font = SecondaryFont
|
||||
Dim oText As String
|
||||
If oProfile.Count = 99999 Then
|
||||
If oProfile.CountDocs = 99999 Then
|
||||
oText = "DocCount 0 = Check Your MatchCountConfig in Profiles!"
|
||||
ElseIf oProfile.Count = 99998 Then
|
||||
ElseIf oProfile.CountDocs = 99998 Then
|
||||
oText = "DocCount (MatchCountConfig has not been configured)"
|
||||
Else
|
||||
oText = $"{oProfile.Count} files!"
|
||||
oText = $"{oProfile.CountDocs} files!"
|
||||
End If
|
||||
|
||||
oCountElement.Text = oText
|
||||
@@ -76,13 +76,9 @@ Public Class frmProfileMatch
|
||||
Logger.Error(ex)
|
||||
Logger.Info("Error in Save FormLayout: " & ex.Message)
|
||||
End Try
|
||||
CURR_MATCH_RESULT = Nothing
|
||||
CLIPBOARD_TEXT = ""
|
||||
End Sub
|
||||
|
||||
Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
|
||||
CURR_MATCH_RESULT = Nothing
|
||||
CLIPBOARD_TEXT = ""
|
||||
Close()
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -88,9 +88,6 @@ Public Class frmResultDoc
|
||||
_frmProfileMatch?.Show()
|
||||
_frmProfileMatch?.BringToFront()
|
||||
End If
|
||||
|
||||
CURR_MATCH_RESULT = Nothing
|
||||
CLIPBOARD_TEXT = ""
|
||||
End Sub
|
||||
|
||||
Private Async Function LoadSearchesAsync() As Task(Of List(Of DocSearch))
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Threading
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports System.Threading
|
||||
Imports DD_LIB_Standards
|
||||
|
||||
Public Class frmStart
|
||||
@@ -39,137 +37,137 @@ Public Class frmStart
|
||||
CURR_MATCH_RESULT = ClipboardContents
|
||||
End Sub
|
||||
|
||||
Private Sub _Watcher_Changed(ByVal sender As Object, ByVal e As EventArgs) ' Handles _Watcher.Changed
|
||||
'Private Sub _Watcher_Changed(ByVal sender As Object, ByVal e As EventArgs) ' Handles _Watcher.Changed
|
||||
|
||||
clsHotkey.GetCaption()
|
||||
' clsHotkey.GetCaption()
|
||||
|
||||
If DT_USER_PROFILES Is Nothing Then
|
||||
Exit Sub
|
||||
End If
|
||||
If DT_USER_PROFILES.Rows.Count = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
CURR_MATCH_RESULT = Nothing
|
||||
'CURR_MATCH_WM_SEARCH = Nothing
|
||||
If MONITORING_ACTIVE = False Then
|
||||
NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Clipboard-watcher is inactive.", ToolTipIcon.Info)
|
||||
Exit Sub
|
||||
End If
|
||||
' If DT_USER_PROFILES Is Nothing Then
|
||||
' Exit Sub
|
||||
' End If
|
||||
' If DT_USER_PROFILES.Rows.Count = 0 Then
|
||||
' Exit Sub
|
||||
' End If
|
||||
' CURR_MATCH_RESULT = Nothing
|
||||
' 'CURR_MATCH_WM_SEARCH = Nothing
|
||||
' If MONITORING_ACTIVE = False Then
|
||||
' NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Clipboard-watcher is inactive.", ToolTipIcon.Info)
|
||||
' Exit Sub
|
||||
' End If
|
||||
|
||||
Dim Data As IDataObject = Clipboard.GetDataObject
|
||||
' Dim Data As IDataObject = Clipboard.GetDataObject
|
||||
|
||||
' Dim RelevantWindow = clsWINDOWSApi.IsRelevantWindow("jonathan")
|
||||
'With Me.TextBox1
|
||||
' .AppendText(String.Concat("Available Formats:", vbNewLine))
|
||||
' .AppendText(String.Join(vbNewLine, Data.GetFormats))
|
||||
' .AppendText(String.Concat(vbNewLine, vbNewLine, "Text = '", _
|
||||
' Clipboard.GetText, "'", vbNewLine, vbNewLine))
|
||||
'End With
|
||||
Dim oFound As Boolean = False
|
||||
CLIPBOARD_TEXT = Clipboard.GetText
|
||||
Logger.Debug(String.Format(" >>[{0}] Clipboard-Watcher fired for process '{1}'", Now.ToString, CurrPROC_Name), False)
|
||||
Dim oDTMatchProfiles As DataTable = New DataTable
|
||||
oDTMatchProfiles.Columns.Add("GUID")
|
||||
oDTMatchProfiles.Columns.Add("NAME")
|
||||
oDTMatchProfiles.Columns.Add("COUNT")
|
||||
oDTMatchProfiles.Columns.Add("COMMENT")
|
||||
' ' Dim RelevantWindow = clsWINDOWSApi.IsRelevantWindow("jonathan")
|
||||
' 'With Me.TextBox1
|
||||
' ' .AppendText(String.Concat("Available Formats:", vbNewLine))
|
||||
' ' .AppendText(String.Join(vbNewLine, Data.GetFormats))
|
||||
' ' .AppendText(String.Concat(vbNewLine, vbNewLine, "Text = '", _
|
||||
' ' Clipboard.GetText, "'", vbNewLine, vbNewLine))
|
||||
' 'End With
|
||||
' Dim oFound As Boolean = False
|
||||
' CLIPBOARD_TEXT = Clipboard.GetText
|
||||
' Logger.Debug(String.Format(" >>[{0}] Clipboard-Watcher fired for process '{1}'", Now.ToString, CurrPROC_Name), False)
|
||||
' Dim oDTMatchProfiles As DataTable = New DataTable
|
||||
' oDTMatchProfiles.Columns.Add("GUID")
|
||||
' oDTMatchProfiles.Columns.Add("NAME")
|
||||
' oDTMatchProfiles.Columns.Add("COUNT")
|
||||
' oDTMatchProfiles.Columns.Add("COMMENT")
|
||||
|
||||
For Each oProfileRow As DataRow In DT_USER_PROFILES.Rows
|
||||
Dim oProfileID = oProfileRow.Item("GUID")
|
||||
'If found = True Then Exit For
|
||||
'#### 1st CHECK: PROCESSNAME EQUAL ####
|
||||
If CurrPROC_Name.ToUpper = oProfileRow.Item("PROC_NAME").ToString.ToUpper Then
|
||||
'### 2nd CHECK: MATCH ClipboardValue
|
||||
Dim oRegex_expression = oProfileRow.Item("REGEX_EXPRESSION")
|
||||
Dim oRegex As New System.Text.RegularExpressions.Regex(oRegex_expression)
|
||||
Dim oMatch As System.Text.RegularExpressions.Match = oRegex.Match(CLIPBOARD_TEXT)
|
||||
If oMatch.Success Then
|
||||
' If match.Groups(0).Value <> CURR_MATCH_RESULT Then
|
||||
CURR_MATCH_RESULT = oMatch.Groups(0).Value
|
||||
If Not IsNothing(CURR_MATCH_RESULT) Then
|
||||
'#### 3rd CHECK: WindowTitle Match
|
||||
Dim oMatchWindow As Boolean = True
|
||||
Dim oCountWindowDefinitions As Integer = 0
|
||||
For Each oWindowMatchRow As DataRow In DTPROFILE_REL_WINDOW.Rows
|
||||
If oWindowMatchRow.Item("PROFILE_ID") = oProfileID Then
|
||||
oCountWindowDefinitions += 1
|
||||
oRegex_expression = oWindowMatchRow.Item("REGEX")
|
||||
oRegex = New System.Text.RegularExpressions.Regex(oRegex_expression)
|
||||
oMatch = oRegex.Match(CURR_FOCUSED_WINDOWNAME)
|
||||
oMatchWindow = oMatch.Success
|
||||
If oMatchWindow = True Then
|
||||
Dim oMatchRegexWindowClipboard As Boolean = False
|
||||
Logger.Debug($"Found a match on windowtitle [{CURR_FOCUSED_WINDOWNAME}]")
|
||||
If oWindowMatchRow.Item("REGEX_CLIPBOARD") <> String.Empty Then
|
||||
oRegex_expression = oWindowMatchRow.Item("REGEX_CLIPBOARD")
|
||||
oRegex = New System.Text.RegularExpressions.Regex(oRegex_expression)
|
||||
oMatch = oRegex.Match(CLIPBOARD_TEXT)
|
||||
oMatchRegexWindowClipboard = oMatch.Success
|
||||
If oMatchRegexWindowClipboard = True Then
|
||||
Logger.Debug($"Found a match on oMatchRegexWindowClipboard [{oRegex_expression}]")
|
||||
Exit For
|
||||
End If
|
||||
End If
|
||||
' For Each oProfileRow As DataRow In DT_USER_PROFILES.Rows
|
||||
' Dim oProfileID = oProfileRow.Item("GUID")
|
||||
' 'If found = True Then Exit For
|
||||
' '#### 1st CHECK: PROCESSNAME EQUAL ####
|
||||
' If CurrPROC_Name.ToUpper = oProfileRow.Item("PROC_NAME").ToString.ToUpper Then
|
||||
' '### 2nd CHECK: MATCH ClipboardValue
|
||||
' Dim oRegex_expression = oProfileRow.Item("REGEX_EXPRESSION")
|
||||
' Dim oRegex As New System.Text.RegularExpressions.Regex(oRegex_expression)
|
||||
' Dim oMatch As System.Text.RegularExpressions.Match = oRegex.Match(CLIPBOARD_TEXT)
|
||||
' If oMatch.Success Then
|
||||
' ' If match.Groups(0).Value <> CURR_MATCH_RESULT Then
|
||||
' CURR_MATCH_RESULT = oMatch.Groups(0).Value
|
||||
' If Not IsNothing(CURR_MATCH_RESULT) Then
|
||||
' '#### 3rd CHECK: WindowTitle Match
|
||||
' Dim oMatchWindow As Boolean = True
|
||||
' Dim oCountWindowDefinitions As Integer = 0
|
||||
' For Each oWindowMatchRow As DataRow In DTPROFILE_REL_WINDOW.Rows
|
||||
' If oWindowMatchRow.Item("PROFILE_ID") = oProfileID Then
|
||||
' oCountWindowDefinitions += 1
|
||||
' oRegex_expression = oWindowMatchRow.Item("REGEX")
|
||||
' oRegex = New System.Text.RegularExpressions.Regex(oRegex_expression)
|
||||
' oMatch = oRegex.Match(CURR_FOCUSED_WINDOWNAME)
|
||||
' oMatchWindow = oMatch.Success
|
||||
' If oMatchWindow = True Then
|
||||
' Dim oMatchRegexWindowClipboard As Boolean = False
|
||||
' Logger.Debug($"Found a match on windowtitle [{CURR_FOCUSED_WINDOWNAME}]")
|
||||
' If oWindowMatchRow.Item("REGEX_CLIPBOARD") <> String.Empty Then
|
||||
' oRegex_expression = oWindowMatchRow.Item("REGEX_CLIPBOARD")
|
||||
' oRegex = New System.Text.RegularExpressions.Regex(oRegex_expression)
|
||||
' oMatch = oRegex.Match(CLIPBOARD_TEXT)
|
||||
' oMatchRegexWindowClipboard = oMatch.Success
|
||||
' If oMatchRegexWindowClipboard = True Then
|
||||
' Logger.Debug($"Found a match on oMatchRegexWindowClipboard [{oRegex_expression}]")
|
||||
' Exit For
|
||||
' End If
|
||||
' End If
|
||||
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
If oMatchWindow = False Then
|
||||
Logger.Debug($"Found NO MATCH on windowtitle [{CURR_FOCUSED_WINDOWNAME}], but [{oCountWindowDefinitions}] definitions are configured")
|
||||
Exit For
|
||||
End If
|
||||
' End If
|
||||
' End If
|
||||
' Next
|
||||
' If oMatchWindow = False Then
|
||||
' Logger.Debug($"Found NO MATCH on windowtitle [{CURR_FOCUSED_WINDOWNAME}], but [{oCountWindowDefinitions}] definitions are configured")
|
||||
' Exit For
|
||||
' End If
|
||||
|
||||
|
||||
|
||||
|
||||
' ================= MOVE TO CTRL + F =================
|
||||
' ' ================= MOVE TO CTRL + F =================
|
||||
|
||||
'CURR_MATCH_WM_SEARCH = oProfileRow.Item("WD_SEARCH")
|
||||
Dim oSQL_COUNT As String = oProfileRow.Item("SQL_COUNT_RESULT")
|
||||
Dim oRESULTDocs As Integer
|
||||
If oSQL_COUNT <> String.Empty Then
|
||||
oSQL_COUNT = clsPatterns.ReplaceAllValues(oSQL_COUNT, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfileID)
|
||||
Try
|
||||
oRESULTDocs = ClassDatabase.Execute_Scalar(oSQL_COUNT, MyConnectionString)
|
||||
Catch ex As Exception
|
||||
oRESULTDocs = 99999
|
||||
End Try
|
||||
Else
|
||||
oRESULTDocs = 99998
|
||||
End If
|
||||
If (oRESULTDocs <> 99998 And oRESULTDocs <> 99998 And oRESULTDocs <> 0) Then
|
||||
Dim onewMatchRow As DataRow = oDTMatchProfiles.NewRow
|
||||
onewMatchRow("GUID") = oProfileID
|
||||
onewMatchRow("NAME") = oProfileRow.Item("NAME")
|
||||
onewMatchRow("COMMENT") = oProfileRow.Item("COMMENT")
|
||||
onewMatchRow("COUNT") = oRESULTDocs
|
||||
oDTMatchProfiles.Rows.Add(onewMatchRow)
|
||||
oFound = True
|
||||
End If
|
||||
' 'CURR_MATCH_WM_SEARCH = oProfileRow.Item("WD_SEARCH")
|
||||
' Dim oSQL_COUNT As String = oProfileRow.Item("SQL_COUNT_DOCS")
|
||||
' Dim oRESULTDocs As Integer
|
||||
' If oSQL_COUNT <> String.Empty Then
|
||||
' oSQL_COUNT = clsPatterns.ReplaceAllValues(oSQL_COUNT, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfileID)
|
||||
' Try
|
||||
' oRESULTDocs = ClassDatabase.Execute_Scalar(oSQL_COUNT, MyConnectionString)
|
||||
' Catch ex As Exception
|
||||
' oRESULTDocs = 99999
|
||||
' End Try
|
||||
' Else
|
||||
' oRESULTDocs = 99998
|
||||
' End If
|
||||
' If (oRESULTDocs <> 99998 And oRESULTDocs <> 99998 And oRESULTDocs <> 0) Then
|
||||
' Dim onewMatchRow As DataRow = oDTMatchProfiles.NewRow
|
||||
' onewMatchRow("GUID") = oProfileID
|
||||
' onewMatchRow("NAME") = oProfileRow.Item("NAME")
|
||||
' onewMatchRow("COMMENT") = oProfileRow.Item("COMMENT")
|
||||
' onewMatchRow("COUNT") = oRESULTDocs
|
||||
' oDTMatchProfiles.Rows.Add(onewMatchRow)
|
||||
' oFound = True
|
||||
' End If
|
||||
|
||||
' ================= MOVE TO CTRL + F =================
|
||||
' ' ================= MOVE TO CTRL + F =================
|
||||
|
||||
|
||||
End If
|
||||
'Else
|
||||
' NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", String.Format("Clipboard Watcher fired but Clipboardcontent is equal: '{0}'", CURR_MATCH_RESULT), ToolTipIcon.Info)
|
||||
' Logger.Debug(String.Format(" >> {0} - Equal Clipboard-result '{1}'", Now.ToString, CURR_MATCH_RESULT), False)
|
||||
' Exit For
|
||||
'End If
|
||||
Else
|
||||
'Logger.Debug(String.Format(" >> {0} - No regex-match for cliboardtext '{1}'", Now.ToString, oMatch.Groups(0).Value), False)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
If oFound = False Then
|
||||
Logger.Debug(String.Format(" >> {0} - oFound is false - no match on Clipboardvalue '{1}'!", Now.ToString, CURR_MATCH_RESULT), False)
|
||||
CurrDT_PROFILE_MATCH = Nothing
|
||||
Else
|
||||
CurrDT_PROFILE_MATCH = oDTMatchProfiles
|
||||
' End If
|
||||
' 'Else
|
||||
' ' NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", String.Format("Clipboard Watcher fired but Clipboardcontent is equal: '{0}'", CURR_MATCH_RESULT), ToolTipIcon.Info)
|
||||
' ' Logger.Debug(String.Format(" >> {0} - Equal Clipboard-result '{1}'", Now.ToString, CURR_MATCH_RESULT), False)
|
||||
' ' Exit For
|
||||
' 'End If
|
||||
' Else
|
||||
' 'Logger.Debug(String.Format(" >> {0} - No regex-match for cliboardtext '{1}'", Now.ToString, oMatch.Groups(0).Value), False)
|
||||
' End If
|
||||
' End If
|
||||
' Next
|
||||
' If oFound = False Then
|
||||
' Logger.Debug(String.Format(" >> {0} - oFound is false - no match on Clipboardvalue '{1}'!", Now.ToString, CURR_MATCH_RESULT), False)
|
||||
' CurrDT_PROFILE_MATCH = Nothing
|
||||
' Else
|
||||
' CurrDT_PROFILE_MATCH = oDTMatchProfiles
|
||||
|
||||
End If
|
||||
' End If
|
||||
|
||||
End Sub
|
||||
'End Sub
|
||||
|
||||
Public Sub New()
|
||||
Dim splash As New frmSplash()
|
||||
@@ -280,11 +278,11 @@ Public Class frmStart
|
||||
Dim oProfiles = CURRENT_MATCHING_PROFILES
|
||||
|
||||
For Each oProfile In oProfiles
|
||||
Dim oSQL = oProfile.CountSQL
|
||||
Dim oSQL = oProfile.SQLCountDocs
|
||||
Dim oResultDocs As Integer = 0
|
||||
|
||||
If oSQL = String.Empty Then
|
||||
oProfile.CountSQL = ClassConstants.NO_COUNT_SQL
|
||||
oProfile.SQLCountDocs = ClassConstants.NO_COUNT_SQL
|
||||
End If
|
||||
|
||||
Try
|
||||
@@ -294,16 +292,16 @@ Public Class frmStart
|
||||
oResultDocs = ClassConstants.INVALID_COUNT_SQL
|
||||
End Try
|
||||
|
||||
oProfile.Count = oResultDocs
|
||||
oProfile.CountDocs = oResultDocs
|
||||
Next
|
||||
|
||||
If oProfiles.Count = 1 Then
|
||||
If oProfiles.First().Count = ClassConstants.INVALID_COUNT_SQL Then
|
||||
If oProfiles.First().CountDocs = ClassConstants.INVALID_COUNT_SQL Then
|
||||
NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Found match but check is wrong - Check Your MatchCountConfig in Profiles!", ToolTipIcon.Info)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If oProfiles.First().Count = ClassConstants.NO_COUNT_SQL Then
|
||||
If oProfiles.First().CountDocs = ClassConstants.NO_COUNT_SQL Then
|
||||
NotifyIconMain.ShowBalloonTip(10000, "Clipboard Watcher", "Found match but MatchCountConfig is not configured!", ToolTipIcon.Info)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user