Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging

Public Class ClassNodeCommands
    Inherits BaseClass

    Private ReadOnly Database As MSSQLServer

    Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
        MyBase.New(pLogConfig)
        Database = pDatabase
    End Sub

    Public Async Function LoadNodes(pEntityId As Integer) As Task(Of DataTable)
        Dim oStructureNodeSql = $"SELECT 
                T.GUID,
                T.RECORD_ID,
                T.NODE_CONFIG_ID,
                T.NODE_CAPTION,
                T.ID1, 
                T.BACK_COLOR,
                T.PARENT_GUID,
                T.SEQUENCE,
                T.TYPE_NODE,
                T.CREATE_RECORD
             FROM 
                VWPMO_STRUCTURE_NODES T 
            INNER JOIN VWPMO_CONSTRUCTOR_FORMS T1 ON T.ENTITY_ID = T1.FORM_ID 
            WHERE T.ENTITY_ID = {pEntityId}"
        Dim oTable = Await Database.GetDatatableAsync(oStructureNodeSql)

        Return oTable
    End Function
End Class
