Enterprise Architect 模型的脚本导出
Scripted Export of Enterprise Architect Model
我正在研究一个存储在 Postgresql 数据库中的模型。存在一个 eapx 文件,用于访问此模型。
是否可以编写脚本,自动将模型导出到 XML 文件或类似文件,以创建常规快照?
您可以使用 EA.Project.ProjectTransfer()
将模型导出到 eap(x) 文件。
这是一个示例 vbs 脚本,可以通过在 windows 资源管理器中双击它来执行。
option explicit
' Purpose: Automated Project Transfer from DBMS to EAP file as weekly backup. See end of script for different databases that are backed up.
const logPath = "C:\shares\Backups\LogFile\"
const backupPath = "C:\shares\Backups\"
sub main
EADEV
MsgBox ("Back-up Finished.")
end sub
sub EADEV
Dim CurrentDate
Currentdate = (Year(Date) & (Right(String(2,"0") & Month(Date), 2)) & (Right(String(2,"0") & Day(Date), 2))) 'yyyymmdd'
dim repository
dim projectInterface
set repository = CreateObject("EA.Repository")
Dim FileName
Filename = "EA_Export.eap"
dim LogFilePath
LogFilePath = logPath&CurrentDate & " EA DEV (back-up).log"
dim TargetFilePath
TargetFilePath = logPath & "EA_Export.eap"
dim eapString
eapString = "DBType=1;Connect=Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DB_Name;Data Source=ServerName;LazyLoad=1;"
'get project interface
set projectInterface = repository.GetProjectInterface()
projectInterface.ProjectTransfer eapString, TargetFilePath, LogFilePath
'close EA
repository.Exit
Dim newFilename
newFilename = backupPath & CurrentDate & " EA DEV (back-up).eap"
Dim Fso
Set Fso = WScript.CreateObject("Scripting.FileSystemObject")
Fso.MoveFile TargetFilePath, newFileName
end sub
main
为了知道要在 eapString
中放入什么,您可以连接到您的数据库项目,然后另存为快捷方式。
然后在文本编辑器中打开生成的文件,您将找到所需的连接字符串。
我正在研究一个存储在 Postgresql 数据库中的模型。存在一个 eapx 文件,用于访问此模型。 是否可以编写脚本,自动将模型导出到 XML 文件或类似文件,以创建常规快照?
您可以使用 EA.Project.ProjectTransfer()
将模型导出到 eap(x) 文件。
这是一个示例 vbs 脚本,可以通过在 windows 资源管理器中双击它来执行。
option explicit
' Purpose: Automated Project Transfer from DBMS to EAP file as weekly backup. See end of script for different databases that are backed up.
const logPath = "C:\shares\Backups\LogFile\"
const backupPath = "C:\shares\Backups\"
sub main
EADEV
MsgBox ("Back-up Finished.")
end sub
sub EADEV
Dim CurrentDate
Currentdate = (Year(Date) & (Right(String(2,"0") & Month(Date), 2)) & (Right(String(2,"0") & Day(Date), 2))) 'yyyymmdd'
dim repository
dim projectInterface
set repository = CreateObject("EA.Repository")
Dim FileName
Filename = "EA_Export.eap"
dim LogFilePath
LogFilePath = logPath&CurrentDate & " EA DEV (back-up).log"
dim TargetFilePath
TargetFilePath = logPath & "EA_Export.eap"
dim eapString
eapString = "DBType=1;Connect=Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DB_Name;Data Source=ServerName;LazyLoad=1;"
'get project interface
set projectInterface = repository.GetProjectInterface()
projectInterface.ProjectTransfer eapString, TargetFilePath, LogFilePath
'close EA
repository.Exit
Dim newFilename
newFilename = backupPath & CurrentDate & " EA DEV (back-up).eap"
Dim Fso
Set Fso = WScript.CreateObject("Scripting.FileSystemObject")
Fso.MoveFile TargetFilePath, newFileName
end sub
main
为了知道要在 eapString
中放入什么,您可以连接到您的数据库项目,然后另存为快捷方式。
然后在文本编辑器中打开生成的文件,您将找到所需的连接字符串。