/// <summary>
        /// 获取所有动态信息
        /// </summary>
        /// <returns></returns>
        public static List <UserActivity> GetUserActivities()
        {
            UserActivityQuery query = new UserActivityQuery();

            query.PageSize = Int32.MaxValue;
            return(GetUserActivities(query).Records);
        }
        /// <summary>
        /// 根据<paramref name="query"/>查询动态信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public static PagingDataSet <UserActivity> GetUserActivities(UserActivityQuery query)
        {
            PagingDataSet <UserActivity> activities = null;
            string cacheKey = CacheKeyManager.GetUserActivityQueryKey(query);

            //从缓存读取
            if (HttpContext.Current != null)
            {
                activities = HttpContext.Current.Items[cacheKey] as PagingDataSet <UserActivity>;
            }

            if (activities != null)
            {
                return(activities);
            }

            activities = HHCache.Instance.Get(cacheKey) as PagingDataSet <UserActivity>;

            if (activities == null)
            {
                int totalRecods;
                List <UserActivity> activityList = CommonDataProvider.Instance.GetUserActivities(query, out totalRecods);
                activities              = new PagingDataSet <UserActivity>();
                activities.Records      = activityList;
                activities.TotalRecords = totalRecods;

                HHCache.Instance.Insert(cacheKey, activities, 1);
                if (HttpContext.Current != null)
                {
                    HttpContext.Current.Items[cacheKey] = activities;
                }
            }
            return(activities);
        }
Пример #3
0
 public static string GetUserActivityQueryKey(UserActivityQuery userActivityQuery)
 {
     return(ActivityPrefix + string.Format(
                "PI{0}PS{1}UID{2}ST{3}ET{4}",
                userActivityQuery.PageIndex,
                userActivityQuery.PageSize,
                userActivityQuery.UserID,
                userActivityQuery.StartTime.Ticks,
                userActivityQuery.EndTime.Ticks));
 }