获取某个结点的所有层
感谢网友Jache在我的blog上提出一个问题:
AX has 16 layers, we have over-layering problems just like the code in syp will cover sys. I want to wrote a tool to solve this problem. But now I don't know how can I get all the layers in one method. Such as method1() has sys syp dis layers. But how can I know it with codes?
我的理解Jache应该是想获取某个方法在多少层上曾经修改过,并且要获取某个方法在某一层的代码,在这里记录一下:
1.获取某个方法在哪些层上修改过
这里以类LedgerBalanceSheetDimPrint的方法buildRowsCalcList为例,该方法在SYS,SYP,GLS,GLP层上修改过.
static void GetLayersOfOneMethod(Args _args)
{
#AOT
TreeNode treeNode = TreeNode::findNode(#ClassesPath+"\\LedgerBalanceSheetDimPrint\\buildRowsCalcList");
int layers = treeNode.applObjectLayerMask();
UtilEntryLevel level;
UtilEntryLevel currentLevel;
int i;
;
for(i=0;i<enumcnt(UtilEntryLevel);i++)
{
if (layers & (1 << i))
{
currentLevel = i;
print currentLevel;
}
}
pause;
}
{
#AOT
TreeNode treeNode = TreeNode::findNode(#ClassesPath+"\\LedgerBalanceSheetDimPrint\\buildRowsCalcList");
int layers = treeNode.applObjectLayerMask();
UtilEntryLevel level;
UtilEntryLevel currentLevel;
int i;
;
for(i=0;i<enumcnt(UtilEntryLevel);i++)
{
if (layers & (1 << i))
{
currentLevel = i;
print currentLevel;
}
}
pause;
}
2.获取某一层的源代码
static void GetSomeLayerSourceOfOneMethod(Args _args)
{
#AOT
TreeNode treeNode = TreeNode::findNode(#ClassesPath+"\\LedgerBalanceSheetDimPrint\\buildRowsCalcList");
;
treeNode = treeNode.getNodeInLayer(UtilEntryLevel::glp);
info(treeNode.AOTgetSource());
}
{
#AOT
TreeNode treeNode = TreeNode::findNode(#ClassesPath+"\\LedgerBalanceSheetDimPrint\\buildRowsCalcList");
;
treeNode = treeNode.getNodeInLayer(UtilEntryLevel::glp);
info(treeNode.AOTgetSource());
}