Esempio n. 1
0
 public void SortAllContacts_ByCreationDateDesc()
 {
     AllContacts         = SortByCreationDateDesc(AllContacts);
     AllContactsFiltered = SortByCreationDateDesc(AllContactsFiltered);
     LastUsedSortType    = ESortType.ByCreationDateDesc;
     RaiseOnContactsModified();
 }
Esempio n. 2
0
    /// <summary>
    /// Sorts the AllContacts list based on the sortType parameter. Does not sort the AllContactsFiltered.
    /// </summary>
    public void SortAllContacts(ESortType sortType)
    {
        switch (sortType)
        {
        case ESortType.None:
            throw new System.Exception("Please assign a SortType in the Inspector.");

        case ESortType.ByName:
            SortAllContacts_ByName();
            break;

        case ESortType.ByNameDesc:
            SortAllContacts_ByNameDesc();
            break;

        case ESortType.ByCreationDate:
            SortAllContacts_ByCreationDate();
            break;

        case ESortType.ByCreationDateDesc:
            SortAllContacts_ByCreationDateDesc();
            break;

        default:
            throw new CaseStatementMissingException(sortType);
        }
    }
Esempio n. 3
0
 public void SortAllContacts_ByName()
 {
     AllContacts         = SortByName(AllContacts);
     AllContactsFiltered = SortByName(AllContactsFiltered);
     LastUsedSortType    = ESortType.ByName;
     RaiseOnContactsModified();
 }
Esempio n. 4
0
 public static List <EventData> SortByRelativeTime(List <EventData> List, ESortType Sort)
 {
     if (Sort == ESortType.ElementAndTime)
     {
         return(List.OrderBy(o => o.Element).ThenBy(o => o.TimeStamp).ToList());
     }
     else if (Sort == ESortType.Time)
     {
         return(List.OrderBy(o => o.TimeStamp).ToList());
     }
     else
     {
         return(List);
     }
 }
Esempio n. 5
0
        private IList <int> sortList(ESortType sortType, int listSize, int maxValue)
        {
            var         generatedList = Helper.generateRandomArray(listSize, maxValue);
            IList <int> sortedList    = null;

            switch (sortType)
            {
            case ESortType.QuickSort:
                sortedList = Sorting.quickSort(generatedList);
                break;

            case ESortType.TreeSort:
                sortedList = Sorting.treeSort(generatedList);
                break;
            }

            return(sortedList);
        }
Esempio n. 6
0
 public IActionResult SortByDate(string user, ESortType sortype)
 {
     return(Ok(messageHandler.SortByDate(user, sortype)));
 }
Esempio n. 7
0
 /// <summary>
 ///  添加OrderBy
 /// </summary>
 /// <param name="FieldName"></param>
 /// <param name="SortType"></param>
 public void AddOrderBy(string FieldName, ESortType SortType)
 {
     AddOrderBy(new OrderByField(FieldName, SortType));
 }
Esempio n. 8
0
 public OrderByField(string FieldName, ESortType SortType)
 {
     this.FieldName = FieldName;
     this.SortType  = SortType;
 }
Esempio n. 9
0
        public IOrderedQueryable <Message> SortByDate(string user, ESortType sortype)
        {
            var messages = sortype == ESortType.Desc ? context.Messages.OrderByDescending(mes => mes.MessageDateTime) : context.Messages.OrderBy(mes => mes.MessageDateTime);

            return(messages);
        }
Esempio n. 10
0
 public List <E> GetEntitysPage <E>(string sql, string fileds, string SortName, ESortType SortType, int iPageIndex, int iPageSize, ref int iPageCount, ref int iRecordCount)
 {
     return(this.GetEntitysPage <E>(sql, "Id", fileds, SortName, SortType, iPageIndex, iPageSize, ref iPageCount, ref iRecordCount));
 }
Esempio n. 11
0
        /// <summary>
        /// 数据查询分页 存储过程
        /// </summary>
        /// <typeparam name="T">要查询的sql语句对应的实体</typeparam>
        /// <param name="TableName">要查询的sql语句</param>
        /// <param name="SortName">排序列的字段名称</param>
        /// <param name="SortType">排序方式升序还是逆序</param>
        /// <param name="iPageIndex">当前页码</param>
        /// <param name="iPageSize">每页数据行数</param>
        /// <param name="iPageCount">输入查询结果的分页的页数</param>
        /// <param name="iRecordCount">输入查询结果的总行数</param>
        /// <returns>返回查询List</returns>
        /// <Author>hqh</Author>
        public List <E> GetEntitysPage <E>(string sql, string key, string fileds, string SortName, ESortType SortType, int iPageIndex, int iPageSize, ref int iPageCount, ref int iRecordCount)
        {
            string spName = "sp_page";

            /*
             * @TableName VARCHAR(200),     --表名
             * @FieldList VARCHAR(2000),    --显示列名,如果是全部字段则为*
             * @PrimaryKey VARCHAR(100),    --单一主键或唯一值键
             * @Where VARCHAR(2000),        --查询条件 不含'where'字符,如id>10 and len(userid)>9
             * @Order VARCHAR(1000),        --排序 不含'order by'字符,如id asc,userid desc,必须指定asc或desc
             *                    --注意当@SortType=3时生效,记住一定要在最后加上主键,否则会让你比较郁闷
             * @SortType INT,               --排序规则 1:正序asc 2:倒序desc 3:多列排序方法
             * @RecorderCount INT,          --记录总数 0:会返回总记录
             * @PageSize INT,               --每页输出的记录数
             * @PageIndex INT,              --当前页数
             * @TotalCount INT OUTPUT,      --记返回总记录
             * @TotalPageCount INT OUTPUT   --返回总页数
             */
            DbParameter[] pramers = new DbParameter[]
            {
                this.mFactory.GetDbParameter("@TableName", DbType.String),     //表名
                this.mFactory.GetDbParameter("@FieldList", DbType.String),     //显示列名,如果是全部字段则为*
                this.mFactory.GetDbParameter("@Order", DbType.String),         //排序 不含'order by'字符,如id asc,userid desc,必须指定asc或desc
                this.mFactory.GetDbParameter("@PageSize", DbType.Int32),       //每页输出的记录数
                this.mFactory.GetDbParameter("@PageIndex", DbType.Int32),      //当前页数
                this.mFactory.GetDbParameter("@SortType", DbType.Int32),       //排序规则 1:正序asc 2:倒序desc 3:多列排序方法
                this.mFactory.GetDbParameter("@Where", DbType.String),         //查询条件 不含'where'字符,如id>10 and len(userid)>9
                this.mFactory.GetDbParameter("@PrimaryKey", DbType.String),    //单一主键或唯一值键
                this.mFactory.GetDbParameter("@TotalPageCount", DbType.Int32), //返回总页数
                this.mFactory.GetDbParameter("@TotalCount", DbType.Int32),     //记返回总记录
                this.mFactory.GetDbParameter("@RecorderCount", DbType.Int32),  //记返回总记录
            };
            int sortValue = 3;

            switch (SortType)
            {
            case ESortType.ASC:
                sortValue = 1;
                break;

            case ESortType.DESC:
                sortValue = 2;
                break;
            }
            pramers[0].Value     = sql;
            pramers[1].Value     = fileds;
            pramers[2].Value     = SortName;
            pramers[3].Value     = iPageSize;
            pramers[4].Value     = iPageIndex;
            pramers[5].Value     = sortValue;
            pramers[6].Value     = "1=1";
            pramers[7].Value     = key;
            pramers[8].Direction = ParameterDirection.Output;
            pramers[9].Direction = ParameterDirection.Output;
            pramers[10].Value    = 0;


            DbCommand sqlCmd = this.mFactory.GetDbCommand();

            sqlCmd.CommandType = CommandType.StoredProcedure;
            List <E>     query     = null;
            DbDataReader SqlReader = null;

            try
            {
                sqlCmd.CommandText = spName;
                sqlCmd.Parameters.AddRange(pramers);
                sqlCmd.Connection = this.mFactory.GetDbConnection();
                if (sqlCmd.Connection.State == System.Data.ConnectionState.Closed)
                {
                    sqlCmd.Connection.Open();
                }
                SqlReader = sqlCmd.ExecuteReader();
                query     = ((IObjectContextAdapter)this.GetDbContext).ObjectContext.Translate <E>(SqlReader).ToList();
                if (SqlReader != null && !SqlReader.IsClosed)
                {
                    SqlReader.Close();
                    SqlReader.Dispose();
                }
                if (sqlCmd.Connection.State == System.Data.ConnectionState.Open)
                {
                    sqlCmd.Connection.Close();
                }

                iPageCount   = pramers[8].Value == DBNull.Value ? 0 : Convert.ToInt32(pramers[8].Value);
                iRecordCount = pramers[9].Value == DBNull.Value ? 0 : Convert.ToInt32(pramers[9].Value);
            }
            catch (Exception ex)
            {
                log.Error(" GetSqlSource<E>(" + sql + ")", ex);
                throw ex;
            }
            finally
            {
                if (SqlReader != null && !SqlReader.IsClosed)
                {
                    SqlReader.Close();
                    SqlReader.Dispose();
                }
                if (sqlCmd.Connection.State == System.Data.ConnectionState.Open)
                {
                    sqlCmd.Connection.Close();
                }
            }
            return(query);
        }
 public ObjectSortComparer(string propertyname, ESortType ordermode)
 {
     this.PropertyName = propertyname;
     this.OrderMode    = ordermode;
 }
Esempio n. 13
0
    /// <summary>
    /// Search
    /// </summary>
    void OnGUI()
    {
        _searchComponentFilter = EditorGUILayout.TextField("TypeFilter", _searchComponentFilter);
        EditorGUILayout.BeginHorizontal();
        var oldSearchMode = _searchMode;

        _searchMode = (ESearchMode)(EditorGUILayout.EnumPopup(_searchMode));
        if (oldSearchMode != _searchMode)
        {
            this.Clear();
            List <GameObject> parentObj = this.GetAllRootGameObjects();
            EditorApplication.isPaused = true;
            CreateTypeDictionary(parentObj);
        }
        if (GUILayout.Button("Search", GUILayout.Width(150)))
        {
            List <GameObject> parentObj = this.GetAllRootGameObjects();
            EditorApplication.isPaused = true;
            CreateTypeDictionary(parentObj);
        }
        EditorGUILayout.EndHorizontal();
        // EditorGUILayout.HelpBox("If root gameObject is disabled, couldn't count child objects..", MessageType.Info);
        EditorGUILayout.HelpBox("If you don't save scene, this doesn't work..", MessageType.Info);

        EditorGUILayout.LabelField("GameObject " + _snapObjectNum);
        EditorGUILayout.LabelField("ActiveNum " + _activeObjectNum);

        EditorGUILayout.LabelField("");
        var oldSortTYpe = _sortType;

        _sortType = (ESortType)EditorGUILayout.EnumPopup(_sortType);
        if (oldSortTYpe != _sortType)
        {
            this.SortComponents();
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Type");
        EditorGUILayout.LabelField("active", GUILayout.Width(50));
        EditorGUILayout.LabelField("all", GUILayout.Width(50));
        EditorGUILayout.LabelField("", GUILayout.Width(20));
        EditorGUILayout.EndHorizontal();

        _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos, GUILayout.Height(150));
        if (_typeCntList != null)
        {
            foreach (var type in _typeCntList)
            {
                if (type == null)
                {
                    continue;
                }
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(type.type.ToString()))
                {
                    _currentSelectType = type.type;
                    this._hasComponentGameObjectList = GetHaveComponentObjects(this.GetAllRootGameObjects(), type.type);
                }
                EditorGUILayout.LabelField(type.activeCnt.ToString(), GUILayout.Width(50));
                EditorGUILayout.LabelField(type.allCnt.ToString(), GUILayout.Width(50));
                EditorGUILayout.EndHorizontal();
            }
        }
        EditorGUILayout.EndScrollView();
        /// gameobject list;
        if (_hasComponentGameObjectList != null && _currentSelectType != null)
        {
            EditorGUILayout.LabelField("");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(_currentSelectType.ToString() + " Compoent Objects");
            _outputType = (EOutputList)(EditorGUILayout.EnumPopup(_outputType, GUILayout.Width(120)));
            EditorGUILayout.EndHorizontal();

            _scrollGameObjectListPos = EditorGUILayout.BeginScrollView(_scrollGameObjectListPos);
            foreach (var gmo in _hasComponentGameObjectList)
            {
                if (gmo)
                {
                    switch (_outputType)
                    {
                    case EOutputList.AllObject:
                        EditorGUILayout.ObjectField(gmo, typeof(GameObject));
                        break;

                    case EOutputList.ActiveOnly:
                        if (gmo.activeInHierarchy)
                        {
                            EditorGUILayout.ObjectField(gmo, typeof(GameObject));
                        }
                        break;

                    case EOutputList.NotActiveOnly:
                        if (!gmo.activeInHierarchy)
                        {
                            EditorGUILayout.ObjectField(gmo, typeof(GameObject));
                        }
                        break;
                    }
                }
            }
            EditorGUILayout.EndScrollView();
        }
    }
Esempio n. 14
0
 public Sort(int index, string field, ESortType sortType)
 {
     Index     = index;
     Field     = field;
     ESortType = sortType;
 }
Esempio n. 15
0
 /// <summary>
 /// 排序方法(内存中)
 /// </summary>
 /// <param name="propertyName">属性名称</param>
 /// <param name="ordermode">排序方式</param>
 public void Sort(string propertyName, ESortType ordermode)
 {
     this.Sort(new ObjectSortComparer <object>(propertyName, ordermode));
 }
Esempio n. 16
0
 /// <summary>
 /// The type of sorting to use.
 /// </summary>    
 public SortLabels SortType (ESortType type) {
   Impl.setSortType(new weka.core.SelectedTag((int) type, weka.filters.unsupervised.attribute.SortLabels.TAGS_SORTTYPE));
   return this;
 }