WIP: Profile Matching
This commit is contained in:
parent
1652a4fb96
commit
f7ff19afeb
184
app/DD_Clipboard_Searcher/ClassProfileFilter.vb
Normal file
184
app/DD_Clipboard_Searcher/ClassProfileFilter.vb
Normal file
@ -0,0 +1,184 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Public Class ClassProfileFilter
|
||||
Private _ProfileTable As DataTable
|
||||
Private _WindowTable As DataTable
|
||||
Private _Profiles As List(Of ProfileData)
|
||||
Private _DebugData As DebugData
|
||||
|
||||
Class ProfileData
|
||||
Public Guid As Integer
|
||||
Public Regex As String
|
||||
Public ProcessName As String
|
||||
Public Name As String
|
||||
Public Comment As String
|
||||
Public CountSQL As String
|
||||
Public Count As Integer = 0
|
||||
Public Windows As List(Of WindowData)
|
||||
End Class
|
||||
|
||||
Class WindowData
|
||||
Public Title As String
|
||||
Public Regex As String
|
||||
Public Sequence As Integer
|
||||
Public ClipboardRegex As String
|
||||
End Class
|
||||
|
||||
' TODO: Fill this Class!!!! :D
|
||||
Class DebugData
|
||||
Public ProcessMatch As List(Of String)
|
||||
Public ClipboardMatch As List(Of String)
|
||||
Public WindowMatch As List(Of String)
|
||||
Public WindowRegexMatch As List(Of String)
|
||||
End Class
|
||||
|
||||
Public Sub New(ProfileDatatable As DataTable, WindowDatatable As DataTable)
|
||||
_DebugData = New DebugData()
|
||||
_ProfileTable = ProfileDatatable
|
||||
_WindowTable = WindowDatatable
|
||||
_Profiles = TransformProfiles()
|
||||
End Sub
|
||||
|
||||
Public Function ToList() As List(Of ProfileData)
|
||||
Return _Profiles
|
||||
End Function
|
||||
|
||||
Public Function FilterProfilesByProcess(CurrentProcessName As String) As ClassProfileFilter
|
||||
_Profiles = _Profiles.
|
||||
Where(Function(p)
|
||||
If p.ProcessName.ToLower = CurrentProcessName.ToLower Then
|
||||
'TODO: Add Debug Data
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function).
|
||||
ToList()
|
||||
|
||||
Return Me
|
||||
End Function
|
||||
|
||||
Public Function FilterProfilesByClipboardRegex(ClipboardContents As String) As ClassProfileFilter
|
||||
_Profiles = _Profiles.
|
||||
Where(Function(p)
|
||||
Try
|
||||
Dim oRegex As New Regex(p.Regex)
|
||||
Dim oMatch = oRegex.Match(ClipboardContents)
|
||||
If oMatch.Success Then
|
||||
'TODO: Add Debug Data
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Regex '{0}' could not be processed for input '{1}'", p.Regex, ClipboardContents)
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function).
|
||||
ToList()
|
||||
|
||||
Return Me
|
||||
End Function
|
||||
|
||||
Public Function FilterWindowsByWindowTitle(WindowTitle As String) As ClassProfileFilter
|
||||
_Profiles = _Profiles.Select(Function(p)
|
||||
Dim oWindows As List(Of WindowData) = p.Windows
|
||||
|
||||
p.Windows = oWindows.
|
||||
Where(Function(w)
|
||||
Try
|
||||
If w.Regex = String.Empty Then Return True
|
||||
|
||||
Dim oRegex As New Regex(w.Regex)
|
||||
Dim oMatch = oRegex.Match(WindowTitle)
|
||||
|
||||
If oMatch.Success Then
|
||||
'TODO: Add Debug Data
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Regex '{0}' could not be processed for input '{1}'", w.Regex, WindowTitle)
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End Function).
|
||||
ToList()
|
||||
Return p
|
||||
End Function).
|
||||
ToList()
|
||||
|
||||
Return Me
|
||||
End Function
|
||||
|
||||
Public Function FilterProfilesByWindowRegex(ClipboardContents As String) As ClassProfileFilter
|
||||
_Profiles = _Profiles.Where(Function(p)
|
||||
If p.Windows.Count = 0 Then Return True
|
||||
|
||||
Return p.Windows.
|
||||
Any(Function(w)
|
||||
Try
|
||||
If w.ClipboardRegex = String.Empty Then Return True
|
||||
|
||||
Dim oRegex As New Regex(w.ClipboardRegex)
|
||||
Dim oMatch = oRegex.Match(ClipboardContents)
|
||||
|
||||
If oMatch.Success Then
|
||||
'TODO: Add Debug Data
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Regex '{0}' could not be processed for input '{1}'", w.ClipboardRegex, ClipboardContents)
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function)
|
||||
End Function).
|
||||
ToList()
|
||||
|
||||
Return Me
|
||||
End Function
|
||||
|
||||
Private Function TransformProfiles() As List(Of ProfileData)
|
||||
Dim oList As New List(Of ProfileData)
|
||||
|
||||
For Each oRow As DataRow In _ProfileTable.Rows
|
||||
Dim oProfileId = oRow.Item("GUID")
|
||||
Dim oWindowList As List(Of WindowData) = TransformWindows(oProfileId, _WindowTable)
|
||||
|
||||
oList.Add(New ProfileData() With {
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.ProcessName = oRow.Item("PROC_NAME"),
|
||||
.Regex = oRow.Item("REGEX_EXPRESSION"),
|
||||
.Name = oRow.Item("NAME"),
|
||||
.Comment = oRow.Item("COMMENT"),
|
||||
.CountSQL = oRow.Item("SQL_COUNT_RESULT"),
|
||||
.Windows = oWindowList
|
||||
})
|
||||
Next
|
||||
|
||||
Return oList
|
||||
End Function
|
||||
|
||||
Private Function TransformWindows(ProfileId As Integer, WindowDatatable As DataTable) As List(Of WindowData)
|
||||
Dim oWindowList As New List(Of WindowData)
|
||||
|
||||
For Each oRow As DataRow In WindowDatatable.Rows
|
||||
If oRow.Item("PROFILE_ID") = ProfileId Then
|
||||
oWindowList.Add(New WindowData() With {
|
||||
.Title = oRow.Item("DESCRIPTION"),
|
||||
.Regex = oRow.Item("REGEX"),
|
||||
.Sequence = oRow.Item("SEQUENCE"),
|
||||
.ClipboardRegex = oRow.Item("REGEX_CLIPBOARD")
|
||||
})
|
||||
End If
|
||||
Next
|
||||
|
||||
Return oWindowList
|
||||
End Function
|
||||
End Class
|
||||
@ -120,6 +120,7 @@
|
||||
<Compile Include="ClassDatabase.vb" />
|
||||
<Compile Include="ClassInit.vb" />
|
||||
<Compile Include="ClassLayout.vb" />
|
||||
<Compile Include="ClassProfileFilter.vb" />
|
||||
<Compile Include="clsHotkey.vb" />
|
||||
<Compile Include="clsLicense.vb" />
|
||||
<Compile Include="clsPatterns.vb" />
|
||||
|
||||
@ -140,6 +140,7 @@ Public Class clsHotkey
|
||||
RaiseEvent HotKeyPressed(mHotKeyList(CShort(m.WParam)).HotKeyID)
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Function GetCaption() As String
|
||||
Dim Caption As New System.Text.StringBuilder(256)
|
||||
Dim hWnd As IntPtr = GetForegroundWindow()
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
Imports DevExpress.XtraEditors
|
||||
|
||||
Public Class frmProfileMatch
|
||||
Private PrimaryFont As New Font("Segoe UI", 12, FontStyle.Bold)
|
||||
Private SecondaryFont As New Font("Segoe UI", 10)
|
||||
|
||||
|
||||
Private Sub frmProfileMatch_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not ConfigManager.Config.MatchWindowLocation.IsEmpty Then
|
||||
Location = ConfigManager.Config.MatchWindowLocation
|
||||
@ -21,38 +25,35 @@ Public Class frmProfileMatch
|
||||
|
||||
Sub CreateTiles()
|
||||
Try
|
||||
Dim oPrimaryFont As New Font("Segoe UI", 12, FontStyle.Bold)
|
||||
Dim oSecondaryFont As New Font("Segoe UI", 10)
|
||||
|
||||
Dim oGroup = TileControl1.Groups.Item("TileGroupDocuments")
|
||||
oGroup.Items.Clear()
|
||||
|
||||
For Each oRow As DataRow In CurrDT_PROFILE_MATCH.Rows
|
||||
Dim oItem As New TileItem() With {.Tag = oRow.Item("GUID")}
|
||||
For Each oProfile As ClassProfileFilter.ProfileData In CURRENT_MATCHING_PROFILES
|
||||
Dim oItem As New TileItem() With {.Tag = oProfile.Guid}
|
||||
oItem.Elements.Clear()
|
||||
|
||||
Dim oNameElement = New TileItemElement()
|
||||
oNameElement.Text = oRow.Item("NAME")
|
||||
oNameElement.Text = oProfile.Name
|
||||
oNameElement.TextAlignment = TileItemContentAlignment.TopLeft
|
||||
oNameElement.Appearance.Normal.Font = oPrimaryFont
|
||||
oNameElement.Appearance.Normal.Font = PrimaryFont
|
||||
oItem.Elements.Add(oNameElement)
|
||||
|
||||
Dim oCommentElement = New TileItemElement()
|
||||
oCommentElement.Text = oRow.Item("COMMENT")
|
||||
oCommentElement.Text = oProfile.Comment
|
||||
oCommentElement.TextAlignment = TileItemContentAlignment.MiddleLeft
|
||||
oCommentElement.Appearance.Normal.Font = oSecondaryFont
|
||||
oCommentElement.Appearance.Normal.Font = SecondaryFont
|
||||
oItem.Elements.Add(oCommentElement)
|
||||
|
||||
Dim oCountElement = New TileItemElement()
|
||||
oCountElement.TextAlignment = TileItemContentAlignment.BottomRight
|
||||
oCountElement.Appearance.Normal.Font = oSecondaryFont
|
||||
oCountElement.Appearance.Normal.Font = SecondaryFont
|
||||
Dim oText As String
|
||||
If oRow.Item("COUNT") = 99999 Then
|
||||
If oProfile.Count = 99999 Then
|
||||
oText = "DocCount 0 = Check Your MatchCountConfig in Profiles!"
|
||||
ElseIf oRow.Item("COUNT") = 99998 Then
|
||||
ElseIf oProfile.Count = 99998 Then
|
||||
oText = "DocCount (MatchCountConfig has not been configured)"
|
||||
Else
|
||||
oText = $"{oRow.Item("COUNT")} files!"
|
||||
oText = $"{oProfile.Count} files!"
|
||||
End If
|
||||
|
||||
oCountElement.Text = oText
|
||||
@ -61,19 +62,11 @@ Public Class frmProfileMatch
|
||||
oGroup.Items.Add(oItem)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
|
||||
Logger.Error(ex)
|
||||
MsgBox("Error while creating profile tiles!" & vbNewLine & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Sub OpenResults_Doc()
|
||||
Dim oFrmResultDoc As Form = New frmResultDoc
|
||||
oFrmResultDoc.Show()
|
||||
End Sub
|
||||
Sub OpenResults_Data()
|
||||
Dim oFrmResultData As Form = New frmResultSQL
|
||||
oFrmResultData.Show()
|
||||
End Sub
|
||||
|
||||
Private Sub frmProfileMatch_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||
Try
|
||||
ConfigManager.Config.MatchWindowSize = Size
|
||||
@ -99,11 +92,11 @@ Public Class frmProfileMatch
|
||||
|
||||
If oProfileId Is Nothing Then
|
||||
Dim oResult As String = ""
|
||||
For Each oRow As DataRow In CurrDT_PROFILE_MATCH.Rows
|
||||
For Each oProfile As ClassProfileFilter.ProfileData In CURRENT_MATCHING_PROFILES
|
||||
If oResult = "" Then
|
||||
oResult = oRow.Item("GUID")
|
||||
oResult = oProfile.Guid
|
||||
Else
|
||||
oResult &= "," & oRow.Item("GUID")
|
||||
oResult &= "," & oProfile.Guid
|
||||
End If
|
||||
Next
|
||||
CurrDocSearch2Load = oResult
|
||||
@ -113,20 +106,11 @@ Public Class frmProfileMatch
|
||||
CurrDataSearch2Load = oProfileId
|
||||
End If
|
||||
|
||||
OpenResults_Doc()
|
||||
OpenResults_Data()
|
||||
Me.Hide()
|
||||
End Sub
|
||||
' Show Result Document Form
|
||||
Dim oFrmResultDoc As Form = New frmResultDoc(Me)
|
||||
oFrmResultDoc.Show()
|
||||
|
||||
Private Sub frmProfileMatch_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged
|
||||
If Me.Visible = True Then
|
||||
If CurrSearchOpen = True Then
|
||||
|
||||
End If
|
||||
Else
|
||||
If CurrSearchOpen = True Then
|
||||
|
||||
End If
|
||||
End If
|
||||
' ..and hide myself
|
||||
Hide()
|
||||
End Sub
|
||||
End Class
|
||||
@ -64,8 +64,6 @@ Public Class frmResultDoc
|
||||
|
||||
Dim oSearches = Await LoadSearchesAsync()
|
||||
|
||||
Await Task.Delay(1000) 'DEBUG
|
||||
|
||||
For Each oSearch As DocSearch In oSearches
|
||||
RefreshTabDoc(oSearch.ProfileId, oSearch.DataTable, oSearch.TabIndex, oSearch.TabCaption)
|
||||
Next
|
||||
@ -73,6 +71,28 @@ Public Class frmResultDoc
|
||||
GridViewDocSearch1.HideLoadingPanel()
|
||||
End Sub
|
||||
|
||||
Private Sub frmResultDoc_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||
Try
|
||||
ConfigManager.Config.ResultDocWindowSize = Size
|
||||
ConfigManager.Config.ResultDocWindowLocation = Location
|
||||
ConfigManager.Save()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn("Error in Save FormLayout: " & ex.Message)
|
||||
End Try
|
||||
|
||||
_frmDocView?.Close()
|
||||
_frmSQL?.Close()
|
||||
|
||||
If CURRENT_MATCHING_PROFILES.Count > 1 Then
|
||||
_frmProfileMatch?.Show()
|
||||
_frmProfileMatch?.BringToFront()
|
||||
End If
|
||||
|
||||
CURR_MATCH_RESULT = Nothing
|
||||
CLIPBOARD_TEXT = ""
|
||||
End Sub
|
||||
|
||||
Private Async Function LoadSearchesAsync() As Task(Of List(Of DocSearch))
|
||||
Return Await Task.Run(AddressOf DoLoadSearches)
|
||||
End Function
|
||||
@ -474,52 +494,6 @@ Public Class frmResultDoc
|
||||
Show_File_Properties()
|
||||
End Sub
|
||||
|
||||
Private Sub frmResultDoc_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||
Try
|
||||
ConfigManager.Config.ResultDocWindowSize = Size
|
||||
ConfigManager.Config.ResultDocWindowLocation = Location
|
||||
ConfigManager.Save()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Info("Error in Save FormLayout: " & ex.Message)
|
||||
End Try
|
||||
Try
|
||||
Dim frmCollection As New FormCollection()
|
||||
frmCollection = Application.OpenForms()
|
||||
Try
|
||||
If frmCollection.Item("frmDocView").IsHandleCreated Then
|
||||
_frmDocView.Close()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
Try
|
||||
If frmCollection.Item("frmResultSQL").IsHandleCreated Then
|
||||
frmResultSQL.Close()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
If frmCollection.Item("frmProfileMatch")?.IsHandleCreated Then
|
||||
frmProfileMatch.Show()
|
||||
frmProfileMatch.BringToFront()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
If Not IsNothing(CurrDT_PROFILE_MATCH) Then
|
||||
If CurrDT_PROFILE_MATCH.Rows.Count > 1 Then
|
||||
_frmProfileMatch.Show()
|
||||
_frmProfileMatch.BringToFront()
|
||||
CURR_MATCH_RESULT = Nothing
|
||||
CLIPBOARD_TEXT = ""
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub ToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem1.Click
|
||||
ReLoad_Active_DocTab()
|
||||
End Sub
|
||||
|
||||
@ -1,23 +1,24 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.IO
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports DevExpress.Utils
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.XtraGrid.Columns
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DD_LIB_Standards
|
||||
Imports DevExpress.XtraGrid.Views.Base
|
||||
Imports System.IO
|
||||
Imports DevExpress.XtraTab
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DevExpress.XtraGrid.Views.Base
|
||||
Imports DD_LIB_Standards
|
||||
|
||||
Public Class frmResultSQL
|
||||
|
||||
#Region "Laufzeitvariablen & Konstanten"
|
||||
Private Shared BW_DocPath As String
|
||||
Private Shared BW_DocID As Integer
|
||||
Private Shared CurrSearchID As Integer
|
||||
Private DTDataSearchDefinition As DataTable
|
||||
Private _activeGridView As GridView
|
||||
#End Region
|
||||
|
||||
Private Class SQLSearch
|
||||
Public DataTable As DataTable
|
||||
Public TabIndex As Integer
|
||||
Public TabCaption As String
|
||||
Public ProfileId As Integer
|
||||
End Class
|
||||
|
||||
Private Sub frmResultDoc_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not ConfigManager.Config.ResultDataWindowSize.IsEmpty Then
|
||||
@ -31,6 +32,21 @@ Public Class frmResultSQL
|
||||
Load_Searches()
|
||||
End Sub
|
||||
|
||||
Private Sub frmResultSQL_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||
BringToFront()
|
||||
End Sub
|
||||
|
||||
Private Sub frmResultDoc_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||
Try
|
||||
ConfigManager.Config.ResultDataWindowSize = Size
|
||||
ConfigManager.Config.ResultDataWindowLocation = Location
|
||||
ConfigManager.Save()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Info("Error in Save FormLayout: " & ex.Message)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Sub RefreshTabData(PROFILE_ID As Integer, ConID As Integer, SQLCommand As String, TabIndex As Integer, TabCaption As String)
|
||||
Try
|
||||
SQLCommand = clsPatterns.ReplaceAllValues(SQLCommand, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, PROFILE_ID)
|
||||
@ -88,24 +104,41 @@ Public Class frmResultSQL
|
||||
End Sub
|
||||
Private Function Get_Grid_Layout_Filename(oIndex As Integer)
|
||||
Dim oFilename As String = String.Format("GridViewData_Search-{0}-{1}-UserLayout.xml", oIndex, CurrSearchID)
|
||||
Dim oPath = System.IO.Path.Combine(Application.UserAppDataPath(), oFilename)
|
||||
Dim oPath = Path.Combine(Application.UserAppDataPath(), oFilename)
|
||||
Return oPath
|
||||
End Function
|
||||
|
||||
Private Sub GridControlDocSearch_Leave(sender As Object, e As EventArgs) Handles GridControlDocSearch1.Leave, GridControlDocSearch2.Leave, GridControlDocSearch3.Leave, GridControlDocSearch4.Leave, GridControlDocSearch5.Leave
|
||||
SaveDocGridLayout()
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewDocSearch1_FocusedRowChanged(sender As GridView, e As FocusedRowChangedEventArgs) Handles GridViewDataSearch1.FocusedRowChanged, GridViewDataSearch2.FocusedRowChanged, GridViewDataSearch3.FocusedRowChanged, GridViewDataSearch4.FocusedRowChanged, GridViewDataSearch5.FocusedRowChanged
|
||||
_activeGridView = sender
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewDocSearch1_ColumnWidthChanged(sender As GridView, e As Views.Base.ColumnEventArgs) Handles GridViewDataSearch1.ColumnWidthChanged, GridViewDataSearch2.ColumnWidthChanged, GridViewDataSearch3.ColumnWidthChanged, GridViewDataSearch4.ColumnWidthChanged, GridViewDataSearch5.ColumnWidthChanged
|
||||
_activeGridView = sender
|
||||
SaveDocGridLayout()
|
||||
End Sub
|
||||
|
||||
Sub SaveDocGridLayout()
|
||||
Dim oXMLPath = Get_Grid_Layout_Filename(XtraTabControlData.SelectedTabPageIndex)
|
||||
_activeGridView.SaveLayoutToXml(oXMLPath)
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewDocSearch1_ColumnWidthChanged(sender As Object, e As Views.Base.ColumnEventArgs) Handles GridViewDataSearch1.ColumnWidthChanged
|
||||
_activeGridView = GridViewDataSearch1
|
||||
SaveDocGridLayout()
|
||||
End Sub
|
||||
Private Async Function LoadSearchesAsync() As Task(Of List(Of SQLSearch))
|
||||
Return Await Task.Run(AddressOf DoLoadSearches)
|
||||
End Function
|
||||
|
||||
Private Function DoLoadSearches() As List(Of SQLSearch)
|
||||
If IsNothing(CurrDocSearch2Load) Then
|
||||
Throw New ApplicationException("CurrDataSearch2Load is empty")
|
||||
End If
|
||||
|
||||
Dim oSQL = $"SELECT * FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID in ({CurrDataSearch2Load}) ORDER BY TAB_INDEX"
|
||||
Dim oSearchesDataTable = clsDatabase.Return_Datatable(oSQL)
|
||||
|
||||
End Function
|
||||
|
||||
Sub Load_Searches()
|
||||
If Not IsNothing(CurrDataSearch2Load) Then
|
||||
@ -121,33 +154,23 @@ Public Class frmResultSQL
|
||||
Next
|
||||
Else
|
||||
MsgBox("Sorry but the selection of profile went wrong. (CurrSearch2Load is nothing)", MsgBoxStyle.Critical)
|
||||
Me.Close()
|
||||
Close()
|
||||
End If
|
||||
End Sub
|
||||
Private Sub frmResultDoc_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
||||
Try
|
||||
ConfigManager.Config.ResultDataWindowSize = Size
|
||||
ConfigManager.Config.ResultDataWindowLocation = Location
|
||||
ConfigManager.Save()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Info("Error in Save FormLayout: " & ex.Message)
|
||||
End Try
|
||||
|
||||
Private Sub MenuItemReload_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem1.Click
|
||||
Reload_Active_DocumentTab()
|
||||
End Sub
|
||||
|
||||
Private Sub ToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem1.Click
|
||||
ReLoad_Active_DocTab()
|
||||
Private Sub MenuItemResetLayout_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem2.Click
|
||||
Reset_Layout()
|
||||
End Sub
|
||||
|
||||
Private Sub ToolStripMenuItem2_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem2.Click
|
||||
Set_DoclayoutBack()
|
||||
End Sub
|
||||
Sub Set_DoclayoutBack()
|
||||
Sub Reset_Layout()
|
||||
Dim oXMLPath = Get_Grid_Layout_Filename(XtraTabControlData.SelectedTabPageIndex)
|
||||
Try
|
||||
If File.Exists(oXMLPath) Then
|
||||
File.Delete(oXMLPath)
|
||||
ReLoad_Active_DocTab()
|
||||
Reload_Active_DocumentTab()
|
||||
tslblState.Text = "Layout has been set back!"
|
||||
Else
|
||||
tslblState.Text = ""
|
||||
@ -156,7 +179,7 @@ Public Class frmResultSQL
|
||||
tslblState.Text = ""
|
||||
End Try
|
||||
End Sub
|
||||
Sub ReLoad_Active_DocTab()
|
||||
Sub Reload_Active_DocumentTab()
|
||||
Dim oTabIndex = XtraTabControlData.SelectedTabPageIndex
|
||||
Dim oConID = DTDataSearchDefinition.Rows(oTabIndex).Item("CONN_ID")
|
||||
Dim oCommand = DTDataSearchDefinition.Rows(oTabIndex).Item("SQL_COMMAND")
|
||||
@ -175,24 +198,4 @@ Public Class frmResultSQL
|
||||
Dim oTabCaption = DTDataSearchDefinition.Rows(XtraTabControlData.SelectedTabPageIndex).Item("TAB_TITLE")
|
||||
RefreshTabData(oProfileID, oConID, oCommand, oTabIndex, oTabCaption)
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewDocSearch1_FocusedRowChanged(sender As Object, e As FocusedRowChangedEventArgs) Handles GridViewDataSearch1.FocusedRowChanged
|
||||
_activeGridView = GridViewDataSearch1
|
||||
End Sub
|
||||
Private Sub GridViewDocSearch2_FocusedRowChanged(sender As Object, e As FocusedRowChangedEventArgs) Handles GridViewDataSearch2.FocusedRowChanged
|
||||
_activeGridView = GridViewDataSearch2
|
||||
End Sub
|
||||
Private Sub GridViewDocSearch3_FocusedRowChanged(sender As Object, e As FocusedRowChangedEventArgs) Handles GridViewDataSearch3.FocusedRowChanged
|
||||
_activeGridView = GridViewDataSearch3
|
||||
End Sub
|
||||
Private Sub GridViewDocSearch4_FocusedRowChanged(sender As Object, e As FocusedRowChangedEventArgs) Handles GridViewDataSearch4.FocusedRowChanged
|
||||
_activeGridView = GridViewDataSearch4
|
||||
End Sub
|
||||
Private Sub GridViewDocSearch5_FocusedRowChanged(sender As Object, e As FocusedRowChangedEventArgs) Handles GridViewDataSearch5.FocusedRowChanged
|
||||
_activeGridView = GridViewDataSearch5
|
||||
End Sub
|
||||
|
||||
Private Sub frmResultSQL_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||
Me.BringToFront()
|
||||
End Sub
|
||||
End Class
|
||||
@ -1,18 +1,45 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Threading
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DD_LIB_Standards
|
||||
|
||||
Public Class frmStart
|
||||
Dim WithEvents Hotkey As New clsHotkey(Me)
|
||||
|
||||
Private PID As Integer
|
||||
Private WithEvents _Watcher As ClipboardWatcher = ClipboardWatcher.Singleton
|
||||
Private Sub frmClipboardWatch_Disposed(ByVal sender As Object,
|
||||
ByVal e As EventArgs) Handles Me.Disposed
|
||||
|
||||
|
||||
Private Sub frmClipboardWatch_Disposed(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Disposed
|
||||
_Watcher.Dispose()
|
||||
End Sub
|
||||
|
||||
Private Sub _Watcher_Changed(ByVal sender As Object,
|
||||
ByVal e As EventArgs) Handles _Watcher.Changed
|
||||
Private Sub WatcherChanged_New(ByVal sender As Object, ByVal e As EventArgs) Handles _Watcher.Changed
|
||||
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 OrElse DT_USER_PROFILES.Rows.Count = 0 Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim ClipboardContents As String = Clipboard.GetText()
|
||||
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()
|
||||
|
||||
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()
|
||||
|
||||
@ -71,8 +98,19 @@ Public Class frmStart
|
||||
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}]")
|
||||
Exit For
|
||||
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
|
||||
@ -80,6 +118,12 @@ Public Class frmStart
|
||||
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_RESULT")
|
||||
Dim oRESULTDocs As Integer
|
||||
@ -103,6 +147,8 @@ Public Class frmStart
|
||||
oFound = True
|
||||
End If
|
||||
|
||||
' ================= MOVE TO CTRL + F =================
|
||||
|
||||
|
||||
End If
|
||||
'Else
|
||||
@ -222,33 +268,50 @@ Public Class frmStart
|
||||
End Sub
|
||||
Private Sub ReceiveHotKey(ByVal HotKeyID As String) Handles Hotkey.HotKeyPressed
|
||||
If HotKeyID = 354523017 Then
|
||||
If Not IsNothing(CURR_MATCH_RESULT) And Not IsNothing(CurrDT_PROFILE_MATCH) And MONITORING_ACTIVE = True Then
|
||||
If CURRENT_MATCHING_PROFILES.Count > 0 And MONITORING_ACTIVE = True Then
|
||||
CHECK_PROFILE_MATCH()
|
||||
End If
|
||||
'If Not IsNothing(CURR_MATCH_RESULT) And Not IsNothing(CURR_MATCH_WM_SEARCH) Then
|
||||
' clsSearch.RUN_WD_SEARCH(CURR_MATCH_WM_SEARCH)
|
||||
' 'Close Wait Form
|
||||
'End If
|
||||
ElseIf HotKeyID = 354522017 Then
|
||||
Change_Monitoring_State()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
Sub CHECK_PROFILE_MATCH()
|
||||
If CurrDT_PROFILE_MATCH.Rows.Count = 1 Then
|
||||
If CurrDT_PROFILE_MATCH.Rows(0).Item("COUNT") = 99999 Then
|
||||
NotifyIconMain.ShowBalloonTip(20000, "Clipboard Watcher", "Found match but check is wrong - Check Your MatchCountConfig in Profiles!", ToolTipIcon.Info)
|
||||
Exit Sub
|
||||
ElseIf CurrDT_PROFILE_MATCH.Rows(0).Item("COUNT") = 99998 Then
|
||||
NotifyIconMain.ShowBalloonTip(10000, "Clipboard Watcher", "Found match but MatchCountConfig is not configured!", ToolTipIcon.Info)
|
||||
Dim oProfiles = CURRENT_MATCHING_PROFILES
|
||||
|
||||
For Each oProfile In oProfiles
|
||||
Dim oSQL = oProfile.CountSQL
|
||||
Dim oResultDocs As Integer = 0
|
||||
|
||||
If oSQL = String.Empty Then
|
||||
oProfile.CountSQL = 99998
|
||||
End If
|
||||
|
||||
Try
|
||||
oSQL = clsPatterns.ReplaceAllValues(oSQL, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, oProfile.Guid)
|
||||
oResultDocs = ClassDatabase.Execute_Scalar(oSQL, MyConnectionString)
|
||||
Catch ex As Exception
|
||||
oResultDocs = 99999
|
||||
End Try
|
||||
|
||||
CurrDocSearch2Load = CurrDT_PROFILE_MATCH.Rows(0).Item("GUID")
|
||||
If (oResultDocs <> 99998 And oResultDocs <> 99998 And oResultDocs <> 0) Then
|
||||
oProfile.Count = oResultDocs
|
||||
End If
|
||||
Next
|
||||
|
||||
If oProfiles.Count = 1 Then
|
||||
If oProfiles.First().Count = 99999 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 = 99998 Then
|
||||
NotifyIconMain.ShowBalloonTip(10000, "Clipboard Watcher", "Found match but MatchCountConfig is not configured!", ToolTipIcon.Info)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
CurrDocSearch2Load = oProfiles.First().Guid
|
||||
frmResultDoc.Show()
|
||||
|
||||
'frmProfileMatch.ShowDialog()
|
||||
'clsSearch.RUN_WD_SEARCH(CURR_MATCH_WM_SEARCH)
|
||||
Else
|
||||
frmProfileMatch.ShowDialog()
|
||||
End If
|
||||
|
||||
@ -47,6 +47,8 @@ Module modCurrent
|
||||
Public DT_USER_PROFILES As DataTable
|
||||
|
||||
Public CLIPBOARD_TEXT As String
|
||||
Public CURRENT_MATCHING_PROFILES As List(Of ClassProfileFilter.ProfileData)
|
||||
|
||||
Public CURR_MATCH_RESULT
|
||||
'Public CURR_MATCH_WM_SEARCH
|
||||
Public CURR_FOCUSED_WINDOWNAME
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user