代码之家  ›  专栏  ›  技术社区  ›  cpoDesign

Sparx Enterprise architect使用powershell创建基线

  •  1
  • cpoDesign  · 技术社区  · 7 年前

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

    到目前为止,我的代码得到了我想要创建新基线的所有模型,即高级包。

    $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时,我发现我要查找的对象在

    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 回复  |  直到 7 年前
        1
  •  3
  •   cpoDesign    7 年前

    好的,在浏览了互联网动态链接库之后,我找到了问题的答案。

    解决方案相当简单,但要做到这一点很痛苦。

    请注意 ,并不是所有字段(如Author)都已填充,并且需要额外的工作才能使其完全可用。 此过程不会绕过包的已配置安全性。

    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上大约需要一个小时