public object Evaluate(Report rpt, Row row)
        {
            bool          bSave = true;
            RowEnumerable re    = this.GetDataScope(rpt, row, out bSave);

            if (re == null)
            {
                return(null);
            }

            object v = GetValue(rpt);

            if (v == null)
            {
                Row saver = null;
                if (re.Data.Count > 0)
                {
                    saver = re.Data[re.FirstRow] as Row;
                }

                v = _Expr.Evaluate(rpt, saver);
                if (bSave)
                {
                    SetValue(rpt, v);
                }
            }
            return(v);
        }
        // Evaluate is for interpretation  (and is relatively slow)
        public object Evaluate(Report rpt, Row row)
        {
            bool          bSave = true;
            RowEnumerable re    = this.GetDataScope(rpt, row, out bSave);

            if (re == null)
            {
                return(null);
            }

            object v = GetValue(rpt);

            if (v == null)
            {
                object    temp;
                ArrayList ar = new ArrayList(Math.Max(1, re.LastRow - re.FirstRow + 1));
                foreach (Row r in re)
                {
                    temp = _Expr.Evaluate(rpt, r);
                    ar.Add(temp);
                }

                v = ar;
                if (bSave)
                {
                    SetValue(rpt, v);
                }
            }
            return(v);
        }
        public object Evaluate(Report rpt, Row row)
        {
            object v = null;

            if (row == null)
            {
                return(null);
            }
            bool          bSave = true;
            RowEnumerable re    = this.GetDataScope(rpt, row, out bSave);

            if (re == null)
            {
                return(null);
            }

            Row crow = null;

            foreach (Row r in re)
            {
                if (r == row)
                {
                    break;
                }
                crow = r;
            }
            if (crow != null)
            {
                v = _Expr.Evaluate(rpt, crow);
            }
            return(v);
        }
Exemplo n.º 4
0
        public int EvaluateInt32(Report rpt, Row row)
        {
            bool          bSave = true;
            RowEnumerable re    = this.GetDataScope(rpt, row, out bSave);

            if (re == null)
            {
                return(0);
            }

            int count = re.LastRow - re.FirstRow + 1;

            return(count);
        }
        public int EvaluateInt32(Report rpt, Row row)
        {
            bool          bSave = true;
            RowEnumerable re    = this.GetDataScope(rpt, row, out bSave);

            if (re == null)
            {
                return(0);
            }

            int v = GetValue(rpt);

            if (v < 0)
            {
                object    temp;
                int       count = Math.Max(2, re.LastRow - re.FirstRow);
                Hashtable ht    = new Hashtable(count);
                foreach (Row r in re)
                {
                    temp = _Expr.Evaluate(rpt, r);
                    if (temp != null)
                    {
                        object o = ht[temp];                            // search for it
                        if (o == null)                                  // if not found; add it to the hash table
                        {
                            ht.Add(temp, temp);
                        }
                    }
                }
                v = ht.Count;
                if (bSave)
                {
                    SetValue(rpt, v);
                }
            }
            return(v);
        }
Exemplo n.º 6
0
        // return an IEnumerable that represents the scope of the data
        protected RowEnumerable GetDataScope(Report rpt, Row row, out bool bSave)
        {
            bSave = true;
            RowEnumerable re = null;

            if (this._Scope != null)
            {
                Type t = this._Scope.GetType();

                //150208AJM GJL Trying - And Succeeding!!! to get data from chart
                if (t == typeof(Chart))
                {
                    Chart c = (Chart)this._Scope;
                    this._Scope = c.ChartMatrix;
                    t           = this._Scope.GetType();
                }

                if (t == typeof(Grouping))
                {
                    bSave = false;
                    Grouping g = (Grouping)(this._Scope);
                    if (g.InMatrix)
                    {
                        Rows rows = g.GetRows(rpt);
                        if (rows == null)
                        {
                            return(null);
                        }
                        re = new RowEnumerable(0, rows.Data.Count - 1, rows.Data, _LevelCheck);
                    }
                    else
                    {
                        if (row == null || row.R.CurrentGroups == null)                             // currentGroups can be null when reference Textbox in header/footer that has a scoped aggr function reference (TODO: this is a problem!)
                        {
                            return(null);
                        }
                        GroupEntry ge = row.R.CurrentGroups[g.GetIndex(rpt)];
                        re = new RowEnumerable(ge.StartRow, ge.EndRow, row.R.Data, _LevelCheck);
                    }
                }
                else if (t == typeof(Matrix))
                {
                    bSave = false;
                    Matrix m     = (Matrix)(this._Scope);
                    Rows   mData = m.GetMyData(rpt);
                    re = new RowEnumerable(0, mData.Data.Count - 1, mData.Data, false);
                }
                else if (t == typeof(string))
                {                       // happens on page header/footer scope
                    if (row != null)
                    {
                        re = new RowEnumerable(0, row.R.Data.Count - 1, row.R.Data, false);
                    }
                    bSave = false;
                }
                else if (row != null)
                {
                    re = new RowEnumerable(0, row.R.Data.Count - 1, row.R.Data, false);
                }
                else
                {
                    DataSetDefn ds = this._Scope as DataSetDefn;
                    if (ds != null && ds.Query != null)
                    {
                        Rows rows = ds.Query.GetMyData(rpt);
                        if (rows != null)
                        {
                            re = new RowEnumerable(0, rows.Data.Count - 1, rows.Data, false);
                        }
                    }
                }
            }
            else if (row != null)
            {
                re = new RowEnumerable(0, row.R.Data.Count - 1, row.R.Data, false);
            }

            return(re);
        }
Exemplo n.º 7
0
 public RowEnumerator(RowEnumerable rea)
 {
     re = rea;
 }
		// return an IEnumerable that represents the scope of the data
		protected RowEnumerable GetDataScope(Report rpt, Row row, out bool bSave)
			{
			bSave=true;
			RowEnumerable re=null;

			if (this._Scope != null)
			{
				Type t = this._Scope.GetType();

                //150208AJM GJL Trying - And Succeeding!!! to get data from chart
                if (t == typeof(Chart)) {
                    Chart c = (Chart)this._Scope;
                    this._Scope = c.ChartMatrix;
                    t = this._Scope.GetType();
                }

				if (t == typeof(Grouping))
				{
					bSave=false;
					Grouping g = (Grouping) (this._Scope);
					if (g.InMatrix)
					{
						Rows rows = g.GetRows(rpt);
						if (rows == null)
							return null;
						re = new RowEnumerable(0, rows.Data.Count-1, rows.Data, _LevelCheck);
					}
					else
					{
						if (row == null || row.R.CurrentGroups == null)     // currentGroups can be null when reference Textbox in header/footer that has a scoped aggr function reference (TODO: this is a problem!)
							return null;
						GroupEntry ge = row.R.CurrentGroups[g.GetIndex(rpt)];
						re = new RowEnumerable (ge.StartRow, ge.EndRow, row.R.Data, _LevelCheck);
					}
				}
				else if (t == typeof(Matrix))
				{
					bSave=false;
					Matrix m = (Matrix) (this._Scope);
					Rows mData = m.GetMyData(rpt);
					re = new RowEnumerable(0, mData.Data.Count-1, mData.Data, false);
				}
				else if (t == typeof(string))
				{	// happens on page header/footer scope
					if (row != null)
						re = new RowEnumerable (0, row.R.Data.Count-1, row.R.Data, false);
					bSave = false;
				}
				else if (row != null)
				{
					re = new RowEnumerable (0, row.R.Data.Count-1, row.R.Data, false);
				}
				else
				{
					DataSetDefn ds = this._Scope as DataSetDefn;
					if (ds != null && ds.Query != null)
					{
						Rows rows = ds.Query.GetMyData(rpt);
						if (rows != null)
							re = new RowEnumerable(0, rows.Data.Count-1, rows.Data, false);
					}
				}
			}
			else if (row != null)
			{
				re = new RowEnumerable (0, row.R.Data.Count-1, row.R.Data, false);
			}

			return re;
		}
		public RowEnumerator(RowEnumerable rea)
		{
			re = rea;
		}