我創建了一個導出AOT(應用程序對象樹)對象的方法。 它的工作原理,但是當我導出Forms-Treenodes無法找到它。Dynamics AX 4.0導出表格
該方法是一種服務器方法,它在BatchServer上運行。
我的想法是每2小時將對象導出爲xpo文件。 通過備份,我可以跟蹤代碼更改。
void run(str Path)
{
List _ValueList = new List(Types::String);
Counter _ListCounter;
ListIterator _ListIterator;
str _RootFolder;
str _FileName;
str _FolderName;
TreeNode _TreeNode;
TreeNode _InnerTreeNode;
TreeNodeIterator _TreeNodeIt;
FileIoPermission _Perm;
#define.ExportMode("w")
;
_RootFolder = Path;
//Objektbaum definition
_ValueList.addEnd("Forms");
_ValueList.addEnd("Reports");
_ValueList.addEnd("Queries");
_ValueList.addEnd("Classes");
_ValueList.addEnd("Macros");
_ValueList.addEnd("Jobs");
_ValueList.addEnd(@"Data Dictionary\Tables");
_ValueList.addEnd(@"Data Dictionary\Maps");
_ValueList.addEnd(@"Data Dictionary\Views");
_ValueList.addEnd(@"Data Dictionary\Extended Data Types");
_ValueList.addEnd(@"Data Dictionary\Base Enums");
_ListIterator = new ListIterator(_ValueList);
info(strfmt("RootExportPath: %1",_RootFolder));
// durch die zuvor definierte Liste laufen
while(_ListIterator.more())
{
try
{
info(strfmt(@"\%1",_ListIterator.value()));
//Haupttreenode objekt laden
_TreeNode = TreeNode::findNode(strfmt(@"\%1",_ListIterator.value()));
if (_TreeNode != null)
{
//Splitten des HauptNodes
_TreeNodeIt = _TreeNode.AOTiterator();
_InnerTreeNode = _TreeNodeIt.next();
//Durchlaufen der SubNodes
info(strfmt("Object found in Node: %1 ",_TreeNode.AOTchildNodeCount()));
while(_InnerTreeNode)
{
//Pfad und Filename bereitstellen
_FolderName = strfmt(@"%1\%2",_RootFolder,strreplace(_ListIterator.value(),@" ","_"));
_FileName = strfmt(@"\%1.xpo",strreplace(_InnerTreeNode.AOTname(),@" ","_"));
//Fileperms setzen ("w") = Write (OverWrite)
_Perm = new FileIoPermission(_FolderName+_FileName , #ExportMode);
if (_Perm == null)
{
return;
}
_Perm.assert();
try
{
if(!WinApi::pathExists(_FolderName))
{
if(WinApi::createDirectory(_FolderName))
{
throw error(strfmt("Pfad konnte nicht erstellt werden %1\n",_FolderName));
}
if(!WinApi::pathExists(_FolderName))
{
throw error(strfmt("Fehler beim erstellen des Pfades %1\n",_FolderName));
}
}
//Export in definierten Filename
if(WinApi::fileLocked(_FolderName+_FileName))
{
throw error("File ist ReadOnly\n");
}
_InnerTreeNode.treeNodeExport(_Foldername+_FileName);
}
catch
{
error(strfmt(@"xpo File %1 konnte nicht geschrieben werden\n",_FolderName+_Filename));
throw error("Abbruch des Jobs\n");
}
CodeAccessPermission::revertAssert();
_InnerTreeNode = _TreeNodeIt.next();
}
// BP deviation documented.
_TreeNode.treeNodeExport(_FileName);
}
else
{
error(strfmt("TreeNode empty %1",_ListIterator.value()));
}
}
catch
{
throw error("Fehler in der Verarbeitungsroutine\n");
}
_ListIterator.next();
}
}
你的問題是什麼? –