Exemple #1
1
        List<TableGroup> _Items;			// list of TableGroup entries

		internal TableGroups(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			TableGroup tg;
            _Items = new List<TableGroup>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "TableGroup":
						tg = new TableGroup(r, this, xNodeLoop);
						break;
					default:	
						tg=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown TableGroups element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (tg != null)
					_Items.Add(tg);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For TableGroups at least one TableGroup is required.");
			else
                _Items.TrimExcess();
		}
        List<ParameterValue> _Items; // list of ParameterValue

        #endregion Fields

        #region Constructors

        internal ParameterValues(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            ParameterValue pv;
            _Items = new List<ParameterValue>();
            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "ParameterValue":
                        pv = new ParameterValue(r, this, xNodeLoop);
                        break;
                    default:
                        pv=null;		// don't know what this is
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown ParameterValues element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
                if (pv != null)
                    _Items.Add(pv);
            }

            if (_Items.Count == 0)
                OwnerReport.rl.LogError(8, "For ParameterValues at least one ParameterValue is required.");
            else
                _Items.TrimExcess();
        }
Exemple #3
0
        List<StaticColumn> _Items;			// list of StaticColumn

		internal StaticColumns(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			StaticColumn sc;
            _Items = new List<StaticColumn>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "StaticColumn":
						sc = new StaticColumn(r, this, xNodeLoop);
						break;
					default:	
						sc=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown StaticColumns element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (sc != null)
					_Items.Add(sc);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For StaticColumns at least one StaticColumn is required.");
			else
                _Items.TrimExcess();
		}
        bool _ContainsArray;                   // true if any of the parameters is an array reference

		internal QueryParameters(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
            _ContainsArray = false;
			QueryParameter q;
            _Items = new List<QueryParameter>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "QueryParameter":
						q = new QueryParameter(r, this, xNodeLoop);
						break;
					default:	
						q=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown QueryParameters element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (q != null)
					_Items.Add(q);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For QueryParameters at least one QueryParameter is required.");
			else
                _Items.TrimExcess();
		}
Exemple #5
0
        List<SortBy> _Items; // list of SortBy

        #endregion Fields

        #region Constructors

        internal Sorting(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            SortBy s;
            _Items = new List<SortBy>();
            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "SortBy":
                        s = new SortBy(r, this, xNodeLoop);
                        break;
                    default:
                        s=null;		// don't know what this is
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown Sorting element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
                if (s != null)
                    _Items.Add(s);
            }
            if (_Items.Count == 0)
                OwnerReport.rl.LogError(8, "Sorting requires at least one SortBy be defined.");
            else
                _Items.TrimExcess();
        }
        List<SeriesGrouping> _Items;			// list of SeriesGrouping

		internal SeriesGroupings(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			SeriesGrouping sg;
            _Items = new List<SeriesGrouping>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "SeriesGrouping":
						sg = new SeriesGrouping(r, this, xNodeLoop);
						break;
					default:
						sg=null;		// don't know what this is
						break;
				}
				if (sg != null)
					_Items.Add(sg);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For SeriesGroupings at least one SeriesGrouping is required.");
			else
                _Items.TrimExcess();
		}
        List<ChartSeries> _Items;			// list of chart series

		internal ChartData(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			ChartSeries cs;
            _Items = new List<ChartSeries>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "ChartSeries":
						cs = new ChartSeries(r, this, xNodeLoop);
						break;
					default:	
						cs=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown ChartData element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (cs != null)
					_Items.Add(cs);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For ChartData at least one ChartSeries is required.");
			else
                _Items.TrimExcess();
		}
Exemple #8
0
        List<TableCell> _Items;			// list of TableCell

		internal TableCells(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			TableCell tc;
            _Items = new List<TableCell>();
			// Loop thru all the child nodes
			int colIndex=0;			// keep track of the column numbers
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "TableCell":
						tc = new TableCell(r, this, xNodeLoop, colIndex);
						colIndex += tc.ColSpan;
						break;
					default:	
						tc=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown TableCells element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (tc != null)
					_Items.Add(tc);
			}
			if (_Items.Count > 0)
                _Items.TrimExcess();
		}
        List<Filter> _Items;			// list of Filter

		internal Filters(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			Filter f;
            _Items = new List<Filter>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "Filter":
						f = new Filter(r, this, xNodeLoop);
						break;
					default:	
						f=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown Filters element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (f != null)
					_Items.Add(f);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "Filters require at least one Filter be defined.");
			else
				_Items.TrimExcess();
		}
Exemple #10
0
        List<DataPoint> _Items;			// list of datapoint

		internal DataPoints(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			DataPoint dp;
            _Items = new List<DataPoint>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "DataPoint":
						dp = new DataPoint(r, this, xNodeLoop);
						break;
					default:	
						dp=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown DataPoints element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (dp != null)
					_Items.Add(dp);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For DataPoints at least one DataPoint is required.");
			else
                _Items.TrimExcess();
		}
        List<GroupExpression> _Items;			// list of GroupExpression

		internal GroupExpressions(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			GroupExpression g;
            _Items = new List<GroupExpression>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "GroupExpression":
						g = new GroupExpression(r, this, xNodeLoop);
						break;
					default:	
						g=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown GroupExpressions element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (g != null)
					_Items.Add(g);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "GroupExpressions require at least one GroupExpression be defined.");
			else
                _Items.TrimExcess();
		}
Exemple #12
0
		internal ColumnGroupings(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			ColumnGrouping g;
            _Items = new List<ColumnGrouping>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "ColumnGrouping":
						g = new ColumnGrouping(r, this, xNodeLoop);
						break;
					default:	
						g=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown ColumnGroupings element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (g != null)
					_Items.Add(g);
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For ColumnGroups at least one ColumnGrouping is required.");
			else
			{
                _Items.TrimExcess();
				_StaticCount = GetStaticCount();
			}
		}
        List<CodeModule> _Items; // list of code module

        #endregion Fields

        #region Constructors

        internal CodeModules(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            _Items = new List<CodeModule>();
            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                if (xNodeLoop.Name == "CodeModule")
                {
                    CodeModule cm = new CodeModule(r, this, xNodeLoop);
                    _Items.Add(cm);
                }
                else
                {
                    // don't know this element - log it
                    OwnerReport.rl.LogError(4, "Unknown CodeModules element '" + xNodeLoop.Name + "' ignored.");
                }
            }
            if (_Items.Count == 0)
                OwnerReport.rl.LogError(8, "For CodeModules at least one CodeModule is required.");
            else
                _Items.TrimExcess();
        }
Exemple #14
0
        List<MatrixRow> _Items; // list of MatrixRow

        #endregion Fields

        #region Constructors

        internal MatrixRows(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            MatrixRow m;
            _Items = new List<MatrixRow>();
            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "MatrixRow":
                        m = new MatrixRow(r, this, xNodeLoop);
                        break;
                    default:
                        m=null;		// don't know what this is
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown MatrixRows element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
                if (m != null)
                    _Items.Add(m);
            }
            if (_Items.Count == 0)
                OwnerReport.rl.LogError(8, "For MatrixRows at least one MatrixRow is required.");
            else
                _Items.TrimExcess();
        }
        List<DrillthroughParameter> _Items;			// list of report items

		internal DrillthroughParameters(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			DrillthroughParameter d;
            _Items = new List<DrillthroughParameter>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "Parameter":
						d = new DrillthroughParameter(r, this, xNodeLoop);
						break;
					default:	
						d=null;		// don't know what this is
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown Parameters element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
				if (d != null)
					_Items.Add(d);
			}
			if (_Items.Count > 0)
                _Items.TrimExcess();
		}
Exemple #16
0
        List<ReportClass> _Items;			// list of report class

		internal Classes(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
            _Items = new List<ReportClass>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				if (xNodeLoop.Name == "Class")
				{
					ReportClass rc = new ReportClass(r, this, xNodeLoop);
					_Items.Add(rc);
				}
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For Classes at least one Class is required.");
			else
                _Items.TrimExcess();
		}
        List<EmbeddedImage> _Items;			// list of EmbeddedImage

		internal EmbeddedImages(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
            _Items = new List<EmbeddedImage>();
			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				if (xNodeLoop.Name == "EmbeddedImage")
				{
					EmbeddedImage ei = new EmbeddedImage(r, this, xNodeLoop);
					_Items.Add(ei);
				}
				else
					this.OwnerReport.rl.LogError(4, "Unknown Report element '" + xNodeLoop.Name + "' ignored.");
			}
			if (_Items.Count == 0)
				OwnerReport.rl.LogError(8, "For EmbeddedImages at least one EmbeddedImage is required.");
			else
                _Items.TrimExcess();
		}
Exemple #18
0
        internal void SetData(Report rpt, IEnumerable ie, Fields flds, Filters f, bool collection = false)
        {
            if (ie == null)                             // Does user want to remove user data?
            {
                SetMyUserData(rpt, null);
                return;
            }

            Rows rows = new Rows(rpt, null, null, null);                        // no sorting and grouping at base data

            List <Row> ar = new List <Row>();

            rows.Data = ar;
            int rowCount   = 0;
            int maxRows    = _RowLimit > 0? _RowLimit: int.MaxValue;
            int fieldCount = flds.Items.Count;

            Field[] orderedFields = null;
            foreach (object dt in ie)
            {
                // Get the type.
                Type myType = dt.GetType();

                // Build the row
                Row or = new Row(rows, fieldCount);

                if (collection)
                {
                    if (dt is IDictionary)
                    {
                        IDictionary dic = (IDictionary)dt;
                        foreach (Field fld in flds)
                        {
                            if (dic.Contains(fld.Name.Nm))
                            {
                                or.Data[fld.ColumnNumber] = dic[fld.Name.Nm];
                            }
                        }
                    }
                    else if (dt is IEnumerable)
                    {
                        if (orderedFields == null)
                        {
                            orderedFields = new Field[fieldCount];
                            foreach (Field fld in flds)
                            {
                                orderedFields[fld.ColumnNumber] = fld;
                            }
                        }
                        IEnumerator inum = ((IEnumerable)dt).GetEnumerator();
                        foreach (Field fld in orderedFields)
                        {
                            if (!inum.MoveNext())
                            {
                                break;
                            }
                            or.Data[fld.ColumnNumber] = inum.Current;
                        }
                    }
                }
                else
                {
                    // Go thru each field and try to obtain a value
                    foreach (Field fld in flds)
                    {
                        // Get the type and fields of FieldInfoClass.
                        FieldInfo fi = myType.GetField(fld.Name.Nm, BindingFlags.Instance | BindingFlags.Public);
                        if (fi != null)
                        {
                            or.Data[fld.ColumnNumber] = fi.GetValue(dt);
                        }
                        else
                        {
                            // Try getting it as a property as well
                            PropertyInfo pi = myType.GetProperty(fld.Name.Nm, BindingFlags.Instance | BindingFlags.Public);
                            if (pi != null)
                            {
                                or.Data[fld.ColumnNumber] = pi.GetValue(dt, null);
                            }
                        }
                    }
                }

                // Apply the filters
                if (f == null || f.Apply(rpt, or))
                {
                    or.RowNumber = rowCount;                            //
                    rowCount++;
                    ar.Add(or);
                }
                if (--maxRows <= 0)                                             // don't retrieve more than max
                {
                    break;
                }
            }
            ar.TrimExcess();            // free up any extraneous space; can be sizeable for large # rows
            if (f != null)
            {
                f.ApplyFinalFilters(rpt, rows, false);
            }

            SetMyUserData(rpt, rows);
        }
Exemple #19
0
		internal void SetData(Report rpt, DataTable dt, Fields flds, Filters f)
		{
			if (dt == null)			// Does user want to remove user data?
			{	
				SetMyUserData(rpt, null);
				return;
			}

			Rows rows = new Rows(rpt,null,null,null);		// no sorting and grouping at base data

            List<Row> ar = new List<Row>();
			rows.Data = ar;
			int rowCount=0;
			int maxRows = _RowLimit > 0? _RowLimit: int.MaxValue;

			int fieldCount = flds.Items.Count;
			foreach (DataRow dr in dt.Rows)
				{
				Row or = new Row(rows, fieldCount);
				// Loop thru the columns obtaining the data values by name
				foreach (Field fld in flds.Items.Values)
				{
					or.Data[fld.ColumnNumber] = dr[fld.DataField];
				}
				// Apply the filters 
				if (f == null || f.Apply(rpt, or))
				{
					or.RowNumber = rowCount;	// 
					rowCount++;
					ar.Add(or);
				}
				if (--maxRows <= 0)				// don't retrieve more than max
					break;
			}
            ar.TrimExcess();		// free up any extraneous space; can be sizeable for large # rows
			if (f != null)
				f.ApplyFinalFilters(rpt, rows, false);

			SetMyUserData(rpt, rows);
		}
Exemple #20
0
		internal void SetData(Report rpt, IDataReader dr, Fields flds, Filters f)
		{
			if (dr == null)			// Does user want to remove user data?
			{	
				SetMyUserData(rpt, null);
				return;
			}

			Rows rows = new Rows(rpt,null,null,null);		// no sorting and grouping at base data

            List<Row> ar = new List<Row>();
			rows.Data = ar;
			int rowCount=0;
			int maxRows = _RowLimit > 0? _RowLimit: int.MaxValue;
			while (dr.Read())
			{
				Row or = new Row(rows, dr.FieldCount);
				dr.GetValues(or.Data);
				// Apply the filters 
				if (f == null || f.Apply(rpt, or))
				{
					or.RowNumber = rowCount;	// 
					rowCount++;
					ar.Add(or);
				}
				if (--maxRows <= 0)				// don't retrieve more than max
					break;
			}
            ar.TrimExcess();		// free up any extraneous space; can be sizeable for large # rows
			if (f != null)
				f.ApplyFinalFilters(rpt, rows, false);

			SetMyUserData(rpt, rows);
		}
Exemple #21
0
		internal void SetData(Report rpt, XmlDocument xmlDoc, Fields flds, Filters f)
		{
			if (xmlDoc == null)			// Does user want to remove user data?
			{	
				SetMyUserData(rpt, null);
				return;
			}

			Rows rows = new Rows(rpt,null,null,null);		// no sorting and grouping at base data
			
			XmlNode xNode;
			xNode = xmlDoc.LastChild;
			if (xNode == null || !(xNode.Name == "Rows" || xNode.Name == "fyi:Rows"))
			{
				throw new Exception("XML Data must contain top level element Rows.");
			}

            List<Row> ar = new List<Row>();
			rows.Data = ar;

			int rowCount=0;
			int fieldCount = flds.Items.Count;
			foreach(XmlNode xNodeRow in xNode.ChildNodes)
			{
				if (xNodeRow.NodeType != XmlNodeType.Element)
					continue;
				if (xNodeRow.Name != "Row")
					continue;
				Row or = new Row(rows, fieldCount);
				foreach (XmlNode xNodeColumn in xNodeRow.ChildNodes)
				{	
					Field fld = (Field) (flds.Items[xNodeColumn.Name]);	// Find the column
					if (fld == null)
						continue;			// Extraneous data is ignored
					if (xNodeColumn.InnerText == null || xNodeColumn.InnerText.Length == 0)
						or.Data[fld.ColumnNumber] = null;
					else if (fld.Type == TypeCode.String)
						or.Data[fld.ColumnNumber] = xNodeColumn.InnerText;
					else
					{
						try
						{
							or.Data[fld.ColumnNumber] = 
								Convert.ChangeType(xNodeColumn.InnerText, fld.Type, NumberFormatInfo.InvariantInfo);
						}
						catch	// all conversion errors result in a null value
						{
							or.Data[fld.ColumnNumber] = null;
						}
					}
				}
				// Apply the filters 
				if (f == null || f.Apply(rpt, or))
				{
					or.RowNumber = rowCount;	// 
					rowCount++;
					ar.Add(or);
				}
			}

            ar.TrimExcess();		// free up any extraneous space; can be sizeable for large # rows
			if (f != null)
				f.ApplyFinalFilters(rpt, rows, false);

			SetMyUserData(rpt, rows);
		}
		internal Rows GetFilteredData(Report rpt, Row row)
		{
			try
			{
				Rows data;
				if (this._Filters == null)
				{
					if (this._ParentDataRegion == null)
					{
						data = DataSetDefn.Query.GetMyData(rpt);
						return data == null? null: new Rows(rpt, data);	// We need to copy in case DataSet is shared by multiple DataRegions
					}
					else
						return GetNestedData(rpt, row);
				}

				if (this._ParentDataRegion == null)
				{
					data = DataSetDefn.Query.GetMyData(rpt);
					if (data != null)
						data = new Rows(rpt, data);
				}
				else
					data = GetNestedData(rpt, row);

				if (data == null)
					return null;

				List<Row> ar = new List<Row>();
				foreach (Row r in data.Data)
				{
					if (_Filters.Apply(rpt, r))
						ar.Add(r);
				}
                ar.TrimExcess();
				data.Data = ar;
				_Filters.ApplyFinalFilters(rpt, data, true);

				// Adjust the rowcount
				int rCount = 0;
				foreach (Row r in ar)
				{
					r.RowNumber = rCount++;
				}
				return data;
			}
			catch (Exception e)
			{
				this.OwnerReport.rl.LogError(8, e.Message);
				return null;
			}
		}
Exemple #23
0
        // Obtain the data from the XML
        internal bool GetData(Report rpt, string xmlData, Fields flds, Filters f)
        {
            Rows uData = this.GetMyUserData(rpt);

            if (uData != null)
            {
                this.SetMyData(rpt, uData);
                return(uData.Data == null || uData.Data.Count == 0? false: true);
            }

            int fieldCount = flds.Items.Count;

            XmlDocument doc = new XmlDocument();

            doc.PreserveWhitespace = false;
            doc.LoadXml(xmlData);

            XmlNode xNode;

            xNode = doc.LastChild;
            if (xNode == null || !(xNode.Name == "Rows" || xNode.Name == "fyi:Rows"))
            {
                throw new Exception(Strings.Query_Error_XMLMustContainTopLevelRows);
            }

            Rows       _Data = new Rows(rpt, null, null, null);
            List <Row> ar    = new List <Row>();

            _Data.Data = ar;

            int rowCount = 0;

            foreach (XmlNode xNodeRow in xNode.ChildNodes)
            {
                if (xNodeRow.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (xNodeRow.Name != "Row")
                {
                    continue;
                }
                Row or = new Row(_Data, fieldCount);
                foreach (XmlNode xNodeColumn in xNodeRow.ChildNodes)
                {
                    Field fld = (Field)(flds.Items[xNodeColumn.Name]);                          // Find the column
                    if (fld == null)
                    {
                        continue;                       // Extraneous data is ignored
                    }
                    TypeCode tc = fld.qColumn != null? fld.qColumn.colType: fld.Type;

                    if (xNodeColumn.InnerText == null || xNodeColumn.InnerText.Length == 0)
                    {
                        or.Data[fld.ColumnNumber] = null;
                    }
                    else if (tc == TypeCode.String)
                    {
                        or.Data[fld.ColumnNumber] = xNodeColumn.InnerText;
                    }
                    else if (tc == TypeCode.DateTime)
                    {
                        try
                        {
                            or.Data[fld.ColumnNumber] =
                                Convert.ToDateTime(xNodeColumn.InnerText,
                                                   System.Globalization.DateTimeFormatInfo.InvariantInfo);
                        }
                        catch   // all conversion errors result in a null value
                        {
                            or.Data[fld.ColumnNumber] = null;
                        }
                    }
                    else
                    {
                        try
                        {
                            or.Data[fld.ColumnNumber] =
                                Convert.ChangeType(xNodeColumn.InnerText, tc, NumberFormatInfo.InvariantInfo);
                        }
                        catch   // all conversion errors result in a null value
                        {
                            or.Data[fld.ColumnNumber] = null;
                        }
                    }
                }
                // Apply the filters
                if (f == null || f.Apply(rpt, or))
                {
                    or.RowNumber = rowCount;                            //
                    rowCount++;
                    ar.Add(or);
                }
            }

            ar.TrimExcess();            // free up any extraneous space; can be sizeable for large # rows
            if (f != null)
            {
                f.ApplyFinalFilters(rpt, _Data, false);
            }

            SetMyData(rpt, _Data);
            return(_Data == null || _Data.Data == null || _Data.Data.Count == 0 ? false : true);
        }
Exemple #24
0
		internal void GetData(Report rpt, Fields flds, Filters f)
		{
			Rows uData = this.GetMyUserData(rpt);
			if (uData != null)
			{
				this.SetMyData(rpt, uData);
				return;
			}

			// Treat this as a SQL statement
			DataSourceDefn ds = _DataSourceDefn;
			if (ds == null || _CommandText == null)
			{
				this.SetMyData(rpt, null);
				return;
			}

			IDbConnection cnSQL = ds.SqlConnect(rpt);
			if (cnSQL == null)
			{
				this.SetMyData(rpt, null);
				return;
			}

			Rows _Data = new Rows(rpt, null,null,null);		// no sorting and grouping at base data
			String sql = _CommandText.EvaluateString(rpt, null);
			IDbCommand cmSQL=null;
			IDataReader dr=null;
			try 
			{
				cmSQL = cnSQL.CreateCommand();		
				cmSQL.CommandText = AddParametersAsLiterals(rpt, cnSQL, sql, true);
                if (this._QueryCommandType == QueryCommandTypeEnum.StoredProcedure)
                    cmSQL.CommandType = CommandType.StoredProcedure;
                if (this._Timeout > 0){
					//cmSQL.CommandTimeout = this._Timeout;
								}
				AddParameters(rpt, cnSQL, cmSQL, true);
				dr = cmSQL.ExecuteReader(CommandBehavior.SingleResult);

                List<Row> ar = new List<Row>();
				_Data.Data = ar;
				int rowCount=0;
				int maxRows = _RowLimit > 0? _RowLimit: int.MaxValue;
				int fieldCount = flds.Items.Count;

				// Determine the query column number for each field
				int[] qcn = new int[flds.Items.Count];
				foreach (Field fld in flds)
				{
					qcn[fld.ColumnNumber] = -1;
					if (fld.Value != null)
						continue;
					try
					{
						qcn[fld.ColumnNumber] = dr.GetOrdinal(fld.DataField);
					}
					catch 
					{
						qcn[fld.ColumnNumber] = -1;
					}
				}

				while (dr.Read())
				{
					Row or = new Row(_Data, fieldCount);

					foreach (Field fld in flds)
					{
						if (qcn[fld.ColumnNumber] != -1)
						{
							or.Data[fld.ColumnNumber] = dr.GetValue(qcn[fld.ColumnNumber]);
						}
					}

					// Apply the filters
					if (f == null || f.Apply(rpt, or))
					{
						or.RowNumber = rowCount;	// 
						rowCount++;
						ar.Add(or);
					}
					if (--maxRows <= 0)				// don't retrieve more than max
						break;
				}
                ar.TrimExcess();		// free up any extraneous space; can be sizeable for large # rows
				if (f != null)
					f.ApplyFinalFilters(rpt, _Data, false);	
//#if DEBUG
//				rpt.rl.LogError(4, "Rows Read:" + ar.Count.ToString() + " SQL:" + sql );
//#endif
			}
			catch (Exception e)
			{
				rpt.rl.LogError(8, "SQL Exception" + e.Message + "\r\n" + e.StackTrace);
			}
			finally
			{
				if (cmSQL != null)
				{
					cmSQL.Dispose();
					if (dr != null)
						dr.Close();
				}
			}
			this.SetMyData(rpt, _Data);
		}
Exemple #25
0
        internal void SetData(Report rpt, XmlDocument xmlDoc, Fields flds, Filters f)
        {
            if (xmlDoc == null)                                 // Does user want to remove user data?
            {
                SetMyUserData(rpt, null);
                return;
            }

            Rows rows = new Rows(rpt, null, null, null);                        // no sorting and grouping at base data

            XmlNode xNode;

            xNode = xmlDoc.LastChild;
            if (xNode == null || !(xNode.Name == "Rows" || xNode.Name == "fyi:Rows"))
            {
                throw new Exception(Strings.Query_Error_XMLMustContainTopLevelRows);
            }

            List <Row> ar = new List <Row>();

            rows.Data = ar;

            int rowCount   = 0;
            int fieldCount = flds.Items.Count;

            foreach (XmlNode xNodeRow in xNode.ChildNodes)
            {
                if (xNodeRow.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (xNodeRow.Name != "Row")
                {
                    continue;
                }
                Row or = new Row(rows, fieldCount);
                foreach (XmlNode xNodeColumn in xNodeRow.ChildNodes)
                {
                    Field fld = (Field)(flds.Items[xNodeColumn.Name]);                          // Find the column
                    if (fld == null)
                    {
                        continue;                                               // Extraneous data is ignored
                    }
                    if (xNodeColumn.InnerText == null || xNodeColumn.InnerText.Length == 0)
                    {
                        or.Data[fld.ColumnNumber] = null;
                    }
                    else if (fld.Type == TypeCode.String)
                    {
                        or.Data[fld.ColumnNumber] = xNodeColumn.InnerText;
                    }
                    else
                    {
                        try
                        {
                            or.Data[fld.ColumnNumber] =
                                Convert.ChangeType(xNodeColumn.InnerText, fld.Type, NumberFormatInfo.InvariantInfo);
                        }
                        catch                           // all conversion errors result in a null value
                        {
                            or.Data[fld.ColumnNumber] = null;
                        }
                    }
                }
                // Apply the filters
                if (f == null || f.Apply(rpt, or))
                {
                    or.RowNumber = rowCount;                            //
                    rowCount++;
                    ar.Add(or);
                }
            }

            ar.TrimExcess();            // free up any extraneous space; can be sizeable for large # rows
            if (f != null)
            {
                f.ApplyFinalFilters(rpt, rows, false);
            }

            SetMyUserData(rpt, rows);
        }
        List<ReportItem> _Items; // list of report items

        #endregion Fields

        #region Constructors

        internal ReportItems(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            ReportItem ri;
            _Items = new List<ReportItem>();

            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "Rectangle":
                        ri = new Rectangle(r, this, xNodeLoop);
                        break;
                    case "Line":
                        ri = new Line(r, this, xNodeLoop);
                        break;
                    case "Textbox":
                        ri = new Textbox(r, this, xNodeLoop);
                        break;
                    case "Image":
                        ri = new Image(r, this, xNodeLoop);
                        break;
                    case "Subreport":
                        ri = new Subreport(r, this, xNodeLoop);
                        break;
                    // DataRegions: list, table, matrix, chart
                    case "List":
                        ri = new List(r, this, xNodeLoop);
                        break;
                    case "Table":
                    case "Grid":
                    case "fyi:Grid":
                        ri = new Table(r, this, xNodeLoop);
                        break;
                    case "Matrix":
                        ri = new Matrix(r, this, xNodeLoop);
                        break;
                    case "Chart":
                        ri = new Chart(r, this, xNodeLoop);
                        break;
                    case "ChartExpression":		// For internal use only
                        ri = new ChartExpression(r, this, xNodeLoop);
                        break;
                    case "CustomReportItem":
                        ri = new CustomReportItem(r, this, xNodeLoop);
                        break;
                    default:
                        ri=null;		// don't know what this is
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown ReportItems element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
                if (ri != null)
                {
                    _Items.Add(ri);
                }
            }
            if (_Items.Count == 0)
                OwnerReport.rl.LogError(8, "At least one item must be in the ReportItems.");
            else
                _Items.TrimExcess();
        }
Exemple #27
0
		// Obtain the data from the XML
		internal void GetData(Report rpt, string xmlData, Fields flds, Filters f)
		{
			Rows uData = this.GetMyUserData(rpt);
			if (uData != null)
			{
				this.SetMyData(rpt, uData);
				return;
			}

			int fieldCount = flds.Items.Count;

			XmlDocument doc = new XmlDocument();
			doc.PreserveWhitespace = false;
			doc.LoadXml(xmlData);

			XmlNode xNode;
			xNode = doc.LastChild;
			if (xNode == null || !(xNode.Name == "Rows" || xNode.Name == "fyi:Rows"))
			{
				throw new Exception("Error: XML Data must contain top level rows.");
			}

			Rows _Data = new Rows(rpt, null,null,null);
            List<Row> ar = new List<Row>();
			_Data.Data = ar;

			int rowCount=0;
			foreach(XmlNode xNodeRow in xNode.ChildNodes)
			{
				if (xNodeRow.NodeType != XmlNodeType.Element)
					continue;
				if (xNodeRow.Name != "Row")
					continue;
				Row or = new Row(_Data, fieldCount);
				foreach (XmlNode xNodeColumn in xNodeRow.ChildNodes)
				{	
					Field fld = (Field) (flds.Items[xNodeColumn.Name]);	// Find the column
					if (fld == null)
						continue;			// Extraneous data is ignored
					TypeCode tc = fld.qColumn != null? fld.qColumn.colType: fld.Type;

					if (xNodeColumn.InnerText == null || xNodeColumn.InnerText.Length == 0)
						or.Data[fld.ColumnNumber] = null;
					else if (tc == TypeCode.String)
						or.Data[fld.ColumnNumber] = xNodeColumn.InnerText;
					else
					{
						try
						{
							or.Data[fld.ColumnNumber] = 
								Convert.ChangeType(xNodeColumn.InnerText, tc, NumberFormatInfo.InvariantInfo);
						}
						catch	// all conversion errors result in a null value
						{
							or.Data[fld.ColumnNumber] = null;
						}
					}
				}
				// Apply the filters 
				if (f == null || f.Apply(rpt, or))
				{
					or.RowNumber = rowCount;	// 
					rowCount++;
					ar.Add(or);
				}
			}

            ar.TrimExcess();		// free up any extraneous space; can be sizeable for large # rows
			if (f != null)
				f.ApplyFinalFilters(rpt, _Data, false);

			SetMyData(rpt, _Data);
		}
Exemple #28
0
		internal void SetData(Report rpt, IEnumerable ie, Fields flds, Filters f)
		{
			if (ie == null)			// Does user want to remove user data?
			{	
				SetMyUserData(rpt, null);
				return;
			}

			Rows rows = new Rows(rpt, null,null,null);		// no sorting and grouping at base data

            List<Row> ar = new List<Row>();
			rows.Data = ar;
			int rowCount=0;
			int maxRows = _RowLimit > 0? _RowLimit: int.MaxValue;
			int fieldCount = flds.Items.Count;
			foreach (object dt in ie)
			{
				// Get the type.
				Type myType = dt.GetType();

				// Build the row
				Row or = new Row(rows, fieldCount);

				// Go thru each field and try to obtain a value
				foreach (Field fld in flds)
				{
					// Get the type and fields of FieldInfoClass.
					FieldInfo fi = myType.GetField(fld.Name.Nm, BindingFlags.Instance | BindingFlags.Public);
					if (fi != null)
					{
						or.Data[fld.ColumnNumber] = fi.GetValue(dt);
					}
				}

				// Apply the filters 
				if (f == null || f.Apply(rpt, or))
				{
					or.RowNumber = rowCount;	// 
					rowCount++;
					ar.Add(or);
				}
				if (--maxRows <= 0)				// don't retrieve more than max
					break;
			}
            ar.TrimExcess();		// free up any extraneous space; can be sizeable for large # rows
			if (f != null)
				f.ApplyFinalFilters(rpt, rows, false);

			SetMyUserData(rpt, rows);
		}
Exemple #29
0
        internal bool GetData(Report rpt, Fields flds, Filters f)
        {
            Rows uData = this.GetMyUserData(rpt);

            if (uData != null)
            {
                this.SetMyData(rpt, uData);
                return(uData.Data == null || uData.Data.Count == 0 ? false : true);
            }

            // Treat this as a SQL statement
            DataSourceDefn ds = _DataSourceDefn;

            if (ds == null || _CommandText == null)
            {
                this.SetMyData(rpt, null);
                return(false);
            }

            IDbConnection cnSQL = ds.SqlConnect(rpt);

            if (cnSQL == null)
            {
                this.SetMyData(rpt, null);
                return(false);
            }

            Rows        _Data = new Rows(rpt, null, null, null);                // no sorting and grouping at base data
            String      sql   = _CommandText.EvaluateString(rpt, null);
            IDbCommand  cmSQL = null;
            IDataReader dr    = null;

            try
            {
                cmSQL             = cnSQL.CreateCommand();
                cmSQL.CommandText = AddParametersAsLiterals(rpt, cnSQL, sql, true);
                if (this._QueryCommandType == QueryCommandTypeEnum.StoredProcedure)
                {
                    cmSQL.CommandType = CommandType.StoredProcedure;
                }
                if (this._Timeout > 0)
                {
                    cmSQL.CommandTimeout = this._Timeout;
                }

                AddParameters(rpt, cnSQL, cmSQL, true);
                dr = cmSQL.ExecuteReader(CommandBehavior.SingleResult);

                List <Row> ar = new List <Row>();
                _Data.Data = ar;
                int rowCount   = 0;
                int maxRows    = _RowLimit > 0? _RowLimit: int.MaxValue;
                int fieldCount = flds.Items.Count;

                // Determine the query column number for each field
                int[] qcn = new int[flds.Items.Count];
                foreach (Field fld in flds)
                {
                    qcn[fld.ColumnNumber] = -1;
                    if (fld.Value != null)
                    {
                        continue;
                    }
                    try
                    {
                        qcn[fld.ColumnNumber] = dr.GetOrdinal(fld.DataField);
                    }
                    catch
                    {
                        qcn[fld.ColumnNumber] = -1;
                    }
                }

                while (dr.Read())
                {
                    Row or = new Row(_Data, fieldCount);

                    foreach (Field fld in flds)
                    {
                        if (qcn[fld.ColumnNumber] != -1)
                        {
                            or.Data[fld.ColumnNumber] = dr.GetValue(qcn[fld.ColumnNumber]);
                        }
                    }

                    // Apply the filters
                    if (f == null || f.Apply(rpt, or))
                    {
                        or.RowNumber = rowCount;                                //
                        rowCount++;
                        ar.Add(or);
                    }
                    if (--maxRows <= 0)                                                 // don't retrieve more than max
                    {
                        break;
                    }
                }
                ar.TrimExcess();                // free up any extraneous space; can be sizeable for large # rows
                if (f != null)
                {
                    f.ApplyFinalFilters(rpt, _Data, false);
                }
//#if DEBUG
//				rpt.rl.LogError(4, "Rows Read:" + ar.Count.ToString() + " SQL:" + sql );
//#endif
            }
            catch (Exception e)
            {
                // Issue #35 - Kept the logging
                rpt.rl.LogError(8, "SQL Exception" + e.Message + "\r\n" + e.StackTrace);
                throw;
            }
            finally
            {
                if (cmSQL != null)
                {
                    cmSQL.Dispose();
                    if (dr != null)
                    {
                        dr.Close();
                    }
                }
            }
            this.SetMyData(rpt, _Data);
            return(_Data == null || _Data.Data == null || _Data.Data.Count == 0 ? false : true);
        }