最近在做一个Wizard,需要操作AOT,用代码创建project,Table,Form,EDT等,刚试了一下用代码添加project,并在project中添加内容,唉,再次谴责Axapta的文档,一些系统类的说明居然什么都没有!
static void CrateProjectAndAddNodes(Args _args)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
TreeNode TNode;
ProjectNode PNode;
;
//得到project的根结点
TNode = infolog.projectRootNode();
//这个根结点只有两个子结点,Private和Shared,第一个结点就是Private
TNode= TNode.AOTfirstChild();
//在Private Project中查找要插入的结点
if(!TNode.AOTfindChild("FarseerTest"))
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
//新增
TNode.AOTadd("FarseerTest");
//查找,这个地方有个隐式转化,在C#中这种转化是不允许的.
PNode = TNode.AOTfindChild("FarseerTest");
PNode = PNode.getRunNode();
//增加元素
PNode.addUtilNode(utilElementtype::Form,tableStr(custTrans));
PNode.addUtilNode(utilElementType::Table,tablestr(custTable));
//编译
PNode.AOTcompile(1);
PNode.AOTcompile(1);
//保存
PNode.AOTsave() ;
}
else
throw error(strFmt("The Project %1 has been exist!","FarseerTest"));
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
}