Diagram is not getting created in QEA repository and creating a journal file. However, elements are getting created and saved as well.
However, this works with QEAX repositories.
internal class Class1
{
public static void Main()
{
// connect to user1
var path = "path";
var repository = new EA.Repository();
repository.SuppressSecurityDialog = true;
repository.SuppressEADialogs = true;
var isOpened = repository.OpenFile2(path, "username", "password");
//create
string packagePath = "path";
Package package = getpackage(repository, packagePath);
//create diagram syncuser
Diagram diagram = package.Diagrams.AddNew(EAConstants.OH_CREATE_TEMPLATE, "Use Case");
diagram.Name = "hello";
diagram.Update();
repository.ReloadDiagram(diagram.DiagramID);
repository.OpenDiagram(diagram.DiagramID);
repository.SaveDiagram(diagram.DiagramID);
repository.CloseDiagram(diagram.DiagramID);
}
private static Package getpackage(Repository repository, string packagePath)
{
//get packages
Dictionary<string, string> packageStructure = new Dictionary<string, string>();
foreach (Package model in repository.Models)
{
//Getting all the packages under a particular module.
EAUtility.ConstructHierarchy(model, "", packageStructure, false);
}
//find package id
string packageGUID = null;
foreach (KeyValuePair<string, string> pair in packageStructure)
{
if (packagePath.Equals(pair.Value))
{
packageGUID = pair.Key;
break;
}
}
Package package = repository.GetPackageByGuid(packageGUID);
return package;
}
}