filter controls by window id, clear duplicate profiles

This commit is contained in:
Jonathan Jenne 2019-09-13 15:35:58 +02:00
parent 46d448236b
commit 88bae3ee92
4 changed files with 97 additions and 70 deletions

View File

@ -332,25 +332,42 @@ Public Class ClassProfileFilter
For Each oProfileMatchedSofar In Profiles
If oProfileMatchedSofar.IsMatched = False Then Continue For
Logger.Debug("Checking ControlDefiniotion on profile: {0}", oProfileMatchedSofar.Name)
If oProfileMatchedSofar.Controls.Count = 0 Then
Logger.Debug("Checking ControlDefinition on profile: {0}", oProfileMatchedSofar.Name)
Logger.Debug("Profile has {0} configured controls", oProfileMatchedSofar.Controls.Count)
Dim oControlsForMatchedWindow As New List(Of ControlData)
For Each oControl In oProfileMatchedSofar.Controls
If oControl.WINDOW_ID = oProfileMatchedSofar.MatchedWindowID Then
oControlsForMatchedWindow.Add(oControl)
End If
Next
If oControlsForMatchedWindow.Count = 0 Then
Logger.Debug("Profile has no configured controls. Skipping.")
oFilteredProfiles.Add(oProfileMatchedSofar)
Dim oNode As New TreeNode($"No Controls configured!")
oNode.ImageIndex = 2
oNode.ForeColor = Color.Blue
oNode.Tag = oProfileMatchedSofar.Name & "-NOCONTROLCONFIG"
Dim f = New Font("Tahoma", 10, FontStyle.Bold)
oNode.NodeFont = f
Dim oNode As New TreeNode($"No Controls configured!") With {
.ImageIndex = 2,
.ForeColor = Color.Blue,
.Tag = oProfileMatchedSofar.Name & "-NOCONTROLCONFIG",
.NodeFont = New Font("Tahoma", 10, FontStyle.Bold)
}
CurrMatchTreeView.Nodes.Add(oNode)
Continue For
End If
Dim oControls As New List(Of ControlData)
For Each oControlDefinition In oProfileMatchedSofar.Controls
For Each oControlDefinition In oControlsForMatchedWindow
Try
If oControlDefinition.WINDOW_ID <> oProfileMatchedSofar.MatchedWindowID Then Continue For
If oControlDefinition.WINDOW_ID <> oProfileMatchedSofar.MatchedWindowID Then
Logger.Debug("Current WindowId {0} does not match Control WindowId {1}. Skipping.", oProfileMatchedSofar.MatchedWindowID, oControlDefinition.WINDOW_ID)
Continue For
End If
Logger.Debug($"Working on ControlDefinition: {oControlDefinition.Guid}-{oControlDefinition.ControlName}...")
If oControlDefinition.Regex = String.Empty Then
oProfileMatchedSofar.MatchedControlID = oControlDefinition.Guid
@ -455,6 +472,14 @@ Public Class ClassProfileFilter
Next
Return oFilteredProfiles
End Function
Public Function ClearDuplicateProfiles(Profiles As List(Of ProfileData)) As List(Of ProfileData)
Return Profiles.
GroupBy(Function(Profile) Profile.Guid).
Select(Function(GroupedProfiles) GroupedProfiles.First).
ToList()
End Function
Private Function TransformProfiles() As List(Of ProfileData)
Dim oList As New List(Of ProfileData)

View File

@ -474,9 +474,10 @@ Public Class frmAdministration
Private Sub XtraTabControl3_SelectedPageChanged(sender As Object, e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles XtraTabControl3.SelectedPageChanged
Dim oTabName As String = e.Page.Name
Try
Select Case oTabName
Case TabPageProcessAssignment.Name
CtrlApplicationAssignment1.Process_Load(PROFILE_IDTextBox.Text)
'CtrlApplicationAssignment1.Process_Load(PROFILE_IDTextBox.Text)
RibbonGroup_Profile.Enabled = False
RibbonGroup_User.Enabled = False
RibbonGroup_Group.Enabled = False
@ -548,7 +549,9 @@ Public Class frmAdministration
RibbonGroup_DocSearch.Enabled = False
RibbonGroup_DataSearch.Enabled = False
End Select
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub BarButtonItem16_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem16.ItemClick

View File

@ -11,7 +11,6 @@ Public NotInheritable Class frmSplash
End If
End Sub
Private Sub frmSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Version.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
Copyright.Text = String.Format("{0} {1}", My.Application.Info.Copyright, My.Application.Info.CompanyName)
@ -33,7 +32,6 @@ Public NotInheritable Class frmSplash
Return _step * (100 / InitSteps)
End Function
Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
Try
Dim Init = New ClassInit()

View File

@ -126,6 +126,7 @@ Public Class frmStart
oProfiles = oProfileFilter.FilterWindowsByWindowTitleRegex(oProfiles, oWindowInfo.WindowTitle)
oProfiles = oProfileFilter.FilterProfilesByFocusedControl(oProfiles, ClipboardContents, oFocusedControl.ToString)
oProfiles = oProfileFilter.ClearNotMatchedProfiles(oProfiles)
oProfiles = oProfileFilter.ClearDuplicateProfiles(oProfiles)
oProfiles = oProfiles.ToList()
CURRENT_MATCHING_PROFILES = oProfiles