zoukankan      html  css  js  c++  java
  • Infolog in the Dynamics AX 2009

     

    Wel all know the small dialog that gives the user usefull information about what is happening in Ax. In this post I will tell u some more about this.

    You can add information to the Infolog by calling:

    • Infolog.add(…)
    • info(…)
    • warning(…) or checkfailed(…)
    • error(…)
    • You can add some structure in it by using setPrefix(…)
    • Using the Proxy-class for the Enterprise Portal




    The info(), warning() and error() method are found in the Global class and can contain up to 3 arguments:

    • a string (mandatory) : the string that is added to the infolog
    • a path to the Axapta Help (optional)
    • an Infolog action (optional) : you can use this parameter to initiate a action, for example open the code editor or open a parameter-form when some parameters are missing. Depending on what action you want to trigger, you need to call the right method that extend from sysInfoAction.
    1234
    SysInfoAction   sysInfoAction;;sysInfoAction = SysInfoAction_Formrun::newFormname(formstr(HRMParameters));info("click on me", "", sysInfoAction);




    Using the keyword Throw before info(), error() or warning will result in terminating the execution (or jump to catch statement) and a rollback of your transactions.

    1
    throw error("Something bad happend");




    The method setPrefix() will help you to group info(), warning() and error() messages with a header. using setPrefix() will make a indentation for your current block of code (everything between { and }). Leaving the code-block will automatically result in going one indentation back.

    1234567891011121314
    int i;int j;;setPrefix("Testing out setPrefix")for (i=1 ; i<=2 ; i++){setPrefix(strfmt("Prefix %1", i))for (j=1 ; j<=3 ; j++){info(strfmt("Info %1", j));}}




    The checkFailed() method is a warning() method that returns a Boolean (alwais false). U can use this method when you want to display a warning and directly set a return value to false.

    1234567
    Boolean ret;;if (true){    ret = checkFailed("Something is wrong");}return ret;




    Note: The infolog can contain maximum 10000 lines. So try to limit the use of it. Building the output of the infolog usually happens at the end of the code you are executing and depending on the number of lines, it can take a while. You can limit the maximum number of lines under a header in a batch by setting the property infolog.errorsPerBatch(#)(). When this number is exceeded only the furst # will appear and Ax will give you a notification that their could be more errors.
    It is also possible to update the infolog while executing code by calling the method infolog.viewUpdate().


    Using the infolog in the Enterprise Portal:
    In the portal you can access the infolog by using the Proxy of the Enterprise Portal.

    12
    using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;Proxy.Info objInfoLog = new Proxy.Info(this.AxSession.AxaptaAdapter);

    Now, when you want to write something to the infolog you need to give a Enum with it, so the portal knows if the message you want to show is a info, warning or error. So pass through Proxy.Exception.Info, Proxy.Exception.Warning or Proxy.Exception.Error.

    1
    objInfoLog.add(Proxy.Exception.Warning, "My warning");



    So in short thing you should keep in mind while using the Infolog-class:

    • Use short & informative messages
    • Choose the righty message level (info, warning, error)
    • Use actions, this simple trick is verry usefull for end-users
    • Limit the number of messages you send to the Infolog-dialog
  • 相关阅读:
    创始人透露Twitter新盈利计划:第三方将受益
    试试ScribeFire转发我的其它博客
    2009年12月30日:新网因清除URL转发域名导致DNS解析故障
    VS2008 如果更改源代码管理插件,将关闭活动解决方案或项目
    Linq使用Group By经验总结
    使用C#的BitmapData
    Java与C#开发上的一些差异与转换方法
    成都七中成绩文件导入SQL脚本
    用SQL SERVER对EXCEL数据进行处理
    NULLIF和ISNULL
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1920751.html
Copyright © 2011-2022 走看看