Пример #1
0
        public ArticleInfo_QueryCollection QueryArticleList(string key, string gameCode, string category, int pageIndex, int pageSize)
        {
            pageIndex = pageIndex < 0 ? 0 : pageIndex;
            pageSize  = pageSize > BusinessHelper.MaxPageSize ? BusinessHelper.MaxPageSize : pageSize;
            string QueryArticleList_sql = SqlModule.DataModule.FirstOrDefault(x => x.Key == "Data_QueryArticleList").SQL;
            var    collection           = DB.CreateSQLQuery(QueryArticleList_sql)
                                          .SetString("@Key", key)
                                          .SetString("@GameCode", gameCode)
                                          .SetString("@Category", category)
                                          .SetInt("@PageIndex", pageIndex)
                                          .SetInt("@PageSize", pageSize).List <ArticleInfo_Query>();

            var returnmodel = new ArticleInfo_QueryCollection();

            returnmodel.ArticleList = collection;
            string QueryArticleCount_sql = SqlModule.DataModule.FirstOrDefault(x => x.Key == "Data_QueryArticleList_TotalCount").SQL;
            var    TotalCount            = DB.CreateSQLQuery(QueryArticleList_sql)
                                           .SetString("@Key", key)
                                           .SetString("@GameCode", gameCode)
                                           .SetString("@Category", category)
                                           .First <int>();

            returnmodel.TotalCount = TotalCount;
            return(returnmodel);
        }
Пример #2
0
        public ArticleInfo_QueryCollection QueryNoStaticPathArticleList(int pageIndex, int pageSize)
        {
            var result     = new ArticleInfo_QueryCollection();
            var manager    = new ArticleManager();
            int totalCount = 0;

            result.ArticleList = manager.QueryNoStaticPathArticleList(pageIndex, pageSize, out totalCount);
            result.TotalCount  = totalCount;
            return(result);
        }
Пример #3
0
 //private static Dictionary<string, ArticleInfo_QueryCollection> _articleCollection = new Dictionary<string, ArticleInfo_QueryCollection>();
 /// <summary>
 /// 查询文章列表
 /// todo:后台权限
 /// </summary>
 public Task <ArticleInfo_QueryCollection> QueryArticleList_YouHua(string category, string gameCode, int pageIndex, int pageSize)
 {
     try
     {
         //string cacheKey = string.Format("{0}_{1}_{2}_{3}", category, gameCode, pageIndex, pageSize);
         var result = new ArticleInfo_QueryCollection();
         //if (_articleCollection != null && _articleCollection.Count > 0 && _articleCollection.ContainsKey(cacheKey))
         //{
         //    result = _articleCollection.FirstOrDefault(s => s.Key == cacheKey).Value;
         //}
         //else
         //{
         if (string.IsNullOrEmpty(category))
         {
             throw new LogicException("未查询到文章类别");
         }
         var    Key      = RedisKeys.ArticleListKey;
         string cacheKey = string.Format("{0}_{1}_{2}_{3}_{4}", Key, category, gameCode, pageIndex, pageSize);
         var    obj      = RedisHelperEx.DB_CoreCacheData.GetObj <ArticleInfo_QueryCollection>(cacheKey);
         if (obj != null)
         {
             return(Task.FromResult(obj));
         }
         var array         = category.Split('|');
         var gameCodeArray = gameCode.Split('|');
         result = new DataQuery().QueryArticleList_YouHua(array, gameCodeArray, pageIndex, pageSize);
         //if (!_articleCollection.ContainsKey(cacheKey))
         //    _articleCollection.Add(cacheKey, result);
         //}
         if (result != null)
         {
             RedisHelperEx.DB_CoreCacheData.SetObj(cacheKey, result, TimeSpan.FromMinutes(5));
         }
         return(Task.FromResult(result));
     }
     catch (LogicException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
Пример #4
0
        public ArticleInfo_QueryCollection QueryArticleList_YouHua(string[] category, string[] gameCode, int pageIndex, int pageSize)
        {
            ArticleInfo_QueryCollection collection = new ArticleInfo_QueryCollection();
            // 通过数据库存储过程进行查询
            var query = from a in DB.CreateQuery <E_SiteMessage_Article_List>()
                        where category.Contains(a.Category) &&
                        gameCode.Contains(a.GameCode)
                        //orderby a.CreateTime descending
                        select a;

            collection.TotalCount  = query.Count();
            collection.ArticleList = query.OrderByDescending(p => p.CreateTime).Skip(pageIndex * pageSize).Take(pageSize).ToList().Select(a => new ArticleInfo_Query
            {
                Category              = a.Category.Trim(),
                CreateTime            = a.CreateTime,
                CreateUserDisplayName = a.CreateUserDisplayName,
                CreateUserKey         = a.CreateUserKey,
                DescContent           = a.DescContent,
                Description           = a.Description,
                GameCode              = a.GameCode,
                Id                    = a.Id,
                IsRedTitle            = a.IsRedTitle,
                KeyWords              = a.KeyWords,
                NextId                = a.NextId,
                NextTitle             = a.NextTitle,
                PreId                 = a.PreId,
                PreTitle              = a.PreTitle,
                ReadCount             = a.ReadCount,
                ShowIndex             = a.ShowIndex,
                Title                 = a.Title,
                UpdateTime            = a.UpdateTime,
                UpdateUserDisplayName = a.UpdateUserDisplayName,
                UpdateUserKey         = a.UpdateUserKey,
                NextStaticPath        = a.NextStaticPath,
                PreStaticPath         = a.PreStaticPath,
                StaticPath            = a.StaticPath,
            }).ToList();

            return(collection);
            //var list = manager.QueryArticleList_YouHua(array, gameCodeArray, pageIndex, pageSize);
            //    return list;
        }
Пример #5
0
        public ArticleInfo_QueryCollection QueryArticleList_YouHua(string[] array_category, string[] gameCodeArray, int pageIndex, int pageSize)
        {
            Session.Clear();
            ArticleInfo_QueryCollection collection = new ArticleInfo_QueryCollection();
            // 通过数据库存储过程进行查询
            var query = from a in Session.Query <Article>()
                        where array_category.Contains(a.Category) &&
                        gameCodeArray.Contains(a.GameCode)
                        orderby a.CreateTime descending
                        select new ArticleInfo_Query
            {
                Category              = a.Category.Trim(),
                CreateTime            = a.CreateTime,
                CreateUserDisplayName = a.CreateUserDisplayName,
                CreateUserKey         = a.CreateUserKey,
                DescContent           = a.DescContent,
                Description           = a.Description,
                GameCode              = a.GameCode,
                Id                    = a.Id,
                IsRedTitle            = a.IsRedTitle,
                KeyWords              = a.KeyWords,
                NextId                = a.NextId,
                NextTitle             = a.NextTitle,
                PreId                 = a.PreId,
                PreTitle              = a.PreTitle,
                ReadCount             = a.ReadCount,
                ShowIndex             = a.ShowIndex,
                Title                 = a.Title,
                UpdateTime            = a.UpdateTime,
                UpdateUserDisplayName = a.UpdateUserDisplayName,
                UpdateUserKey         = a.UpdateUserKey,
                NextStaticPath        = a.NextStaticPath,
                PreStaticPath         = a.PreStaticPath,
                StaticPath            = a.StaticPath,
            };

            collection.TotalCount  = query.Count();
            collection.ArticleList = query.Skip(pageIndex * pageSize).Take(pageSize).ToList();

            return(collection);
        }