ZooFlow: First working version of Clipboard Watcher

This commit is contained in:
Jonathan Jenne 2021-01-19 16:03:11 +01:00
parent f5fd5ed1e1
commit e946a130ba
11 changed files with 195 additions and 118 deletions

View File

@ -60,10 +60,10 @@ Public Class ProfileSearches
Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId} ORDER BY TAB_INDEX" Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId} ORDER BY TAB_INDEX"
Dim oSearchesDataTable As DataTable Dim oSearchesDataTable As DataTable
If _Environment.Service.IsActive = True Then If _Environment.Service.IsActive = True Then
Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DOC_SEARCH", $"PROFILE_ID = {ProfileId}", "TAB_INDEX") Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DOC_SEARCH", $"PROFILE_ID = {ProfileId} AND ACTIVE = 1", "TAB_INDEX")
oSearchesDataTable = oTableResult.Table oSearchesDataTable = oTableResult.Table
If oSearchesDataTable Is Nothing Then If oSearchesDataTable Is Nothing Then
_Logger.Warn("TBCW_PROF_DOC_SEARCH from ApPServer is nothing: Failover started...") _Logger.Warn("TBCW_PROF_DOC_SEARCH from AppServer is nothing: Failover started...")
oSearchesDataTable = _Environment.Database.GetDatatable(oSQL) oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
End If End If
Else Else
@ -126,8 +126,12 @@ Public Class ProfileSearches
Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId} ORDER BY TAB_INDEX" Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId} ORDER BY TAB_INDEX"
Dim oSearchesDataTable As DataTable Dim oSearchesDataTable As DataTable
If _Environment.Service.IsActive = True Then If _Environment.Service.IsActive = True Then
Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DATA_SEARCH", $"PROFILE_ID = {ProfileId}", "TAB_INDEX") Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DATA_SEARCH", $"PROFILE_ID = {ProfileId} AND ACTIVE = 1", "TAB_INDEX")
oSearchesDataTable = oTableResult.Table oSearchesDataTable = oTableResult.Table
If oSearchesDataTable Is Nothing Then
_Logger.Warn("TBCW_PROF_DATA_SEARCH from AppServer is nothing: Failover started...")
oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
End If
Else Else
oSearchesDataTable = _Environment.Database.GetDatatable(oSQL) oSearchesDataTable = _Environment.Database.GetDatatable(oSQL)
End If End If

View File

@ -25,6 +25,8 @@
Public Const HOTKEY_TOGGLE_WATCHER = 354522017 Public Const HOTKEY_TOGGLE_WATCHER = 354522017
Public Const HOTKEY_TRIGGER_WATCHER = 354523017 Public Const HOTKEY_TRIGGER_WATCHER = 354523017
Public Const NOTIFICATION_DELAY = 2500
Public Const SQLCMD_FLOW_SEARCH1 = "FLOW_SEARCH1" Public Const SQLCMD_FLOW_SEARCH1 = "FLOW_SEARCH1"
Public Const RESULTLIST_COL_ADDED_WHEN_DE = "Erstellt wann" Public Const RESULTLIST_COL_ADDED_WHEN_DE = "Erstellt wann"

View File

@ -8,7 +8,7 @@ Public Class ClassDataASorDB
End Sub End Sub
Public Function GetDatatable(pDB As String, pSQL As String, pAppServDT As String, pAppServFilter As String, Optional pAppServSort As String = "", Optional pForce As String = "") As DataTable Public Function GetDatatable(pDB As String, pSQL As String, pAppServDT As String, pAppServFilter As String, Optional pAppServSort As String = "", Optional pForce As String = "") As DataTable
Try Try
Dim oReturnDT As DataTable Dim oReturnDT As DataTable = Nothing
If EDMI_SERVICE_ACTIVE = True And pForce = String.Empty Then If EDMI_SERVICE_ACTIVE = True And pForce = String.Empty Then
Try Try
Dim oTableResult As TableResult = _Client.GetDatatableByName(pAppServDT, pAppServFilter, pAppServSort) Dim oTableResult As TableResult = _Client.GetDatatableByName(pAppServDT, pAppServFilter, pAppServSort)
@ -35,7 +35,7 @@ Public Class ClassDataASorDB
End Try End Try
End Function End Function
Public Function CheckModuleData() Public Function CheckModuleData() As Boolean
Try Try
Dim oSql = String.Format("SELECT * FROM [dbo].[FNDD_CHECK_USER_MODULE] ('{0}','CW',{1})", My.Application.User.UserName) Dim oSql = String.Format("SELECT * FROM [dbo].[FNDD_CHECK_USER_MODULE] ('{0}','CW',{1})", My.Application.User.UserName)
Dim DT_CHECKUSER_MODULE As DataTable Dim DT_CHECKUSER_MODULE As DataTable

View File

@ -47,7 +47,6 @@ Public Class ClassInit
_Loader.AddStep("Initializing IDB Database..", AddressOf InitializeIDBDatabase, True) _Loader.AddStep("Initializing IDB Database..", AddressOf InitializeIDBDatabase, True)
_Loader.AddStep("Initializing IDB Service..", AddressOf InitializeIDBService, True) _Loader.AddStep("Initializing IDB Service..", AddressOf InitializeIDBService, True)
_Loader.AddStep("Initializing Language..", AddressOf InitializeLanguage, False) _Loader.AddStep("Initializing Language..", AddressOf InitializeLanguage, False)
_Loader.AddStep("Initializing Clipboard Watcher..", AddressOf InitializeClipboardWatcher, False)
_Loader.AddStep("Loading 3rd-party licenses..", AddressOf Initialize3rdParty, False) _Loader.AddStep("Loading 3rd-party licenses..", AddressOf Initialize3rdParty, False)
_Loader.AddStep("Loading Basic Configs..", AddressOf InitBasicData, False) _Loader.AddStep("Loading Basic Configs..", AddressOf InitBasicData, False)
' === Init Schritte definieren ' === Init Schritte definieren
@ -259,39 +258,6 @@ Public Class ClassInit
End Try End Try
End Sub End Sub
Private Sub InitializeClipboardWatcher(MyApplication As My.MyApplication)
Try
Dim oUserId = My.Application.User.UserId
Dim oWhereClause = $"T1.USER_ID = {oUserId} OR GROUP_ID IN (SELECT DISTINCT GUID FROM TBDD_GROUPS WHERE GUID IN (SELECT GROUP_ID FROM TBDD_GROUPS_USER WHERE USER_ID = {oUserId}))"
Dim oProfileSQL As String = $"SELECT DISTINCT GUID, NAME,REGEX_EXPRESSION,COMMENT,PROC_NAME,PROFILE_TYPE FROM VWCW_USER_PROFILE T1 WHERE {oWhereClause}"
Dim oProcessSQL As String = $"SELECT DISTINCT T.GUID, T.PROFILE_ID,T.PROC_NAME FROM TBCW_PROFILE_PROCESS T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})"
Dim oWindowSQL As String = $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_WINDOW T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})"
Dim oControlSQL As String = $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_CONTROL T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})"
Dim oUserProfiles = My.Database.GetDatatable(oProfileSQL)
If oUserProfiles Is Nothing OrElse oUserProfiles.Rows.Count = 0 Then
MyApplication.ClipboardWatcher.Status = ClipboardWatcher.State.EnumStatus.NoProfilesConfigured
End If
Dim oProfileProcesses = My.Database.GetDatatable(oProcessSQL)
Dim oProfileWindows = My.Database.GetDatatable(oWindowSQL)
Dim oProfileControls = My.Database.GetDatatable(oControlSQL)
MyApplication.ClipboardWatcher.Status = ClipboardWatcher.State.EnumStatus.OK
MyApplication.ClipboardWatcher.UserProfiles = oUserProfiles
MyApplication.ClipboardWatcher.ProfileProcesses = oProfileProcesses
MyApplication.ClipboardWatcher.ProfileWindows = oProfileWindows
MyApplication.ClipboardWatcher.ProfileControls = oProfileControls
MyApplication.ClipboardWatcher.MonitoringActive = True
Catch ex As Exception
MyApplication.ClipboardWatcher.Status = ClipboardWatcher.State.EnumStatus.Exception
_Logger.Error(ex)
Throw New InitException("Error while initializing clipboard watcher!", ex)
End Try
End Sub
Private Sub HandleUserInfo(MyApplication As My.MyApplication, Row As DataRow) Private Sub HandleUserInfo(MyApplication As My.MyApplication, Row As DataRow)
Dim oValue As Object = Row.Item("VALUE") Dim oValue As Object = Row.Item("VALUE")
Dim oName As String = Row.Item("NAME").ToString Dim oName As String = Row.Item("NAME").ToString

View File

@ -17,6 +17,17 @@ Public Class ClassWin32
[True] [True]
End Enum End Enum
<StructLayout(LayoutKind.Sequential)>
Public Structure WINDOWPOS
Public hwnd As IntPtr
Public hwndInsertAfter As IntPtr
Public x As Integer
Public y As Integer
Public cx As Integer
Public cy As Integer
Public flags As Integer
End Structure
<StructLayout(LayoutKind.Sequential)> <StructLayout(LayoutKind.Sequential)>
Public Structure Point Public Structure Point
Public x As Int32 Public x As Int32

View File

@ -0,0 +1,55 @@
Imports DigitalData.Modules.Logging
Namespace ClipboardWatcher
Public Class ClassProfileLoader
Private ReadOnly LogConfig As LogConfig
Private ReadOnly Logger As Logger
Private Database As ClassDataASorDB
Public Sub New(LogConfig As LogConfig, AppServerOrDB As ClassDataASorDB)
Me.LogConfig = LogConfig
Me.Logger = LogConfig.GetLogger()
Me.Database = AppServerOrDB
End Sub
Public Function LoadProfiles() As Boolean
Try
Dim oUserId = My.Application.User.UserId
Dim oWhereClause = $"T1.USER_ID = {oUserId} OR GROUP_ID IN (SELECT DISTINCT GUID FROM TBDD_GROUPS WHERE GUID IN (SELECT GROUP_ID FROM TBDD_GROUPS_USER WHERE USER_ID = {oUserId}))"
Dim oProfileSQL As String = $"SELECT DISTINCT GUID, NAME,REGEX_EXPRESSION,COMMENT,PROC_NAME,PROFILE_TYPE FROM VWCW_USER_PROFILE T1 WHERE {oWhereClause}"
Dim oProcessSQL As String = $"SELECT DISTINCT T.GUID, T.PROFILE_ID,T.PROC_NAME FROM TBCW_PROFILE_PROCESS T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})"
Dim oWindowSQL As String = $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_WINDOW T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})"
Dim oControlSQL As String = $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_CONTROL T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})"
Dim oUserProfiles = Database.GetDatatable("DD_ECM", oProfileSQL, "VWCW_USER_PROFILE", "", "", "DB")
If oUserProfiles Is Nothing OrElse oUserProfiles.Rows.Count = 0 Then
My.Application.ClipboardWatcher.Status = State.EnumStatus.NoProfilesConfigured
End If
Dim oProfileProcesses = Database.GetDatatable("DD_ECM", oProcessSQL, "TBCW_PROFILE_PROCESS", "", "", "DB")
Dim oProfileWindows = Database.GetDatatable("DD_ECM", oWindowSQL, "VWCW_PROFILE_REL_WINDOW", "", "", "DB")
Dim oProfileControls = Database.GetDatatable("DD_ECM", oControlSQL, "VWCW_PROFILE_REL_CONTROL", "", "", "DB")
My.Application.ClipboardWatcher.Status = State.EnumStatus.OK
My.Application.ClipboardWatcher.UserProfiles = oUserProfiles
My.Application.ClipboardWatcher.ProfileProcesses = oProfileProcesses
My.Application.ClipboardWatcher.ProfileWindows = oProfileWindows
My.Application.ClipboardWatcher.ProfileControls = oProfileControls
My.Application.ClipboardWatcher.MonitoringActive = True
Return True
Catch ex As Exception
My.Application.ClipboardWatcher.Status = State.EnumStatus.Exception
Logger.Error(ex)
Return False
End Try
End Function
End Class
End Namespace

View File

@ -67,7 +67,7 @@ Public Class frmGlobix_Index
DocumentViewer1.Init(_LogConfig, My.Application.GDPictureLicense) DocumentViewer1.Init(_LogConfig, My.Application.Settings.GdPictureKey)
If DropType Is Nothing Then If DropType Is Nothing Then
_Logger.Debug("File with Id [{0}] was not found in TBGI_FILES_USER. Exiting.", My.Application.Globix.CURRENT_WORKFILE_GUID) _Logger.Debug("File with Id [{0}] was not found in TBGI_FILES_USER. Exiting.", My.Application.Globix.CURRENT_WORKFILE_GUID)

View File

@ -54,12 +54,20 @@ Namespace My
Public Property Globix As New Globix.State Public Property Globix As New Globix.State
Public Property Search As New Search.State Public Property Search As New Search.State
Public Property GDPictureLicense As String
Public CommandLineFunction As String Public CommandLineFunction As String
Public CommandLineArguments As New Dictionary(Of String, String) Public CommandLineArguments As New Dictionary(Of String, String)
Public Property IDB_DT_DOC_DATA As DataTable Public Property IDB_DT_DOC_DATA As DataTable
Public Function GetEnvironment() As Environment
Return New Environment With {
.Database = My.Database,
.DatabaseIDB = My.DatabaseIDB,
.Modules = My.Application.Modules,
.Service = My.Application.Service,
.Settings = My.Application.Settings,
.User = My.Application.User
}
End Function
End Class End Class
End Namespace End Namespace

View File

@ -113,6 +113,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="ApplicationEvents.vb" /> <Compile Include="ApplicationEvents.vb" />
<Compile Include="Base\BaseClass.vb" /> <Compile Include="Base\BaseClass.vb" />
<Compile Include="ClipboardWatcher\ClassProfileLoader.vb" />
<Compile Include="ClipboardWatcher\Watcher.vb" /> <Compile Include="ClipboardWatcher\Watcher.vb" />
<Compile Include="ClassCommandlineArgs.vb" /> <Compile Include="ClassCommandlineArgs.vb" />
<Compile Include="ClassDataASorDB.vb" /> <Compile Include="ClassDataASorDB.vb" />

View File

@ -1,13 +1,14 @@
Option Explicit On Option Explicit On
Imports System.IO Imports System.IO
Imports System.Runtime.InteropServices
Imports DevExpress.XtraSplashScreen Imports DevExpress.XtraSplashScreen
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Messaging
Imports DigitalData.GUIs.ClipboardWatcher Imports DigitalData.GUIs.ClipboardWatcher
Imports DigitalData.GUIs.ZooFlow.ClassConstants Imports DigitalData.GUIs.ZooFlow.ClassConstants
Imports DigitalData.GUIs.ZooFlow.ClipboardWatcher
Imports DigitalData.Modules Imports DigitalData.Modules
Imports System.Runtime.InteropServices Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Messaging
Imports DigitalData.Modules.Windows Imports DigitalData.Modules.Windows
Public Class frmFlowForm Public Class frmFlowForm
@ -19,14 +20,20 @@ Public Class frmFlowForm
Private Logger As Logger Private Logger As Logger
Private DTIDB_SEARCHES As DataTable Private DTIDB_SEARCHES As DataTable
' Helper Classes ' Common Helpers Classes
Private Init As ClassInit Private Init As ClassInit
Private AppServerOrDB As ClassDataASorDB
Private FileClass As Filesystem.File
' Globix Helper Classes
Private FileDrop As ClassFileDrop Private FileDrop As ClassFileDrop
Private FileHandle As ClassFilehandle Private FileHandle As ClassFilehandle
Private FolderWatch As ClassFolderwatcher
' ClipboardWatcher Helper Classes
Private ClassWindow As Window
Private ProfileFilter As ProfileFilter Private ProfileFilter As ProfileFilter
Private clsFW As ClassFolderwatcher Private ProfileLoader As ClassProfileLoader
Private _DataASorDB As ClassDataASorDB
Private WindowClass As Window
' Runtime Flags ' Runtime Flags
Private ApplicationLoading As Boolean = True Private ApplicationLoading As Boolean = True
@ -49,51 +56,26 @@ Public Class frmFlowForm
' === Hide form initially === ' === Hide form initially ===
Opacity = OPACITY_INITIAL Opacity = OPACITY_INITIAL
End Sub End Sub
<StructLayout(LayoutKind.Sequential)>
Public Structure WINDOWPOS
Public hwnd As IntPtr
Public hwndInsertAfter As IntPtr
Public x As Integer
Public y As Integer
Public cx As Integer
Public cy As Integer
Public flags As Integer
End Structure
Private Sub frmFlowForm_Load(sender As Object, e As EventArgs) Handles Me.Load Private Sub frmFlowForm_Load(sender As Object, e As EventArgs) Handles Me.Load
' === Initialize Logger === ' === Initialize Logger ===
Logger = My.LogConfig.GetLogger() Logger = My.LogConfig.GetLogger()
' === Show Splash Screen === ' === Show Splash Screen ===
SplashScreenManager.ShowForm(Me, GetType(frmSplash), False, False) SplashScreenManager.ShowForm(Me, GetType(frmSplash), False, False)
Try
Try
Dim directory As New IO.DirectoryInfo(My.LogConfig.LogDirectory)
For Each file As IO.FileInfo In directory.GetFiles ' === Clean up logfiles ===
If (Now - file.CreationTime).Days > 29 Then FileClass = New Filesystem.File(My.LogConfig)
file.Delete() FileClass.RemoveFiles(My.LogConfig.LogDirectory, 30, String.Empty, "log")
Else
Exit For
End If
' === Initialize AppServer Database Connection with Failover
AppServerOrDB = New ClassDataASorDB(My.LogConfig)
Next
Catch ex As Exception
End Try
Catch ex As Exception
End Try
' === Initialization === ' === Initialization ===
Init = New ClassInit(My.LogConfig, Me) Init = New ClassInit(My.LogConfig, Me)
AddHandler Init.Completed, AddressOf Init_Completed AddHandler Init.Completed, AddressOf Init_Completed
Init.InitializeApplication() Init.InitializeApplication()
_DataASorDB = New ClassDataASorDB(My.LogConfig)
End Sub End Sub
Protected Overrides Sub WndProc(ByRef m As Message) Protected Overrides Sub WndProc(ByRef m As Message)
' Listen for operating system messages ' Listen for operating system messages
@ -104,8 +86,7 @@ Public Class frmFlowForm
MyBase.WndProc(m) MyBase.WndProc(m)
End Sub End Sub
Public Shared Sub SnapToDesktopBorder(ByVal clientForm _ Public Shared Sub SnapToDesktopBorder(ByVal clientForm As Form, ByVal LParam As IntPtr, ByVal widthAdjustment As Integer)
As Form, ByVal LParam As IntPtr, ByVal widthAdjustment As Integer)
If clientForm Is Nothing Then If clientForm Is Nothing Then
' Satisfies rule: Validate parameters ' Satisfies rule: Validate parameters
Throw New ArgumentNullException("clientForm") Throw New ArgumentNullException("clientForm")
@ -116,9 +97,9 @@ Public Class frmFlowForm
Try Try
' Marshal the LPARAM value which is a WINDOWPOS struct ' Marshal the LPARAM value which is a WINDOWPOS struct
Dim NewPosition As New WINDOWPOS Dim NewPosition As New ClassWin32.WINDOWPOS
NewPosition = CType(Runtime.InteropServices.Marshal.PtrToStructure( NewPosition = CType(Marshal.PtrToStructure(
LParam, GetType(WINDOWPOS)), WINDOWPOS) LParam, GetType(ClassWin32.WINDOWPOS)), ClassWin32.WINDOWPOS)
If NewPosition.y = 0 OrElse NewPosition.x = 0 Then If NewPosition.y = 0 OrElse NewPosition.x = 0 Then
Return ' Nothing to do! Return ' Nothing to do!
@ -182,11 +163,11 @@ Public Class frmFlowForm
End If End If
' Marshal it back ' Marshal it back
Runtime.InteropServices.Marshal.StructureToPtr(NewPosition, Marshal.StructureToPtr(NewPosition, LParam, True)
LParam, True)
Catch ex As ArgumentException Catch ex As ArgumentException
End Try End Try
End Sub End Sub
Private Sub Init_Completed(sender As Object, e As EventArgs) Private Sub Init_Completed(sender As Object, e As EventArgs)
Me.Cursor = Cursors.WaitCursor Me.Cursor = Cursors.WaitCursor
' === Initialization Complete === ' === Initialization Complete ===
@ -230,7 +211,7 @@ Public Class frmFlowForm
If My.Application.ModulesActive.Contains(MODULE_CLIPBOARDWATCHER) Then If My.Application.ModulesActive.Contains(MODULE_CLIPBOARDWATCHER) Then
Try Try
WindowClass = New Window(My.LogConfig) ClassWindow = New Window(My.LogConfig)
HotkeyClass = New Hotkey(Me) HotkeyClass = New Hotkey(Me)
'Add Toggle Hotkey 'Add Toggle Hotkey
@ -256,19 +237,24 @@ Public Class frmFlowForm
Case "WIN" Case "WIN"
HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_WIN, ClassConstants.HOTKEY_TRIGGER_WATCHER) HotkeyClass.AddHotKey(oKeyCode, Hotkey.ModfierKey.MOD_WIN, ClassConstants.HOTKEY_TRIGGER_WATCHER)
End Select End Select
AddHandler HotkeyClass.HotKeyPressed, AddressOf HotkeyClass_HotKeyPressed
ProfileLoader = New ClassProfileLoader(My.LogConfig, AppServerOrDB)
ProfileLoader.LoadProfiles()
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
MsgBox("Error while initializing Hotkeys for Clipboard Watcher!", MsgBoxStyle.Critical, Text) MsgBox("Error while initializing Clipboard Watcher!", MsgBoxStyle.Critical, Text)
End Try End Try
Else Else
My.Application.ClipboardWatcher.MonitoringActive = False My.Application.ClipboardWatcher.MonitoringActive = False
Logger.Info("Clipboard Watcher Module is not active. Hotkey Monitoring will be disabled!") Logger.Info("Clipboard Watcher Module is not active. Hotkey Monitoring will be disabled!")
End If End If
If My.Application.ModulesActive.Contains(ClassConstants.MODULE_GLOBAL_INDEXER) Then If My.Application.ModulesActive.Contains(MODULE_GLOBAL_INDEXER) Then
FileDrop = New ClassFileDrop(My.LogConfig) FileDrop = New ClassFileDrop(My.LogConfig)
FileHandle = New ClassFilehandle() FileHandle = New ClassFilehandle()
clsFW = New ClassFolderwatcher FolderWatch = New ClassFolderwatcher
Refresh_RegexTable() Refresh_RegexTable()
If My.Application.Globix.LoadFileExclusion = False Then If My.Application.Globix.LoadFileExclusion = False Then
If My.Application.User.Language = "de-DE" Then If My.Application.User.Language = "de-DE" Then
@ -286,17 +272,17 @@ Public Class frmFlowForm
End If End If
oSQL = "SELECT * FROM TBIDB_ATTRIBUTE" oSQL = "SELECT * FROM TBIDB_ATTRIBUTE"
My.DTAttributes = _DataASorDB.GetDatatable("IDB", oSQL, "TBIDB_ATTRIBUTE", "", "") My.DTAttributes = AppServerOrDB.GetDatatable("IDB", oSQL, "TBIDB_ATTRIBUTE", "", "")
Me.Cursor = Cursors.Default Me.Cursor = Cursors.Default
End Sub End Sub
Public Sub Init_Folderwatch() Public Sub Init_Folderwatch()
Try Try
Dim oSql As String = "SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'DEFAULT' AND USER_ID = " & My.Application.User.UserId Dim oSql As String = "SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE FOLDER_TYPE = 'DEFAULT' AND USER_ID = " & My.Application.User.UserId
Dim folderwatchPath = My.Database.GetScalarValue(oSql) Dim oFolderWatchPath As Object = My.Database.GetScalarValue(oSql)
oFolderWatchPath = NotNull(oFolderWatchPath, String.Empty)
folderwatchPath = IIf(IsDBNull(folderwatchPath), "", folderwatchPath) If oFolderWatchPath = String.Empty Then
If folderwatchPath = String.Empty Then
Logger.Info("Init_Folderwatch: folderwatchPath is empty") Logger.Info("Init_Folderwatch: folderwatchPath is empty")
My.Application.Globix.Folderwatchstarted = False My.Application.Globix.Folderwatchstarted = False
'SaveConfigValue("my.Application.Globix.Folderwatchstarted", "False") 'SaveConfigValue("my.Application.Globix.Folderwatchstarted", "False")
@ -305,7 +291,7 @@ Public Class frmFlowForm
End If End If
If Not IO.Directory.Exists(folderwatchPath) Then If Not IO.Directory.Exists(oFolderWatchPath) Then
Logger.Info("Init_Folderwatch: folderwatchPath does not exists or is invalid path") Logger.Info("Init_Folderwatch: folderwatchPath does not exists or is invalid path")
My.Application.Globix.Folderwatchstarted = False My.Application.Globix.Folderwatchstarted = False
'SaveConfigValue("my.Application.Globix.Folderwatchstarted", "False") 'SaveConfigValue("my.Application.Globix.Folderwatchstarted", "False")
@ -314,11 +300,11 @@ Public Class frmFlowForm
End If End If
My.Application.Globix.CURRENT_FOLDERWATCH = folderwatchPath My.Application.Globix.CURRENT_FOLDERWATCH = oFolderWatchPath
My.Application.Globix.Folderwatchstarted = True My.Application.Globix.Folderwatchstarted = True
'FWFunction_STARTED = True 'FWFunction_STARTED = True
clsFW.StartStop_FolderWatch() FolderWatch.StartStop_FolderWatch()
Catch ex As Exception Catch ex As Exception
MsgBox($"Init_Folderwatch: Unexpected error while starting FolderWatch: {ex.Message}", MsgBoxStyle.Critical) MsgBox($"Init_Folderwatch: Unexpected error while starting FolderWatch: {ex.Message}", MsgBoxStyle.Critical)
Logger.Info($"Init_Folderwatch: Unexpected error: {ex.Message}") Logger.Info($"Init_Folderwatch: Unexpected error: {ex.Message}")
@ -348,7 +334,7 @@ Public Class frmFlowForm
'FWFunction_STARTED = True 'FWFunction_STARTED = True
clsFW.StartStop_FolderWatchSCAN() FolderWatch.StartStop_FolderWatchSCAN()
Catch ex As Exception Catch ex As Exception
MsgBox($"Init_Folderwatch: Unexpected error while starting FolderWatchScan: {ex.Message}", MsgBoxStyle.Critical) MsgBox($"Init_Folderwatch: Unexpected error while starting FolderWatchScan: {ex.Message}", MsgBoxStyle.Critical)
Logger.Info($"Init_Folderwatch: Unexpected error: {ex.Message}") Logger.Info($"Init_Folderwatch: Unexpected error: {ex.Message}")
@ -855,46 +841,44 @@ Public Class frmFlowForm
End Sub End Sub
Private Sub Watcher_ClipboardChanged(sender As Object, e As IDataObject) Private Sub Watcher_ClipboardChanged(sender As Object, e As IDataObject)
If My.Application.ClipboardWatcher.MonitoringActive = False Then Dim oState = My.Application.ClipboardWatcher
If oState.MonitoringActive = False Then
Logger.Info("Clipboard Watcher is not active!") Logger.Info("Clipboard Watcher is not active!")
Exit Sub Exit Sub
End If End If
If My.Application.ClipboardWatcher.UserProfiles Is Nothing OrElse My.Application.ClipboardWatcher.UserProfiles.Rows.Count = 0 Then If oState.UserProfiles Is Nothing OrElse oState.UserProfiles.Rows.Count = 0 Then
Logger.Warn("User Profiles is empty!") Logger.Warn("User Profiles is empty!")
Exit Sub Exit Sub
End If End If
If My.Application.ClipboardWatcher.ProfileProcesses Is Nothing OrElse My.Application.ClipboardWatcher.ProfileProcesses.Rows.Count = 0 Then If oState.ProfileProcesses Is Nothing OrElse oState.ProfileProcesses.Rows.Count = 0 Then
Logger.Warn("Profile Processes is empty!") Logger.Warn("Profile Processes is empty!")
Exit Sub Exit Sub
End If End If
If My.Application.ClipboardWatcher.ProfileWindows Is Nothing OrElse My.Application.ClipboardWatcher.ProfileWindows.Rows.Count = 0 Then If oState.ProfileWindows Is Nothing OrElse oState.ProfileWindows.Rows.Count = 0 Then
Logger.Warn("Profile Processes is empty!") Logger.Warn("Profile Processes is empty!")
Exit Sub Exit Sub
End If End If
If My.Application.ClipboardWatcher.ProfileProcesses Is Nothing OrElse My.Application.ClipboardWatcher.ProfileProcesses.Rows.Count = 0 Then If oState.ProfileProcesses Is Nothing OrElse oState.ProfileProcesses.Rows.Count = 0 Then
Logger.Warn("Profile Processes is empty!") Logger.Warn("Profile Processes is empty!")
Exit Sub Exit Sub
End If End If
Dim oWindowInfo = ClassWindow.GetWindowInfo()
Dim oWindowInfo = WindowClass.GetWindowInfo()
Dim ClipboardContents As String = Clipboard.GetText().Trim() Dim ClipboardContents As String = Clipboard.GetText().Trim()
Try Try
' Tree View zurücksetzen ' Tree View zurücksetzen
My.Application.ClipboardWatcher.MatchTreeView.Nodes.Clear() oState.MatchTreeView.Nodes.Clear()
ProfileFilter = New ProfileFilter(My.LogConfig, ProfileFilter = New ProfileFilter(My.LogConfig,
My.Application.ClipboardWatcher.UserProfiles, oState.UserProfiles, oState.ProfileProcesses,
My.Application.ClipboardWatcher.ProfileProcesses, oState.ProfileWindows, oState.ProfileControls,
My.Application.ClipboardWatcher.ProfileWindows, oState.MatchTreeView)
My.Application.ClipboardWatcher.ProfileControls,
My.Application.ClipboardWatcher.MatchTreeView
)
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
MsgBox("Fehler beim Laden der Profile. Möglicherweise liegt ein Konfigurationsfehler vor. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text) MsgBox("Fehler beim Laden der Profile. Möglicherweise liegt ein Konfigurationsfehler vor. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text)
@ -919,7 +903,7 @@ Public Class frmFlowForm
' Filter by Focused Control ' Filter by Focused Control
oProfiles = ProfileFilter.FilterProfilesByFocusedControl(oProfiles, ClipboardContents, Handle) oProfiles = ProfileFilter.FilterProfilesByFocusedControl(oProfiles, ClipboardContents, Handle)
oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "FilterProfilesByFocusedControl") oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "FilterProfilesByFocusedControl")
My.Application.ClipboardWatcher.CurrentMatchingProfiles = oProfiles.ToList() oState.CurrentMatchingProfiles = oProfiles.ToList()
' Filter by Search Results ' Filter by Search Results
oProfiles = ProfileFilter.FilterProfilesBySearchResults(oProfiles, oEnvironment.Database, oEnvironment.User, ClipboardContents) oProfiles = ProfileFilter.FilterProfilesBySearchResults(oProfiles, oEnvironment.Database, oEnvironment.User, ClipboardContents)
@ -930,11 +914,56 @@ Public Class frmFlowForm
oProfiles = ProfileFilter.ClearDuplicateProfiles(oProfiles) oProfiles = ProfileFilter.ClearDuplicateProfiles(oProfiles)
oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "CleanUp") oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "CleanUp")
My.Application.ClipboardWatcher.CurrentProfilesWithResults = oProfiles.ToList() oState.CurrentProfilesWithResults = oProfiles.ToList()
My.Application.ClipboardWatcher.CurrentClipboardContents = ClipboardContents oState.CurrentClipboardContents = ClipboardContents
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
MsgBox("Fehler beim Auswerten der Profile. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text) MsgBox("Fehler beim Auswerten der Profile. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text)
End Try End Try
End Sub End Sub
End Class
Private Sub HotkeyClass_HotKeyPressed(HotKeyID As String)
Dim oState = My.Application.ClipboardWatcher
Select Case HotKeyID
Case HOTKEY_TRIGGER_WATCHER
If oState.CurrentClipboardContents = String.Empty Then
Logger.Info("Current Clipboard Contents is empty. Exiting.")
Exit Sub
End If
If oState.MonitoringActive = False Then
Logger.Info("Monitoring is inactive. Exiting.")
Exit Sub
End If
If oState.CurrentMatchingProfiles.Count = 0 Then
NotifyIcon.ShowBalloonTip(NOTIFICATION_DELAY, "ClipboardWatcher", "Es wurden keine passenden Profile gefunden.", ToolTipIcon.Warning)
ElseIf oState.CurrentProfilesWithResults.Count = 0 Then
NotifyIcon.ShowBalloonTip(NOTIFICATION_DELAY, "ClipboardWatcher", "Es wurden keine passenden Profile gefunden.", ToolTipIcon.Warning)
Else
Dim oProfiles = oState.CurrentProfilesWithResults
Dim oEnvironment = My.Application.GetEnvironment()
Dim oParams As New DigitalData.Modules.ZooFlow.ClipboardWatcherParams With {
.ClipboardContents = oState.CurrentClipboardContents,
.MatchingProfiles = oProfiles,
.MatchTreeView = oState.MatchTreeView
}
Dim oForm As New frmMatch(My.LogConfig, oEnvironment, oParams)
oForm.Show()
End If
Case HOTKEY_TOGGLE_WATCHER
If oState.MonitoringActive = True Then
NotifyIcon.ShowBalloonTip(NOTIFICATION_DELAY, "ClipboardWatcher", "Clipboard-Watcher wurde deaktiviert!", ToolTipIcon.Info)
Else
NotifyIcon.ShowBalloonTip(NOTIFICATION_DELAY, "ClipboardWatcher", "Clipboard-Watcher wurde aktiviert!", ToolTipIcon.Info)
End If
oState.MonitoringActive = Not oState.MonitoringActive
End Select
End Sub
End Class

View File

@ -164,7 +164,8 @@ Public Class File
EnumerateFiles($"*{FileBaseName}*"). EnumerateFiles($"*{FileBaseName}*").
Where(Function(oFileInfo As FileInfo) Where(Function(oFileInfo As FileInfo)
Return oFileInfo.Extension = FileExtension And oFileInfo.LastWriteTime < oDateLimit Return oFileInfo.Extension = FileExtension And oFileInfo.LastWriteTime < oDateLimit
End Function) End Function).
ToList()
If oFiles.Count = 0 Then If oFiles.Count = 0 Then
_logger.Debug("No files found that match the criterias.") _logger.Debug("No files found that match the criterias.")