Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.ZooFlow
Imports DigitalData.Modules.EDMI.API

Namespace My
    ''' <summary>
    ''' Extends the My Namespace
    ''' Example: My.LogConfig
    ''' </summary>
    <HideModuleName()>
    Module Extension
        Property SystemConfigManager As ConfigManager(Of SystemConfig)
        ReadOnly Property SystemConfig As SystemConfig
            Get
                Return SystemConfigManager.Config
            End Get
        End Property

        Property UIConfigManager As ConfigManager(Of UIConfig)
        ReadOnly Property UIConfig As UIConfig
            Get
                Return UIConfigManager.Config
            End Get
        End Property

        Property LogConfig As LogConfig

#Region "Database"
        Property Database As DatabaseWithFallback
        Property DatabaseECM As MSSQLServer
        Property DatabaseIDB As MSSQLServer

        Property Tables As New ClassTables
        Property Queries As New ClassQueries
#End Region

    End Module

    ''' <summary>
    ''' Extends the My.Application Namespace to hold Application State
    ''' Example: My.Application.User
    ''' </summary>
    Partial Friend Class MyApplication
        Public Property Skin As String = ""
        Public Property Palette As String = ""
        Public Property GlobixDropAreaStyle As String = "PROGRESSIVE"

        Public Property Settings As New State.SettingsState
        Public Property User As New State.UserState
        Public Property Service As New State.ServiceState
        Public Property Modules As New Dictionary(Of String, State.ModuleState)
        Public Property ModulesActive As New List(Of String)
        Public Property ClipboardWatcher As New ClipboardWatcher.State
        Public Property Globix As New Globix.State
        Public Property Search As New Search.State

        Public CommandLineFunction As String
        Public CommandLineArguments As New Dictionary(Of String, String)

        Public Function GetEnvironment() As Environment
            Return New Environment With {
                .Database = My.DatabaseECM,
                .DatabaseIDB = My.DatabaseIDB,
                .Modules = My.Application.Modules,
                .Service = My.Application.Service,
                .Settings = My.Application.Settings,
                .User = My.Application.User
            }
        End Function
        Public Function GetAdHocWorkflow(pObjectID As Long) As AdHocWorkflow
            Return New AdHocWorkflow With {
                .AHWF_CMD_LAYOUT_SELECT = SQL_AHW_LAYOUT_SELECT,
                .AHWF_CMD_USR_SELECT = SQL_AHW_USR_SELECT,
                .OBJECT_ID = pObjectID
            }
        End Function
    End Class
End Namespace

