Adding DMS Tab to a Module

1. Add xModule-Control to the new created Tab

Design Mode

XAML Code:

<tl:xDockTabItem Header="DMS" Name="tabDMS" Uid="4352f300-c8a7-430f-a10a-bd291d2a3de6" IsEnabled="False">
    <tl:xGrid Uid="d68e9eec-9a33-4eae-96ab-d8884dae960d">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <tl:xModule Name="xModDMS" Grid.Row="0" Grid.Column="0" ModuleID="modDMS3" IsEnabled="True" />
    </tl:xGrid>
</tl:xDockTabItem>

2. Initialize and load DMS Control

public xModule DmsModule
{
    get
    {
        return this.GetControlByNameAndTyp<xModule>("xModDMS");
    }
}

public IxDmsModule DmsControl
{
    get
    {
        if (DmsModule == null) return null;
        return DmsModule.ModuleWHO as IxDmsModule;
    }
}
public virtual void InitDms()
{            
    if (DmsControl != null)
    {
        DmsControl.Init(hybrid, "proz_charg");
    }
}

For newly created tables or hybrids, the connection between the DMS-tables and the current table will be done by creating a SQL Command for inserting a new record in dms_class, dms_categories, dms_tree and dms_treepos.

$START
-- create the dms class
if not exists (select * from dms_class where id = 'my_dms_class') then
    insert into dms_class("id", "matchcode", "default_category")
    values ('my_dms_class', 'My-Class', null)
endif;
 
-- create a dms category for the class and set it as default
if not exists (select * from dms_categories where class='my_dms_class') then
    insert into dms_categories (id, class, matchcode, default_arch_type, default_arch_zeitraum, hybrid)
    values ((select max(id) from dms_categories) + 1, 'my_dms_class', 'Standard', null, null, 'DMS_CATEGORY^'||(select max(id) from dms_categories) + 1);
    update dms_class set default_category=(select max(id) from dms_categories)
    where id='my_dms_class';
endif;
 
--create a dms tree for the class
if not exists (select * from dms_tree where ref_hybrid='my_dms_class') then
    insert into dms_tree (nr, "type", ref_hybrid)
    values (((select coalesce( max(nr), 1) from dms_tree) + 1), 1, 'my_dms_class')
endif;
 
-- create a tree root node for the class as well as a default folder
if not exists(select * from dms_treepos where treenr = (select nr from dms_tree where ref_hybrid = 'my_dms_class') and handle = 0) then
    insert into dms_treepos (treenr, handle, lnode, rnode, "info", dms_class_id, typ, hybrid)
    values ((select nr from dms_tree where ref_hybrid = 'my_dms_class'),0,1,4,'My-Class','my_dms_class',10,'DMS_TREEPOS^'||CAST((select nr from dms_tree where ref_hybrid='my_dms_class') AS INTEGER)||'^0');
    insert into dms_treepos (treenr, handle, lnode, rnode, "info", dms_class_id, dms_categories_id, typ, hybrid)
    values ((select nr from dms_tree where ref_hybrid = 'my_dms_class'),1,2,3,'Standard','my_dms_class',(select default_category from dms_class where "id"= 'my_dms_class'), 20,'DMS_TREEPOS^'||CAST((select nr from dms_tree where ref_hybrid='my_dms_class') AS INTEGER)||'^1');


-- create the virtual node for emails
    insert into dms_treepos (treenr, handle, lnode, rnode, "info", dms_class_id, dms_categories_id, typ, content_type, hybrid)
    values ((select nr from dms_tree where ref_hybrid = 'my_dms_class'),2,4,5,'E-Mails','my_dms_class',(select default_category from dms_class where "id"= 'my_dms_class'), 20, 10, 'DMS_TREEPOS^'||CAST((select nr from dms_tree where ref_hybrid='my_dms_class') AS INTEGER)||'^2');
-------------------------------------------------------------------------------------------------------------------
endif;

$ENDE

If you need to add the E-Mails folder to an already existing hybrid dms tree, use the following script:

$START
IF NOT EXISTS (SELECT 1 FROM dms_treepos where content_type=10 AND treenr=(SELECT nr FROM dms_tree WHERE ref_hybrid='my_dms_class')) THEN 
    INSERT INTO dms_treepos (treenr, handle, hybrid, lnode, rnode, "info", dms_class_id, dms_categories_id, typ, content_type)
    VALUES 
    (
        (SELECT nr FROM dms_tree WHERE ref_hybrid='my_dms_class'),
        (SELECT max(handle)+1 FROM dms_treepos WHERE treenr=(SELECT nr FROM dms_tree WHERE ref_hybrid='my_dms_class')),
        (string('DMS_TREEPOS^',(SELECT nr FROM dms_tree WHERE ref_hybrid='my_dms_class'),'^',(SELECT max(handle)+1 FROM dms_treepos WHERE treenr=(SELECT nr FROM dms_tree WHERE ref_hybrid='my_dms_class')))),
        (SELECT lnode+2 FROM dms_treepos WHERE treenr=(SELECT nr FROM dms_tree WHERE ref_hybrid='my_dms_class') AND handle=1),
        (SELECT rnode+2 FROM dms_treepos WHERE treenr=(SELECT nr FROM dms_tree WHERE ref_hybrid='my_dms_class') AND handle=1),
        'E-Mails',
        'my_dms_class',
        (SELECT default_category FROM dms_class WHERE "id"='my_dms_class'), 
        20, 
        10
    );
    UPDATE dms_treepos SET rnode=rnode+2 WHERE treenr=(select nr from dms_tree where ref_hybrid='my_dms_class') AND handle=0;
END IF;
$ENDE

Last updated