add groups, count functions per search
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Imports System.Threading
|
||||
Imports System.IO
|
||||
Imports DD_LIB_Standards
|
||||
|
||||
Public Class frmStart
|
||||
@@ -26,149 +27,22 @@ Public Class frmStart
|
||||
Dim WindowTitle As String = clsHotkey.GetCaption()
|
||||
|
||||
Dim oProfileFilter As New ClassProfileFilter(DT_USER_PROFILES, DTPROFILE_REL_WINDOW)
|
||||
|
||||
Dim oProfiles = oProfileFilter.
|
||||
FilterProfilesByProcess(CurrPROC_Name).
|
||||
FilterProfilesByClipboardRegex(ClipboardContents).
|
||||
FilterWindowsByWindowTitle(WindowTitle).
|
||||
FilterProfilesByWindowRegex(ClipboardContents).
|
||||
ToList()
|
||||
Profiles.
|
||||
AsEnumerable()
|
||||
|
||||
oProfiles = oProfileFilter.FilterProfilesByProcess(oProfiles, CurrPROC_Name)
|
||||
oProfiles = oProfileFilter.FilterProfilesByClipboardRegex(oProfiles, ClipboardContents)
|
||||
oProfiles = oProfileFilter.FilterWindowsByWindowTitle(oProfiles, WindowTitle)
|
||||
oProfiles = oProfileFilter.FilterProfilesByWindowRegex(oProfiles, ClipboardContents)
|
||||
oProfiles = oProfileFilter.RemoveDuplicateProfiles()
|
||||
oProfiles = oProfiles.ToList()
|
||||
|
||||
CURRENT_MATCHING_PROFILES = oProfiles
|
||||
CURR_MATCH_RESULT = ClipboardContents
|
||||
End Sub
|
||||
|
||||
'Private Sub _Watcher_Changed(ByVal sender As Object, ByVal e As EventArgs) ' Handles _Watcher.Changed
|
||||
|
||||
' 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
|
||||
|
||||
' 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")
|
||||
|
||||
' 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
|
||||
|
||||
|
||||
|
||||
|
||||
' ' ================= MOVE TO CTRL + F =================
|
||||
|
||||
' '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 =================
|
||||
|
||||
|
||||
' 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 Sub
|
||||
|
||||
Public Sub New()
|
||||
Dim splash As New frmSplash()
|
||||
splash.ShowDialog()
|
||||
@@ -209,32 +83,26 @@ Public Class frmStart
|
||||
End Try
|
||||
Try
|
||||
Hotkey.RemoveHotKey(ClassConstants.HOTKEY_TOGGLE_WATCHER)
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
Try
|
||||
Hotkey.RemoveHotKey(ClassConstants.HOTKEY_TRIGGER_WATCHER)
|
||||
Catch ex As Exception
|
||||
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("Hotkeys could not be removed")
|
||||
End Try
|
||||
|
||||
'TempDateien löschen
|
||||
Try
|
||||
For Each _file In TEMP_FILES
|
||||
System.IO.File.Delete(_file)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
If clsLogger.LOGG_MSG <> String.Empty Then
|
||||
Logger.Info(clsLogger.LOGG_MSG, False)
|
||||
End If
|
||||
For Each oFile In TEMP_FILES
|
||||
Try
|
||||
File.Delete(oFile)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Temp file {0} could not be deleted", oFile)
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
ClassWindowLocation.LoadFormLocationSize(Me)
|
||||
If ERROR_INIT = "FAILED DBCONNECTION" Or ERROR_INIT = "DATABASE" Then
|
||||
|
||||
frmConfig_Basic.ShowDialog()
|
||||
End If
|
||||
|
||||
@@ -247,22 +115,23 @@ Public Class frmStart
|
||||
End If
|
||||
Exit Sub
|
||||
End If
|
||||
Me.NotifyIconMain.Visible = True
|
||||
NotifyIconMain.Visible = True
|
||||
clsHotkey.Refresh_Profile_Links()
|
||||
Hotkey.AddHotKey(Keys.T, clsHotkey.MODKEY.MOD_CONTROL, ClassConstants.HOTKEY_TOGGLE_WATCHER)
|
||||
Dim keyCode As Keys
|
||||
Dim kc As New KeysConverter
|
||||
Dim obj As Object = kc.ConvertFromString(HotkeySearchKey.ToUpper)
|
||||
keyCode = CType(obj, Keys)
|
||||
If HotkeyFunctionKey = "strg" Then
|
||||
Hotkey.AddHotKey(keyCode, clsHotkey.MODKEY.MOD_CONTROL, ClassConstants.HOTKEY_TRIGGER_WATCHER)
|
||||
Dim oKeyCode As Keys
|
||||
Dim oConverter As New KeysConverter
|
||||
Dim oObject As Object = oConverter.ConvertFromString(HotkeySearchKey.ToUpper)
|
||||
oKeyCode = CType(oObject, Keys)
|
||||
|
||||
If HotkeyFunctionKey = ClassConstants.HOTKEY_CTRL Then
|
||||
Hotkey.AddHotKey(oKeyCode, clsHotkey.MODKEY.MOD_CONTROL, ClassConstants.HOTKEY_TRIGGER_WATCHER)
|
||||
ElseIf HotkeyFunctionKey = "SHIFT" Then
|
||||
Hotkey.AddHotKey(keyCode, clsHotkey.MODKEY.MOD_SHIFT, ClassConstants.HOTKEY_TRIGGER_WATCHER)
|
||||
Hotkey.AddHotKey(oKeyCode, clsHotkey.MODKEY.MOD_SHIFT, ClassConstants.HOTKEY_TRIGGER_WATCHER)
|
||||
End If
|
||||
|
||||
End If
|
||||
tslblUser.Text = USER_USERNAME
|
||||
lbHKFunction.Text = HotkeyFunctionKey & " + " & HotkeySearchKey.ToUpper
|
||||
lbHKFunction.Text = HotkeyFunctionKey.ToUpper & " + " & HotkeySearchKey.ToUpper
|
||||
End Sub
|
||||
Private Sub ReceiveHotKey(ByVal HotKeyID As String) Handles Hotkey.HotKeyPressed
|
||||
If HotKeyID = ClassConstants.HOTKEY_TRIGGER_WATCHER Then
|
||||
@@ -276,6 +145,8 @@ Public Class frmStart
|
||||
End Sub
|
||||
Sub CHECK_PROFILE_MATCH()
|
||||
Dim oProfiles = CURRENT_MATCHING_PROFILES
|
||||
Dim oInvalidDocumentSQL = False
|
||||
Dim oInvalidDataSQL = False
|
||||
|
||||
For Each oProfile In oProfiles
|
||||
Dim oDocumentSQL = oProfile.SQLCountDocs
|
||||
@@ -283,62 +154,67 @@ Public Class frmStart
|
||||
Dim oResultDocs As Integer = 0
|
||||
Dim oResultData As Integer = 0
|
||||
|
||||
If oDataSQL = String.Empty Then
|
||||
oProfile.SQLCountData = ClassConstants.NO_COUNT_SQL
|
||||
End If
|
||||
Dim oDataSearches As DataTable = clsDatabase.Return_Datatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DATA_SEARCH WHERE PROFILE_ID = {oProfile.Guid}")
|
||||
Dim oDocSearches As DataTable = clsDatabase.Return_Datatable($"SELECT COUNT_COMMAND FROM TBCW_PROF_DOC_SEARCH WHERE PROFILE_ID = {oProfile.Guid}")
|
||||
|
||||
If oDocumentSQL = String.Empty Then
|
||||
oProfile.SQLCountDocs = ClassConstants.NO_COUNT_SQL
|
||||
End If
|
||||
For Each oRow As DataRow In oDataSearches.Rows
|
||||
Try
|
||||
Dim oCountCommand = oRow.Item("COUNT_COMMAND")
|
||||
|
||||
Try
|
||||
oDataSQL = clsPatterns.ReplaceAllValues(oDataSQL, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfile.Guid)
|
||||
oResultData = ClassDatabase.Execute_Scalar(oDataSQL, MyConnectionString)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oDataSQL)
|
||||
oResultData = ClassConstants.INVALID_COUNT_SQL
|
||||
End Try
|
||||
If oCountCommand = String.Empty Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Try
|
||||
oDocumentSQL = clsPatterns.ReplaceAllValues(oDocumentSQL, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfile.Guid)
|
||||
oResultDocs = ClassDatabase.Execute_Scalar(oDocumentSQL, MyConnectionString)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Invalid SQL Query for Counting Documents in Profile {0}: {1}", oProfile.Guid, oDocumentSQL)
|
||||
oResultDocs = ClassConstants.INVALID_COUNT_SQL
|
||||
End Try
|
||||
oDataSQL = clsPatterns.ReplaceAllValues(oCountCommand, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfile.Guid)
|
||||
oResultData += ClassDatabase.Execute_Scalar(oDataSQL, MyConnectionString)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oDataSQL)
|
||||
oInvalidDataSQL = True
|
||||
End Try
|
||||
Next
|
||||
|
||||
For Each oRow As DataRow In oDocSearches.Rows
|
||||
Try
|
||||
Dim oCountCommand = oRow.Item("COUNT_COMMAND")
|
||||
|
||||
If oCountCommand = String.Empty Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
oDataSQL = clsPatterns.ReplaceAllValues(oCountCommand, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfile.Guid)
|
||||
oResultDocs += ClassDatabase.Execute_Scalar(oDataSQL, MyConnectionString)
|
||||
Catch ex As Exception
|
||||
oInvalidDocumentSQL = True
|
||||
Logger.Warn("Invalid SQL Query for Counting Data in Profile {0}: {1}", oProfile.Guid, oDataSQL)
|
||||
End Try
|
||||
Next
|
||||
|
||||
oProfile.CountData = oResultData
|
||||
oProfile.CountDocs = oResultDocs
|
||||
Next
|
||||
|
||||
'If oProfiles.Count = 1 Then
|
||||
' If oProfiles.First().CountDocs = ClassConstants.INVALID_COUNT_SQL Then
|
||||
' NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Found match but check is wrong - Check Your Data SQL in Profiles!", ToolTipIcon.Info)
|
||||
' Exit Sub
|
||||
' End If
|
||||
If oInvalidDocumentSQL Or oInvalidDataSQL Then
|
||||
MsgBox("Ein oder mehrere Abfragen konnten nicht ausgeführt werden. Bitte überprüfen Sie das Log.", MsgBoxStyle.Exclamation, "Warnung")
|
||||
End If
|
||||
|
||||
' If oProfiles.First().CountDocs = ClassConstants.NO_COUNT_SQL Then
|
||||
' NotifyIconMain.ShowBalloonTip(10000, "Clipboard Watcher", "Found match but Data SQL is not configured!", ToolTipIcon.Info)
|
||||
' Exit Sub
|
||||
' End If
|
||||
If oProfiles.Count = 1 Then
|
||||
Dim oCountData = oProfiles.First().CountData
|
||||
Dim oCountDocs = oProfiles.First().CountDocs = 0
|
||||
|
||||
' If oProfiles.First().CountData = ClassConstants.INVALID_COUNT_SQL Then
|
||||
' NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Found match but check is wrong - Check Your Document SQL in Profiles!", ToolTipIcon.Info)
|
||||
' Exit Sub
|
||||
' End If
|
||||
|
||||
' If oProfiles.First().CountData = ClassConstants.NO_COUNT_SQL Then
|
||||
' NotifyIconMain.ShowBalloonTip(10000, "Clipboard Watcher", "Found match but Document SQL is not configured!", ToolTipIcon.Info)
|
||||
' Exit Sub
|
||||
' End If
|
||||
|
||||
' CurrDocSearch2Load = oProfiles.First().Guid
|
||||
' frmResultDoc.Show()
|
||||
'Else
|
||||
' frmProfileMatch.ShowDialog()
|
||||
'End If
|
||||
|
||||
frmProfileMatch.ShowDialog()
|
||||
If oCountData = 0 Then
|
||||
CurrDocSearch2Load = oProfiles.First().Guid
|
||||
frmResultDoc.Show()
|
||||
ElseIf oCountDocs = 0 Then
|
||||
CurrDocSearch2Load = oProfiles.First().Guid
|
||||
frmResultDoc.Show()
|
||||
ElseIf oCountDocs = 0 And oCountData = 0 Then
|
||||
MsgBox("Es wurden keine Ergebnisse gefunden!")
|
||||
Else
|
||||
frmProfileMatch.ShowDialog()
|
||||
End If
|
||||
Else
|
||||
frmProfileMatch.ShowDialog()
|
||||
End If
|
||||
End Sub
|
||||
Sub Change_Monitoring_State()
|
||||
If MONITORING_ACTIVE = True Then
|
||||
@@ -352,15 +228,15 @@ Public Class frmStart
|
||||
Private Sub frmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||
If ERROR_INIT <> "INVALID USER" And LICENSE_COUNT > 0 Then
|
||||
If DT_USER_PROFILES.Rows.Count >= 1 Then
|
||||
Me.Hide()
|
||||
Hide()
|
||||
End If
|
||||
Else
|
||||
If USER_IS_ADMIN = True And ERROR_INIT = "NO LICENSE" Then
|
||||
MsgBox("As an admin You have access! Please inform Digital Data to add a valid license!", MsgBoxStyle.Exclamation, "")
|
||||
MsgBox("As an admin You have access! Please inform Digital Data to add a valid license!", MsgBoxStyle.Exclamation, "No valid License")
|
||||
Else
|
||||
If Not USER_IS_ADMIN Then
|
||||
MsgBox("Application will close now!", MsgBoxStyle.Critical, "")
|
||||
Me.Close()
|
||||
MsgBox("Application will close now!", MsgBoxStyle.Critical, "No valid License")
|
||||
Close()
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Reference in New Issue
Block a user