Javascript 获取项目中的“本地项目路径”目录';s`版本控制设置`
前言 这与企业架构师的API及其脚本功能直接相关,与实际的JScript/Javascript关系不大Javascript 获取项目中的“本地项目路径”目录';s`版本控制设置`,javascript,version-control,jscript,enterprise-architect,Javascript,Version Control,Jscript,Enterprise Architect,前言 这与企业架构师的API及其脚本功能直接相关,与实际的JScript/Javascript关系不大 问题: 如何使用EA的脚本API在项目的版本控制设置中获取本地项目路径目录 注意:[Package].XMLPath仅提供相对于该位置的路径,这在我的情况下是不可用的 背景 尝试创建脚本,使用EA的通用SCC版本控制设置和脚本功能将EA项目中的所有包添加到我们的版本控制软件(MKS/PTC Integrity) 我已经设置了版本控制,并将其链接到我们VC软件的本地项目,并且能够很好地使用内
问题: 如何使用EA的脚本API在项目的
版本控制设置
中获取本地项目路径
目录
注意:[Package].XMLPath
仅提供相对于该位置的路径,这在我的情况下是不可用的
背景 尝试创建脚本,使用EA的通用SCC版本控制设置和脚本功能将EA项目中的所有包添加到我们的版本控制软件(MKS/PTC Integrity) 我已经设置了版本控制,并将其链接到我们VC软件的本地项目,并且能够很好地使用内置功能
为什么简单的解决方案不起作用 首先,我知道EA有一个
addbranchtoversioncontrol
选项。但是,在将文件签入VC时,如果本地项目目录(沙盒)中不存在filepath中的文件夹,VC将创建目录而不是子项目(不同类型的容器,长话短说:我们需要子项目)
我不能使用EAP文件的位置作为引用路径,因为它不在本地项目目录中(我们在服务器上使用单一的集中式文件)
我目前正在尝试的内容
package.VersionControlAdd
方法将XML文件添加到本地项目目录中的该目录中(不工作!)本地项目路径
我在EA的内置帮助中找不到有关检索此信息的任何引用。只需查看文本文件即可
%appdata%\Sparx Systems\EA\paths.txt
您要查找的值存储在此文件中。没有API。这是EA…重新获得thomas Killian的提示:这里有一个很好的方法-为您的要求编写C代码 访问%appdata%文件夹中的paths.txt文件
string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string localPathsFilePath= System.IO.Path.Combine(appDataFolder, @"Sparx Systems\EA\paths.txt");
有一种解决方案可以从EA脚本(或设置了适当引用的任何其他VBscript/VBA环境)中获取本地版本控制配置。 下面是我的助手类来做这件事;目前它仅限于单个VC配置(我不需要更多,而且我很匆忙…)。 注意,解析XML需要“Msxml2.DOMDocument.6.0”;适当更改版本以适应您的环境
'Language: VBScript
' helper class to get local SVN repository set-up; currently able to deal with single VC configuration only
' version 1.0.0
' (c) MJ, 5/2016
'
const EA_VC_CONF_KEY="HKEY_CURRENT_USER\Software\Sparx Systems\EA400\EA\OPTIONS\VCConfigs"
const SVN_EXE_PATH_KEY="HKEY_CURRENT_USER\Software\Sparx Systems\EA400\EA\OPTIONS\VC_SVNExePath"
const VC_TIMEOUT="HKEY_CURRENT_USER\Software\Sparx Systems\EA400\EA\OPTIONS\VC_TIMEOUT"
const APPDATA_KEY="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\AppData"
class VCConfig
public vcPath 'path to local VC copy
public vcGuid 'ID of the config
public vcLocalPath ' path id
public svnExePath 'version control exe file
public vcTimeout 'command timeout
public function readConfig()
dim WSHShell 'Windows Scripting Host Shell
dim EaVCConf 'version control configurations
dim PathsTxtLocation 'location of the paths.txt file
Set WSHShell = CreateObject("WScript.Shell")
EaVCConf = WSHShell.RegRead(EA_VC_CONF_KEY)
Me.svnExePath = WSHShell.RegRead(SVN_EXE_PATH_KEY)
Me.vcTimeout = WSHShell.RegRead(VC_TIMEOUT)
PathsTxtLocation = WSHShell.RegRead(APPDATA_KEY)
PathsTxtLocation=PathsTxtLocation & "\Sparx Systems\EA\"
set WSHShell = nothing
dim xmldoc 'XML document
dim nodes 'XML nodes
dim node 'XML
dim cfgGUID 'ID of the config
dim cfgPath 'ID of the path
const QUERY_CFG="//Config"
const QUERY_ID="//GUID"
const QUERY_PATH="//LocalPath"
Set xmldoc = CreateObject("Msxml2.DOMDocument.6.0")
xmldoc.loadXML EaVCConf
set nodes = xmldoc.selectNodes (QUERY_CFG)
'session.output "Number of VC configs: " & nodes.length
if nodes.length<>1 then
result=Session.Prompt("More than one configuration of version control present. Can't continue.", promptOk)
exit function
end if
set node=xmldoc.selectSingleNode (QUERY_ID)
Me.vcGuiD=node.Text
set node=xmldoc.selectSingleNode (QUERY_PATH)
Me.vcLocalPath=node.Text
'session.output "Location of paths.txt: " & PathsTxtLocation
dim fso 'FileSystemObject
dim pathsTxtFile 'paths.txt file
dim pathsStream 'text stream
dim pathsString 'string content of the paths.txt file
const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
set pathsStream = fso.OpenTextFile(PathsTxtLocation & "paths.txt",ForReading,false)
pathsString=pathsStream.readline()
dim lo, hi 'integers
lo=instr(pathsString,"path=")
hi=InstrRev(pathsString,";")
pathsString=mid(pathsString,lo+5, (hi)-(lo+5))
'session.output pathsString
Me.vcPath=pathsString
set fso=nothing
'in the file paths.txt: "%PATH%;type=Version Control;id=sa_ea;path=<path>"
'session.output "SVN exe path: " & Me.svnExePath
end function
end class
”语言:VBScript
'帮助器类以获取本地SVN存储库设置;目前只能处理单个VC配置
'版本1.0.0
(c)美赞臣,2016年5月
'
const EA\u VC\u CONF\u KEY=“HKEY\u CURRENT\u USER\Software\Sparx Systems\EA400\EA\OPTIONS\VCConfigs”
const SVN\u EXE\u PATH\u KEY=“HKEY\u CURRENT\u USER\Software\Sparx Systems\EA400\EA\OPTIONS\VC\u SVNExePath”
const VC\u TIMEOUT=“HKEY\u CURRENT\u USER\Software\Sparx Systems\EA400\EA\OPTIONS\VC\u TIMEOUT”
const APPDATA\u KEY=“HKEY\u CURRENT\u USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell文件夹\APPDATA”
类VCConfig
“公共vcPath”指向本地VC副本的路径
配置的公共vcGuid'ID
公共vcLocalPath的路径id
公共svnExePath的版本控制exe文件
“公共vcTimeout”命令超时
公共函数readConfig()
dim WSHShell的Windows脚本主机外壳
dim EaVCConf的版本控制配置
dim PathsTxtLocation“path.txt文件的位置
设置WSHShell=CreateObject(“WScript.Shell”)
EaVCConf=WSHShell.regrad(EA_VC_CONF_键)
Me.svnExePath=WSHShell.regrad(SVN\u EXE\u PATH\u键)
Me.vcTimeout=WSHShell.regrad(VC\u超时)
路径stxtlocation=WSHShell.regrad(APPDATA\u键)
PathsTxtLocation=PathsTxtLocation&“\Sparx Systems\EA\”
设置WSHShell=nothing
dim xmldoc的XML文档
dim节点的XML节点
dim节点的XML
配置的dim cfgGUID'ID
路径的dim cfgPath'ID
const QUERY_CFG=“//配置”
const QUERY_ID=“//GUID”
const QUERY_PATH=“//LocalPath”
设置xmldoc=CreateObject(“Msxml2.DOMDocument.6.0”)
xmldoc.loadXML EaVCConf
set nodes=xmldoc.selectNodes(查询)
“session.output”VC配置的数量:“&nodes.length”
如果是nodes.length1,则
结果=Session.Prompt(“存在多个版本控制配置。无法继续。”,promptOk)
退出功能
如果结束
set node=xmldoc.selectSingleNode(查询ID)
Me.vcGuiD=node.Text
set node=xmldoc.selectSingleNode(查询路径)
Me.vcLocalPath=node.Text
“session.output”path.txt的位置:“&PathsTxtLocation”
dim fso文件系统对象
dim pathsTxtFile“path.txt文件
dim pathsStream的文本流
path.txt文件的dim pathsString字符串内容
常数ForReading=1
设置fso=CreateObject(“Scripting.FileSystemObject”)
设置pathsStream=fso.OpenTextFile(PathsTxtLocation&“paths.txt”,ForReading,false)
pathsString=pathsStream.readline()
dim lo,hi'整数
lo=instr(路径字符串,“路径=”)
hi=InstrRev(路径字符串“;”)
路径字符串=中间(路径字符串,lo+5,(hi)-(lo+5))
'session.output pathsString
Me.vcPath=pathsString
设置fso=无
'在paths.txt文件中:“%PATH%;type=版本控制;id=sa_ea;PATH=”
'session.output“SVN exe路径:”&Me.svnExePath
端函数
末级
@humble.rumble它确实回答了这个问题。版本控制配置的本地路径存储在该文本文件中。@GeertBellekens当我回顾时,我也会遇到类似我的文章。在审查过程中会发生这种情况。我已经习惯了这一点,也习惯了没有动机的反对票…@Thomas Kilian这正是我所需要的,谢谢!对一个经过深思熟虑的问题的简单回答。是的,我想我指的是自动化接口,而不是API的措辞
'Language: VBScript
' helper class to get local SVN repository set-up; currently able to deal with single VC configuration only
' version 1.0.0
' (c) MJ, 5/2016
'
const EA_VC_CONF_KEY="HKEY_CURRENT_USER\Software\Sparx Systems\EA400\EA\OPTIONS\VCConfigs"
const SVN_EXE_PATH_KEY="HKEY_CURRENT_USER\Software\Sparx Systems\EA400\EA\OPTIONS\VC_SVNExePath"
const VC_TIMEOUT="HKEY_CURRENT_USER\Software\Sparx Systems\EA400\EA\OPTIONS\VC_TIMEOUT"
const APPDATA_KEY="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\AppData"
class VCConfig
public vcPath 'path to local VC copy
public vcGuid 'ID of the config
public vcLocalPath ' path id
public svnExePath 'version control exe file
public vcTimeout 'command timeout
public function readConfig()
dim WSHShell 'Windows Scripting Host Shell
dim EaVCConf 'version control configurations
dim PathsTxtLocation 'location of the paths.txt file
Set WSHShell = CreateObject("WScript.Shell")
EaVCConf = WSHShell.RegRead(EA_VC_CONF_KEY)
Me.svnExePath = WSHShell.RegRead(SVN_EXE_PATH_KEY)
Me.vcTimeout = WSHShell.RegRead(VC_TIMEOUT)
PathsTxtLocation = WSHShell.RegRead(APPDATA_KEY)
PathsTxtLocation=PathsTxtLocation & "\Sparx Systems\EA\"
set WSHShell = nothing
dim xmldoc 'XML document
dim nodes 'XML nodes
dim node 'XML
dim cfgGUID 'ID of the config
dim cfgPath 'ID of the path
const QUERY_CFG="//Config"
const QUERY_ID="//GUID"
const QUERY_PATH="//LocalPath"
Set xmldoc = CreateObject("Msxml2.DOMDocument.6.0")
xmldoc.loadXML EaVCConf
set nodes = xmldoc.selectNodes (QUERY_CFG)
'session.output "Number of VC configs: " & nodes.length
if nodes.length<>1 then
result=Session.Prompt("More than one configuration of version control present. Can't continue.", promptOk)
exit function
end if
set node=xmldoc.selectSingleNode (QUERY_ID)
Me.vcGuiD=node.Text
set node=xmldoc.selectSingleNode (QUERY_PATH)
Me.vcLocalPath=node.Text
'session.output "Location of paths.txt: " & PathsTxtLocation
dim fso 'FileSystemObject
dim pathsTxtFile 'paths.txt file
dim pathsStream 'text stream
dim pathsString 'string content of the paths.txt file
const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
set pathsStream = fso.OpenTextFile(PathsTxtLocation & "paths.txt",ForReading,false)
pathsString=pathsStream.readline()
dim lo, hi 'integers
lo=instr(pathsString,"path=")
hi=InstrRev(pathsString,";")
pathsString=mid(pathsString,lo+5, (hi)-(lo+5))
'session.output pathsString
Me.vcPath=pathsString
set fso=nothing
'in the file paths.txt: "%PATH%;type=Version Control;id=sa_ea;path=<path>"
'session.output "SVN exe path: " & Me.svnExePath
end function
end class