• Using X++ Modify Table and class name From AOT Project


    Wrote by Jimmy on DEC.2th 2010
    1)  create to a Customized table(class),table(class) name need to add the short for company Name referred to as the prefix;
        then table field/method name is not necessary add short for company name;
    2)  add the table field/method name need to add the short for company name referred to as a prefix on a system table or class

    using x++ code modify tableName and fieldName or className and classmethod name for define customization
    such as table name prefix "QVS_" as our  short name for company from AOT Private Project (Project1)

    代码
    static void Jimmy_ModifyTableAndClassFromProject(Args _args)
    {
    /***
    Wrote by Jimmy on DEC.2th 2010
    1) create to a Customized table(class),table(class) name need to add the short for company Name referred to as the prefix;
    then table field/method name is not necessary add short for company name;
    2) add the table field/method name need to add the short for company name referred to as a prefix on a system table or class

    using x++ code modify tableName and fieldName or className and classmethod name for define customization
    such as table name prefix "QVS_" as our short name for company from AOT Private Project (Project1)
    */
    #TreeNodeSysNodeType
    #define.prefix("QVS_")
    #define.ProjectName("Project1")
    ProjectGroupNode pNode;
    TreeNodeIterator projectIt;
    TreeNode projectListNode
    = SysTreeNode::getPrivateProject();
    ProjectNode projectNode
    = projectListNode.AOTfindChild(#ProjectName);

    //Only has current Layers?
    Boolean onlyCurrentLayer(TreeNode _treeNode)
    {
    int layers = _treeNode.applObjectLayerMask();
    UtilEntryLevel level;
    UtilEntryLevel currentLevel;
    int i,j=0;
    ;
    for(i=0;i<enumcnt(UtilEntryLevel);i++)
    {
    if (layers & (1 << i))
    {
    currentLevel
    = i;
    j
    ++;
    }
    }
    if(j == 1 && currentLevel == infolog.currentAOLayer())
    return true;
    return false;

    }
    //Modify Classes and Tables
    void modify(TreeNode _treeNode)
    {
    str property;
    TreeNode childTreeNode;
    SysDictClass SysDictClass;
    name tableName,fieldName;
    name className,classMethodName;
    int i;
    ;
    switch(_treeNode.sysNodeType())
    {
    case #NT_DBTABLE:
    {
    //Modify TableName
    if(onlyCurrentLayer(_treeNode))
    {
    tableName
    = tableId2Name(_treeNode.applObjectId());
    if(substr(tableName,1,4) != #prefix)
    _treeNode.AOTsetProperty(
    "Name",#Prefix + tableName);
    }

    //Modify field Name
    childTreeNode = _treeNode.AOTfirstChild().AOTfirstChild();
    while(childTreeNode)
    {
    if(!onlyCurrentLayer(_treeNode) && onlyCurrentLayer(childTreeNode))
    {
    fieldName
    = fieldId2Name(_treeNode.applObjectId(),childTreeNode.applObjectId());
    if(substr(fieldName,1,4) != #prefix)
    {
    childTreeNode.AOTsetProperty(
    "Name",#Prefix + fieldName);
    childTreeNode.AOTcompile(
    1);
    childTreeNode.AOTsave();
    }
    }
    childTreeNode
    = childTreeNode.AOTnextSibling();

    }
    //Save
    _treeNode.AOTcompile(1);
    _treeNode.AOTsave();
    //Synchronize Table
    appl.dbSynchronize(SysDictTable::newTreeNode(_treeNode).id());
    break;
    }
    case #NT_CLASS :
    {
    //Modify className
    if(onlyCurrentLayer(_treeNode))
    {
    className
    = ClassId2Name(_treeNode.applObjectId());
    if(substr(className,1,4) != #prefix)
    _treeNode.AOTsetProperty(
    "Name",#Prefix + className);
    }
    //Modify method Name on this class
    childTreeNode = _treeNode.AOTfirstChild();
    SysDictClass
    = new SysDictClass(_treeNode.applObjectId());
    i
    = 0;
    while(childTreeNode)
    {
    if(!onlyCurrentLayer(_treeNode) && onlyCurrentLayer(childTreeNode))
    {
    info(int2str(_treeNode.applObjectId()));
    classMethodName
    = SysDictClass.objectMethodObject(i).name();
    info(classMethodName);
    if(classMethodName && substr(classMethodName,1,4) != #prefix)
    {
    childTreeNode.AOTsetProperty(
    "Name",#Prefix + classMethodName);

    childTreeNode.AOTcompile(
    1);//It look like throw waring....?????
    childTreeNode.AOTsave();
    }
    }
    childTreeNode
    = childTreeNode.AOTnextSibling();
    i
    ++;
    }
    //Save
    _treeNode.AOTcompile(1);
    _treeNode.AOTsave();
    break;
    }
    default : break;
    }
    }

    //Get the classes and tables to be modify
    void getElementsToBeModified(TreeNode _treeNode)
    {
    TreeNodeIterator projectGroupIt;
    TreeNode projectSuperNode,projectGroupNode;
    ;
    if(!_treeNode)
    return;

    //Project Group
    if(_treeNode.sysNodeType() == #NT_PROJECT_GROUP)
    {
    projectGroupIt
    = _treeNode.AOTiterator();
    projectGroupNode
    = projectGroupIt.next();
    while(projectGroupNode != null)
    {
    getElementsToBeModified(projectGroupNode);
    projectGroupNode
    = projectGroupIt.next();
    }
    }
    else
    info(strfmt(
    "Modify object : %1", _treeNode.toString()));
    modify(_treeNode);
    }
    ;
    projectNode
    = projectNode.getRunNode();
    projectIt
    = projectNode.AOTiterator();
    pNode
    = projectIt.next();

    while(pNode)
    {
    getElementsToBeModified(pNode);
    pNode
    = projectIt.next();
    }
    }
  • 相关阅读:
    cocos2d-x之物理引擎初试
    cocos2d-x之猜数字游戏
    cocos2d-x之加法计算器
    cocos2d-x之悦动的小球
    cocos2d-x之多个移动的小球
    cocos2d-x之json文件读取初试
    cocos2d-x之xml文件读取初试
    cocos2d-x之使用plist文件初试
    cocos2d-x之文件读写
    cocos2d-x之首选项数据初试
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1894678.html
Copyright © 2020-2023  润新知