Importing Linked Universes

Problem

Let’s assume there are two universes: Base and Derived. The Derived universe is linked to Base (Base does not have any link to other universes).

If you are importing Derived and then Base using .NET Designer SDK – everything is ok.

Universe derivedUnv = application.Universes.OpenFromEnterprise("", "Derived", false);
Universe baseUnv = application.Universes.OpenFromEnterprise("", "Base", false);

If you try to import Base and then Derived, import of the Derived universe will fail with the error: ‘Base’ is already open. Please close it and try again.

Let’s assume that we need to import a bunch of universes. The derived universes should be imported first, and the base universes should be imported last. How to determine if the universe is a base universe?

“Solution”

For me the most simple and working solution has been to avoid problem. I usually process universes one-by-one, i.e. I do not import many universes.

Solution

A solution is to query CMS to get the list of base universes:

List<String> list = new List<string>();

CrystalDecisions.Enterprise.InfoObjects unv_objects =
    infoStore.Query("SELECT * FROM CI_APPOBJECTS WHERE SI_KIND = 'Universe' "
                   +"AND SI_DERIVEDUNIVERSE.SI_TOTAL>0");

foreach (CrystalDecisions.Enterprise.InfoObject unv_object in unv_objects)
{
    list.Add(unv_object.CUID);
}

Now you can import the derived universes:

foreach (StoredUniverse unv in src_folder.StoredUniverses)
{
    if (!list.Contains(unv.CUID))
    {
        application.Universes.OpenFromEnterprise(src_path, unv.Name, false);
    }
}

and then the base universes:

foreach (StoredUniverse unv in src_folder.StoredUniverses)
{
    if (list.Contains(unv.CUID))
    {
        application.Universes.OpenFromEnterprise(src_path, unv.Name, false);
    }
}

Details

Let me know if you need details or complete code..

1 thought on “Importing Linked Universes

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s