Inside Dynamics Axapta源代码赏析(四)

第八章:Developing Applications Using Business Connector
这一章的代码主要演示如何通过Business Connector与Axapta交互
在Dynamics Axapta的客户端安装目录中找到Microsoft.Dynamics.BusinessConnectorNet.dll这个文件,添加到VS.NET的工程中.
1.HelloWorldBC.cs

None.gif class  HelloWorldBC
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif {
InBlock.gif        
static void Main(string[] args)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Axapta ax;
InBlock.gif
InBlock.gif            
// Log on to Dynamics AX
InBlock.gif
            ax = new Axapta();
InBlock.gif
InBlock.gif            
try
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                ax.Logon(
nullnullnullnull);
ExpandedSubBlockEnd.gif            }

InBlock.gif            
catch (Exception)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Console.WriteLine(
"Exception occurred during logon");
ExpandedSubBlockEnd.gif            }

InBlock.gif            
InBlock.gif            Console.WriteLine(
"Hello World!");
InBlock.gif            
InBlock.gif            
// Log off from Dynamics AX
InBlock.gif
            ax.Logoff();
InBlock.gif
ExpandedSubBlockEnd.gif        }

ExpandedBlockEnd.gif    }
好久没用VS2005了,今天用了一下,智能提示忒爽了,Axapta编辑器也快点好起来吧......
搞不清楚四个参数都填null是怎么找到AOS的?本来想用Reflector反编译一下Microsoft.Dynamics.BusinessConnectorNet.dll,结果出来的是乱七八糟的东西,唉,忒不友好了......
2.AccessingDataBC.cs
遍历所有的料品,并打印料品Id和料品名称.
None.gif   //  Instantiate a Dynamics AX record object for the 
None.gif            
//  record we want to work with
None.gif
            AxaptaRecord axRecord  =  ax.CreateAxaptaRecord( " InventTable " );
None.gif            
None.gif            
//  Execute a query against the record 
None.gif
            axRecord.ExecuteStmt( " select * from %1 " );
None.gif
None.gif            
//  Loop through the returned records
None.gif            
//  Extract the data from two fields for each record
None.gif
             while  (axRecord.Found)
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif {
InBlock.gif                invItemName 
= axRecord.get_Field(invItemNameField);
InBlock.gif                invItemId 
= axRecord.get_Field(invItemIdField);
InBlock.gif
InBlock.gif                Console.WriteLine(invItemId 
+ "\t" + invItemName);
InBlock.gif
InBlock.gif                
// Go to the next record
InBlock.gif
                axRecord.Next();
ExpandedBlockEnd.gif            }
3.InvokingBusinessLogicBC.cs
调用Axapta中的静态方法.
None.gif   //  Invoke the CallStaticClassMethod managed class
None.gif                
//  Provide the X++ class name and method to execute
None.gif                
//  The return value is placed into returnValue
None.gif
                returnValue  =  ax.CallStaticClassMethod( " InventoryManager " ,
None.gif                            
" updateInventoryQty " );
None.gif
None.gif                
//  Use the return value to take some action
None.gif
                 if ((Boolean)returnValue)
None.gif                    Console.WriteLine(
" Inventory quantity updated successfully " );
None.gif                
else
None.gif                    Console.WriteLine(
" Inventory quantity update failed " );

其中的类InventoryManager在工程InsideDynamicsAXChapter8中定义.

这些连接和简单的操作倒还可以,不过Axapta的接口和SDK写得确实不甘恭维......

转载于:https://www.cnblogs.com/Farseer1215/archive/2006/09/26/515255.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值