• AX SSRS report data helper


    While we develop a ax ssrs report often using 'Business Logic' rather than 'AX Queries'. The 'Business Logic' is base on a AX class, there is a static method return a data type as 'System.Data.DataTable'.  While using the 'DataTable' type, we need to define the data columns frequently. It is a boring job. So I define a data helper to help to reduce the boring process. 

    Note: Befor using the helper, it needs to assign the code permission.

      InteropPermission    InteropPermission;
      ;
      interopPermission = new InteropPermission(InteropKind::ClrInterop);
        interopPermission.assert();
    
        //Helper code
    
        CodeAccessPermission::revertAssert();
    

      

    public class DataHelperNewSRS
    {
        System.Data.DataTable               g_DataTable;
        System.Data.DataColumnCollection    g_DataColumnCon;
        System.Data.DataRowCollection       g_DataRowCon;
        System.Data.DataRow                 g_DataRow;
    
        List                                g_List;
        Container                           g_Con;
    }
    
    void run()
    {
        ;
    
        this.init();
        this.fetchData();
    }
    
    protected void init()
    {
        ;
    
        g_DataTable     = new System.Data.DataTable();
        g_DataColumnCon = g_DataTable.get_Columns();
        g_DataRowCon    = g_DataTable.get_Rows();
        g_List          = new List(Types::Container);
    }
    
    protected void fetchData()
    {
        ;
    
        //Fetch the data here
    }
    
    protected void insertColumns(str _Name, Types _DataType, boolean _IsEnd = false)
    {
        ;
    
        g_List.addEnd([_Name, _DataType]);
    
        if (_IsEnd)
            this.insertColumns_DEL();
    }
    
    private void insertColumns_DEL()
    {
        ListEnumerator      m_LE;
        str                 m_Name, m_Type;
        Types               m_DataType;
        int                 i;
        ;
    
        m_LE = g_List.getEnumerator();
    
        while (m_LE.moveNext())
        {
            [m_Name, m_DataType] = m_LE.current();
    
            m_Type = this.getDataType(m_DataType);
            g_DataColumnCon.Add(m_Name, System.Type::GetType(m_Type));
    
            i++;
            g_Con = conins(g_Con, i, m_Name);
        }
    
    }
    
    private str getDataType(Types _DataType)
    {
        ;
    
        switch (_DataType)
        {
            case Types::String   : return "System.String";
            case Types::Integer  : return "System.Int32";
            case Types::Int64    : return "System.Int64";
            case Types::Date     : return "System.DateTime";
            case Types::Real     : return "System.Decimal";
        }
    
        return "System.String";
    }
    
    protected void insertDataRows(container _con)
    {
        int         i, m_RecNum = conlen(_con);
        str         m_Name;
        anytype     m_Data;
        ;
    
        g_DataRow = g_DataTable.NewRow();
    
        for (i = 1; i <= m_RecNum; i++)
        {
            m_Name = conpeek(g_Con, i);
            m_Data = conpeek(_con, i);
    
            g_DataRow.set_Item(m_Name, m_Data);
        }
    
        g_DataRowCon.Add(g_DataRow);
    
    }
    
    System.Data.DataTable getData()
    {
        ;
    
        return g_DataTable;
    }
    

      

  • 相关阅读:
    【转】聚集索引和非聚集索引的区别
    【转】【Android游戏开发十三】(保存游戏数据 [下文])详解SQLite存储方式,并把SQLite的数据库文件存储在SD卡中!!!
    【转】数据库范式(1NF 2NF 3NF BCNF)详解一
    【转】数据库 无损连接分解
    如何防止被路由器限速如何更改电脑网卡的MAC地址
    BZOJ 1497 最大权闭合图
    POJ 1966 无向图点联通度 最小割
    POJ 1815 最小割
    POJ 2987 最大权闭合图
    POJ 2391 floyd+二分+最大流
  • 原文地址:https://www.cnblogs.com/Jinnchu/p/4103973.html
Copyright © 2020-2023  润新知