ZooFlow: Add special case when no profiles are configured

This commit is contained in:
Jonathan Jenne 2021-01-20 14:15:09 +01:00
parent 1fe39022c4
commit 0a77e55b7d
3 changed files with 14 additions and 19 deletions

View File

@ -23,16 +23,10 @@ Namespace ClipboardWatcher
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
@ -42,7 +36,6 @@ Namespace ClipboardWatcher
Return True
Catch ex As Exception
My.Application.ClipboardWatcher.Status = State.EnumStatus.Exception
Logger.Error(ex)
Return False

View File

@ -2,12 +2,6 @@
Namespace ClipboardWatcher
Public Class State
Public Enum EnumStatus
OK
NoProfilesConfigured
Exception
End Enum
Public Property UserProfiles As DataTable = Nothing
Public Property ProfileProcesses As DataTable = Nothing
Public Property ProfileWindows As DataTable = Nothing
@ -20,6 +14,5 @@ Namespace ClipboardWatcher
Public Property CurrentClipboardContents As String = String.Empty
Public Property MonitoringActive As Boolean = False
Public Property Status As EnumStatus
End Class
End Namespace

View File

@ -848,14 +848,17 @@ Public Class frmFlowForm
End Sub
Private Sub Watcher_ClipboardChanged(sender As Object, e As IDataObject)
Dim ClipboardContents As String = Clipboard.GetText().Trim()
Dim oState = My.Application.ClipboardWatcher
oState.CurrentClipboardContents = ClipboardContents
If oState.MonitoringActive = False Then
Logger.Info("Clipboard Watcher is not active!")
Exit Sub
End If
If oState.UserProfiles Is Nothing OrElse oState.UserProfiles.Rows.Count = 0 Then
If oState.UserProfiles Is Nothing Then
Logger.Warn("User Profiles is empty!")
Exit Sub
End If
@ -876,7 +879,6 @@ Public Class frmFlowForm
End If
Dim oWindowInfo = ClassWindow.GetWindowInfo()
Dim ClipboardContents As String = Clipboard.GetText().Trim()
Try
' Tree View zurücksetzen
@ -922,7 +924,6 @@ Public Class frmFlowForm
oProfiles = ProfileFilter.LogRemainingProfiles(oProfiles, "CleanUp")
oState.CurrentProfilesWithResults = oProfiles.ToList()
oState.CurrentClipboardContents = ClipboardContents
Catch ex As Exception
Logger.Error(ex)
MsgBox("Fehler beim Auswerten der Profile. Mehr Informationen im Log.", MsgBoxStyle.Critical, Text)
@ -944,10 +945,15 @@ Public Class frmFlowForm
Exit Sub
End If
If oState.CurrentMatchingProfiles.Count = 0 Then
If oState.UserProfiles.Rows.Count = 0 Then
NotifyIcon.ShowBalloonTip(NOTIFICATION_DELAY, "ClipboardWatcher", "Es wurden keine Profile für Sie gefunden.", ToolTipIcon.Warning)
ElseIf 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)
NotifyIcon.ShowBalloonTip(NOTIFICATION_DELAY, "ClipboardWatcher", "Es wurden weder Dokumente noch Daten gefunden!", ToolTipIcon.Warning)
Else
Dim oProfiles = oState.CurrentProfilesWithResults
Dim oEnvironment = My.Application.GetEnvironment()
@ -959,13 +965,16 @@ Public Class frmFlowForm
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