用代码创建扩展数据类型EDT

在Axapta中有两个类UtilElements和UtilIdElements,从Inside Microsoft Axapta4.0中的示例代码中,可以看到两者的应用.帮助文档一点记载都没有......
我们知道Axapta把AOT的信息以*.aod后缀文件方式存放在物理磁盘中.这两个类的功能就是可以让用户用SQL的方式查询AOT中的元素,UtilElementType这个枚举类型有很多AOT中结点的类型值,比如Form,Report等,下面的示例代码显示了查询Inventory相关的类.
None.gif static   void  TableAPI_FindInventoryClasses(Args _args)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    UtilElements utilElements;
InBlock.gif
InBlock.gif    
while select name from utilElements
InBlock.gif        where utilElements.RecordType 
== UtilElementType::Class
InBlock.gif           
&& utilElements.Name like 'Invent*'
InBlock.gif           
&& utilElements.ModifiedDate == today()-30
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        info(strfmt(
"%1", utilElements.Name));
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}
按照我的理解,UtilElement只能操作大的方面,对具体元素的操作还是要靠TreeNode这个类.
不过在Axapta3.0中,TreeNode这个对象并没有增加EDT的方法,用AOTAdd()这个方法加其他元素没啥问题,加EDT死活不玩,服了.后来在狂找一气,发现了下面的方法
None.gif UtilIdElements uie; 
None.gif
None.gifselect maxof(id) from uie where uie.recordType 
==  
None.gifUtilElementType::ExtendedType 
&&  uie.utilLevel  ==  XInfo.currentAOLayer(); 
None.gif
None.gifuie.id
++
None.gifuie.utilLevel 
=  XInfo.currentAOLayer(); 
None.gifuie.recordType 
=  UtilElementType::ExtendedType; 
None.gifuie.name 
=   " FarseerTest "
None.gif
None.gifuie.insert(); 
加倒是加上去了,可是一点击这个新建的EDT旁边的加号,或者点右键,用英文说就是Axapta Crash了,晕死......
好在Axapta4.0的TreeNode增加了一个方法AOTaddExtendedDataType,估计是微软被吵得实在过意不去了,增加了这个方法来平息众怒,呵呵.
None.gif static  server  void  AddEDT()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    TreeNode TNode;
InBlock.gif    str strEDTName;
InBlock.gif    str strProperty;
InBlock.gif    ;
InBlock.gif    
//属性
InBlock.gif
    strProperty = @"Properties
InBlock.gif                    Label #Farseer  Test
InBlock.gif                    HelpText #Farseer Test
InBlock.gif                    Extends #AccountName
InBlock.gif                    EndProperties
InBlock.gif                    
";
InBlock.gif    strEDTName 
= "FarseerTest";
InBlock.gif    
//找到EDT结点
InBlock.gif
    TNode = TreeNode::findNode(@"Data Dictionary\Extended Data Types");
InBlock.gif    
//不存在添加,存在报错.
InBlock.gif
    if(!TNode.AOTfindChild(strEDTName))
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        TNode 
= TNode.AOTaddExtendedDataType(strEDTName,Types::String);
InBlock.gif        TNode.AOTsetProperties(strProperty);
InBlock.gif        Box::info(
"Successful!");
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
InBlock.gif        
throw error(strFmt("The EDT %1 has been exist","Farseer"));
ExpandedBlockEnd.gif }

转载于:https://www.cnblogs.com/Farseer1215/archive/2006/09/29/518480.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值