Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Enterprise Architect中将公共表中的列添加到新表中_Javascript_Vbscript_Enterprise Architect - Fatal编程技术网

Javascript 如何在Enterprise Architect中将公共表中的列添加到新表中

Javascript 如何在Enterprise Architect中将公共表中的列添加到新表中,javascript,vbscript,enterprise-architect,Javascript,Vbscript,Enterprise Architect,我正在使用EnterpriseArchitect10工具为SQL数据库设计模式 每次向EA模式添加一个新表(比如“Name”和“Description”列),都必须向新表添加公共列(UserId、Status、Role、15个这样的列) 目标表列=源表列+公共表列 目标表应具有列-名称、描述、用户ID、状态和角色 我有100多个表,无法手动将所有公共列添加到每个表中 当我添加新表并执行脚本时,是否有任何规定或脚本(javascript或vbscript)可以执行此操作 --尝试后添加了此代码 !

我正在使用EnterpriseArchitect10工具为SQL数据库设计模式

每次向EA模式添加一个新表(比如“Name”和“Description”列),都必须向新表添加公共列(UserId、Status、Role、15个这样的列)

目标表列=源表列+公共表列

目标表应具有列-名称、描述、用户ID、状态和角色

我有100多个表,无法手动将所有公共列添加到每个表中

当我添加新表并执行脚本时,是否有任何规定或脚本(javascript或vbscript)可以执行此操作

--尝试后添加了此代码

!INC Local Scripts.EAConstants-JScript
/* *脚本名称: *作者: *目的: *日期: */

函数main() { //TODO:在此处输入脚本代码! //显示脚本输出窗口 存储库。确保输出可见(“脚本”)

但我不清楚要复制所有属性的目标表

请帮忙

谢谢,,
Ramm

首先,您可以使用一个模板包,其中放置了包含列的公共表

要回顾性地执行此操作,您可以使用内部脚本支持。转到工具->EA中的脚本,并查找“VBScript-属性生命周期示例”或“JScript-属性生命周期示例”以查看如何从元素中添加/删除属性

// Get the currently selected element in the tree to work on
var theElement as EA.Element;
var theDestElement as EA.Element;

theElement = Repository.GetTreeSelectedObject();
//theDestElement = Repository.GetTreeSelectedObject();
//theDestElement.Name='Newtable1';

if( theElement != null && theElement.ObjectType == otElement)
{

    Session.Output( "Working on element '" + theElement.Name + "' (Type=" + theElement.Type +
        ", ID=" + theElement.ElementID + ")" );



    var srcAttributes as EA.Collection;
    srcAttributes = theElement.Attributes;

    theDestElement = Repository.
    Session.Output(theDestElement);
    theDestElement.Name='NewTable1';
    var dstAttributes as EA.Collection;
    dstAttributes = theDestElement.Attributes;

    newAttribute = null;

    // List attributes
    for ( var i = 0 ; i < srcAttributes.Count ; i++ )
    {
        var currentAttribute as EA.Attribute;
        currentAttribute = srcAttributes.GetAt( i );
        dstAttributes.AddNew(currentAttribute.,currentAttribute);
        //theDestElement


        Session.Output( "Attribute: " + currentAttribute.Name  );
    }

    Session.Output( "Done!" );

}

else
{
    // No item selected in the tree, or the item selected was not an element
    Session.Prompt( "This script requires an element be selected in the Project Browser.\n" +
        "Please select an element in the Project Browser and try again.", promptOK );
}
theElement = Repository.GetTreeSelectedObject();