public void Collection_Contains_Subclass()
        {
            var            modifyedCollection = this.ModifyCollection();
            IDataManager   dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(modifyedCollection, new ReportSettings());
            IDataNavigator dn = dm.GetNavigator;

            ReportItemCollection searchCol = new ReportItemCollection();

            searchCol.Add(new BaseDataItem()
            {
                ColumnName = "DummyClass.DummyString"
            }
                          );

            searchCol.Add(new BaseDataItem()
            {
                Name       = "GroupItem",
                ColumnName = "GroupItem"
            }
                          );

            dn.Reset();
            dn.MoveNext();

            while (dn.MoveNext())
            {
                dn.Fill(searchCol);
                var a = (BaseDataItem)searchCol[0];
                var b = (BaseDataItem)searchCol[1];
                var c = modifyedCollection[dn.CurrentRow];
                Assert.AreEqual(a.DBValue, c.DummyClass.DummyString);
                Assert.AreEqual(b.DBValue, c.GroupItem);
            }
        }
        public void NullValue_In_Property_Should_Return_EmptyString()
        {
            ContributorsList contributorsList = new ContributorsList();
            var contColl = contributorsList.ContributorCollection;

            foreach (Contributor element in contColl)
            {
                element.GroupItem = null;
            }

            IDataManager   dm      = ICSharpCode.Reports.Core.DataManager.CreateInstance(contColl, new ReportSettings());
            IDataNavigator dataNav = dm.GetNavigator;


            ReportItemCollection searchCol = new ReportItemCollection();

            searchCol.Add(new BaseDataItem()
            {
                Name       = "GroupItem",
                ColumnName = "GroupItem"
            }
                          );
            dataNav.Reset();
            dataNav.MoveNext();
            do
            {
                dataNav.Fill(searchCol);
                BaseDataItem resultItem = searchCol[0] as BaseDataItem;

                Assert.That(resultItem.Name, Is.EqualTo("GroupItem"));
                Assert.That(resultItem.DBValue, Is.EqualTo(String.Empty));
            }while (dataNav.MoveNext());
        }
        public void EnumeratorStartFromBegin()
        {
            IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table,
                                                                                  new ReportSettings());
            IDataNavigator dn = dm.GetNavigator;

            dn.MoveNext();
            int start = 0;

            do
            {
                DataRow v = dn.Current as DataRow;
                start++;
            }while (dn.MoveNext());
            Assert.AreEqual(this.table.Rows.Count, start);
        }
Exemple #4
0
        private List <object> SetupDataSource(object data, IDataNavigator navigator)
        {
            navigator.Reset();
            List <object> list = new List <object>();

            while (navigator.MoveNext())
            {
                CurrentItemsCollection row         = navigator.GetDataRow();
                CurrentItem            currentItem = ExtractItemFromDataSet(row, data);

                if (currentItem != null)
                {
                    object s1 = Convert.ToString(currentItem.Value.ToString(), CultureInfo.CurrentCulture);

                    if (IsNumeric(s1))
                    {
                        list.Add(Convert.ToDouble(s1, System.Globalization.CultureInfo.CurrentCulture));
                    }
                    else
                    {
                        list.Add(true);
                    }
                }
                else
                {
                    string str = String.Format("<{0}> not found in AggregateFunction", data.ToString());
                    throw new FieldNotFoundException(str);
                }
            }
            return(list);
        }
        public void EnumeratorStartFromBegin()
        {
            IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection, new ReportSettings());

            IDataNavigator dataNav = dm.GetNavigator;

            dataNav.MoveNext();
            int start = 0;

            do
            {
                Contributor view = dataNav.Current as Contributor;
                start++;
            }while (dataNav.MoveNext());
            Assert.AreEqual(this.contributorCollection.Count, start);
        }
        public void CollectionContainsSubclass()
        {
            var            modifyedCollection = this.ModifyCollection();
            GroupColumn    gc = new GroupColumn("GroupItem", 1, ListSortDirection.Ascending);
            ReportSettings rs = new ReportSettings();

            rs.GroupColumnsCollection.Add(gc);

            IDataManager   dm            = ICSharpCode.Reports.Core.DataManager.CreateInstance(modifyedCollection, rs);
            IDataNavigator dataNavigator = dm.GetNavigator;

            ReportItemCollection searchCol = new ReportItemCollection();

            searchCol.Add(new BaseDataItem()
            {
                ColumnName = "DummyClass.DummyString"
            }
                          );
            searchCol.Add(new BaseDataItem()
            {
                Name       = "Last",
                ColumnName = "Last"
            }
                          );

            searchCol.Add(new BaseDataItem()
            {
                ColumnName = "GroupItem"
            }
                          );

            string compare = string.Empty;

            while (dataNavigator.MoveNext())
            {
                dataNavigator.Fill(searchCol);
                var b1     = (BaseDataItem)searchCol[2];
                var result = b1.DBValue;
                Assert.That(compare, Is.LessThan(result));

                if (dataNavigator.HasChildren)
                {
                    var childNavigator = dataNavigator.GetChildNavigator;
                    do
                    {
                        childNavigator.Fill(searchCol);
                        var itemDummy = (BaseDataItem)searchCol[0];
                        var itemLast  = (BaseDataItem)searchCol[1];
                        var itemGroup = (BaseDataItem)searchCol[2];
                        Console.WriteLine("\t{0} - {1} - {2}", itemDummy.DBValue, itemLast.DBValue, itemGroup.DBValue);
                        Assert.That(itemDummy.DBValue, Is.Not.Empty);
                        Assert.That(itemLast.DBValue, Is.Not.Empty);
                        Assert.That(itemGroup.DBValue, Is.Not.Empty);
                    }while (childNavigator.MoveNext());
                }
                compare = result;
            }
        }
        public void SubPropertyName_Is_Wrong()
        {
            var                  modifyedCollection = this.ModifyCollection();
            IDataManager         dm        = ICSharpCode.Reports.Core.DataManager.CreateInstance(modifyedCollection, new ReportSettings());
            IDataNavigator       dn        = dm.GetNavigator;
            ReportItemCollection searchCol = new ReportItemCollection();

            searchCol.Add(new BaseDataItem()
            {
                Name       = "GroupItem",
                ColumnName = "DummyClass.Wrong",
                DataType   = "System.Int32"
            }
                          );
            dn.Reset();
            dn.MoveNext();
            while (dn.MoveNext())
            {
                dn.Fill(searchCol);
                var a = (BaseDataItem)searchCol[0];
                Assert.That(a.DBValue.StartsWith("Error"));
            }
        }
 private void RecursiveCall(IDataNavigator startNavigator)
 {
     do
     {
         DataRow r  = startNavigator.Current as DataRow;
         string  v1 = r["last"].ToString() + " :" + r[3].ToString();
         Console.WriteLine("\t {0}", v1);
         if (startNavigator.HasChildren)
         {
             IDataNavigator child = startNavigator.GetChildNavigator();
             Console.WriteLine("header {0} - Child_Count:{1}", v1, child.Count);
             RecursiveCall(child);
         }
     } while (startNavigator.MoveNext());
 }
        public void DataNavigator_Return_ErrMessage_If_ColumnName_NotExist()
        {
            IDataManager   dm      = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection, new ReportSettings());
            IDataNavigator dataNav = dm.GetNavigator;
            BaseDataItem   item    = new BaseDataItem();

            item.ColumnName = "ColumnNotExist";
            var items = new ReportItemCollection();

            items.Add(item);
            dataNav.Reset();
            dataNav.MoveNext();
            dataNav.Fill(items);
//			string str = "<" + item.ColumnName +">";
            Assert.That(item.DBValue.StartsWith("Error"));
        }
        private ExporterCollection ConvertDataRow(ISimpleContainer simpleContainer)
        {
            ExporterCollection exporterCollection = new ExporterCollection();

            base.CurrentPosition = base.SectionBounds.Offset;
            var         p       = base.CurrentPosition;
            BaseSection section = parent as BaseSection;

            DefaultLeftPosition = parent.Location.X;
            Size groupSize = Size.Empty;
            Size childSize = Size.Empty;

            if (section.Items.FindGroupHeader().Count > 0)
            {
                groupSize = section.Items[0].Size;
                childSize = section.Items[1].Size;
            }

            do
            {
                base.SaveSectionSize(section.Size);
                PrintHelper.AdjustSectionLocation(section);
                section.Size = this.SectionBounds.DetailSectionRectangle.Size;

                // did we have GroupedItems at all
                if (section.Items.FindGroupHeader().Count > 0)
                {
                    // GetType child navigator
                    IDataNavigator childNavigator = base.DataNavigator.GetChildNavigator;

                    base.Evaluator.SinglePage.IDataNavigator = childNavigator;
                    base.CurrentPosition  = ConvertGroupHeader(exporterCollection, section, base.CurrentPosition);
                    section.Size          = base.RestoreSectionSize;
                    section.Items[0].Size = groupSize;
                    section.Items[1].Size = childSize;

                    childNavigator.Reset();
                    childNavigator.MoveNext();

                    //Convert children
                    if (childNavigator != null)
                    {
                        StandardPrinter.AdjustBackColor(simpleContainer);
                        do
                        {
                            section.Size          = base.RestoreSectionSize;
                            section.Items[0].Size = groupSize;
                            section.Items[1].Size = childSize;

                            FillRow(simpleContainer, childNavigator);
                            FireRowRendering(simpleContainer, childNavigator);
                            PrepareContainerForConverting(section, simpleContainer);
                            base.CurrentPosition = ConvertStandardRow(exporterCollection, simpleContainer);
                            CheckForPageBreak(section, exporterCollection);
                        }while (childNavigator.MoveNext());

                        // GroupFooter
                        base.ConvertGroupFooter(section, exporterCollection);

                        base.PageBreakAfterGroupChange(section, exporterCollection);

                        base.Evaluator.SinglePage.IDataNavigator = base.DataNavigator;
                    }
                }
                else
                {
                    // No Grouping at all, the first item in section.items is the DetailRow
                    Size containerSize = section.Items[0].Size;
                    FillRow(simpleContainer, base.DataNavigator);
                    FireRowRendering(simpleContainer, base.DataNavigator);
                    Console.WriteLine("ConvertDazaRow");
                    base.PrepareContainerForConverting(section, simpleContainer);
                    base.CurrentPosition  = ConvertStandardRow(exporterCollection, simpleContainer);
                    section.Size          = base.RestoreSectionSize;
                    section.Items[0].Size = containerSize;
                }
                CheckForPageBreak(section, exporterCollection);
                ShouldDrawBorder(section, exporterCollection);
            }while (base.DataNavigator.MoveNext());

            SectionBounds.ReportFooterRectangle = new Rectangle(SectionBounds.ReportFooterRectangle.Left,
                                                                section.Location.Y + section.Size.Height,
                                                                SectionBounds.ReportFooterRectangle.Width,
                                                                SectionBounds.ReportFooterRectangle.Height);

            return(exporterCollection);
        }
		private void RecursiveCall (IDataNavigator startNavigator)
		{
			do
			{
				DataRow r = startNavigator.Current as DataRow;
				string v1 = r["last"].ToString() + " :" +  r[3].ToString();
				Console.WriteLine("\t {0}",v1);
				if (startNavigator.HasChildren) {
					IDataNavigator child = startNavigator.GetChildNavigator();
					Console.WriteLine("header {0} - Child_Count:{1}",v1,child.Count);
					RecursiveCall (child);
				}
				
			} while (startNavigator.MoveNext());
		}
Exemple #12
0
        private ExporterCollection ConvertInternal(ExporterCollection exporterCollection)
        {
            BaseSection section = table.Parent as BaseSection;

            ISimpleContainer headerRow     = null;
            Point            dataAreaStart = new Point(table.Items[0].Location.X, table.Items[0].Location.Y + base.CurrentPosition.Y);

            base.CurrentPosition = new Point(PrintHelper.DrawingAreaRelativeToParent(this.table.Parent, this.table).Location.X,
                                             base.SectionBounds.DetailArea.Top);

            base.DefaultLeftPosition = base.CurrentPosition.X;

            this.table.Items.SortByLocation();

            // Header

            var  simpleContainer = table.Items[0] as ISimpleContainer;
            Size containerSize   = Size.Empty;

            if (simpleContainer.Items.Count > 0)
            {
                simpleContainer.Location = new Point(simpleContainer.Location.X, simpleContainer.Location.Y);
                simpleContainer.Parent   = (BaseReportItem)this.table;

                base.SaveSectionSize(section.Size);
                containerSize = simpleContainer.Size;

                if (PrintHelper.IsTextOnlyRow(simpleContainer))
                {
                    headerRow = simpleContainer;
                    base.PrepareContainerForConverting(section, headerRow);
                    base.CurrentPosition = ConvertContainer(exporterCollection, headerRow, base.DefaultLeftPosition, base.CurrentPosition);
                }

                GroupHeader row = table.Items[1] as GroupHeader;

                if (row != null)
                {
                    //grouped
                    do
                    {
                        // GetType child navigator
                        IDataNavigator childNavigator = base.DataNavigator.GetChildNavigator;

                        base.Evaluator.SinglePage.IDataNavigator = childNavigator;
                        // Convert Grouping Header

                        base.CurrentPosition = ConvertGroupHeader(exporterCollection, section, base.CurrentPosition);

                        childNavigator.Reset();
                        childNavigator.MoveNext();

                        //Convert children
                        if (childNavigator != null)
                        {
                            do
                            {
                                StandardPrinter.AdjustBackColor(simpleContainer);
                                simpleContainer = table.Items[2] as ISimpleContainer;
                                containerSize   = simpleContainer.Size;

                                FillRow(simpleContainer, childNavigator);
                                FireRowRendering(simpleContainer, childNavigator);
                                PrepareContainerForConverting(section, simpleContainer);
                                base.CurrentPosition = ConvertStandardRow(exporterCollection, simpleContainer);

                                simpleContainer.Size = containerSize;
                                CheckForPageBreak(section, simpleContainer, headerRow, exporterCollection);
                            }while (childNavigator.MoveNext());

                            // GroupFooter
                            base.ConvertGroupFooter(table, exporterCollection);
                            base.PageBreakAfterGroupChange(section, exporterCollection);

                            base.Evaluator.SinglePage.IDataNavigator = base.DataNavigator;
                        }
                    }while (base.DataNavigator.MoveNext());
                }

                else
                {
                    // No Grouping at all

                    simpleContainer = table.Items[1] as ISimpleContainer;
                    base.SaveSectionSize(section.Size);
                    containerSize = simpleContainer.Size;

                    do
                    {
                        PrintHelper.AdjustSectionLocation(section);
                        CheckForPageBreak(section, simpleContainer, headerRow, exporterCollection);

                        FillRow(simpleContainer, base.DataNavigator);
                        FireRowRendering(simpleContainer, base.DataNavigator);
                        base.PrepareContainerForConverting(section, simpleContainer);

                        base.CurrentPosition = ConvertStandardRow(exporterCollection, simpleContainer);
                        simpleContainer.Size = containerSize;
                        section.Size         = base.RestoreSectionSize;
                    }while (base.DataNavigator.MoveNext());
                    base.DataNavigator.Reset();
                    base.DataNavigator.MoveNext();
                    SectionBounds.ReportFooterRectangle = new Rectangle(SectionBounds.ReportFooterRectangle.Left,
                                                                        base.CurrentPosition.Y,
                                                                        SectionBounds.ReportFooterRectangle.Width,
                                                                        SectionBounds.ReportFooterRectangle.Height);
                }
            }
            return(exporterCollection);
        }