将本地 Enterprise Architect 项目设置保存到数据库服务器

问题描述 投票:0回答:3

是否可以将本地 Sparx Enterprise Architect 项目首选项(开始 > 首选项)保存到数据库服务器?

我们通过数据库共享项目,并更改了项目的一些设置,这些设置似乎没有保存到数据库中,我怀疑它们只保存在本地 Windows 注册表中。

enterprise-architect
3个回答
1
投票

EA 中有两种类型的偏好:

用户偏好

  • 通过开始 | 访问外观|偏好设置
  • 这些设置大部分都存储在注册表中:Computer\HKEY_CURRENT_USER\Software\Sparx Systems\EA400\EA\OPTIONS

型号偏好

  • 通过设置|访问型号|选项
  • 这些设置存储在存储库本身中。

EA 不支持开箱即用地在模型级别设置用户设置。

使用 EA-Matic 的解决方案

EA-Matic是我自己编写的免费开源插件。
它支持执行脚本作为对事件的反应,例如

EA_FileOpen()
使用下面的脚本是为了确保存储库的每个用户都具有相同的设置。

它基本上检查许多注册表值,并在需要时更新它们。由于 EA 仅在启动时读取注册表,因此脚本会在更新设置后关闭 EA,并要求用户重新启动它。

'[path=\Projects\EA-Matic Scripts]
'[group=EA-Matic]
option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Script Name: Fix Mandatory User Settings
' Author: Geert Bellekens
' Purpose: Check the mandatory user settings in the registry and set them correctly if needed
' Date: 2019-11-05
'

'EA-Matic

const REG_SZ = "REG_SZ"
const REG_DWORD = "REG_DWORD"
const REG_BINARY = "REG_BINARY"

function fixSettings
    dim regPath
    Dim regkey
    dim regValue
    dim existingValue
    'place in the registry that contains all of the user settings
    regPath = "HKEY_CURRENT_USER\Software\Sparx Systems\EA400\EA\OPTIONS\"
    'get the EA version
    dim eaVersion
    eaVersion = Repository.LibraryVersion
    
    dim settingsValid
    settingsValid = true
    'Fontname13 is only relevant for V15
    if eaVersion > 1300 then
        settingsValid = settingsValid AND validateRegValue(regPath, "FONTNAME13","Arial", REG_SZ)
    else
        settingsValid = settingsValid AND validateRegValue(regPath, "FONTNAME","Arial", REG_SZ)
    end if
    settingsValid = settingsValid AND validateRegValue(regPath, "SAVE_CLIP_FRAME","1", REG_DWORD)
    settingsValid = settingsValid AND validateRegValue(regPath, "PRINT_IMAGE_FRAME","1", REG_DWORD)
    settingsValid = settingsValid AND validateRegValue(regPath, "SAVE_IMAGE_FRAME","1", REG_DWORD)
    settingsValid = settingsValid AND validateRegValue(regPath, "SORT_FEATURES","0", REG_DWORD)
    settingsValid = settingsValid AND validateRegValue(regPath, "ALLOW_DUPLICATE_TAGS","1", REG_DWORD)
    
    if not settingsValid then
        msgbox "Mandatory user settings have been corrected." & vbNewLine & "Please restart EA",vbOKOnly+vbExclamation,"Corrected mandatory user settings!" 
        Repository.Exit
    end if
        
end function

function validateRegValue(regPath, regKey, regValue, regType)
    Dim shell
    ' Create the Shell object
    Set shell = CreateObject("WScript.Shell")
    dim existingValue
    on error resume next
    'read registry value
    existingValue = shell.RegRead(regPath & regkey)
    'if the key doesn't exist then RegRead throws an error
    If Err.Number <> 0 Then
        existingValue = ""
        Err.Clear
    end if
    on error goto 0
    'check the value in the registry with the desired value
    if Cstr(existingValue) <> regValue then
        'write the correct value to the registry
        shell.RegWrite regPath & regkey, regValue, regType
        'return false
        validateRegValue = false
    else
        'value was already OK, return true
        validateRegValue = true
    end if
end function

function EA_FileOpen()
     fixSettings
end function

0
投票

除了 Geerts 的出色回答之外,我还想补充一点,您可以通过在打开 EA 时向命令行提供选项来更改选项的注册表位置(转到注册表而不是数据库)。

例如如果您使用

调用 EA
"C:\Program Files (x86)\Sparx Systems\EA\EA.exe" /regkey:P1

它将创建/访问密钥

HKEY_CURRENT_USER\Software\Sparx Systems\P1
而不是默认的
\EA400

选项本身可以在下面的

OPTIONS
键下找到。

这使您有机会处理开箱即用的不同设置。至少对于这些选项,Sparx 决定使用注册表而不是数据库。 (编者注:无论如何,这都将是一个选项丛林)


0
投票

这很有趣。 谢谢瓦尔。 真挚地, 西蒙

© www.soinside.com 2019 - 2024. All rights reserved.