コード例 #1
0
        private static void AssignOwnerAndUniquePath(BaseBand owner)
        {
            foreach (var band in owner.Bands)
            {
                band.Owner      = owner;
                band.ViewID     = owner.ViewID;
                band.UniquePath = CalculateUniquePath(band);
                AssignOwnerAndUniquePath(band);
            }

            foreach (var column in owner.Columns)
            {
                column.Owner      = owner;
                column.ViewID     = owner.ViewID;
                column.UniquePath = CalculateUniquePath(column);
            }
        }
コード例 #2
0
        public void SetIds(BaseBand band)
        {
            for (var i = 0; i < Bands.Count; i++)
            {
                if (band.Bands.Exists(b => b.UniquePath == Bands[i].UniquePath))
                {
                    Bands[i].ID = band.Bands.Single(b => b.UniquePath == Bands[i].UniquePath).ID;
                }
            }

            for (var i = 0; i < Columns.Count; i++)
            {
                if (band.Columns.Exists(c => c.UniquePath == Columns[i].UniquePath))
                {
                    Columns[i].ID = band.Columns.Single(c => c.UniquePath == Columns[i].UniquePath).ID;
                }
            }
        }
コード例 #3
0
        protected void AdjustToNew(BaseBand pivotBand)
        {
            //delete deleted in pivot bands, save pivot properties if bands preserved in pivot
            for (var i = 0; i < Bands.Count; i++)
            {
                if (pivotBand.Bands.Exists(b => b.UniquePath == Bands[i].UniquePath))
                {
                    // save pivot properties if bands preserved in pivot
                    var nBand = pivotBand.Bands.Single(b => b.UniquePath == Bands[i].UniquePath);
                    Bands[i].SavePivotSettings(pivotBand.Bands.IndexOf(nBand), nBand);
                    Bands[i].AdjustToNew(nBand);
                }
                else
                {
                    //delete deleted in pivot bands and count remained bands
                    if (!Bands[i].Delete())
                    {
                        Bands.RemoveAt(i--);
                    }
                }
            }

            //delete deleted in pivot columns, save pivot properties if columns preserved in pivot
            for (var i = 0; i < Columns.Count; i++)
            {
                if (pivotBand.Columns.Exists(c => c.UniquePath == Columns[i].UniquePath))
                {
                    // save pivot properties if columns were preserved in pivot
                    var newCol = pivotBand.Columns.Single(c => c.UniquePath == Columns[i].UniquePath);
                    Columns[i].SavePivotSettings(pivotBand.Columns.IndexOf(newCol), newCol);
                }
                else
                {
                    //delete deleted in pivot columns and count remained columns
                    if (!Columns[i].IsAggregate)
                    {
                        if (!Columns[i].Delete())
                        {
                            Columns.RemoveAt(i--);
                        }
                    }
                    // delete references of aggregate column if its references died
                    else
                    {
                        if (Columns[i].SourceViewColumn != null && pivotBand.GetColumnByOriginalName(Columns[i].SourceViewColumn) == null)
                        {
                            Columns[i].SourceViewColumn = null;
                        }

                        if (Columns[i].DenominatorViewColumn != null &&
                            pivotBand.GetColumnByOriginalName(Columns[i].DenominatorViewColumn) == null)
                        {
                            Columns[i].DenominatorViewColumn = null;
                        }
                    }
                }
            }

            // add new pivot bands
            for (var i = 0; i < pivotBand.Bands.Count; i++)
            {
                if (!Bands.Exists(b => b.UniquePath == pivotBand.Bands[i].UniquePath))
                {
                    pivotBand.Bands[i].OriginalName = pivotBand.Bands[i].DisplayText;
                    AddBand(i, pivotBand.Bands[i]);
                }
            }

            // add new pivot columns
            for (var i = 0; i < pivotBand.Columns.Count; i++)
            {
                if (!Columns.Exists(c => c.UniquePath == pivotBand.Columns[i].UniquePath))
                {
                    pivotBand.Columns[i].OriginalName = pivotBand.Columns[i].DisplayText;
                    pivotBand.Columns[i].SavePivotSettings(i, pivotBand.Columns[i]);
                    pivotBand.Columns[i].SetUnchanged();
                    AddColumn(pivotBand.Columns[i]);
                }
            }

            // set default order for aggregate columns as last in band
            var maxNotAggr = Columns.Count(c => !c.IsAggregate);

            foreach (var cCol in Columns.FindAll(c => c.IsAggregate))
            {
                cCol.Order_Pivot = maxNotAggr++;
            }
        }