问题
I am attempting to programmatically duplicate the following steps in X++
- In the AOT Tree right click on the root node and click "Export"
- Provide a file name
- Click the "Application object layer" checkbox
- Specify "cus" as the Application object layer
- Export the XPO to the file
I've gotten as far as bring able to export entire AOT tree but I can't figure out a way to narrow it down to just the cus layer. Here is my current code sample ...
TreeNode treeNode;
FileIoPermission perm;
#define.ExportFile(@"c:\XPO\AOTCusExport.xpo")
#define.ExportMode("w")
;
perm = new FileIoPermission(#ExportFile, #ExportMode);
if (perm == null)
{
return;
}
perm.assert();
treeNode = TreeNode::findNode(@"\");
if (treeNode != null)
{
// BP deviation documented.
treeNode.treeNodeExport(#ExportFile);
}
CodeAccessPermission::revertAssert();
I have a feeling that the solution lies within the "treeNodeExport" method. There is an "int _flags" property that I am not using. I've looked around but I'm not sure what value to populate the flags with? Has anyone attempted this kind of process duplication before? Am I heading down the right path?
回答1:
Please have a look on the AOTExport
macro.
Then read this:
#AOT
#AOTExport
TreeNode rootNode = infolog.rootNode();
;
rootNode.treeNodeExport(@'c:\fullaot.xpo', #expKeepIds | #expLables | #expLayer);
I am not sure on how to specify the layers, but it is most likely just a logical OR on the flag argument.
If in doubt take a look on the SysElementExport
form and related classes.
Update: as expected the layer is specified in the bitmask.
In \Forms\SysExportDialog\Methods\getutilLayer
the mask is specified as:
return 1 << layer.selection();
So if you want to export the CUS layer you do:
rootNode.treeNodeExport(@'c:\fullaot.xpo', #export | #expLayer | (1 << (UtilEntryLevel::cus+1)));
There is room for 15 bits for layers as the next flag is:
#define.expKeepIds(0x0100)
回答2:
You have an example of how to pass flags to the method in the SysTreeNode.toFile()
class method
#AOTExport
...
int flags;
...
flags = #expProjectOnly;
...
// This code runs on the client side only
//BP deviation documented
treenodeToExport.treeNodeExport(_filename, #export | #expKeepIds | #expLayer | flags);
...
According to the macro documentation:
// System export flags
#define.noExport(0) // Do not export
#define.export(1) // Export
#define.expKeepIds(0x0100) // Export with ID's
#define.expLables(0x0400) // Export labels
#define.expProjectOnly(0x800) // Export project only
#define.expLockOnExport(0x1000) // Lock exported elements
#define.expDefaultValues(0x2000) // Export default properties values
#define.expLayer(0x4000) // Export current layer only
you can only export the active layer... what is very strange, as form let you choose a layer from the list. It's a bit more strange when you get inside the SysExportDialog
form code, where the list is and the export class is called, and you can't find the layer usage anywhere... so that, may be the macro documentation is right after all.
来源:https://stackoverflow.com/questions/15166313/how-to-mimic-the-aot-export-by-layer-functionality-x