Sparx Enterprise Architect使用Powershell创建基准

时间:2018-10-23 14:12:07

标签: powershell-v2.0 enterprise-architect

我想使用PowerShell为我的企业架构师项目中的每个项目自动创建一个基线。

  

如何从PowerShell创建基准?

到目前为止,我的代码已获取我要为其创建新基准的所有IE高级模型包。

$conString = "private connection string"


## implementation do not chage
add-type -path “C:\Program Files (x86)\Sparx Systems\ea\Interop.EA.dll”
$ea = New-Object -ComObject EA.Repository

$ea.OpenFile($conString);

function Process-Packages($packages)
{
  if(!$packages) { throw [System.ArgumentNullException]::new('packages'); }
  if(0 -ge $packages.Count) { return; }

    ## create a baseline for each package
}

foreach($model in $ea.models) 
{ 
  Process-Packages $model.packages;
}

$ea.CloseFile();
$ea.Exit();

更新: 使用VS时,我发现我要查找的对象在 EA.ProjectClass 下 公开了相关功能以创建程序包:

public virtual bool CreateBaseline(string PackageGUID, string Version, string Notes)
    Member of EA.ProjectClass

Summary:
Creates a baseline on the specified package.

Attributes:
[System.Runtime.InteropServices.DispIdAttribute(66)]

并且有相对实现getbaselines

public virtual string GetBaselines(string PackageGUID, string ConnectString)
    Member of EA.ProjectClass

Summary:
Returns an xml string containing the list of guids available for that package.

Attributes:
[System.Runtime.InteropServices.DispIdAttribute(65)]

1 个答案:

答案 0 :(得分:3)

好了,经过Internet dll之后,我发现了一个问题的答案。

解决方案很简单,但是到达那里却很痛苦。

  

请注意,并非所有字段(例如“作者”)都已填写,并且需要进行额外的工作才能使其完全可用。 此过程不会绕过程序包的已配置安全性。

脚本的RAW实现

add-type -path “C:\Program Files (x86)\Sparx Systems\ea\Interop.EA.dll”
$ea = New-Object -ComObject EA.Repository

$ea.OpenFile("private db connection string");

foreach($model in $ea.models) 
{ 
    $eaProject = $ea.GetProjectInterface()
    $eaProject.CreateBaseline($model.PackageGUID,"9.9.9","PowerShell generated")
}

$ea.CloseFile();
$ea.Exit();

处理信息

如评论中所述,这是耗时的过程。对我来说,在22k对象上运行此PowerShell,在i3 intel / 4GB RAM上大约需要一个小时