Skip to content

Instantly share code, notes, and snippets.

@andyhuey
Last active December 16, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyhuey/5470950 to your computer and use it in GitHub Desktop.
Save andyhuey/5470950 to your computer and use it in GitHub Desktop.
AX - export all active projects
public void exportAllProjects()
{
// get the project list, and export all projects.
Array projects;
int i;
ProjectNode sharedProjects, privateProjects, projectNode;
str myDocsPath, filePath;
#WinAPI
myDocsPath = WinAPI::getFolderPath(#CSIDL_PERSONAL);
myDocsPath += @"\xpo_backup";
// make sure myDocsPath exists.
if (!WinAPI::pathExists(myDocsPath))
{
WinAPI::createDirectoryPath(myDocsPath);
}
projects = this.getProjectList();
sharedProjects = Infolog.projectRootNode().AOTfindChild('Shared');
if (!sharedProjects)
throw error("Error: cannot located shared project node!" );
privateProjects = Infolog.projectRootNode().AOTfindChild('Private');
if (!privateProjects)
throw error("Error: cannot located private project node!" );
for (i= 1; i <= projects.lastIndex(); i++)
{
// skip any line starting with a semi-colon
if (subStr (projects.value(i), 1, 1) == ";" )
continue;
projectNode = sharedProjects.AOTfindChild(projects.value(i));
if (!ProjectNode)
projectNode = privateProjects.AOTfindChild(projects.value(i));
if (projectNode)
{
filePath = myDocsPath + @"\" + projects.value(i) + ".xpo" ;
projectNode.treeNodeExport(filePath);
}
else
warning(strFmt("Project %1 cannot be found." , projects.value(i)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment