예제 #1
0
        /// <summary>
        /// 获取公告(前台)
        /// </summary>
        /// <param name="pageSize">pageSize</param>
        /// <param name="pageIndex">pageIndex</param>
        /// <returns></returns>
        public PagingDataSet <Announcement> Gets(int pageSize = 20, int pageIndex = 1)
        {
            //使用全局缓存
            Sql sql = Sql.Builder;

            sql.Select("Id")
            .From("spb_Announcements")
            .Where("ReleaseDate <= @0 and ExpiredDate >= @1", DateTime.UtcNow.ToLocalTime(), DateTime.UtcNow.ToLocalTime())
            .OrderBy("DisplayOrder desc");

            return(GetPagingEntities(pageSize, pageIndex, Caching.CachingExpirationType.UsualObjectCollection, () =>
            {
                return string.Format("Announcement::GlobalVersion-{0};", RealTimeCacheHelper.GetGlobalVersion());
            }, () =>
            {
                return sql;
            }));
        }
예제 #2
0
        /// <summary>
        /// 根据展示区域获取公告
        /// </summary>
        /// <param name="displayArea">展示区域</param>
        /// <returns></returns>
        public IEnumerable <Announcement> Gets(string displayArea)
        {
            Sql sql = Sql.Builder;

            sql.Select("*")
            .From("spb_Announcements")
            .Where("ReleaseDate <= @0 and ExpiredDate >= @1 and DisplayArea like @2", DateTime.UtcNow.ToLocalTime(), DateTime.UtcNow.ToLocalTime(), "%" + displayArea + "%")
            .OrderBy("DisplayOrder desc");

            return(base.GetTopEntities(1000, Caching.CachingExpirationType.UsualObjectCollection, () =>
            {
                return string.Format("Announcement::GlobalVersion-{0};displayArea-{1};", RealTimeCacheHelper.GetGlobalVersion(), displayArea);
            }, () =>
            {
                return sql;
            }));
        }