Sparx 企业架构师使用 powershell 创建基线
Sparx Enterprise architect Create baseline using powershell
我想使用 PowerShell 为我的企业架构师项目中的每个项目自动创建基线。
How do you create a baseline from 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)]
好的,通过互联网 dll 后,我找到了我的问题的答案。
解决方案相当简单,但实现起来很痛苦。
Please note, not all fields such as Author are populated and additional work is required to make it fully usable solution. This process does bypass configured security for packages.
脚本的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 上需要大约一个小时
我想使用 PowerShell 为我的企业架构师项目中的每个项目自动创建基线。
How do you create a baseline from 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)]
好的,通过互联网 dll 后,我找到了我的问题的答案。
解决方案相当简单,但实现起来很痛苦。
Please note, not all fields such as Author are populated and additional work is required to make it fully usable solution. This process does bypass configured security for packages.
脚本的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 上需要大约一个小时