Exemple #1
0
		List<GroupEntry> _NestedGroup;	// group one hierarchy below
	
		internal GroupEntry(Grouping g, Sorting s, int start)
		{
			_Group = g;
			_Sort = s;
			_StartRow = start;
			_EndRow = -1;
            _NestedGroup = new List<GroupEntry>();

			// Check to see if grouping and sorting are the same
			if (g == null || s == null)
				return;			// nothing to check if either is null

			if (s.Items.Count != g.GroupExpressions.Items.Count)
				return;

			for (int i = 0; i < s.Items.Count; i++)
			{
				SortBy sb = s.Items[i] as SortBy;

				if (sb.Direction == SortDirectionEnum.Descending)
					return;			// TODO we could optimize this 
				
				FunctionField ff = sb.SortExpression.Expr as FunctionField;
				if (ff == null || ff.GetTypeCode() != TypeCode.String)
					return;

				GroupExpression ge = g.GroupExpressions.Items[i] as GroupExpression;
				FunctionField ff2 = ge.Expression.Expr as FunctionField;
				if (ff2 == null || ff.Fld != ff2.Fld)
					return;
			}
			_Sort = null;		// we won't need to sort since the groupby will handle it correctly
		}
		Expression _Label;	// (string) The label displayed on the legend.		
	
		internal DynamicSeries(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			_Grouping=null;
			_Sorting=null;
			_Label=null;

			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "Grouping":
						_Grouping = new Grouping(r, this, xNodeLoop);
						break;
					case "Sorting":
						_Sorting = new Sorting(r, this, xNodeLoop);
						break;
					case "Label":
						_Label = new Expression(r, this, xNodeLoop, ExpressionType.String);
						break;
					default:
						break;
				}
			}
			if (_Grouping == null)
				OwnerReport.rl.LogError(8, "DynamicSeries requires the Grouping element.");
			if (_Label == null)
				OwnerReport.rl.LogError(8, "DynamicSeries requires the Label element.");
		}
		string _ExprName;			// name of the expression; this isn't always set

		internal NameLookup(IDictionary f, IDictionary p, IDictionary r, 
			IDictionary gbl, IDictionary u, IDictionary ascope, 
			Grouping ag, Matrix mt, CodeModules cm, Classes i, DataSetsDefn ds, Type ct)
		{
			fields=f;
			parameters=p;
			reportitems=r;
			globals=gbl;
			user=u;
			aggrScope = ascope;
			g=ag;
			m = mt;
			cms = cm;
			instances = i;
			dsets = ds;
			codeType = ct;
		}
Exemple #4
0
		Visibility _Visibility;	// Indicates if all of the dynamic rows for this grouping
							// should be hidden and replaced with a subtotal row for
							// this grouping scope		

		internal DynamicRows(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p)
		{
			_Grouping=null;
			_Sorting=null;
			_Subtotal=null;
			_ReportItems=null;
			_Visibility=null;
			// Run thru the attributes
			//			foreach(XmlAttribute xAttr in xNode.Attributes)
			//			{
			//			}

			// Loop thru all the child nodes
			foreach(XmlNode xNodeLoop in xNode.ChildNodes)
			{
				if (xNodeLoop.NodeType != XmlNodeType.Element)
					continue;
				switch (xNodeLoop.Name)
				{
					case "Grouping":
						_Grouping = new Grouping(r, this, xNodeLoop);
						break;
					case "Sorting":
						_Sorting = new Sorting(r, this, xNodeLoop);
						break;
					case "Subtotal":
						_Subtotal = new Subtotal(r, this, xNodeLoop);
						break;
					case "ReportItems":
						_ReportItems = new ReportItems(r, this, xNodeLoop);
						break;
					case "Visibility":
						_Visibility = new Visibility(r, this, xNodeLoop);
						break;
					default:	
						// don't know this element - log it
						OwnerReport.rl.LogError(4, "Unknown DynamicRow element '" + xNodeLoop.Name + "' ignored.");
						break;
				}
			}
			if (_Grouping == null)
				OwnerReport.rl.LogError(8, "DynamicRows requires the Grouping element.");
			if (_ReportItems == null || _ReportItems.Items.Count != 1)
				OwnerReport.rl.LogError(8, "DynamicRows requires the ReportItems element defined with exactly one report item.");
		}
        Visibility _Visibility; // Indicates if the group (and all groups embedded

        #endregion Fields

        #region Constructors

        internal TableGroup(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            _Grouping=null;
            _Sorting=null;
            _Header=null;
            _Footer=null;
            _Visibility=null;
            _ToggleTextbox=null;

            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "Grouping":
                        _Grouping = new Grouping(r, this, xNodeLoop);
                        break;
                    case "Sorting":
                        _Sorting = new Sorting(r, this, xNodeLoop);
                        break;
                    case "Header":
                        _Header = new Header(r, this, xNodeLoop);
                        break;
                    case "Footer":
                        _Footer = new Footer(r, this, xNodeLoop);
                        break;
                    case "Visibility":
                        _Visibility = new Visibility(r, this, xNodeLoop);
                        break;
                    default:
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown TableGroup element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
            }
            if (_Grouping == null)
                OwnerReport.rl.LogError(8, "TableGroup requires the Grouping element.");
        }
Exemple #6
0
        Sorting _Sorting; // The expressions to sort the repeated list regions by

        #endregion Fields

        #region Constructors

        internal List(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r,p,xNode)
        {
            _Grouping=null;
            _Sorting=null;
            _ReportItems=null;
            _DataInstanceName="Item";
            _DataInstanceElementOutput=DataInstanceElementOutputEnum.Output;

            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "Grouping":
                        _Grouping = new Grouping(r, this, xNodeLoop);
                        break;
                    case "Sorting":
                        _Sorting = new Sorting(r, this, xNodeLoop);
                        break;
                    case "ReportItems":
                        _ReportItems = new ReportItems(r, this, xNodeLoop);
                        break;
                    case "DataInstanceName":
                        _DataInstanceName = xNodeLoop.InnerText;
                        break;
                    case "DataInstanceElementOutput":
                        _DataInstanceElementOutput = fyiReporting.RDL.DataInstanceElementOutput.GetStyle(xNodeLoop.InnerText, OwnerReport.rl);
                        break;
                    default:
                        if (DataRegionElement(xNodeLoop))	// try at DataRegion level
                            break;
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown List element '" + xNodeLoop.Name + "' ignored.");
                        break;
                }
            }
            DataRegionFinish();			// Tidy up the DataRegion
        }
Exemple #7
0
        Visibility _Visibility; // Indicates if the details should be hidden

        #endregion Fields

        #region Constructors

        internal Details(ReportDefn r, ReportLink p, XmlNode xNode)
            : base(r, p)
        {
            _TableRows=null;
            _Grouping=null;
            _Sorting=null;
            _Visibility=null;
            _ToggleTextbox = null;

            // Loop thru all the child nodes
            foreach(XmlNode xNodeLoop in xNode.ChildNodes)
            {
                if (xNodeLoop.NodeType != XmlNodeType.Element)
                    continue;
                switch (xNodeLoop.Name)
                {
                    case "TableRows":
                        _TableRows = new TableRows(r, this, xNodeLoop);
                        break;
                    case "Grouping":
                        _Grouping = new Grouping(r, this, xNodeLoop);
                        break;
                    case "Sorting":
                        _Sorting = new Sorting(r, this, xNodeLoop);
                        break;
                    case "Visibility":
                        _Visibility = new Visibility(r, this, xNodeLoop);
                        break;
                    default:
                        // don't know this element - log it
                        OwnerReport.rl.LogError(4, "Unknown Details element " + xNodeLoop.Name + " ignored.");
                        break;
                }
            }
            if (_TableRows == null)
                OwnerReport.rl.LogError(8, "Details requires the TableRows element.");
        }
 // called at start of grouping
 public virtual void GroupingStart(Grouping g)
 {
 }
Exemple #9
0
		private void SetGrouping(Report rpt, Grouping g, MatrixEntry me, Rows data)
		{
			if (g == null)
				return;

			if (me.Data == null)
				me.Data = new Rows(rpt, data, me.FirstRow, me.LastRow,  me.Rows);
			g.SetRows(rpt, me.Data);
		}
Exemple #10
0
 public void GroupingEnd(Grouping g)			// called at end of grouping
 {
 }
Exemple #11
0
 // called at end of grouping
 public void GroupingEnd(Grouping g)
 {
     if (g.DataElementOutput != DataElementOutputEnum.Output)
         return;
     PopContainer(g.DataCollectionName);
 }
Exemple #12
0
 public void GroupingInstanceEnd(Grouping g)
 {
 }
Exemple #13
0
 public void GroupingStart(Grouping g)			// called at start of grouping
 {
 }
Exemple #14
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 (t == typeof(DataSetDefn))
                {
                    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);
                }
                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 void GroupingInstanceEnd(Grouping g)	// called at start for each grouping instance
		{
			if (g.DataElementOutput != DataElementOutputEnum.Output)
				return;
			PopContainer(g.DataElementName);
		}
Exemple #16
0
 public void GroupingInstanceEnd(Grouping g)             // called at start for each grouping instance
 {
 }
Exemple #17
0
 public void GroupingEnd(Grouping g)                             // called at end of grouping
 {
 }
Exemple #18
0
 public void GroupingStart(Grouping g)                           // called at start of grouping
 {
 }
Exemple #19
0
        internal TypeCode DoParse(Report rpt)
        {
            // optimization: avoid expression overhead if this isn't really an expression
            if (_Source == null)
            {
                _Expr = new Constant("");
                return(_Expr.GetTypeCode());
            }
            else if (_Source == string.Empty ||         // empty expression
                     _Source[0] != '=')                 // if 1st char not '='
            {
                _Expr = new Constant(_Source);          //   this is a constant value
                return(_Expr.GetTypeCode());
            }

            Parser p = new Parser(new System.Collections.Generic.List <ICacheData>());

            // find the fields that are part of the DataRegion (if there is one)
            IDictionary fields = null;
            ReportLink  dr     = _rl.Parent;
            Grouping    grp    = null;                  // remember if in a table group or detail group or list group
            Matrix      m      = null;

            while (dr != null)
            {
                if (dr is Grouping)
                {
                    p.NoAggregateFunctions = true;
                }
                else if (dr is TableGroup)
                {
                    grp = ((TableGroup)dr).Grouping;
                }
                else if (dr is Matrix)
                {
                    m = (Matrix)dr;                                     // if matrix we need to pass special
                    break;
                }
                else if (dr is Details)
                {
                    grp = ((Details)dr).Grouping;
                }
                else if (dr is List)
                {
                    grp = ((List)dr).Grouping;
                    break;
                }
                else if (dr is DataRegion || dr is DataSetDefn)
                {
                    break;
                }
                dr = dr.Parent;
            }
            if (dr != null)
            {
                if (dr is DataSetDefn)
                {
                    DataSetDefn d = (DataSetDefn)dr;
                    if (d.Fields != null)
                    {
                        fields = d.Fields.Items;
                    }
                }
                else                    // must be a DataRegion
                {
                    DataRegion d = (DataRegion)dr;
                    if (d.DataSetDefn != null &&
                        d.DataSetDefn.Fields != null)
                    {
                        fields = d.DataSetDefn.Fields.Items;
                    }
                }
            }

            NameLookup lu = new NameLookup(fields, rpt.ReportDefinition.LUReportParameters,
                                           rpt.ReportDefinition.LUReportItems, rpt.ReportDefinition.LUGlobals,
                                           rpt.ReportDefinition.LUUser, rpt.ReportDefinition.LUAggrScope,
                                           grp, m, rpt.ReportDefinition.CodeModules, rpt.ReportDefinition.Classes, rpt.ReportDefinition.DataSetsDefn,
                                           rpt.ReportDefinition.CodeType);

            try
            {
                _Expr = p.Parse(lu, _Source);
            }
            catch (Exception e)
            {
                _Expr = new ConstantError(e.Message);
                // Invalid expression
                rpt.rl.LogError(8, ErrorText(e.Message));
            }

            // Optimize removing any expression that always result in a constant
            try
            {
                _Expr = _Expr.ConstantOptimization();
            }
            catch (Exception ex)
            {
                rpt.rl.LogError(4, "Expression:" + _Source + "\r\nConstant Optimization exception:\r\n" + ex.Message + "\r\nStack trace:\r\n" + ex.StackTrace);
            }

            return(_Expr.GetTypeCode());
        }
 // called at start for each grouping instance
 public virtual void GroupingInstanceEnd(Grouping g)
 {
 }
Exemple #21
0
        private void PrepGroups(Report rpt, WorkClass wc)
        {
            if (_Grouping == null)
            {
                return;
            }

            int i = 0;
            // 1) Build array of all GroupExpression objects
            List <GroupExpression> gea = _Grouping.GroupExpressions.Items;

            GroupEntry[] currentGroups = new GroupEntry[1];
            _Grouping.SetIndex(rpt, 0);                 // set the index of this group (so we can find the GroupEntry)
            currentGroups[0] = new GroupEntry(_Grouping, _Sorting, 0);

            // Save the typecodes, and grouping by groupexpression; for later use
            TypeCode[] tcs = new TypeCode[gea.Count];
            Grouping[] grp = new Grouping[gea.Count];
            i = 0;
            foreach (GroupExpression ge in gea)
            {
                grp[i]   = (Grouping)(ge.Parent.Parent);                // remember the group
                tcs[i++] = ge.Expression.GetTypeCode();                 // remember type of expression
            }

            // 2) Loop thru the data, then loop thru the GroupExpression list
            wc.Groups = new List <GroupEntry>();
            object[] savValues  = null;
            object[] grpValues  = null;
            int      rowCurrent = 0;

            foreach (Row row in wc.Data.Data)
            {
                // Get the values for all the group expressions
                if (grpValues == null)
                {
                    grpValues = new object[gea.Count];
                }

                i = 0;
                foreach (GroupExpression ge in gea)                  // Could optimize to only calculate as needed in comparison loop below??
                {
                    grpValues[i++] = ge.Expression.Evaluate(rpt, row);
                }

                // For first row we just primed the pump; action starts on next row
                if (rowCurrent == 0)                                    // always start new group on first row
                {
                    rowCurrent++;
                    savValues = grpValues;
                    grpValues = null;
                    continue;
                }

                // compare the values; if change then we have a group break
                for (i = 0; i < savValues.Length; i++)
                {
                    if (Filter.ApplyCompare(tcs[i], savValues[i], grpValues[i]) != 0)
                    {
                        // start a new group; and force a break on every subgroup
                        GroupEntry saveGe = null;
                        for (int j = grp[i].GetIndex(rpt); j < currentGroups.Length; j++)
                        {
                            currentGroups[j].EndRow = rowCurrent - 1;
                            if (j == 0)
                            {
                                wc.Groups.Add(currentGroups[j]);                                                // top group
                            }
                            else if (saveGe == null)
                            {
                                currentGroups[j - 1].NestedGroup.Add(currentGroups[j]);
                            }
                            else
                            {
                                saveGe.NestedGroup.Add(currentGroups[j]);
                            }

                            saveGe           = currentGroups[j];                        // retain this GroupEntry
                            currentGroups[j] = new GroupEntry(currentGroups[j].Group, currentGroups[j].Sort, rowCurrent);
                        }
                        savValues = grpValues;
                        grpValues = null;
                        break;                                  // break out of the value comparison loop
                    }
                }
                rowCurrent++;
            }

            // End of all rows force break on end of rows
            for (i = 0; i < currentGroups.Length; i++)
            {
                currentGroups[i].EndRow = rowCurrent - 1;
                if (i == 0)
                {
                    wc.Groups.Add(currentGroups[i]);                                    // top group
                }
                else
                {
                    currentGroups[i - 1].NestedGroup.Add(currentGroups[i]);
                }
            }
            return;
        }
Exemple #22
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();
                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)
                        {
                            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 void GroupingStart(Grouping g)			// called at start of grouping
		{
			if (g.DataElementOutput != DataElementOutputEnum.Output)
				return;

			PushContainer(g.DataCollectionName);

		}
Exemple #24
0
        private void PrepGroups(Report rpt, TableWorkClass wc)
        {
            wc.RecursiveGroup = null;
            if (_TableGroups == null)
            {                   // no tablegroups; check to ensure details is grouped
                if (_Details == null || _Details.Grouping == null)
                {
                    return;                                     // no groups to prepare
                }
            }

            int i = 0;
            // 1) Build array of all GroupExpression objects
            List <GroupExpression> gea = new List <GroupExpression>();
            //    count the number of groups
            int countG = 0;

            if (_TableGroups != null)
            {
                countG = _TableGroups.Items.Count;
            }

            Grouping dg = null;
            Sorting  ds = null;

            if (_Details != null && _Details.Grouping != null)
            {
                dg = _Details.Grouping;
                ds = _Details.Sorting;
                countG++;
            }
            GroupEntry[] currentGroups = new GroupEntry[countG++];
            if (_TableGroups != null)
            {                   // add in the groups for the tablegroup
                foreach (TableGroup tg in _TableGroups.Items)
                {
                    if (tg.Grouping.ParentGroup != null)
                    {
                        wc.RecursiveGroup = tg.Grouping;
                    }
                    tg.Grouping.SetIndex(rpt, i);                               // set the index of this group (so we can find the GroupEntry)
                    currentGroups[i++] = new GroupEntry(tg.Grouping, tg.Sorting, 0);
                    foreach (GroupExpression ge in tg.Grouping.GroupExpressions.Items)
                    {
                        gea.Add(ge);
                    }
                }
            }
            if (dg != null)
            {                   // add in the groups for the details grouping
                if (dg.ParentGroup != null)
                {
                    wc.RecursiveGroup = dg;
                }
                dg.SetIndex(rpt, i);                            // set the index of this group (so we can find the GroupEntry)
                currentGroups[i++] = new GroupEntry(dg, ds, 0);
                foreach (GroupExpression ge in dg.GroupExpressions.Items)
                {
                    gea.Add(ge);
                }
            }

            if (wc.RecursiveGroup != null)
            {
                if (gea.Count != 1)                             // Limitiation of implementation
                {
                    throw new Exception("Error: Recursive groups must be the only group definition.");
                }

                PrepRecursiveGroup(rpt, wc);                    // only one group and it's recursive: optimization
                return;
            }

            // Save the typecodes, and grouping by groupexpression; for later use
            TypeCode[] tcs = new TypeCode[gea.Count];
            Grouping[] grp = new Grouping[gea.Count];
            i = 0;
            foreach (GroupExpression ge in gea)
            {
                grp[i]   = (Grouping)(ge.Parent.Parent);                // remember the group
                tcs[i++] = ge.Expression.GetTypeCode();                 // remember type of expression
            }

            // 2) Loop thru the data, then loop thru the GroupExpression list
            wc.Groups = new List <GroupEntry>();
            object[] savValues  = null;
            object[] grpValues  = null;
            int      rowCurrent = 0;

            foreach (Row row in wc.Data.Data)
            {
                // Get the values for all the group expressions
                if (grpValues == null)
                {
                    grpValues = new object[gea.Count];
                }

                i = 0;
                foreach (GroupExpression ge in gea)
                {
                    if (((Grouping)(ge.Parent.Parent)).ParentGroup == null)
                    {
                        grpValues[i++] = ge.Expression.Evaluate(rpt, row);
                    }
                    else
                    {
                        grpValues[i++] = null;                          // Want all the parentGroup to evaluate equal
                    }
                }

                // For first row we just primed the pump; action starts on next row
                if (rowCurrent == 0)                                    // always start new group on first row
                {
                    rowCurrent++;
                    savValues = grpValues;
                    grpValues = null;
                    continue;
                }

                // compare the values; if change then we have a group break
                for (i = 0; i < savValues.Length; i++)
                {
                    if (Filter.ApplyCompare(tcs[i], savValues[i], grpValues[i]) != 0)
                    {
                        // start a new group; and force a break on every subgroup
                        GroupEntry saveGe = null;
                        for (int j = grp[i].GetIndex(rpt); j < currentGroups.Length; j++)
                        {
                            currentGroups[j].EndRow = rowCurrent - 1;
                            if (j == 0)
                            {
                                wc.Groups.Add(currentGroups[j]);                                                // top group
                            }
                            else if (saveGe == null)
                            {
                                currentGroups[j - 1].NestedGroup.Add(currentGroups[j]);
                            }
                            else
                            {
                                saveGe.NestedGroup.Add(currentGroups[j]);
                            }

                            saveGe           = currentGroups[j];                        // retain this GroupEntry
                            currentGroups[j] = new GroupEntry(currentGroups[j].Group, currentGroups[j].Sort, rowCurrent);
                        }
                        savValues = grpValues;
                        grpValues = null;
                        break;                                  // break out of the value comparison loop
                    }
                }
                rowCurrent++;
            }

            // End of all rows force break on end of rows
            for (i = 0; i < currentGroups.Length; i++)
            {
                currentGroups[i].EndRow = rowCurrent - 1;
                if (i == 0)
                {
                    wc.Groups.Add(currentGroups[i]);                                    // top group
                }
                else
                {
                    currentGroups[i - 1].NestedGroup.Add(currentGroups[i]);
                }
            }

            return;
        }
Exemple #25
0
 public void GroupingEnd(Grouping g)
 {
 }
Exemple #26
0
 // called at end of grouping
 public void GroupingEnd(Grouping g)
 {
 }
Exemple #27
0
Fichier : List.cs Projet : mnisl/OD
		private void PrepGroups(Report rpt, WorkClass wc)
		{
			if (_Grouping == null)
				return;

			int i=0;
			// 1) Build array of all GroupExpression objects
			List<GroupExpression> gea = _Grouping.GroupExpressions.Items;
			GroupEntry[] currentGroups = new GroupEntry[1];
			_Grouping.SetIndex(rpt, 0);	// set the index of this group (so we can find the GroupEntry)
			currentGroups[0] = new GroupEntry(_Grouping, _Sorting, 0);

			// Save the typecodes, and grouping by groupexpression; for later use
			TypeCode[] tcs = new TypeCode[gea.Count];
			Grouping[] grp = new Grouping[gea.Count];
			i=0;
			foreach (GroupExpression ge in gea)
			{
				grp[i] = (Grouping) (ge.Parent.Parent);			// remember the group
				tcs[i++] = ge.Expression.GetTypeCode();	// remember type of expression
			}

			// 2) Loop thru the data, then loop thru the GroupExpression list
			wc.Groups = new List<GroupEntry>();
			object[] savValues=null;
			object[] grpValues=null;
			int rowCurrent = 0;

			foreach (Row row in wc.Data.Data)
			{
				// Get the values for all the group expressions
				if (grpValues == null)
					grpValues = new object[gea.Count];

				i=0;
				foreach (GroupExpression ge in gea)  // Could optimize to only calculate as needed in comparison loop below??
				{
					grpValues[i++] = ge.Expression.Evaluate(rpt, row);
				}

				// For first row we just primed the pump; action starts on next row
				if (rowCurrent == 0)			// always start new group on first row
				{
					rowCurrent++;
					savValues = grpValues;
					grpValues = null;
					continue;
				}

				// compare the values; if change then we have a group break
				for (i = 0; i < savValues.Length; i++)
				{
					if (Filter.ApplyCompare(tcs[i], savValues[i], grpValues[i]) != 0)
					{
						// start a new group; and force a break on every subgroup
						GroupEntry saveGe=null;	
						for (int j = grp[i].GetIndex(rpt); j < currentGroups.Length; j++)
						{
							currentGroups[j].EndRow = rowCurrent-1;
							if (j == 0)
								wc.Groups.Add(currentGroups[j]);		// top group
							else if (saveGe == null)
								currentGroups[j-1].NestedGroup.Add(currentGroups[j]);
							else 
								saveGe.NestedGroup.Add(currentGroups[j]);

							saveGe = currentGroups[j];	// retain this GroupEntry
							currentGroups[j] = new GroupEntry(currentGroups[j].Group,currentGroups[j].Sort, rowCurrent);
						}
						savValues = grpValues;
						grpValues = null;
						break;		// break out of the value comparison loop
					}
				}
				rowCurrent++;
			}

			// End of all rows force break on end of rows
			for (i = 0; i < currentGroups.Length; i++)
			{
				currentGroups[i].EndRow = rowCurrent-1;
				if (i == 0)
					wc.Groups.Add(currentGroups[i]);		// top group
				else
					currentGroups[i-1].NestedGroup.Add(currentGroups[i]);
			}
			return;
		}
Exemple #28
0
 // called at start for each grouping instance
 public void GroupingInstanceStart(Grouping g)
 {
 }
Exemple #29
0
 public void GroupingInstanceEnd(Grouping g)	// called at start for each grouping instance
 {
 }
Exemple #30
0
 public void GroupingInstanceStart(Grouping g)
 {
 }
Exemple #31
0
 // called at start for each grouping instance
 public void GroupingInstanceStart(Grouping g)
 {
     if (g.DataElementOutput != DataElementOutputEnum.Output)
         return;
     PushContainer(g.DataElementName);
 }
 // called at end of grouping
 public virtual void GroupingEnd(Grouping g)
 {
 }
Exemple #33
0
        private void PrepRecursiveGroup(Report rpt, TableWorkClass wc)
        {
            // Prepare for processing recursive group
            Grouping        g          = wc.RecursiveGroup;
            IExpr           parentExpr = g.ParentGroup;
            GroupExpression gexpr      = g.GroupExpressions.Items[0] as GroupExpression;
            IExpr           groupExpr  = gexpr.Expression;
            TypeCode        tc         = groupExpr.GetTypeCode();
            List <Row>      odata      = new List <Row>(wc.Data.Data);          // this is the old data that we'll recreate using the recursive hierarchy
            List <Row>      newrows    = new List <Row>(odata.Count);

            // For now we assume on a single top of tree (and it must sort first as null)
            //   spec is incomplete: should have ability to specify starting value of tree
            // TODO: pull all of the rows that start with null
            newrows.Add(odata[0]);                                              // add the starting row
            odata.RemoveAt(0);                                                  //   remove olddata

            // we need to build the group entry stack
            // Build the initial one
            wc.Groups = new List <GroupEntry>();
            GroupEntry ge = new GroupEntry(null, null, 0);

            ge.EndRow = odata.Count - 1;
            wc.Groups.Add(ge);                                          // top group

            List <GroupEntry> ges = new List <GroupEntry>();

            ges.Add(ge);

            // loop thru the rows and find their children
            //   we place the children right after the parent
            //   this reorders the rows in the form of the hierarchy
            Row r;
            RecursiveCompare rc = new RecursiveCompare(rpt, parentExpr, tc, groupExpr);

            for (int iRow = 0; iRow < newrows.Count; iRow++)            // go thru the temp rows
            {
                r = newrows[iRow];

                r.GroupEntry        = ge = new GroupEntry(g, null, iRow);               // TODO: sort for this group??
                r.GroupEntry.EndRow = iRow;

                // pull out all the rows that match this value
                int iMainRow = odata.BinarySearch(r, rc);
                if (iMainRow < 0)
                {
                    for (int i = 0; i <= r.Level + 1 && i < ges.Count; i++)
                    {
                        ge = ges[i] as GroupEntry;
                        Row rr = newrows[ge.StartRow];                          // start row has the base level of group
                        if (rr.Level < r.Level)
                        {
                            ge.EndRow = iRow;
                        }
                    }
                    continue;
                }

                // look backward for starting row;
                //   in case of duplicates, BinarySearch can land on any of the rows
                object cmpvalue = groupExpr.Evaluate(rpt, r);

                int sRow = iMainRow - 1;
                while (sRow >= 0)
                {
                    object v = parentExpr.Evaluate(rpt, odata[sRow]);
                    if (Filter.ApplyCompare(tc, cmpvalue, v) != 0)
                    {
                        break;
                    }
                    sRow--;
                }
                sRow++;                         // adjust; since we went just prior it
                // look forward for ending row
                int eRow = iMainRow + 1;
                while (eRow < odata.Count)
                {
                    object v = parentExpr.Evaluate(rpt, odata[eRow]);
                    if (Filter.ApplyCompare(tc, cmpvalue, v) != 0)
                    {
                        break;
                    }
                    eRow++;
                }
                // Build a group entry for this
                GroupEntry ge2 = ges[r.Level] as GroupEntry;
                ge2.NestedGroup.Add(ge);
                if (r.Level + 1 >= ges.Count)                   // ensure we have room in the array (based on level)
                {
                    ges.Add(ge);                                // add to the array
                }
                else
                {
                    ges[r.Level + 1] = ge;                                              // put this in the array
                }

                // add all of them in; want the same order for these rows.
                int offset = 1;
                for (int tRow = sRow; tRow < eRow; tRow++)
                {
                    Row tr = odata[tRow];
                    tr.Level = r.Level + 1;
                    newrows.Insert(iRow + offset, tr);
                    offset++;
                }
                // remove from old data
                odata.RemoveRange(sRow, eRow - sRow);
            }

            // update the groupentries for the very last row
            int lastrow = newrows.Count - 1;

            r = newrows[lastrow];
            for (int i = 0; i < r.Level + 1 && i < ges.Count; i++)
            {
                ge        = ges[i] as GroupEntry;
                ge.EndRow = lastrow;
            }

            wc.Data.Data = newrows;                     // we've completely replaced the rows
            return;
        }
 // called at start for each grouping instance
 public virtual void GroupingInstanceStart(Grouping g)
 {
 }
Exemple #35
0
 // called at start for each grouping instance
 public void GroupingInstanceEnd(Grouping g)
 {
 }
Exemple #36
0
        override internal void FinalPass()
        {
            // optimization: avoid expression overhead if this isn't really an expression
            if (_Source == null)
            {
                _Expr = new Constant("");
                return;
            }
            else if (_Source == "" ||                   // empty expression
                     _Source[0] != '=')                 // if 1st char not '='
            {
                _Expr = new Constant(_Source);          //   this is a constant value
                return;
            }

            Parser p = new Parser(OwnerReport.DataCache);

            // find the fields that are part of the DataRegion (if there is one)
            IDictionary fields = null;
            ReportLink  dr     = Parent;
            Grouping    grp    = null;                  // remember if in a table group or detail group or list group
            Matrix      m      = null;
            ReportLink  phpf   = null;

            while (dr != null)
            {
                if (dr is Grouping)
                {
                    p.NoAggregateFunctions = true;
                }
                else if (dr is TableGroup)
                {
                    grp = ((TableGroup)dr).Grouping;
                }
                else if (dr is Matrix)
                {
                    m = (Matrix)dr;                                     // if matrix we need to pass special
                    break;
                }
                else if (dr is Details)
                {
                    grp = ((Details)dr).Grouping;
                }
                else if (dr is List)
                {
                    grp = ((List)dr).Grouping;
                    break;
                }
                else if (dr is PageHeader || dr is PageFooter)
                {
                    phpf = dr;
                }
                else if (dr is DataRegion || dr is DataSetDefn)
                {
                    break;
                }
                dr = dr.Parent;
            }
            if (dr != null)
            {
                if (dr is DataSetDefn)
                {
                    DataSetDefn d = (DataSetDefn)dr;
                    if (d.Fields != null)
                    {
                        fields = d.Fields.Items;
                    }
                }
                else                    // must be a DataRegion
                {
                    DataRegion d = (DataRegion)dr;
                    if (d.DataSetDefn != null &&
                        d.DataSetDefn.Fields != null)
                    {
                        fields = d.DataSetDefn.Fields.Items;
                    }
                }
            }

            NameLookup lu = new NameLookup(fields, OwnerReport.LUReportParameters,
                                           OwnerReport.LUReportItems, OwnerReport.LUGlobals,
                                           OwnerReport.LUUser, OwnerReport.LUAggrScope,
                                           grp, m, OwnerReport.CodeModules, OwnerReport.Classes, OwnerReport.DataSetsDefn,
                                           OwnerReport.CodeType);

            if (phpf != null)
            {
                // Non-null when expression is in PageHeader or PageFooter;
                //   Expression name needed for dynamic lookup of ReportItems on a page.
                lu.PageFooterHeader = phpf;
                lu.ExpressionName   = _UniqueName = "xn_" + Interlocked.Increment(ref Parser.Counter).ToString();
            }

            try
            {
                _Expr = p.Parse(lu, _Source);
            }
            catch (Exception e)
            {
                _Expr = new ConstantError(e.Message);
                // Invalid expression
                OwnerReport.rl.LogError(8, ErrorText(e.Message));
            }

            // Optimize removing any expression that always result in a constant
            try
            {
                _Expr = _Expr.ConstantOptimization();
            }
            catch (Exception ex)
            {
                OwnerReport.rl.LogError(4, "Expression:" + _Source + "\r\nConstant Optimization exception:\r\n" + ex.Message + "\r\nStack trace:\r\n" + ex.StackTrace);
            }
            _Type = _Expr.GetTypeCode();

            return;
        }
Exemple #37
0
 // called at start of grouping
 public void GroupingStart(Grouping g)
 {
 }
Exemple #38
0
 public void GroupingStart(Grouping g)
 {
 }