예제 #1
0
        public List <string> Getimg(string user_id, string kid, string projectId)
        {
            MongoDBClass <FreeBotItem> helper = new MongoDBClass <FreeBotItem>();
            var queryTask = new QueryDocument {
                { "UId", new ObjectId(user_id) }, { "taskId", new ObjectId(kid) }, { "ProjectId", new ObjectId(projectId) }
            };
            FieldsDocument fd = new FieldsDocument();

            fd.Add("pic_url", 1);
            List <FreeBotItem>            list = new List <FreeBotItem>();
            MongoCollection <FreeBotItem> col  = new MongoDBClass <FreeBotItem>().GetMongoDB().GetCollection <FreeBotItem>("FreeBotItem");
            SortByDocument s = new SortByDocument();

            s.Add("Recent30DaysSoldNum", -1);//获取数据时进行排序,-1为降序
            var           TaskList = col.Find(queryTask).SetSortOrder(s).SetLimit(10).SetFields(fd);
            List <string> str      = new List <string>();

            foreach (var item in TaskList)
            {
                string v;
                v = "http:" + item.pic_url;
                str.Add(v);
            }
            return(str);
        }
예제 #2
0
    public static MongoCursor GetEnteringTempRecords(int limit)
    {
        QueryDocument  query = new QueryDocument(new BsonElement("$where", "this.QValueIn>this.QValueOut"));
        SortByDocument s     = new SortByDocument();

        s.Add("QValueIn", -1);        //-1=DESC
        return(collection1.Find(query).SetSortOrder(s).SetLimit(limit).SetFields(new string[] { "Symbol", "QValueIn", "QValueOut" }));;
    }
예제 #3
0
        protected override void OK()
        {
            BsonDocument d   = string.IsNullOrEmpty(FindCriteria) ? new BsonDocument() : BsonDocument.Parse(FindCriteria);
            var          sbd = new SortByDocument();

            foreach (SortParameterViewModel sort in FieldsToSort)
            {
                sbd.Add(sort.FieldName, sort.CurrentDirection == OrderByDirection.Ascending ? 1 : -1);
            }
            var doc = new QueryDocument(d);

            QueryResults = _coll.Find(doc).SetSortOrder(sbd).SetFields(FieldsToView.SelectedItems.ToArray()).ToList();
        }
예제 #4
0
        public List <T> FindDataByTop(string tbName, IMongoQuery query, string orderby)
        {
            MongoServer server = new MongoClient(conn).GetServer();
            var         db     = server.GetDatabase(dbName); // WriteConcern defaulted to Acknowledged

            SortByDocument s = new SortByDocument();

            s.Add(orderby, -1); //-1=DESC
            MongoCollection <T> col = db.GetCollection <T>(tbName);
            var      resultcur      = col.Find(query).SetSortOrder(s);
            List <T> results        = new List <T>();

            foreach (var result in resultcur)
            {
                results.Add(result);
            }
            return(results);
        }
예제 #5
0
        /// <summary>
        /// 获取小孩一个月轨迹日期列表
        /// </summary>
        /// <param name="childId">小孩Id</param>
        /// <param name="beginTime">一个月的第一天</param>
        /// <param name="beginTime">一个月的最后一天</param>
        /// <returns></returns>
        public List <StepRankingModel> GetChildOneMonthTraceListImpl(int childId, DateTime begin, DateTime end)
        {
            MongoClient   client     = new MongoClient(connection);
            var           db         = client.GetDatabase(this.dbName);
            var           collection = db.GetCollection <StepRankingModel>(this.collection);
            string        beginTime  = begin.ToString("yyyyMMdd");
            string        endTime    = end.ToString("yyyyMMdd");
            QueryDocument query      = new QueryDocument();
            BsonDocument  timeBson   = new BsonDocument();

            timeBson.Add("$gt", beginTime); //>beginTime
            timeBson.Add("$lt", endTime);   //<endTime
            query.Add("Date", timeBson);
            query.Add(new BsonElement("ChildId", childId));
            SortByDocument s = new SortByDocument();

            s.Add("Date", 1);//order by asc
            return(collection.Find(query).Sort(s).ToList());
        }
예제 #6
0
 public List <FreeBotItemDto> GetBotResultList(string user_id, string kid, string projectId)
 {
     try
     {
         MongoDBClass <FreeBotItem> helper = new MongoDBClass <FreeBotItem>();
         var queryTask = new QueryDocument {
             { "UId", new ObjectId(user_id) }, { "taskId", new ObjectId(kid) }, { "ProjectId", new ObjectId(projectId) }
         };
         List <FreeBotItemDto> list = new List <FreeBotItemDto>();
         FieldsDocument        fd   = new FieldsDocument();
         fd.Add("_id", 1);
         fd.Add("ShopName", 1);
         fd.Add("Location", 1);
         fd.Add("Recent30DaysSoldNum", 1);
         fd.Add("ItemName", 1);
         fd.Add("Price", 1);
         fd.Add("CreatedAt", 1);
         MongoCollection <FreeBotItem> col = new MongoDBClass <FreeBotItem>().GetMongoDB().GetCollection <FreeBotItem>("FreeBotItem");
         SortByDocument so = new SortByDocument();
         so.Add("CreatedAt", -1);
         var TaskList = col.Find(queryTask).SetSortOrder(so).SetFields(fd);
         foreach (var item in TaskList)
         {
             FreeBotItemDto v = new FreeBotItemDto();
             v._id                 = item._id.ToString();
             v.ShopName            = item.ShopName;
             v.Location            = item.Location;
             v.ItemName            = item.ItemName;
             v.Price               = item.Price;
             v.Recent30DaysSoldNum = item.Recent30DaysSoldNum;
             list.Add(v);
         }
         return(list);
     }
     catch (Exception)
     {
         return(null);
     }
 }
예제 #7
0
        /// <summary>
        /// Executes the translated Find query.
        /// </summary>
        /// <returns>The result of executing the translated Find query.</returns>
        public override object Execute()
        {
            var query = BuildQuery();

            if (_distinct)
            {
                return(ExecuteDistinct(query));
            }

            var cursor = Collection.FindAs(DocumentType, query);

            if (_orderBy != null)
            {
                var sortBy = new SortByDocument();
                foreach (var clause in _orderBy)
                {
                    var keyExpression     = clause.Key.Body;
                    var serializationInfo = _serializationInfoHelper.GetSerializationInfo(keyExpression);
                    var direction         = (clause.Direction == OrderByDirection.Descending) ? -1 : 1;
                    sortBy.Add(serializationInfo.ElementName, direction);
                }
                cursor.SetSortOrder(sortBy);
            }

            if (_skip != null)
            {
                cursor.SetSkip(ToInt32(_skip));
            }

            if (_take != null)
            {
                cursor.SetLimit(ToInt32(_take));
            }

            var projection = _projection;

            if (_ofType != null)
            {
                if (projection == null)
                {
                    var paramExpression   = Expression.Parameter(DocumentType, "x");
                    var convertExpression = Expression.Convert(paramExpression, _ofType);
                    projection = Expression.Lambda(convertExpression, paramExpression);
                }
                else
                {
                    var paramExpression   = Expression.Parameter(DocumentType, "x");
                    var convertExpression = Expression.Convert(paramExpression, _ofType);
                    var body = ExpressionParameterReplacer.ReplaceParameter(projection.Body, projection.Parameters[0], convertExpression);
                    projection = Expression.Lambda(body, paramExpression);
                }
            }

            IEnumerable enumerable;

            if (projection == null)
            {
                enumerable = cursor;
            }
            else
            {
                var lambdaType         = projection.GetType();
                var delegateType       = lambdaType.GetGenericArguments()[0];
                var sourceType         = delegateType.GetGenericArguments()[0];
                var resultType         = delegateType.GetGenericArguments()[1];
                var projectorType      = typeof(Projector <,>).MakeGenericType(sourceType, resultType);
                var compiledProjection = projection.Compile();
                var projector          = Activator.CreateInstance(projectorType, cursor, compiledProjection);
                enumerable = (IEnumerable)projector;
            }

            if (_elementSelector != null)
            {
                return(_elementSelector(enumerable));
            }
            else
            {
                return(enumerable);
            }
        }
예제 #8
0
        /// <summary>
        /// Executes the translated Find query.
        /// </summary>
        /// <returns>The result of executing the translated Find query.</returns>
        public override object Execute()
        {
            if (_take.HasValue && _take.Value == 0)
            {
                var type = _ofType ?? DocumentType;

                return typeof(Enumerable).GetMethod("Empty").MakeGenericMethod(type).Invoke(null, null);
            }

            var query = BuildQuery();

            //if (_distinct != null)
            //{
            //    return ExecuteDistinct(query);
            //}
            
            //var cursor = Collection.FindAs(DocumentType, query);

            DBQuery dbQuery = new DBQuery();
            dbQuery.Matcher = query as BsonDocument;

            if (_orderBy != null)
            {
                var sortBy = new SortByDocument();
                foreach (var clause in _orderBy)
                {
                    var keyExpression = clause.Key.Body;
                    var serializationInfo = _serializationInfoHelper.GetSerializationInfo(keyExpression);
                    var direction = (clause.Direction == OrderByDirection.Descending) ? -1 : 1;
                    sortBy.Add(serializationInfo.ElementName, direction);
                }                
                //cursor.SetSortOrder(sortBy);
                dbQuery.OrderBy = sortBy;
            }

            if (_skip != null)
            {
                //cursor.SetSkip(_skip.Value);
                dbQuery.SkipRowsCount = _skip.Value;
            }

            if (_take != null)
            {
                //cursor.SetLimit(_take.Value);
                dbQuery.ReturnRowsCount = _take.Value;
            }

            if (_indexHint != null)
            {
                if (_indexHint.IsString)
                {
                    //cursor.SetHint(_indexHint.AsString);
                }
                else if (_indexHint.IsBsonDocument)
                {
                    //cursor.SetHint(_indexHint.AsBsonDocument);
                    dbQuery.Hint = _indexHint.AsBsonDocument;
                }
                else
                {
                    throw new NotSupportedException("Index hints must be strings or documents");
                }
            }

            var cursor = Collection.Query(dbQuery);
            cursor.DBQuery = dbQuery;

            var projection = _projection;
            if (_ofType != null)
            {
                if (projection == null)
                {
                    var paramExpression = Expression.Parameter(DocumentType, "x");
                    var convertExpression = Expression.Convert(paramExpression, _ofType);
                    projection = Expression.Lambda(convertExpression, paramExpression);
                }
                else
                {
                    var paramExpression = Expression.Parameter(DocumentType, "x");
                    var convertExpression = Expression.Convert(paramExpression, _ofType);
                    var body = ExpressionParameterReplacer.ReplaceParameter(projection.Body, projection.Parameters[0], convertExpression);
                    projection = Expression.Lambda(body, paramExpression);
                }
            }

            IProjector projector;
            if (projection == null)
            {
                var projectorType = typeof(IdentityProjector<>).MakeGenericType(DocumentType);
                projector = (IProjector)Activator.CreateInstance(projectorType, cursor);
            }
            else
            {
                var lambdaType = projection.GetType();
                var delegateType = lambdaType.GetGenericArguments()[0];
                var sourceType = delegateType.GetGenericArguments()[0];
                var resultType = delegateType.GetGenericArguments()[1];
                var projectorType = typeof(Projector<,>).MakeGenericType(sourceType, resultType);
                var compiledProjection = projection.Compile();
                projector = (IProjector)Activator.CreateInstance(projectorType, cursor, compiledProjection);
            }

            if (_elementSelector != null)
            {
                return _elementSelector(projector);
            }
            else
            {
                return projector;
            }
        }
예제 #9
0
        /// <summary>
        /// Executes the translated Find query.
        /// </summary>
        /// <returns>The result of executing the translated Find query.</returns>
        public override object Execute()
        {
            var query = BuildQuery();

            if (_distinct)
            {
                return ExecuteDistinct(query);
            }

            var cursor = Collection.FindAs(DocumentType, query);

            if (_orderBy != null)
            {
                var sortBy = new SortByDocument();
                foreach (var clause in _orderBy)
                {
                    var keyExpression = clause.Key.Body;
                    var serializationInfo = GetSerializationInfo(keyExpression);
                    if (serializationInfo == null)
                    {
                        var message = string.Format("Invalid OrderBy expression: {0}.", ExpressionFormatter.ToString(keyExpression));
                        throw new NotSupportedException(message);
                    }
                    var direction = (clause.Direction == OrderByDirection.Descending) ? -1 : 1;
                    sortBy.Add(serializationInfo.ElementName, direction);
                }
                cursor.SetSortOrder(sortBy);
            }

            if (_skip != null)
            {
                cursor.SetSkip(ToInt32(_skip));
            }

            if (_take != null)
            {
                cursor.SetLimit(ToInt32(_take));
            }

            IEnumerable enumerable;
            if (_projection == null)
            {
                enumerable = cursor;
            }
            else
            {
                var lambdaType = _projection.GetType();
                var delegateType = lambdaType.GetGenericArguments()[0];
                var sourceType = delegateType.GetGenericArguments()[0];
                var resultType = delegateType.GetGenericArguments()[1];
                var projectorType = typeof(Projector<,>).MakeGenericType(sourceType, resultType);
                var projection = _projection.Compile();
                var projector = Activator.CreateInstance(projectorType, cursor, projection);
                enumerable = (IEnumerable)projector;
            }

            if (_elementSelector != null)
            {
                return _elementSelector(enumerable);
            }
            else
            {
                return enumerable;
            }
        }
예제 #10
0
        /// <summary>
        /// Executes the translated Find query.
        /// </summary>
        /// <returns>The result of executing the translated Find query.</returns>
        public override object Execute()
        {
            if (_take.HasValue && _take.Value == 0)
            {
                var type = _ofType ?? DocumentType;

                return(typeof(Enumerable).GetMethod("Empty").MakeGenericMethod(type).Invoke(null, null));
            }

            var query = BuildQuery();

            if (_distinct != null)
            {
                return(ExecuteDistinct(query));
            }

            var cursor = Collection.FindAs(DocumentType, query);

            if (_orderBy != null)
            {
                var sortBy = new SortByDocument();
                foreach (var clause in _orderBy)
                {
                    var keyExpression     = clause.Key.Body;
                    var serializationInfo = _serializationInfoHelper.GetSerializationInfo(keyExpression);
                    var direction         = (clause.Direction == OrderByDirection.Descending) ? -1 : 1;
                    sortBy.Add(serializationInfo.ElementName, direction);
                }
                cursor.SetSortOrder(sortBy);
            }

            if (_skip != null)
            {
                cursor.SetSkip(_skip.Value);
            }

            if (_take != null)
            {
                cursor.SetLimit(_take.Value);
            }

            if (_indexHint != null)
            {
                if (_indexHint.IsString)
                {
                    cursor.SetHint(_indexHint.AsString);
                }
                else if (_indexHint.IsBsonDocument)
                {
                    cursor.SetHint(_indexHint.AsBsonDocument);
                }
                else
                {
                    throw new NotSupportedException("Index hints must be strings or documents");
                }
            }

            var projection = _projection;

            if (_ofType != null)
            {
                if (projection == null)
                {
                    var paramExpression   = Expression.Parameter(DocumentType, "x");
                    var convertExpression = Expression.Convert(paramExpression, _ofType);
                    projection = Expression.Lambda(convertExpression, paramExpression);
                }
                else
                {
                    var paramExpression   = Expression.Parameter(DocumentType, "x");
                    var convertExpression = Expression.Convert(paramExpression, _ofType);
                    var body = ExpressionParameterReplacer.ReplaceParameter(projection.Body, projection.Parameters[0], convertExpression);
                    projection = Expression.Lambda(body, paramExpression);
                }
            }

            IProjector projector;

            if (projection == null)
            {
                var projectorType = typeof(IdentityProjector <>).MakeGenericType(DocumentType);
                projector = (IProjector)Activator.CreateInstance(projectorType, cursor);
            }
            else
            {
                var lambdaType         = projection.GetType();
                var delegateType       = lambdaType.GetGenericArguments()[0];
                var sourceType         = delegateType.GetGenericArguments()[0];
                var resultType         = delegateType.GetGenericArguments()[1];
                var projectorType      = typeof(Projector <,>).MakeGenericType(sourceType, resultType);
                var compiledProjection = projection.Compile();
                projector = (IProjector)Activator.CreateInstance(projectorType, cursor, compiledProjection);
            }

            if (_elementSelector != null)
            {
                return(_elementSelector(projector));
            }
            else
            {
                return(projector);
            }
        }
예제 #11
0
        /// <summary>
        /// Executes the translated Find query.
        /// </summary>
        /// <returns>The result of executing the translated Find query.</returns>
        public override object Execute()
        {
            if (_take.HasValue && _take.Value == 0)
            {
                var type = _ofType ?? DocumentType;

                return typeof(Enumerable).GetMethod("Empty").MakeGenericMethod(type).Invoke(null, null);
            }

            var query = BuildQuery();

            if (_distinct != null)
            {
                return ExecuteDistinct(query);
            }

            var cursor = Collection.FindAs(DocumentType, query);

            if (_orderBy != null)
            {
                var sortBy = new SortByDocument();
                foreach (var clause in _orderBy)
                {
                    var keyExpression = clause.Key.Body;
                    var serializationInfo = _serializationInfoHelper.GetSerializationInfo(keyExpression);
                    var direction = (clause.Direction == OrderByDirection.Descending) ? -1 : 1;
                    sortBy.Add(serializationInfo.ElementName, direction);
                }
                cursor.SetSortOrder(sortBy);
            }

            if (_skip != null)
            {
                cursor.SetSkip(_skip.Value);
            }

            if (_take != null)
            {
                cursor.SetLimit(_take.Value);
            }

            var projection = _projection;
            if (_ofType != null)
            {
                if (projection == null)
                {
                    var paramExpression = Expression.Parameter(DocumentType, "x");
                    var convertExpression = Expression.Convert(paramExpression, _ofType);
                    projection = Expression.Lambda(convertExpression, paramExpression);
                }
                else
                {
                    var paramExpression = Expression.Parameter(DocumentType, "x");
                    var convertExpression = Expression.Convert(paramExpression, _ofType);
                    var body = ExpressionParameterReplacer.ReplaceParameter(projection.Body, projection.Parameters[0], convertExpression);
                    projection = Expression.Lambda(body, paramExpression);
                }
            }

            IProjector projector;
            if (projection == null)
            {
                var projectorType = typeof(IdentityProjector<>).MakeGenericType(DocumentType);
                projector = (IProjector)Activator.CreateInstance(projectorType, cursor);
            }
            else
            {
                var lambdaType = projection.GetType();
                var delegateType = lambdaType.GetGenericArguments()[0];
                var sourceType = delegateType.GetGenericArguments()[0];
                var resultType = delegateType.GetGenericArguments()[1];
                var projectorType = typeof(Projector<,>).MakeGenericType(sourceType, resultType);
                var compiledProjection = projection.Compile();
                projector = (IProjector)Activator.CreateInstance(projectorType, cursor, compiledProjection);
            }

            if (_elementSelector != null)
            {
                return _elementSelector(projector);
            }
            else
            {
                return projector;
            }
        }
예제 #12
0
        /// <summary>
        /// Executes the translated Find query.
        /// </summary>
        /// <returns>The result of executing the translated Find query.</returns>
        public override object Execute()
        {
            var query = BuildQuery();
            var cursor = Collection.FindAs(DocumentType, query);

            if (_orderBy != null)
            {
                var sortBy = new SortByDocument();
                foreach (var clause in _orderBy)
                {
                    var memberExpression = (MemberExpression)clause.Key.Body;
                    var dottedElementName = GetDottedElementName(memberExpression);
                    var direction = (clause.Direction == OrderByDirection.Descending) ? -1 : 1;
                    sortBy.Add(dottedElementName, direction);
                }
                cursor.SetSortOrder(sortBy);
            }

            if (_skip != null)
            {
                cursor.SetSkip(ToInt32(_skip));
            }

            if (_take != null)
            {
                cursor.SetLimit(ToInt32(_take));
            }

            IEnumerable enumerable;
            if (_projection == null)
            {
                enumerable = cursor;
            }
            else
            {
                var lambdaType = _projection.GetType();
                var delegateType = lambdaType.GetGenericArguments()[0];
                var sourceType = delegateType.GetGenericArguments()[0];
                var resultType = delegateType.GetGenericArguments()[1];
                var projectorType = typeof(Projector<,>).MakeGenericType(sourceType, resultType);
                var projection = _projection.Compile();
                var projector = Activator.CreateInstance(projectorType, cursor, projection);
                enumerable = (IEnumerable)projector;
            }

            if (_elementSelector != null)
            {
                return _elementSelector(enumerable);
            }
            else
            {
                return enumerable;
            }
        }
예제 #13
0
        public List <FreeBotItemVo> GetBubbleList(string user_id, string kid, int?pagesize, string projectId)
        {
            var queryl = new QueryDocument {
                { "UId", new ObjectId(user_id) }, { "taskId", new ObjectId(kid) }
            };
            var colFS = MongoDBHelper.Instance.Get_FreeShopTimeline();
            var aryl  = colFS.Find(queryl).SortByDescending(x => x.Recent30DaysSoldNum).ToList();
            List <FreeBotItemDto> fst = new List <FreeBotItemDto>();

            if (aryl.Count > 0)
            {
                foreach (var item in aryl)
                {
                    FreeBotItemDto fstDto = new FreeBotItemDto()
                    {
                        _id                 = item._id.ToString(),
                        CreatedAt           = Convert.ToDateTime(item.CreatedAt),// item.CreatedAt,
                        CreatedAt2          = item.CreatedAt2,
                        Position            = item.Position,
                        Recent30DaysSoldNum = item.Recent30DaysSoldNum,
                        ShopName            = item.ShopName,
                        ItemId              = item.SId,
                        taskId              = item.taskId.ToString(),
                        TotalComments       = item.TotalComments,
                        UId                 = item.UId.ToString()
                    };

                    fst.Add(fstDto);
                }
                List <FreeBotItemVo> am = new List <FreeBotItemVo>();
                foreach (var item in fst.GroupBy(x => x.CreatedAt))
                {
                    if (pagesize.HasValue)
                    {
                        //TaskList = col.Find(queryTask).SetFields(fd).SetSortOrder(s).SetLimit(Convert.ToInt16(pagesize)).ToList();
                        FreeBotItemVo amm = new FreeBotItemVo();
                        amm.TimeKey         = item.Key.ToString();
                        amm.FreeBotItemList = item.OrderByDescending(x => x.Recent30DaysSoldNum).Take(Convert.ToInt16(pagesize)).ToList();
                        am.Add(amm);
                    }
                    else
                    {
                        //TaskList = col.Find(queryTask).SetFields(fd).SetSortOrder(s).ToList();
                        FreeBotItemVo amm = new FreeBotItemVo();
                        amm.TimeKey         = item.Key.ToString();
                        amm.FreeBotItemList = item.OrderByDescending(x => x.Recent30DaysSoldNum).ToList();
                        am.Add(amm);
                    }
                }
                return(am.OrderBy(x => x.TimeKey).ToList());
            }
            else
            {
                try
                {
                    MongoDBClass <FreeBotItem> helper = new MongoDBClass <FreeBotItem>();
                    var queryTask = new QueryDocument {
                        { "UId", new ObjectId(user_id) }, { "taskId", new ObjectId(kid) }, { "ProjectId", new ObjectId(projectId) }
                    };
                    List <FreeBotItemDto> list = new List <FreeBotItemDto>();
                    FieldsDocument        fd   = new FieldsDocument();
                    fd.Add("_id", 1);
                    fd.Add("Position", 1);
                    fd.Add("Location", 1);
                    fd.Add("Recent30DaysSoldNum", 1);
                    fd.Add("ItemName", 1);
                    fd.Add("ShopName", 1);
                    fd.Add("TotalComments", 1);
                    fd.Add("DetailUrl", 1);
                    fd.Add("CreatedAt", 1);
                    MongoCollection <FreeBotItem> col = new MongoDBClass <FreeBotItem>().GetMongoDB().GetCollection <FreeBotItem>("FreeBotItem");
                    var            TaskList           = new List <FreeBotItem>();
                    SortByDocument s = new SortByDocument();
                    s.Add("Recent30DaysSoldNum", -1);
                    TaskList = col.Find(queryTask).SetFields(fd).SetSortOrder(s).ToList();
                    foreach (var item in TaskList)
                    {
                        FreeBotItemDto v = new FreeBotItemDto();
                        v._id                 = item._id.ToString();
                        v.Position            = item.Position;
                        v.Location            = item.Location;
                        v.Recent30DaysSoldNum = item.Recent30DaysSoldNum;
                        v.ItemName            = item.ItemName;
                        v.ShopName            = item.ShopName;
                        v.TotalComments       = item.TotalComments;
                        v.DetailUrl           = item.DetailUrl;
                        v.CreatedAt2          = Convert.ToDateTime(item.CreatedAt).ToString("yyyy/MM/dd");
                        list.Add(v);
                    }
                    var ary = from t in list
                              group t by new { t.ShopName, t.CreatedAt2 } into g
                        select new FreeBotItemDto
                    {
                        _id                 = Guid.NewGuid().ToString(),
                        ShopName            = g.Key.ShopName,
                        Position            = Convert.ToInt32(g.Average(p => p.Position)),
                        TotalComments       = g.Sum(p => p.TotalComments),
                        Recent30DaysSoldNum = g.Sum(p => p.Recent30DaysSoldNum),
                        CreatedAt2          = g.Key.CreatedAt2
                    };
                    List <FreeBotItemVo> am = new List <FreeBotItemVo>();
                    foreach (var item in ary.GroupBy(x => x.CreatedAt2))
                    {
                        if (pagesize.HasValue)
                        {
                            FreeBotItemVo amm = new FreeBotItemVo();
                            amm.TimeKey         = item.Key;//key即为CreateAt2
                            amm.FreeBotItemList = item.Take(Convert.ToInt16(pagesize)).ToList();
                            am.Add(amm);
                        }
                        else
                        {
                            FreeBotItemVo amm = new FreeBotItemVo();
                            amm.TimeKey         = item.Key;
                            amm.FreeBotItemList = item.ToList();
                            am.Add(amm);
                        }
                    }
                    return(am.OrderBy(x => x.TimeKey).ToList());
                }
                catch (Exception)
                {
                    return(null);
                }
            }
        }