I am trying to use a C# Script to recreate Enterprise Architects functionality get all latest. I have succeeded at scanning every package and looking if its version controlled with the following code:
Collection models = eaRepository.Models;
foreach (Package package in models) {
resolveRecursivelyGetLatestOnPackage(package);
}
eaRepository.ScanXMIAndReconcile();
Console.WriteLine("GetLatestFinished.");
private void resolveRecursivelyGetLatestOnPackage(Package package)
{
if (package.IsVersionControlled) {
package.VersionControlGetLatest(false);
}
foreach (Package childPackage in package.Packages) {
resolveRecursivelyGetLatestOnPackage(childPackage);
}
}
However the EAP model I am using this on is quite big and the upper code takes a lot of time since it scans through all packages. Therefore I am trying to get all version Controlled packages by using the Select statement.
SELECT *
FROM t_package
WHERE IsControlled = True
Sadly I have found no way to receive a collection of packages in the automation interface of EA.
What I have tried so far:
eArepository.GetElementSet ("SELECT * FROM t_package WHERE IsControlled = True", false);
eArepository.SQLQuery ("SELECT * FROM t_package WHERE IsControlled = True");
The getElementSet does returns an empty collection, since it is no elements I am searching for.
The SQL query seems to return what I want, but in the wrong format. I don't know how to get packages out of the XML it returns. Is there a way to do this?
How do I get a collection of all version controlled Packages Fast?
You should only query the package ID's using the query and then use
Repository.GetPackageByID()
to get theEA.Package
object.The query then becomes
You can use an operation similar to this operation from the Enterprise Architect Addin Framework