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

@@ -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