Create AOT Project
Autor: Arnaldo Ono | Publicado: 2012-10-09T15:28:00-03:00


static void CreateAotProject(Args _args)
{
&nbsp; &nbsp; #AOT
&nbsp; &nbsp; ProjectNode projectNode;
&nbsp; &nbsp; TreeNode projRoot;
&nbsp; &nbsp; ProjectGroupNode parentGroup;

&nbsp; &nbsp; ProjectNode createProject(str _name)
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; TreeNode proj;
&nbsp; &nbsp; &nbsp; &nbsp; ProjectNode newProj;
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; str projectName = _name;
&nbsp; &nbsp; &nbsp; &nbsp; int i;
&nbsp; &nbsp; &nbsp; &nbsp; ;
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; proj = SysTreeNode::getPrivateProject();
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; while (proj.AOTfindChild(projectName))
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i++;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; projectName = strfmt('%1_%2', _name, i);
&nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; proj.AOTadd(projectName);

&nbsp; &nbsp; &nbsp; &nbsp; newProj = proj.AOTfindChild(projectName);
&nbsp; &nbsp; &nbsp; &nbsp; return newProj.getRunNode();
&nbsp; &nbsp; }

&nbsp; &nbsp; ProjectGroupNode addGroup(ProjectGroupNode _parent, GroupNodeType _groupNodeType, str _name)
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; ProjectGroupNode child;
&nbsp; &nbsp; &nbsp; &nbsp; ProjectGroupNode parent;
&nbsp; &nbsp; &nbsp; &nbsp; TreeNodeName nodeName;
&nbsp; &nbsp; &nbsp; &nbsp; ;
&nbsp; &nbsp; &nbsp; &nbsp; parent = _parent;
&nbsp; &nbsp; &nbsp; &nbsp; nodeName = SysTreeNode::pathName(_name);
&nbsp; &nbsp; &nbsp; &nbsp; parent.AOTadd(nodeName);
&nbsp; &nbsp; &nbsp; &nbsp; child = parent.AOTfindChild(_name);

&nbsp; &nbsp; &nbsp; &nbsp; if (child)
&nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; child.projectGroupType(_groupNodeType);
&nbsp; &nbsp; &nbsp; &nbsp; }

&nbsp; &nbsp; &nbsp; &nbsp; return child;
&nbsp; &nbsp; }
&nbsp; &nbsp; ;

&nbsp; &nbsp; projectNode = createProject('NewProject');

&nbsp; &nbsp; projectNode.lockUpdate();
&nbsp; &nbsp; projRoot = projectNode;

&nbsp; &nbsp; parentGroup = addGroup(projRoot, GroupNodeType::MenuItems, 'MenuItems');
&nbsp; &nbsp; addGroup(parentGroup, GroupNodeType::Action, 'Action');
&nbsp; &nbsp; addGroup(parentGroup, GroupNodeType::Output, 'Output');
&nbsp; &nbsp; addGroup(parentGroup, GroupNodeType::Display, 'Display');

&nbsp; &nbsp; addGroup(projRoot, GroupNodeType::Menus, 'Menus');
&nbsp; &nbsp; addGroup(projRoot, GroupNodeType::Jobs, 'Jobs');
&nbsp; &nbsp; addGroup(projRoot, GroupNodeType::Forms, 'Forms');
&nbsp; &nbsp; addGroup(projRoot, GroupNodeType::Classes, 'Classes');
&nbsp; &nbsp; addGroup(projRoot, GroupNodeType::Macros, 'Macros');

&nbsp; &nbsp; parentGroup = addGroup(projRoot, GroupNodeType::DataDictionary, 'DataDictionary');
&nbsp; &nbsp; addGroup(parentGroup, GroupNodeType::SecurityKeys, 'SecurityKeys');
&nbsp; &nbsp; addGroup(parentGroup, GroupNodeType::ConfigurationKeys, 'ConfigurationKeys');
&nbsp; &nbsp; addGroup(parentGroup, GroupNodeType::BaseEnums, 'BaseEnums');
&nbsp; &nbsp; addGroup(parentGroup, GroupNodeType::Tables, 'Tables');

&nbsp; &nbsp; projectNode.AOTsave();
&nbsp; &nbsp; projectNode.unlockUpdate();
&nbsp; &nbsp; projectNode.AOTrun();
}