This commit is contained in:
Jonathan Jenne 2019-08-30 16:09:16 +02:00
parent c03bb248fc
commit b6508ba650
4 changed files with 24 additions and 56 deletions

View File

@ -248,7 +248,7 @@ Public Class ClassInit
Try Try
Dim oSql = String.Format("SELECT DISTINCT GUID, NAME,REGEX_EXPRESSION,COMMENT,PROC_NAME,PROFILE_TYPE FROM VWCW_USER_PROFILE WHERE ACTIVE = 1 AND USER_ID = {0} OR GROUP_ID IN (SELECT DISTINCT GUID FROM TBDD_GROUPS WHERE GUID IN (SELECT GROUP_ID FROM TBDD_GROUPS_USER WHERE USER_ID = {0}))", USER_ID) Dim oSql = String.Format("SELECT DISTINCT GUID, NAME,REGEX_EXPRESSION,COMMENT,PROC_NAME,PROFILE_TYPE FROM VWCW_USER_PROFILE WHERE ACTIVE = 1 AND USER_ID = {0} OR GROUP_ID IN (SELECT DISTINCT GUID FROM TBDD_GROUPS WHERE GUID IN (SELECT GROUP_ID FROM TBDD_GROUPS_USER WHERE USER_ID = {0}))", USER_ID)
DT_USER_PROFILES = Database.GetDatatable(oSql) DT_USER_PROFILES = Database.GetDatatable(oSql)
If DT_USER_PROFILES.Rows.Count = 0 Then If DT_USER_PROFILES Is Nothing OrElse DT_USER_PROFILES.Rows.Count = 0 Then
MsgBox("No profiles configured for this user so far!", MsgBoxStyle.Exclamation) MsgBox("No profiles configured for this user so far!", MsgBoxStyle.Exclamation)
Else Else
oSql = $"SELECT T.* FROM TBCW_PROFILE_PROCESS T, VWPM_PROFILE_USER T1 WHERE T.PROFILE_ID = T1.PROFIL_ID AND T1.USER_ID = {USER_ID}" oSql = $"SELECT T.* FROM TBCW_PROFILE_PROCESS T, VWPM_PROFILE_USER T1 WHERE T.PROFILE_ID = T1.PROFIL_ID AND T1.USER_ID = {USER_ID}"

View File

@ -89,32 +89,24 @@ Public Class ClassProfileFilter
Return _Profiles Return _Profiles
End Function End Function
Friend Function RemoveDuplicateProfiles() As Object Private Function FindNode(ByVal Node As TreeNode, SearchTerm As String)
Return _Profiles. Dim oNode As TreeNode
GroupBy(Function(p) p.Guid). For Each oNode In Node.Nodes
Select(Function(p) p.FirstOrDefault()) If oNode.Text = SearchTerm Then
End Function Return oNode
Private Function NodeFind(ByVal n As TreeNode, searchTerm As String)
Dim aNode As TreeNode
For Each aNode In n.Nodes
If aNode.Text = searchTerm Then
Return aNode
End If End If
Next Next
Return n Return Node
End Function End Function
Private Function GetLowestNode(ByVal n As TreeNode)
Dim aNode As TreeNode Private Function GetLowestNode(ByVal Node As TreeNode) As TreeNode
If n.GetNodeCount(False) = 1 Then If Node.GetNodeCount(False) = 1 Then
For Each aNode In n.Nodes Return GetLowestNode(Node.Nodes.Item(0))
Return GetLowestNode(aNode)
Next
Else Else
Return n Return Node
End If End If
End Function End Function
Public Function FilterProfilesByClipboardRegex(Profiles As List(Of ProfileData), ClipboardContents As String) As List(Of ProfileData) Public Function FilterProfilesByClipboardRegex(Profiles As List(Of ProfileData), ClipboardContents As String) As List(Of ProfileData)
Dim oFilteredProfiles As New List(Of ProfileData) Dim oFilteredProfiles As New List(Of ProfileData)
For Each oProfile In Profiles For Each oProfile In Profiles

View File

@ -73,8 +73,9 @@
<Reference Include="DigitalData.Modules.Config"> <Reference Include="DigitalData.Modules.Config">
<HintPath>..\..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath> <HintPath>..\..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Database"> <Reference Include="DigitalData.Modules.Database, Version=1.0.0.5, Culture=neutral, processorArchitecture=MSIL">
<HintPath>P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\Digital Data\DigitalData.Modules.Database.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\DDMonorepo\Modules.Database\bin\Debug\DigitalData.Modules.Database.dll</HintPath>
</Reference> </Reference>
<Reference Include="DigitalData.Modules.Filesystem, Version=0.0.0.1, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="DigitalData.Modules.Filesystem, Version=0.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>

View File

@ -1,9 +1,7 @@
Imports System.Threading Imports System.Threading
Imports System.IO Imports System.IO
Imports System.Globalization Imports System.Globalization
Imports DD_LIB_Standards
Imports DD_Clipboard_Watcher.ClassConstants Imports DD_Clipboard_Watcher.ClassConstants
Imports System.Windows.Automation
Imports DD_Clipboard_Watcher.ClassWindowAPI Imports DD_Clipboard_Watcher.ClassWindowAPI
Public Class frmStart Public Class frmStart
@ -75,8 +73,8 @@ Public Class frmStart
End Try End Try
Try Try
Hotkey.RemoveHotKey(ClassConstants.HOTKEY_TOGGLE_WATCHER) Hotkey.RemoveHotKey(HOTKEY_TOGGLE_WATCHER)
Hotkey.RemoveHotKey(ClassConstants.HOTKEY_TRIGGER_WATCHER) Hotkey.RemoveHotKey(HOTKEY_TRIGGER_WATCHER)
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Logger.Warn("Hotkeys could not be removed") Logger.Warn("Hotkeys could not be removed")
@ -107,10 +105,10 @@ Public Class frmStart
Exit Sub Exit Sub
End If End If
Dim oWindowInfo = ClassWindowAPI.GetWindowInfo() Dim oWindowInfo = GetWindowInfo()
Dim ClipboardContents As String = Clipboard.GetText() Dim ClipboardContents As String = Clipboard.GetText()
Dim oProfileFilter As ClassProfileFilter Dim oProfileFilter As ClassProfileFilter
Dim newoResult As IntPtr = FocusedControlinActiveWindow(Handle) Dim oFocusedControl As IntPtr = FocusedControlinActiveWindow(Handle)
Try Try
oProfileFilter = New ClassProfileFilter(DT_USER_PROFILES, DTPROFILE_REL_PROCESS, DTPROFILE_REL_WINDOW, DTPROFILE_REL_CONTROL) oProfileFilter = New ClassProfileFilter(DT_USER_PROFILES, DTPROFILE_REL_PROCESS, DTPROFILE_REL_WINDOW, DTPROFILE_REL_CONTROL)
Catch ex As Exception Catch ex As Exception
@ -124,37 +122,14 @@ Public Class frmStart
CurrMatchTreeView.SelectedImageIndex = 0 CurrMatchTreeView.SelectedImageIndex = 0
oProfiles = oProfileFilter.FilterProfilesByClipboardRegex(oProfiles, ClipboardContents) oProfiles = oProfileFilter.FilterProfilesByClipboardRegex(oProfiles, ClipboardContents)
If oProfiles.Count > 0 Then oProfiles = oProfileFilter.FilterProfilesByProcess(oProfiles, oWindowInfo.ProcessName)
oProfiles = oProfileFilter.FilterProfilesByProcess(oProfiles, oWindowInfo.ProcessName) oProfiles = oProfileFilter.FilterWindowsByWindowTitleRegex(oProfiles, oWindowInfo.WindowTitle)
If oProfiles.Count > 0 Then oProfiles = oProfileFilter.FilterProfilesByFocusedControl(oProfiles, ClipboardContents, oFocusedControl.ToString)
oProfiles = oProfileFilter.FilterWindowsByWindowTitleRegex(oProfiles, oWindowInfo.WindowTitle)
If oProfiles.Count > 0 Then
' Dim ControlFocusResult
Dim oResult As WindowInfo = GetFocusedControl(Handle)
'Automation = New ClassAutomation(LogConfig)
'If Not IsNothing(Automation.AutomationId) Then
' ControlFocusResult = Automation.AutomationId
'Else
' ControlFocusResult = String.Empty
'End If
' MsgBox(newoResult.ToString)
oProfiles = oProfileFilter.FilterProfilesByFocusedControl(oProfiles, ClipboardContents, newoResult.ToString)
'oProfiles = oProfileFilter.FilterWindowsByWindowClipboardRegex(oProfiles, ClipboardContents)
End If
End If
End If
'oProfiles = oProfileFilter.RemoveDuplicateProfiles()
oProfiles = oProfileFilter.ClearNotMatchedProfiles(oProfiles) oProfiles = oProfileFilter.ClearNotMatchedProfiles(oProfiles)
oProfiles = oProfiles.ToList() oProfiles = oProfiles.ToList()
CURRENT_MATCHING_PROFILES = oProfiles CURRENT_MATCHING_PROFILES = oProfiles
CURRENT_CLIPBOARD_CONTENTS = ClipboardContents CURRENT_CLIPBOARD_CONTENTS = ClipboardContents
End Sub End Sub
Private Sub ReceiveHotKey(ByVal HotKeyID As String) Handles Hotkey.HotKeyPressed Private Sub ReceiveHotKey(ByVal HotKeyID As String) Handles Hotkey.HotKeyPressed