public void SortColumCollection_Sorting_Should_Set()
		{
			ReportModel m = ReportGenerationHelper.CreateModel(reportName,false);
			var rs = m.ReportSettings;
			
			SortColumn gc = new SortColumn("GroupItem",ListSortDirection.Ascending);
			rs.SortColumnsCollection.Add(gc);
			
			Assert.AreEqual(rs.SortColumnsCollection.Count,1);
		}
Ejemplo n.º 2
0
        protected static List <BaseComparer> GenericSorter(List <BaseComparer> list)
        {
            BaseComparer        bc  = list[0];
            SortColumn          scc = bc.ColumnCollection[0] as SortColumn;
            ListSortDirection   sd  = scc.SortDirection;
            List <BaseComparer> lbc = null;

            if (sd == ListSortDirection.Ascending)
            {
                lbc = list.AsQueryable().AscendingOrder().ToList();
            }
            else
            {
                lbc = list.AsQueryable().DescendingOrder().ToList();
            }
            return(lbc);
        }
		public void SortDescendingByOneColumn()
		{
			SortColumn sc = new SortColumn("Last",System.ComponentModel.ListSortDirection.Descending);
			ReportSettings rs = new ReportSettings();
			rs.SortColumnCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection,rs);
			DataNavigator dataNav = dm.GetNavigator;
			string compareTo = "z";
			while (dataNav.MoveNext()) {
				Contributor view = dataNav.Current as Contributor;
				string actual = view.Last;
				Assert.GreaterOrEqual(compareTo,actual);
//				string ss = String.Format("< {0} > <{1}>",compareTo,actual);
//				Console.WriteLine(ss);
				compareTo = actual;
			}
			Assert.IsTrue(dataNav.IsSorted);
		}
		public void SortAscendingByTwoColumns()
		{
			SortColumn sc = new SortColumn("Last",System.ComponentModel.ListSortDirection.Ascending);
			SortColumn sc1 = new SortColumn("RandomInt",System.ComponentModel.ListSortDirection.Ascending);
			
			ReportSettings rs = new ReportSettings();
			rs.SortColumnCollection.Add(sc);
			rs.SortColumnCollection.Add(sc1);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection,rs);
			DataNavigator dataNav = dm.GetNavigator;
			string v1 = String.Empty;
			while (dataNav.MoveNext()) {
				Contributor view = dataNav.Current as Contributor;
				string v2 = view.Last + "-" + view.RandomInt;
				//string ss = String.Format("< {0} > <{1}>",v1,v2);
				//Console.WriteLine(ss);
				//Console.WriteLine(v2);
				Assert.LessOrEqual(v1,v2);
				v1 = v2;
			}
			Assert.IsTrue(dataNav.IsSorted);
		}
		public void SortDescendingByDateTime()
		{
			SortColumn sc = new SortColumn("RandomDate",System.ComponentModel.ListSortDirection.Descending,
			                               typeof(System.Int16),false);
			ReportSettings rs = new ReportSettings();
			rs.SortColumnCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.contributorCollection,rs);
			DataNavigator dataNav = dm.GetNavigator;
			DateTime d1 = new DateTime(2099,12,30);
			while (dataNav.MoveNext()) {
				Contributor view = dataNav.Current as Contributor;
				Assert.GreaterOrEqual(d1,view.RandomDate);
				d1 = view.RandomDate;
			}
			Assert.IsTrue(dataNav.IsSorted);
		}
Ejemplo n.º 6
0
		private ColumnCollection CollectSortColumns()
		{
			ColumnCollection cl = new ColumnCollection();
			if (this.nodeSorting.Nodes.Count > 0) {
				SortColumn sortColumn;
				AbstractColumn abstrCol;
			
				foreach (SortColumnNode sortNode in this.nodeSorting.Nodes) {
				abstrCol = this.reportModel.ReportSettings.AvailableFieldsCollection.Find(sortNode.Text);
					
					if (abstrCol != null) {
						sortColumn = new SortColumn (sortNode.FieldName,
						                     sortNode.SortDirection,
						                     abstrCol.DataType,true);
					} else {
						sortColumn = new SortColumn (sortNode.Text,
						                     sortNode.SortDirection,
						                     typeof(System.String),true);
					}
					cl.Add(sortColumn);
				}
			}
			return cl;
		}
Ejemplo n.º 7
0
        internal int CompareTo(SortComparer value)
        {
            // we shouldn't get to this point
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            if (value.ObjectArray.Length != base.ObjectArray.Length)
            {
                throw new InvalidOperationException();
            }

            int compare = 0;

            for (int index = 0; index < base.ObjectArray.Length; index++)
            {
                object leftValue = base.ObjectArray[index];

                object rightValue = value.ObjectArray[index];

                // Indizes sind hier deckungsgleich
                Type       t          = rightValue.GetType();
                SortColumn sortColumn = (SortColumn)base.ColumnCollection[index];

                bool descending = (sortColumn.SortDirection == ListSortDirection.Descending);

                // null means equl
                if (leftValue == null || leftValue == System.DBNull.Value)
                {
                    if (rightValue != null && rightValue != System.DBNull.Value)
                    {
                        return((descending) ? 1 : -1);
                    }

                    // Beide Null
                    continue;
                }

                if (rightValue == null || rightValue == System.DBNull.Value)
                {
                    return((descending) ? -1 : 1);
                }


                if (leftValue.GetType() != rightValue.GetType())
                {
                    string s = String.Format(CultureInfo.CurrentCulture,
                                             "{0} {1} {2}", this.GetType().ToString(),
                                             leftValue.GetType().ToString(),
                                             rightValue.GetType().ToString());

                    throw new ReportException(s);
                }
                if (leftValue.GetType() == typeof(string))
                {
                    compare = String.Compare((string)leftValue, (string)rightValue,
                                             !sortColumn.CaseSensitive, CultureInfo.CurrentCulture);
                }
                else
                {
                    compare = ((IComparable)leftValue).CompareTo(rightValue);
                }

                // Sind ungleich, tauschen je nach Richtung
                if (compare != 0)
                {
                    return((descending) ? -compare : compare);
                }
            }

            // Gleich Werte, dann Index bercksichtigen
            return(this.ListIndex.CompareTo(value.ListIndex));
        }
		public void SortDescendingByDateTime()
		{
			SortColumn sc = new SortColumn("RandomDate",System.ComponentModel.ListSortDirection.Descending,
			                               typeof(System.Int16),false);
			ReportSettings rs = new ReportSettings();
			rs.SortColumnsCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table,rs);
			DataNavigator dataNav = dm.GetNavigator;
			DateTime d1 = new DateTime(2099,12,30);
			while (dataNav.MoveNext()) {
				DataRow r = dataNav.Current as DataRow;
				DateTime d2 = Convert.ToDateTime(r["randomDate"]);
//				string ss = String.Format("<{0}>",d2);
//				Console.WriteLine(ss);
				Assert.GreaterOrEqual(d1,d2);
				d1 = d2;
			}
			Assert.IsTrue(dataNav.IsSorted);
		}
		public void ColumnNotExistThrow()
		{
			SortColumn sc = new SortColumn("notexist",System.ComponentModel.ListSortDirection.Ascending);
			ReportSettings rs = new ReportSettings();
			rs.SortColumnsCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table,rs);
			DataNavigator dataNav = dm.GetNavigator;
		}
		public void SortDescendingByOneColumn()
		{
			SortColumn sc = new SortColumn("Last",System.ComponentModel.ListSortDirection.Descending);
			ReportSettings rs = new ReportSettings();
			rs.SortColumnsCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table,rs);
			DataNavigator dataNav = dm.GetNavigator;
			string compareTo = "z";
			while (dataNav.MoveNext()) {
				DataRow r = dataNav.Current as DataRow;
				string actual = r["last"].ToString();
				Assert.GreaterOrEqual(compareTo,actual);
				compareTo = actual;
			}
		}
		public void SortAscendingByOneColumn()
		{
			SortColumn sc = new SortColumn("Last",System.ComponentModel.ListSortDirection.Ascending);
			ReportSettings rs = new ReportSettings();
			rs.SortColumnCollection.Add(sc);
			IDataManager dm = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.table,rs);
			DataNavigator dataNav = dm.GetNavigator;
			string v1 = String.Empty;
			while (dataNav.MoveNext()) {
				DataRow r = dataNav.Current as DataRow;
				string v2 = r["last"].ToString();
				Assert.LessOrEqual(v1,v2);
				v1 = v2;
			}
			Assert.IsTrue(dataNav.IsSorted);
		}