Public Class ClassClipboardWatcherQueries
    Private Function ProfileWhereClause(UserId As Integer) As String
        Return $"T1.USER_ID = {UserId} OR GROUP_ID IN (SELECT DISTINCT GUID FROM TBDD_GROUPS WHERE GUID IN (SELECT GROUP_ID FROM TBDD_GROUPS_USER WHERE USER_ID = {UserId}))"
    End Function

    Public Function VWCW_USER_PROFILE(UserId As Integer) As String
        Dim oWhereClause = ProfileWhereClause(UserId)
        Return $"SELECT DISTINCT GUID, NAME,REGEX_EXPRESSION,COMMENT,PROC_NAME,PROFILE_TYPE FROM VWCW_USER_PROFILE T1 WHERE {oWhereClause}"
    End Function

    Public Function VWCW_PROFILE_REL_WINDOW(UserId As Integer) As String
        Dim oWhereClause = ProfileWhereClause(UserId)
        Return $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_WINDOW T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})"
    End Function

    Public Function VWCW_PROFILE_REL_CONTROL(UserId As Integer) As String
        Dim oWhereClause = ProfileWhereClause(UserId)
        Return $"SELECT DISTINCT T.* FROM VWCW_PROFILE_REL_CONTROL T, VWCW_USER_PROFILE T1 WHERE T.PROFILE_ID = T1.GUID AND ({oWhereClause})"
    End Function

    Public Function TBCW_PROFILE_PROCESS(UserId As Integer) As String
        Dim oWhereClause = ProfileWhereClause(UserId)
        Return $"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})"
    End Function

    Public Function TBCW_PROF_DATA_SEARCH(ProfileId As Integer) As String
        Return $"SELECT COUNT_COMMAND FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId}"
    End Function

    Public Function TBCW_PROF_DOC_SEARCH(ProfileId As Integer) As String
        Return $"SELECT COUNT_COMMAND FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId}"
    End Function

End Class
