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 For Each oProfileMatchedSofar In Profiles
If oProfileMatchedSofar.IsMatched = False Then Continue For If oProfileMatchedSofar.IsMatched = False Then Continue For
Logger.Debug("Checking ControlDefiniotion on profile: {0}", oProfileMatchedSofar.Name) Logger.Debug("Checking ControlDefinition on profile: {0}", oProfileMatchedSofar.Name)
If oProfileMatchedSofar.Controls.Count = 0 Then 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) oFilteredProfiles.Add(oProfileMatchedSofar)
Dim oNode As New TreeNode($"No Controls configured!") Dim oNode As New TreeNode($"No Controls configured!") With {
oNode.ImageIndex = 2 .ImageIndex = 2,
oNode.ForeColor = Color.Blue .ForeColor = Color.Blue,
oNode.Tag = oProfileMatchedSofar.Name & "-NOCONTROLCONFIG" .Tag = oProfileMatchedSofar.Name & "-NOCONTROLCONFIG",
Dim f = New Font("Tahoma", 10, FontStyle.Bold) .NodeFont = New Font("Tahoma", 10, FontStyle.Bold)
oNode.NodeFont = f }
CurrMatchTreeView.Nodes.Add(oNode) CurrMatchTreeView.Nodes.Add(oNode)
Continue For Continue For
End If End If
Dim oControls As New List(Of ControlData) Dim oControls As New List(Of ControlData)
For Each oControlDefinition In oProfileMatchedSofar.Controls For Each oControlDefinition In oControlsForMatchedWindow
Try 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}...") Logger.Debug($"Working on ControlDefinition: {oControlDefinition.Guid}-{oControlDefinition.ControlName}...")
If oControlDefinition.Regex = String.Empty Then If oControlDefinition.Regex = String.Empty Then
oProfileMatchedSofar.MatchedControlID = oControlDefinition.Guid oProfileMatchedSofar.MatchedControlID = oControlDefinition.Guid
@ -455,6 +472,14 @@ Public Class ClassProfileFilter
Next Next
Return oFilteredProfiles Return oFilteredProfiles
End Function 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) Private Function TransformProfiles() As List(Of ProfileData)
Dim oList As New 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 Private Sub XtraTabControl3_SelectedPageChanged(sender As Object, e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles XtraTabControl3.SelectedPageChanged
Dim oTabName As String = e.Page.Name Dim oTabName As String = e.Page.Name
Try
Select Case oTabName Select Case oTabName
Case TabPageProcessAssignment.Name Case TabPageProcessAssignment.Name
CtrlApplicationAssignment1.Process_Load(PROFILE_IDTextBox.Text) 'CtrlApplicationAssignment1.Process_Load(PROFILE_IDTextBox.Text)
RibbonGroup_Profile.Enabled = False RibbonGroup_Profile.Enabled = False
RibbonGroup_User.Enabled = False RibbonGroup_User.Enabled = False
RibbonGroup_Group.Enabled = False RibbonGroup_Group.Enabled = False
@ -548,7 +549,9 @@ Public Class frmAdministration
RibbonGroup_DocSearch.Enabled = False RibbonGroup_DocSearch.Enabled = False
RibbonGroup_DataSearch.Enabled = False RibbonGroup_DataSearch.Enabled = False
End Select End Select
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub End Sub
Private Sub BarButtonItem16_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem16.ItemClick 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 If
End Sub End Sub
Private Sub frmSplash_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 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) 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) 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) Return _step * (100 / InitSteps)
End Function End Function
Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
Try Try
Dim Init = New ClassInit() Dim Init = New ClassInit()

View File

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