I know how to iterate through the model and get the steps and I know how to get a list of tables, but how do I get the "parent" of a table, the DictionaryStep. I know it can be done because the DevToolBox will set the attribute of the class.
This is what the toolbox will create:
[Dictionary("EDS table container 01.pv_Budgetmaal", 1, ReleaseState.Released)]
Here I can see what dictionary step that the table is created in. I would like to get the same info from the model data somehow.
To get all tables:
private void ListTables()
{
try
{
SoTable[] sotables = SoDatabase.GetCurrent().Dictionary.Tables;
LogHelper.Log("Total number of tables: {0}", sotables.Length);
foreach (SoTable sotable in sotables)
{
LogHelper.Log("Table name: {0}. Number: {1}. Sequence id: {2}.", sotable.Name, sotable.TableNumber, sotable.SequenceId);;
}
}
catch (Exception ex)
{
LogHelper.Log(string.Format("[Error]:Error during get table list.\r\nDetails: {0}", ex.Message));
}
}
Here is to get the dictionary steps:
private void ListContainers()
{
try
{
var curdb = SoDatabase.GetCurrent();
string ConnectionString = curdb.ConnectionString.Replace("[@Server]", curdb.Server).Replace("[@Database]", curdb.Database).Replace("[@User]", curdb.DBUser).Replace("[@Password]", curdb.DbPassword);
var dbManagement = DatabaseManagement.CreateInstance(curdb.DatabaseMajor, curdb.DatabaseMinor, curdb.TablePrefix, DbConnectionProvider.GetConnection(ConnectionString, curdb.DatabaseMajor, curdb.DatabaseMinor));
var databaseModel = dbManagement.ReadDatabaseModel();
LogHelper.Log("Total number of containers: {0}", databaseModel.DictionarySteps.Count);
foreach (DictionaryStepInfo step in databaseModel.DictionarySteps)
{
LogHelper.Log("Container name: {0}. Step number: {1}. State: {2}. Description: {3}", step.Name, step.StepNumber, step.State, step.Description);
}
}
catch (Exception ex)
{
LogHelper.Log(string.Format("[Error]:Error during get container list.\r\nDetails: {0}", ex.Message));
}
}