Click here to Skip to main content
15,896,726 members
Articles / Web Development / ASP.NET

An Open Source RDL Engine

Rate me:
Please Sign up or sign in to vote.
4.77/5 (12 votes)
20 Dec 2010CPOL3 min read 83.8K   3.5K   55  
An Open Source RDL engine for rendering reports to WinForms or ASP.NET
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace RdlEngine
{
    class DataSet : ReportElement
    {
        private string _name;
        private Dictionary<string, Field> _fields = new Dictionary<string, Field>();
        private Query _query = null;
        private Enums.Auto _caseSensitivity = Enums.Auto.False;
        private string _colation = null;
        private Enums.Auto _accentSensitivity = Enums.Auto.False;
        private Enums.Auto _kanatypeSensitivity = Enums.Auto.False;
        private Enums.Auto _widthSensitivity = Enums.Auto.False;
        private Filters _filters = null;

        private System.Data.DataTable _table = null;

        public DataSet(XmlNode node, ReportElement parent)
            : base(node, parent)
        {
        }

        protected override void ParseAttribute(XmlNode attr)
        {
            switch (attr.Name.ToLower())
            {
                case "name":
                    _name = attr.InnerText;
                    break;
                case "fields":
                    foreach (XmlNode child in attr.ChildNodes)
                    {
                        Field fld = new Field(child, this);
                        _fields.Add(fld.Name, fld);
                    }
                    break;
                case "query":
                    _query = new Query(attr, this);
                    break;
                case "casesensitivity":
                    _caseSensitivity = (Enums.Auto)Enum.Parse(typeof(Enums.Auto), attr.InnerText,true);
                    break;
                case "colation":
                    _colation = attr.InnerText;
                    break;
                case "accentsensitivity":
                    _accentSensitivity = (Enums.Auto)Enum.Parse(typeof(Enums.Auto), attr.InnerText, true);
                    break;
                case "kanatypesensitivity":
                    _kanatypeSensitivity = (Enums.Auto)Enum.Parse(typeof(Enums.Auto), attr.InnerText, true);
                    break;
                case "widthsensitivity":
                    _widthSensitivity = (Enums.Auto)Enum.Parse(typeof(Enums.Auto), attr.InnerText, true);
                    break;
                case "filters":
                    _filters = new Filters(attr, this);
                    break;
                default:
                    break;
            }
        }

        public void Initialize(System.Data.DataSet ds)
        {
            RdlRuntime.InitializeDataSetEventArgs args = new RdlRuntime.InitializeDataSetEventArgs();
            args.DataSetName = _name;

            Report.OnInitializeDataSet(args);
            if (args.dt != null)
                _table = args.dt;
            else
            {
                _query.Exec(ds, _name);
                _table = ds.Tables[_name];
            }
        }

        public string Name
        {
            get { return _name; }
        }

        public Dictionary<string, Field> Fields
        {
            get { return _fields; }
        }

        public System.Data.DataTable Table
        {
            get { return _table; }
        }

        public Int32 Rows
        {
            get { return _table.Rows.Count; }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Sawiki Software
United States United States
I have been a professional software developer for 25+ years, most of it supporting the business community of Maine. I have been working with MS dotnet since 1.0 beta. I organized Sawiki Software LLC as an outlet for some open source software that I have been working on.

Comments and Discussions