如何解决Enterprise Architect 模型的脚本导出
我正在研究一个存储在 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
中放入什么,您可以连接到您的数据库项目,然后保存为快捷方式。
然后在文本编辑器中打开生成的文件,您将找到所需的连接字符串。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。