Esempio n. 1
0
        public string GetGroupSortStringWithPrefix(int level, string prefix)
        {
            StringBuilder sbsort = new StringBuilder();

            for (int i = 0; i < _quickSortItems.Count; i++)
            {
                QuickSortItem item = _quickSortItems[i];
                if (item.Level > level || item.Level <= 0)
                {
                    //if (item.Level > level)
                    continue;
                }
                if (level == 1 && item.Level < 0)
                {
                    continue;
                }
                if (level > 1 && item.Level <= 0)
                {
                    continue;
                }

                if (sbsort.Length > 0)
                {
                    sbsort.Append(",");
                }
                sbsort.Append(GetAItemString(item, prefix));
            }
            return(sbsort.ToString());
        }
Esempio n. 2
0
 public void InsertToFirst(QuickSortItem item)
 {
     if (item.SortDirection == SortDirection.None)
     {
         return;
     }
     this._quickSortItems.Insert(0, item);
 }
Esempio n. 3
0
        public bool Contains(QuickSortItem item)
        {
            bool exists = false;

            if (this[item.Name] != null)
            {
                exists = true;
            }

            return(exists);
        }
Esempio n. 4
0
        public object Clone()
        {
            GroupSchema gs = new GroupSchema();

            gs.ID               = this.ID;
            gs.Name             = this.Name;
            gs.bDefault         = this.bDefault;
            gs.bGroupItemsAhead = this.bGroupItemsAhead;
            gs.bShowSubTotal    = this.bShowSubTotal;

            //************2012-5-17 add by yanghx
            gs.bShowDetail = this.bShowDetail;
            gs.ShowStyle   = this.ShowStyle;
            //**************

            gs.SchemaItems = this.SchemaItems.Clone() as GroupSchemaItems;
            //gs.CurrentLocaleId = this.CurrentLocaleId;
            gs._names = this._names.Clone() as Hashtable;
            foreach (string key in this.DateDimensions.Keys)
            {
                gs.DateDimensions.Add(key, this.DateDimensions[key]);
            }
            //复制排序
            if (this.SortSchema != null)
            {
                gs.SortSchema = new QuickSortSchema();
                foreach (QuickSortItem sortItem in this.SortSchema.QuickSortItems)
                {
                    QuickSortItem newItem = new QuickSortItem(sortItem.Level, sortItem.Name, sortItem.SortDirection, sortItem.Priority);
                    gs.SortSchema.QuickSortItems.Add(newItem);
                }
            }
            //复制列排序
            if (this.ColumnSortSchema != null && this.ColumnSortSchema.QuickSortItems != null)
            {
                gs.ColumnSortSchema = new QuickSortSchema();
                foreach (QuickSortItem sortItem in this.ColumnSortSchema.QuickSortItems)
                {
                    QuickSortItem newItem = new QuickSortItem(sortItem.Level, sortItem.Name, sortItem.SortDirection, sortItem.Priority);
                    gs.ColumnSortSchema.QuickSortItems.Add(newItem);
                }
            }
            //11.1增加行分组复制
            if (this.CrossRowGroup != null &&
                (this.CrossRowGroup.SchemaItems != null || this.CrossRowGroup.SortSchema != null))
            {
                gs.CrossRowGroup = this.CrossRowGroup.Clone() as GroupSchema;
            }
            gs.BShowHorizonTotal = this.BShowHorizonTotal;
            return(gs);
        }
Esempio n. 5
0
        //倒着加
        public void AddAfterGroup(QuickSortItem item)
        {
            //是否是一层分组的情况,或者只有明细的情况,
            //因为一层分组的情况下,分组和明细是平级的关系,可以随便排序

            if (item.SortDirection == SortDirection.None)
            {
                return;
            }
            bool badd = false;
            bool bdel = false;
            int  i    = 0;

            while (i < _quickSortItems.Count)
            {
                QuickSortItem tmp = _quickSortItems[i];
                if (tmp.Name.ToLower() == item.Name.ToLower())
                {
                    if (tmp.Level > 0)
                    {
                        tmp.SortDirection = item.SortDirection;
                        badd = true;
                        break;
                    }
                    else
                    {
                        _quickSortItems.RemoveAt(i);
                        bdel = true;
                        break;
                    }
                }
                i++;
            }
            if (bdel || !badd)
            {
                i = 0;
                while (i < _quickSortItems.Count)
                {
                    QuickSortItem tmp = _quickSortItems[i];
                    //if (tmp.Level <=0)
                    //    break;
                    if (tmp.Level < 0)//小于0即是默认排序或者日期维度等现在都是正序
                    {
                        break;
                    }
                    i++;
                }
                _quickSortItems.Insert(i, item);
            }
        }
Esempio n. 6
0
        public string GetSortString()
        {
            StringBuilder sbsort = new StringBuilder();

            for (int i = 0; i < _quickSortItems.Count; i++)
            {
                if (sbsort.Length > 0)
                {
                    sbsort.Append(",");
                }
                QuickSortItem item = _quickSortItems[i];
                sbsort.Append(GetAItemString(item, ""));
            }
            return(sbsort.ToString());
        }
Esempio n. 7
0
 public QuickSortItem this[string name]
 {
     get
     {
         QuickSortItem qsi = null;
         foreach (QuickSortItem item in this)
         {
             if (item.Name.ToLower() == name.ToLower())
             {
                 qsi = item;
                 break;
             }
         }
         return(qsi);
     }
 }
Esempio n. 8
0
        private string GetRankSortString()
        {
            StringBuilder sbsort = new StringBuilder();

            for (int i = 0; i < _quickSortItems.Count; i++)
            {
                QuickSortItem item = _quickSortItems[i];
                if (item.Level > 0)
                {
                    continue;
                }
                if (sbsort.Length > 0)
                {
                    sbsort.Append(",");
                }
                sbsort.Append(GetAItemString(item, ""));
            }
            return(sbsort.ToString());
        }
        private void InitSort(GroupSchema gs)
        {
            QuickSortSchema sortSchema = new QuickSortSchema();
            int             Priority   = 1;

            if (gs.SchemaItems.Count < 1)
            {
                return;
            }
            if (gs.SchemaItems.Count < 3)
            {
                foreach (GroupSchemaItem group in gs.SchemaItems)
                {
                    foreach (string name in group.Items)
                    {
                        QuickSortItem item = new QuickSortItem();
                        item.Level    = group.Level;
                        item.Priority = Priority;
                        Priority++;
                        item.Name          = name;
                        item.SortDirection = SortDirection.Descend;
                        sortSchema.QuickSortItems.Add(item);
                    }
                }
            }
            else
            {
                gs.SortSchema = sortSchema;
                GroupSchemaItem column = gs.SchemaItems[1];
                foreach (string name in column.Items)
                {
                    QuickSortItem item = new QuickSortItem();
                    item.Level    = 2;
                    item.Priority = Priority;
                    Priority++;
                    item.Name          = name;
                    item.SortDirection = SortDirection.Descend;
                    sortSchema.QuickSortItems.Add(item);
                }
                gs.ColumnSortSchema = sortSchema;
            }
        }
Esempio n. 10
0
        private string GetAItemString(QuickSortItem item, string b, string mapName)
        {
            StringBuilder sbsort = new StringBuilder();

            if (!string.IsNullOrEmpty(b))
            {
                sbsort.Append(b);
                sbsort.Append(".");
            }
            sbsort.Append("[");
            sbsort.Append(mapName);
            sbsort.Append("]");
            if (item.SortDirection == SortDirection.Ascend)
            {
                sbsort.Append(" asc");
            }
            else
            {
                sbsort.Append(" desc");
            }
            return(sbsort.ToString());
        }
Esempio n. 11
0
        public string GetGroupSortString(Report report)
        {
            Cells         designCells = report.GridDetailCells;
            string        realMapName = string.Empty;
            StringBuilder sbsort      = new StringBuilder();

            for (int i = 0; i < _quickSortItems.Count; i++)
            {
                QuickSortItem item = _quickSortItems[i];
                //if (item.Level <=0)
                if (item.Level < 0)
                {
                    continue;
                }

                //根据item找到真正的name
                Cell cell = designCells.GetBySource(item.Name);
                realMapName = this.GetMapname(cell, report);
                if (string.IsNullOrEmpty(realMapName))
                {
                    if (report.DataSources[item.Name] != null)
                    {
                        realMapName = report.DataSources[item.Name].Name;
                    }
                    if (string.IsNullOrEmpty(realMapName))
                    {
                        continue;
                    }
                }

                //end
                if (sbsort.Length > 0)
                {
                    sbsort.Append(",");
                }
                sbsort.Append(GetAItemString(item, "", realMapName));
            }
            return(sbsort.ToString());
        }
Esempio n. 12
0
 public void Remove(QuickSortItem item)
 {
     this.List.Remove(item);
 }
Esempio n. 13
0
 public void Add(QuickSortItem item)
 {
     this.List.Add(item);
 }
Esempio n. 14
0
 public void Insert(int index, QuickSortItem item)
 {
     this.List.Insert(index, item);
 }
Esempio n. 15
0
        public void Add(string name, SortOption direction, int level)
        {
            QuickSortItem item = new QuickSortItem(level, name, direction.SortDirection, direction.Priority);

            AddQuickSortItem(item);
        }
Esempio n. 16
0
        public void AddQuickSortItem(QuickSortItem item)
        {
            if (item.SortDirection == SortDirection.None)
            {
                return;
            }
            bool exists = this._quickSortItems.Contains(item);

            if (!exists)
            {
                //int i = 0;
                //bool badded = false;
                //if (item.Level <= 0)
                //{
                //    while (i < _quickSortItems.Count)
                //    {
                //        QuickSortItem tmp = _quickSortItems[i];
                //        if (tmp.Level <= 0 && item.Priority < tmp.Priority)
                //        {
                //            this._quickSortItems.Insert(i, item);
                //            badded = true;
                //            break;
                //        }
                //        i++;
                //    }
                //}
                //else
                //{
                //    while (i < _quickSortItems.Count)
                //    {
                //        QuickSortItem tmp = _quickSortItems[i];
                //        if (tmp.Level <= 0 || item.Level < tmp.Level || (item.Level == tmp.Level && item.Priority < tmp.Priority))
                //        {
                //            this._quickSortItems.Insert(i, item);
                //            badded = true;
                //            break;
                //        }
                //        i++;
                //    }
                //}
                //if (!badded)
                //    this._quickSortItems.Add(item);
                //----------------------10.0
                //if (item.Level > 0)
                //    item.Priority -= 100000;
                //int i = 0;
                //bool badd = false;
                //while (i < _quickSortItems.Count)
                //{
                //    QuickSortItem tmp = _quickSortItems[i];
                //    //if (tmp.Level <= 0 && item.Priority <= tmp.Priority)
                //    if (item.Priority <= tmp.Priority)
                //    {
                //        this._quickSortItems.Insert(i, item);
                //        badd = true;
                //        break;
                //    }
                //    i++;
                //}
                //if (!badd)
                //    this._quickSortItems.Add(item);
                try
                {
                    if (_quickSortItems.Count == 0)//没有数据时直接插入
                    {
                        this._quickSortItems.Add(item);
                    }
                    else
                    {
                        AddItemByLevel(item);
                    }
                }
                catch
                {
                    ;
                }
            }
        }
Esempio n. 17
0
        private void AddItemByLevel(QuickSortItem item)
        {
            int           i     = 0;
            int           pos   = 0;
            int           poe   = 0;
            bool          badd  = false;
            int           level = item.Level;
            QuickSortItem tmp   = null;

            if (level <= 0)
            {
                while (i < this._quickSortItems.Count)
                {
                    tmp = this._quickSortItems[i];
                    if (tmp.Level <= 0)
                    {
                        pos = i;
                        break;
                    }
                    i++;
                }
                while (i < _quickSortItems.Count)
                {
                    tmp = _quickSortItems[i];
                    if (item.Priority < tmp.Priority)
                    {
                        this._quickSortItems.Insert(i, item);
                        badd = true;
                        break;
                    }
                    i++;
                }
                if (!badd)
                {
                    this._quickSortItems.Add(item);
                }
            }
            else
            {
                if (level < _quickSortItems[0].Level)
                {
                    this._quickSortItems.Insert(0, item);
                    return;
                }
                if (level == _quickSortItems[0].Level)
                {
                    while (i < this._quickSortItems.Count)
                    {
                        tmp = this._quickSortItems[i];
                        if (tmp.Level != level || i + 1 == this._quickSortItems.Count)
                        {
                            pos = i;
                            break;
                        }
                        i++;
                    }
                    i = 0;
                    while (i <= pos)
                    {
                        tmp = _quickSortItems[i];
                        if (item.Priority < tmp.Priority)
                        {
                            this._quickSortItems.Insert(i, item);
                            badd = true;
                            break;
                        }
                        i++;
                    }
                    if (!badd)
                    {
                        if (tmp.Level != level)
                        {
                            this._quickSortItems.Insert(pos, item);
                        }
                        else
                        {
                            this._quickSortItems.Insert(pos + 1, item);
                        }
                    }

                    return;
                }

                if (level > _quickSortItems[0].Level)
                {
                    while (i < this._quickSortItems.Count)
                    {
                        tmp = this._quickSortItems[i];
                        if (tmp.Level == level || tmp.Level == 0 || i + 1 == this._quickSortItems.Count)
                        {
                            pos = i;
                            break;
                        }
                        i++;
                    }
                    while (i < this._quickSortItems.Count)
                    {
                        tmp = this._quickSortItems[i];
                        if (tmp.Level > level || tmp.Level == 0 || i + 1 == this._quickSortItems.Count)
                        {
                            poe = i;
                            break;
                        }
                        i++;
                    }
                    i = pos;
                    while (i <= poe)
                    {
                        tmp = _quickSortItems[i];
                        if (item.Priority < tmp.Priority && item.Level == tmp.Level)
                        {
                            this._quickSortItems.Insert(i, item);
                            badd = true;
                            break;
                        }
                        i++;
                    }
                    if (!badd)
                    {
                        this._quickSortItems.Insert(poe + 1, item);
                    }
                }
            }
        }