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);
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        public void SortChildrenDescending()
        {
            ReportSettings rs = new ReportSettings();
            GroupColumn    gc = new GroupColumn("GroupItem", 1, ListSortDirection.Ascending);

            rs.GroupColumnsCollection.Add(gc);

            SortColumn sc = new SortColumn("Last", ListSortDirection.Descending);

            rs.SortColumnsCollection.Add(sc);
            IDataManager dm            = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection, rs);
            var          dataNavigator = dm.GetNavigator;

            ReportItemCollection searchCol = new ReportItemCollection();

            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 column = (BaseDataItem)searchCol[1];
                var result = column.DBValue.ToString();

                Assert.That(compare, Is.LessThan(result));
                if (dataNavigator.HasChildren)
                {
                    string compareChild   = String.Empty;
                    var    childNavigator = dataNavigator.GetChildNavigator;
                    do
                    {
                        childNavigator.Fill(searchCol);
                        var childColumn = (BaseDataItem)searchCol[0];
                        var childResult = childColumn.DBValue.ToString();
//						Console.WriteLine("\t{0}",childResult);
                        if (!String.IsNullOrEmpty(compareChild))
                        {
                            Assert.LessOrEqual(childResult, compareChild);
                        }
                        compareChild = childResult;
                    }while (childNavigator.MoveNext());
                }
            }
        }
Exemplo n.º 4
0
        private ReportItemCollection PlainCollection()
        {
            ReportItemCollection ri = new ReportItemCollection();
            BaseTextItem         t1 = new BaseTextItem();

            t1.Name = "t1";
            ri.Add(t1);
            t1      = new BaseTextItem();
            t1.Name = "t2";
            ri.Add(t1);
            t1      = new BaseTextItem();
            t1.Name = "t3";
            ri.Add(t1);
            return(ri);
        }
Exemplo n.º 5
0
        public void DateTimeCan_FillChild()
        {
            var dataNavigator = PrepareDateTimeGrouping();
            ReportItemCollection searchCol = new ReportItemCollection();

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

            var compare = System.DateTime.MinValue;

            while (dataNavigator.MoveNext())
            {
                Contributor groupResult = dataNavigator.Current as Contributor;
                Assert.LessOrEqual(compare, groupResult.RandomDate);
                if (dataNavigator.HasChildren)
                {
                    var childNavigator = dataNavigator.GetChildNavigator;
                    do
                    {
                        Assert.That(dataNavigator.HasChildren, Is.True);
                        // we know that current is a 'contributor'
                        Contributor c = dataNavigator.Current as Contributor;
                        Assert.IsNotNull(c);
//						string v2 = c.Last + " GroupVal :" +  c.RandomDate;
//						Console.WriteLine(v2);
                    }while (childNavigator.MoveNext());
                }
            }
        }
        public void  Convert_SimpleItems_Should_Calculate_Correct_Locations()
        {
            ReportItemCollection ri     = new ReportItemCollection();
            Point          itemLocation = new Point(10, 10);
            BaseReportItem r            = new BaseTextItem()
            {
                Location = itemLocation,
                Size     = new Size(20, 100)
            };

            ri.Add(r);

            Point     offset          = new Point(20, 20);
            Rectangle parentRectangle = new Rectangle(50, 50, 700, 50);

            Sut.ParentRectangle = parentRectangle;

            ExporterCollection ec = Sut.ConvertSimpleItems(offset, ri);

            BaseExportColumn be = ec[0];

//			this.ParentRectangle.Location.X + lineItem.StyleDecorator.Location.X,
//				                                             lineItem.StyleDecorator.Location.Y + offset.Y);


            Point resultLocation = new Point(parentRectangle.Location.X + itemLocation.X, itemLocation.Y + offset.Y);

            Assert.AreEqual(resultLocation, be.StyleDecorator.Location);
        }
        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());
        }
Exemplo n.º 8
0
        private void WriteResult()
        {
            if (this.resultDataSet != null)
            {
                // check reordering of columns
                DataGridViewColumn[]         displayCols;
                DataGridViewColumnCollection dc = this.grdQuery.Columns;

                displayCols = new DataGridViewColumn[dc.Count];
                for (int i = 0; i < dc.Count; i++)
                {
                    if (dc[i].Visible)
                    {
                        displayCols[dc[i].DisplayIndex] = dc[i];
                    }
                }


                ReportItemCollection sourceItems = WizardHelper.ReportItemCollection(this.resultDataSet);

                AvailableFieldsCollection abstractColumns = WizardHelper.AvailableFieldsCollection(this.resultDataSet);

                ReportItemCollection destItems = new ReportItemCollection();

                // only checked columns are used in the report
                foreach (DataGridViewColumn cc in displayCols)
                {
                    DataGridViewColumnHeaderCheckBoxCell hc = (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell;
                    if (hc.Checked)
                    {
                        BaseReportItem br = (BaseReportItem)sourceItems.Find(cc.HeaderText);
                        destItems.Add(br);
                    }
                }

                reportStructure.ReportItemCollection.Clear();
                reportStructure.ReportItemCollection.AddRange(destItems);

                /*
                 * if ((this.sqlParamsCollection != null) && (this.sqlParamsCollection.Count > 0)) {
                 *      reportStructure.SqlQueryParameters.AddRange(sqlParamsCollection);
                 * }
                 */
                if (abstractColumns != null)
                {
                    reportStructure.AvailableFieldsCollection.Clear();
                    reportStructure.AvailableFieldsCollection.AddRange(abstractColumns);
                }

                /*
                 * if ((this.sqlParamsCollection != null) && (this.sqlParamsCollection.Count > 0)) {
                 *      reportStructure.SqlQueryParameters.Clear();
                 *      reportStructure.SqlQueryParameters.AddRange(sqlParamsCollection);
                 * }
                 */
            }
            base.EnableNext   = true;
            base.EnableFinish = true;
        }
Exemplo n.º 9
0
        internal static ReportItemCollection DataItemsFromDataSet(DataSet dataSet)
        {
            if (dataSet == null)
            {
                throw new ArgumentNullException("dataSet");
            }

            if (dataSet.Tables.Count > 1)
            {
                string s = String.Format(System.Globalization.CultureInfo.InvariantCulture,
                                         "AutoBuildFromDataSet : at this time no more than one table is allowed <{0}>", dataSet.Tables.Count);
                ICSharpCode.Core.MessageService.ShowError(s);
            }

            ReportItemCollection itemCol = new ReportItemCollection();

            foreach (DataTable tbl in dataSet.Tables)
            {
                foreach (DataColumn col  in tbl.Columns)
                {
                    if (col.DataType == typeof(System.Byte[]))
                    {
                        ICSharpCode.Reports.Core.BaseImageItem rItem = new ICSharpCode.Reports.Core.BaseImageItem();
                        rItem.ColumnName       = col.ColumnName;
                        rItem.BaseTableName    = tbl.TableName;
                        rItem.Name             = col.ColumnName;
                        rItem.ScaleImageToSize = false;
                        itemCol.Add(rItem);
                    }
                    else
                    {
                        ICSharpCode.Reports.Core.BaseDataItem rItem = new ICSharpCode.Reports.Core.BaseDataItem();
                        rItem.ColumnName    = col.ColumnName;
                        rItem.DBValue       = col.ColumnName;
                        rItem.BaseTableName = tbl.TableName;
                        rItem.DataType      = col.DataType.ToString();
                        rItem.Name          = col.ColumnName;
                        rItem.Text          = "=[" + col.ColumnName + "]";
                        itemCol.Add(rItem);
                    }
                }
            }
            return(itemCol);
        }
Exemplo n.º 10
0
        public void Add()
        {
            var addView = new AddReportItemView();

            if (addView.ShowDialog() == true)
            {
                _lookup.Add(addView.NewItem);
                _viewModel.Collection.Add(addView.NewItem);
            }
        }
Exemplo n.º 11
0
		internal static  ReportItemCollection ExtractSelectedItems(ReportItemCollection sourceItems,DataGridViewColumn[] displayCols)
		{
			var destItems = new ReportItemCollection();
			foreach (DataGridViewColumn cc in displayCols) {
				DataGridViewColumnHeaderCheckBoxCell hc = (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell;
				if (hc.Checked) {
					BaseReportItem br = (BaseReportItem)sourceItems.Find(cc.HeaderText);
					destItems.Add(br);
				}
			}
			return destItems;
		}
Exemplo n.º 12
0
		public void FillCollection()
		{
			var dataNavigator = PrepareStringGrouping();
			ReportItemCollection searchCol = new ReportItemCollection();
			
			searchCol.Add(new BaseDataItem ()
			              {
			              	Name ="Last",
			              	ColumnName ="Last"
			              }
			             );
			searchCol.Add(new BaseDataItem ()
			              {
			              
			              	ColumnName ="GroupItem"
			              }
			             );
			dataNavigator.Reset();
			dataNavigator.MoveNext();

			do
			{
				if (dataNavigator.HasChildren)
				{
					dataNavigator.Fill(searchCol);
					var b = (BaseDataItem)searchCol[1];
//					Console.WriteLine("-- <{0}>-",b.DBValue);
					var childNavigator = dataNavigator.GetChildNavigator;
					do
					{
						childNavigator.Fill(searchCol);
						var filledItem = (BaseDataItem)searchCol[0];
						Assert.That(filledItem.DBValue,Is.Not.Empty);
					}
					while (childNavigator.MoveNext());
				}
			}
			while (dataNavigator.MoveNext());
		}
Exemplo n.º 13
0
        internal static ReportItemCollection CollectAll()
        {
            var dataTable  = DatabaseController.ExecuteSelectQuery("SELECT * FROM " + TableName);
            var collection = new ReportItemCollection();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                var item = new ReportItem();
                item.SetPropertiesFromDataRow(dataRow);
                collection.Add(item);
            }
            return(collection);
        }
Exemplo n.º 14
0
		internal static ReportItemCollection ReportItemCollection (DataSet dataSet)
		{
			if (dataSet == null) {
				throw new ArgumentNullException("dataSet");
			}
		
			if (dataSet.Tables.Count > 1) {
				string s = String.Format(System.Globalization.CultureInfo.InvariantCulture,
				                         "AutoBuildFromDataSet : at this time no more than one table is allowed <{0}>",dataSet.Tables.Count);
				ICSharpCode.Core.MessageService.ShowError(s);
			}
			
			ReportItemCollection itemCol = new ReportItemCollection();
			
			foreach (DataTable tbl in dataSet.Tables) {
				foreach (DataColumn col  in tbl.Columns) {
					if (col.DataType == typeof(System.Byte[])) {
						ICSharpCode.Reports.Core.BaseImageItem rItem = new ICSharpCode.Reports.Core.BaseImageItem();
						rItem.ColumnName = col.ColumnName;
						rItem.BaseTableName = tbl.TableName;
						rItem.Name = col.ColumnName;
						rItem.ScaleImageToSize = false;
						itemCol.Add (rItem);
					} else {
						ICSharpCode.Reports.Core.BaseDataItem rItem = new ICSharpCode.Reports.Core.BaseDataItem();
						rItem.ColumnName = col.ColumnName;
						rItem.DBValue = col.ColumnName;
						rItem.BaseTableName = tbl.TableName;
						rItem.DataType = col.DataType.ToString();
						rItem.Name = col.ColumnName;
						rItem.Text = "=[" + col.ColumnName + "]";
						itemCol.Add (rItem);
					}
				}
			}
			return itemCol;
		}
        public void DataNavigator_Return_ErrMessage_If_ColumnName_NotExist()
        {
            IDataManager   dm      = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection as System.Collections.IList, new ReportSettings());
            IDataNavigator dataNav = dm.GetNavigator;
            BaseDataItem   item    = new BaseDataItem();

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

            items.Add(item);
            dataNav.Fill(items);
            string str = "<" + item.ColumnName + ">";

            Assert.That(item.DBValue.Contains(str));
        }
Exemplo n.º 16
0
        public void FillCollection()
        {
            var dataNavigator = PrepareStringGrouping();
            ReportItemCollection searchCol = new ReportItemCollection();

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

            do
            {
                if (dataNavigator.HasChildren)
                {
                    dataNavigator.Fill(searchCol);
                    var b = (BaseDataItem)searchCol[1];
//					Console.WriteLine("-- <{0}>-",b.DBValue);
                    var childNavigator = dataNavigator.GetChildNavigator;
                    do
                    {
                        childNavigator.Fill(searchCol);
                        var filledItem = (BaseDataItem)searchCol[0];
                        Assert.That(filledItem.DBValue, Is.Not.Empty);
                    }while (childNavigator.MoveNext());
                }
            }while (dataNavigator.MoveNext());
        }
Exemplo n.º 17
0
        internal static ReportItemCollection ExtractSelectedItems(ReportItemCollection sourceItems, DataGridViewColumn[] displayCols)
        {
            var destItems = new ReportItemCollection();

            foreach (DataGridViewColumn cc in displayCols)
            {
                DataGridViewColumnHeaderCheckBoxCell hc = (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell;
                if (hc.Checked)
                {
                    BaseReportItem br = (BaseReportItem)sourceItems.Find(cc.HeaderText);
                    destItems.Add(br);
                }
            }
            return(destItems);
        }
Exemplo n.º 18
0
        protected ReportItemCollection AddItemsToContainer()
        {
            int locationX = GlobalValues.ControlMargins.Left;

            var minCtrlWidth = CalculateControlWidth(Container, ReportItems);

            var col = new ReportItemCollection();

            foreach (var ir in ReportItems)
            {
                ir.Location = new Point(locationX, GlobalValues.ControlMargins.Top);
                col.Add(ir);
                locationX += minCtrlWidth;
            }
            return(col);
        }
Exemplo n.º 19
0
        public override void DeserializeChildren(PersistenceReader ip)
        {
            while (ip.HasChild)
            {
                PersistableObject child = ip.GetChild();

                if (child is ReportColumn)
                {
                    m_Columns.Add((ReportColumn)child);
                }
                else if (child is ReportItem)
                {
                    m_Items.Add((ReportItem)child);
                }
            }
        }
        public void  Convert_SimpleItems_Should_Return_Valid_Collection()
        {
            ReportItemCollection ri = new ReportItemCollection();
            BaseReportItem       r  = new BaseTextItem()
            {
                Location = new Point(10, 10),
                Size     = new Size(20, 100)
            };

            ri.Add(r);
            IExportItemsConverter sut = new ExportItemsConverter();

            ExporterCollection ec = sut.ConvertSimpleItems(new Point(10, 10), ri);

            Assert.IsNotNull(ec);
            Assert.AreEqual(1, ec.Count);
        }
Exemplo n.º 21
0
        // only checked columns are use in the report

        private ReportItemCollection CreateItemsCollection(DataGridViewColumn[] displayCols)
        {
            ReportItemCollection items = new ReportItemCollection();

            foreach (DataGridViewColumn cc in displayCols)
            {
                DataGridViewColumnHeaderCheckBoxCell hc = (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell;
                if (hc.Checked)
                {
                    AbstractColumn ac = this.abstractColumns.Find(cc.HeaderText);
                    ICSharpCode.Reports.Core.BaseDataItem br = new ICSharpCode.Reports.Core.BaseDataItem();
                    br.Name       = ac.ColumnName;
                    br.ColumnName = ac.ColumnName;
                    br.DataType   = ac.DataTypeName;
                    br.DBValue    = ac.ColumnName;
                    items.Add(br);
                }
            }
            return(items);
        }
Exemplo n.º 22
0
        private static ReportItemCollection HeaderColumnsFromReportItems(ReportItemCollection reportItemCollection)
        {
            if (reportItemCollection == null)
            {
                throw new ArgumentNullException("reportItemCollection");
            }

            ReportItemCollection itemCol = new ReportItemCollection();

            ICSharpCode.Reports.Core.BaseTextItem rItem;
            int i = 1;

            foreach (IDataRenderer dataRenderer in reportItemCollection)
            {
                rItem      = WizardHelper.CreateTextItem(dataRenderer.ColumnName);
                rItem.Name = rItem.Text + i.ToString(System.Globalization.CultureInfo.InvariantCulture);
                itemCol.Add(rItem);
                i++;
            }
            return(itemCol);
        }
Exemplo n.º 23
0
        internal static ReportItemCollection GetListByCategory(string category)
        {
            var sqlBuilder = new System.Text.StringBuilder();

            sqlBuilder.AppendLine("SELECT * FROM");
            sqlBuilder.AppendLine(TableName);
            sqlBuilder.AppendLine("WHERE Category = ?Category");

            var       param     = new SqlParameter("?Category", category);
            DataTable dataTable = DatabaseController.ExecuteSelectQuery(sqlBuilder, param);

            var collection = new ReportItemCollection();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                var item = new ReportItem();
                item.SetPropertiesFromDataRow(dataRow);
                collection.Add(item);
            }
            return(collection);
        }
Exemplo n.º 24
0
Arquivo: DataBase.cs Projeto: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        virtual public ReportItemCollection GetReportItems()
        {
            ReportItemCollection reportItems = new ReportItemCollection();

            AttributePropertyInfoPairCollection attPropertyInfos = this.GetDeviceDataItemAttributes();

            foreach (AttributePropertyInfoPair item in attPropertyInfos)
            {
                DataItemAttribute att   = item.Attribute;
                PropertyInfo      pi    = item.PropertyInfo;
                object            value = pi.GetValue(this, null);

                //if (!this.HideDataAttributeNames.Contains(att.Name))
                if (!HideDataAttributeNameManager.Default.Contains(this.GetType().Name, att.Name))
                {
                    ReportItem reportItem = new ReportItem(att.Name, value, att.Unit, att.Format);
                    reportItems.Add(reportItem);
                }
            }

            return(reportItems);
        }
        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"));
            }
        }
        public void Expression_In_Text_Evaluate()
        {
            ReportSettings rs      = new ReportSettings();
            IDataManager   dm      = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table, rs);
            DataNavigator  dataNav = dm.GetNavigator;
            BaseDataItem   bdi     = new BaseDataItem()
            {
                Name       = "MyDataItem",
                ColumnName = "last",
                Text       = "=Substring(Fields!last,0,3)",
                Expression = "=Substring(Fields!last,0,3)"
            };
            var ri = new ReportItemCollection();

            ri.Add(bdi);

            while (dataNav.MoveNext())
            {
                dataNav.Fill(ri);
                DataRow r      = dataNav.Current as DataRow;
                string  actual = r["last"].ToString();
                Assert.That(actual.Substring(0, 3), Is.EqualTo(bdi.DBValue));
            }
        }
Exemplo n.º 27
0
		// only checked columns are use in the report
		
		private ReportItemCollection CreateItemsCollection (DataGridViewColumn[] displayCols)
		{
			ReportItemCollection items = new ReportItemCollection();
			foreach (DataGridViewColumn cc in displayCols) {
				DataGridViewColumnHeaderCheckBoxCell hc= (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell;
				if (hc.Checked) {
					AbstractColumn ac = this.abstractColumns.Find(cc.HeaderText);
					ICSharpCode.Reports.Core.BaseDataItem br = new ICSharpCode.Reports.Core.BaseDataItem();
					br.Name = ac.ColumnName;
					br.ColumnName = ac.ColumnName;
					br.DataType = ac.DataTypeName;
					br.DBValue = ac.ColumnName;
					items.Add(br);
				}
			}
			return items;
		}
Exemplo n.º 28
0
		private static ReportItemCollection HeaderColumnsFromReportItems(ReportItemCollection reportItemCollection)
		{
			if (reportItemCollection == null) {
				throw new ArgumentNullException ("reportItemCollection");
			}
			
			ReportItemCollection itemCol = new ReportItemCollection();
			ICSharpCode.Reports.Core.BaseTextItem rItem;
			int i = 1;
			foreach (IDataRenderer dataRenderer in reportItemCollection) {
				rItem = WizardHelper.CreateTextItem(dataRenderer.ColumnName);
				rItem.Name = rItem.Text + i.ToString(System.Globalization.CultureInfo.InvariantCulture);
				itemCol.Add(rItem);
				i ++;
			}
			return itemCol;
		}
		private ReportItemCollection PlainCollection()
		{
			ReportItemCollection ri = new ReportItemCollection();
			BaseTextItem t1 = new BaseTextItem();
			t1.Name = "t1";
			ri.Add(t1);
			 t1 = new BaseTextItem();
			t1.Name = "t2";
			ri.Add(t1);
			t1 = new BaseTextItem();
			t1.Name = "t3";
			ri.Add(t1);
			return ri;
		}
Exemplo n.º 30
0
		public void DateTimeCan_FillChild()
		{
			var dataNavigator = PrepareDateTimeGrouping();
			ReportItemCollection searchCol = new ReportItemCollection();
			searchCol.Add(new BaseDataItem ()
			              {
			              	Name ="RandomDate",
			              	ColumnName ="Last"
			              }
			             );
			
			var compare = System.DateTime.MinValue;

			while (dataNavigator.MoveNext())
			{
				Contributor groupResult = dataNavigator.Current as Contributor;
				Assert.LessOrEqual(compare,groupResult.RandomDate);
				if (dataNavigator.HasChildren) {
					var childNavigator = dataNavigator.GetChildNavigator;
					do
					{
						Assert.That(dataNavigator.HasChildren,Is.True);
						// we know that current is a 'contributor'
						Contributor c = dataNavigator.Current as Contributor;
						Assert.IsNotNull(c);
//						string v2 = c.Last + " GroupVal :" +  c.RandomDate;
//						Console.WriteLine(v2);
					}
					while (childNavigator.MoveNext());
				}
				
			}
		}
Exemplo n.º 31
0
		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);
			}
		}
Exemplo n.º 32
0
		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());
		}
Exemplo n.º 33
0
 private void SaveItem(ReportItemCollection items, string name)
 {
     Control container = this.report.MultiView;
     if (this.report.ItemIndexTable.Contains(name) && !this.report.ItemIndexTable[name].Equals(Guid.Empty))
     {
         Guid id = (Guid)this.report.ItemIndexTable[name];
         SaveItem(name, id);
     }
     items.Clear();
     ListBox listboxItem = (ListBox)container.FindControl(string.Format("{0}{1}", LISTBOX_ITEM, name));
     foreach (ListItem li in listboxItem.Items)
     {
         Guid id = new Guid(li.Value);
         byte[] value = (byte[])report.ItemTable[id];
         ReportItem reportItem = (ReportItem)XmlConverter.ConvertTo(value);
         items.Add(reportItem);
     }
 }
Exemplo n.º 34
0
		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"));
			}
		}
Exemplo n.º 35
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual ReportItemCollection GetReportItems()
        {
            ReportItemCollection reportItems = new ReportItemCollection();

            AttributePropertyInfoPairCollection attPropertyInfos = this.GetDeviceDataItemAttributes();
            foreach (AttributePropertyInfoPair item in attPropertyInfos)
            {
                DataItemAttribute att = item.Attribute;
                PropertyInfo pi = item.PropertyInfo;
                object value = pi.GetValue(this, null);
                ReportItem reportItem = new ReportItem(att.Name, value, att.Unit, att.Format);
                reportItems.Add(reportItem);
            }

            return reportItems;
        }
		public void Expression_In_Text_Evaluate()
		{
			ReportSettings rs = new ReportSettings();
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table,rs);
			DataNavigator dataNav = dm.GetNavigator;
			BaseDataItem bdi = new BaseDataItem(){
				Name ="MyDataItem",
				ColumnName = "last",
				Text ="=Substring(Fields!last,0,3)",
				Expression ="=Substring(Fields!last,0,3)"	
			};
			var ri = new ReportItemCollection();
			ri.Add(bdi);
			
			while (dataNav.MoveNext())
			{
				dataNav.Fill(ri);
				DataRow r = dataNav.Current as DataRow;
				string actual = r["last"].ToString();
				Assert.That(actual.Substring(0,3), Is.EqualTo(bdi.DBValue));
			}
		}
Exemplo n.º 37
0
		private void WriteResult ()
		{
				if (this.resultDataSet != null) {
					// check reordering of columns
					DataGridViewColumn[] displayCols;
					DataGridViewColumnCollection dc = this.grdQuery.Columns;
					
					displayCols = new DataGridViewColumn[dc.Count];
					for (int i = 0; i < dc.Count; i++){
						if (dc[i].Visible) {
							displayCols[dc[i].DisplayIndex] = dc[i];
						}
					}
					
					
					ReportItemCollection sourceItems = WizardHelper.ReportItemCollection(this.resultDataSet);
					
					AvailableFieldsCollection abstractColumns = WizardHelper.AvailableFieldsCollection(this.resultDataSet);
					
					ReportItemCollection destItems = new ReportItemCollection();
					
					// only checked columns are used in the report
					foreach (DataGridViewColumn cc in displayCols) {
						DataGridViewColumnHeaderCheckBoxCell hc= (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell;
						if (hc.Checked) {
							BaseReportItem br = (BaseReportItem)sourceItems.Find(cc.HeaderText);
							destItems.Add(br);
						}
					}
					
					reportStructure.ReportItemCollection.Clear();
					reportStructure.ReportItemCollection.AddRange(destItems);
					/*
					if ((this.sqlParamsCollection != null) && (this.sqlParamsCollection.Count > 0)) {
						reportStructure.SqlQueryParameters.AddRange(sqlParamsCollection);
					}
					*/
					if (abstractColumns != null) {
						reportStructure.AvailableFieldsCollection.Clear();
						reportStructure.AvailableFieldsCollection.AddRange(abstractColumns);
					}
					/*
					if ((this.sqlParamsCollection != null) && (this.sqlParamsCollection.Count > 0)) {
						reportStructure.SqlQueryParameters.Clear();
						reportStructure.SqlQueryParameters.AddRange(sqlParamsCollection);
					}
					*/
				}
				base.EnableNext = true;
				base.EnableFinish = true;
		}
Exemplo n.º 38
0
        public override bool ReceiveDialogMessage(DialogMessage message)
        {
            if (customizer == null)
            {
                customizer      = (Properties)base.CustomizationObject;
                reportStructure = (ReportStructure)customizer.Get("Generator");
            }
            if (message == DialogMessage.Activated)
            {
                this.model         = reportStructure.CreateAndFillReportModel();
                this.resultDataSet = FillGrid();

                if (this.resultDataSet != null)
                {
                    this.grdQuery.DataSource = this.resultDataSet.Tables[0];
                    foreach (DataGridViewColumn dd in this.grdQuery.Columns)
                    {
                        DataGridViewColumnHeaderCheckBoxCell cb = new DataGridViewColumnHeaderCheckBoxCell();
                        cb.CheckBoxAlignment = HorizontalAlignment.Right;
                        cb.Checked           = true;
                        dd.HeaderCell        = cb;
                        dd.SortMode          = DataGridViewColumnSortMode.NotSortable;
                    }
                    this.grdQuery.AllowUserToOrderColumns = true;
                }
                base.EnableNext   = true;
                base.EnableFinish = true;
            }
            else if (message == DialogMessage.Finish)
            {
                if (this.resultDataSet != null)
                {
                    // check reordering of columns
                    DataGridViewColumn[]         displayCols;
                    DataGridViewColumnCollection dc = this.grdQuery.Columns;
                    displayCols = new DataGridViewColumn[dc.Count];
                    for (int i = 0; i < dc.Count; i++)
                    {
                        if (dc[i].Visible)
                        {
                            displayCols[dc[i].DisplayIndex] = dc[i];
                        }
                    }

                    // only checked columns are used in the report
                    ReportItemCollection      sourceItems     = WizardHelper.DataItemsFromDataSet(this.resultDataSet);
                    AvailableFieldsCollection abstractColumns = WizardHelper.AbstractColumnsFromDataSet(this.resultDataSet);
                    ReportItemCollection      destItems       = new ReportItemCollection();

                    foreach (DataGridViewColumn cc in displayCols)
                    {
                        DataGridViewColumnHeaderCheckBoxCell hc = (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell;
                        if (hc.Checked)
                        {
                            BaseReportItem br = (BaseReportItem)sourceItems.Find(cc.HeaderText);
                            destItems.Add(br);
                        }
                    }
                    reportStructure.ReportItemCollection.AddRange(destItems);
                    if ((this.sqlParamsCollection != null) && (this.sqlParamsCollection.Count > 0))
                    {
                        reportStructure.SqlQueryParameters.AddRange(sqlParamsCollection);
                    }

                    if (abstractColumns != null)
                    {
                        reportStructure.AvailableFieldsCollection.AddRange(abstractColumns);
                    }
                }
                base.EnableNext   = true;
                base.EnableFinish = true;
            }
            return(true);
        }
Exemplo n.º 39
0
		public override bool ReceiveDialogMessage(DialogMessage message)
		{
			if (customizer == null) {
				customizer = (Properties)base.CustomizationObject;
				reportStructure = (ReportStructure)customizer.Get("Generator");
			}
			if (message == DialogMessage.Activated) {
				this.model = reportStructure.CreateAndFillReportModel();
				this.resultDataSet =  FillGrid();
				
				if (this.resultDataSet != null) {
					this.grdQuery.DataSource = this.resultDataSet.Tables[0];
					foreach (DataGridViewColumn dd in this.grdQuery.Columns) {
						DataGridViewColumnHeaderCheckBoxCell cb = new DataGridViewColumnHeaderCheckBoxCell();
						cb.CheckBoxAlignment = HorizontalAlignment.Right;
						cb.Checked = true;
						dd.HeaderCell = cb;
						dd.SortMode = DataGridViewColumnSortMode.NotSortable;
					}
					this.grdQuery.AllowUserToOrderColumns = true;
				}
				base.EnableNext = true;
				base.EnableFinish = true;
			} else if (message == DialogMessage.Finish) {
				if (this.resultDataSet != null) {
					// check reordering of columns
					DataGridViewColumn[] displayCols;
					DataGridViewColumnCollection dc = this.grdQuery.Columns;
					displayCols = new DataGridViewColumn[dc.Count];
					for (int i = 0; i < dc.Count; i++){
						if (dc[i].Visible) {
							displayCols[dc[i].DisplayIndex] = dc[i];
						}
					}
					
					// only checked columns are used in the report
					ReportItemCollection sourceItems = WizardHelper.DataItemsFromDataSet(this.resultDataSet);
					AvailableFieldsCollection abstractColumns = WizardHelper.AbstractColumnsFromDataSet(this.resultDataSet);
					ReportItemCollection destItems = new ReportItemCollection();
					
					foreach (DataGridViewColumn cc in displayCols) {
						DataGridViewColumnHeaderCheckBoxCell hc= (DataGridViewColumnHeaderCheckBoxCell)cc.HeaderCell;
						if (hc.Checked) {
							BaseReportItem br = (BaseReportItem)sourceItems.Find(cc.HeaderText);
							destItems.Add(br);
						}
					}
					reportStructure.ReportItemCollection.AddRange(destItems);
					if ((this.sqlParamsCollection != null) && (this.sqlParamsCollection.Count > 0)) {
						reportStructure.SqlQueryParameters.AddRange(sqlParamsCollection);
					}
					
					if (abstractColumns != null) {
						reportStructure.AvailableFieldsCollection.AddRange(abstractColumns);
					}
				}
				base.EnableNext = true;
				base.EnableFinish = true;
			}
			return true;
		}
Exemplo n.º 40
0
		public void SortChildrenDescending()
		{
			ReportSettings rs = new ReportSettings();
			GroupColumn gc = new GroupColumn("GroupItem",1,ListSortDirection.Ascending);
			rs.GroupColumnsCollection.Add(gc);
			
			SortColumn sc = new SortColumn("Last",ListSortDirection.Descending);
			rs.SortColumnsCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection,rs);
			var dataNavigator = dm.GetNavigator;
			
			ReportItemCollection searchCol = new ReportItemCollection();
			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 column = (BaseDataItem)searchCol[1];
				var result = column.DBValue.ToString();
				
				Assert.That (compare,Is.LessThan(result));
				if (dataNavigator.HasChildren) {
					string compareChild = String.Empty;
					var childNavigator = dataNavigator.GetChildNavigator;
					do
					{
						childNavigator.Fill(searchCol);
						var childColumn = (BaseDataItem)searchCol[0];
						var childResult = childColumn.DBValue.ToString();
//						Console.WriteLine("\t{0}",childResult);
						if (!String.IsNullOrEmpty(compareChild)) {
							Assert.LessOrEqual(childResult,compareChild);
						}
						compareChild = childResult;
					}
					while (childNavigator.MoveNext());
				}
			}
		}
Exemplo n.º 41
0
		protected ReportItemCollection AddItemsToContainer (ReportItemCollection items)
		{
			int locationX = GlobalValues.ControlMargins.Left;
			
			var minCtrlWidth = CalculateControlWidth(ParentItem,items);
			
			var col = new ReportItemCollection();
			
			foreach (var ir in items) {
				ir.Location = new Point(locationX,GlobalValues.ControlMargins.Top);
				col.Add(ir);
				locationX += minCtrlWidth;
			}
			return col;
		}
		public void DataNavigator_Return_ErrMessage_If_ColumnName_NotExist ()
		{
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection as System.Collections.IList,new ReportSettings());
			IDataNavigator dataNav = dm.GetNavigator;
			BaseDataItem item = new BaseDataItem();
			item.ColumnName = "ColumnNotExist";
			var items = new ReportItemCollection();
			items.Add(item);
			dataNav.Fill(items);
			string str = "<" + item.ColumnName +">";
			Assert.That(item.DBValue.Contains(str));
		}
Exemplo n.º 43
0
		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;
			}
		}