Beispiel #1
0
        /// <summary>获取帖子列表,带缓存</summary>
        /// <param name="inf"></param>
        /// <returns></returns>
        public static EntityList <Topic> GetTopicList(ForumHotItemInfo inf)
        {
            if (inf.Cachetimeout < 60)
            {
                inf.Cachetimeout = 60;
            }
            if (inf.Dataitemcount > 50)
            {
                inf.Dataitemcount = 50;
            }
            else if (inf.Dataitemcount < 1)
            {
                inf.Dataitemcount = 1;
            }

            var list = XCache.Current.RetrieveObject("/Forum/ForumHostList-" + inf.Id) as EntityList <Topic>;

            if (list == null)
            {
                string visibleFidList = string.IsNullOrEmpty(inf.Forumlist) ? Forums.GetVisibleForum() : inf.Forumlist;
                //string fieldName = Focuses.GetFieldName((TopicOrderType)Enum.Parse(typeof(TopicOrderType), inf.Sorttype));
                var type = Focuses.GetStartDate((TopicTimeType)Enum.Parse(typeof(TopicTimeType), inf.Datatimetype));
                list = Topic.GetFocusTopicList(inf.Dataitemcount, -1, 0, "", type, inf.Sorttype, visibleFidList, inf.Sorttype == "digest", false);
                if (inf.Cachetimeout > 0)
                {
                    XCache.Add("/Forum/ForumHostList-" + inf.Id, list, inf.Cachetimeout);
                }
            }
            return(list);
        }
Beispiel #2
0
        //public static EntityList<Topic> GetDigestTopicList(int count)
        //{
        //	return Focuses.GetTopicList(count, -1, 0, "", TopicTimeType.All, TopicOrderType.ID, true, 20, false, "");
        //}
        //public static EntityList<Topic> GetDigestTopicList(int count, int fid, TopicTimeType timetype, TopicOrderType ordertype)
        //{
        //	return Focuses.GetTopicList(count, -1, fid, "", timetype, ordertype, true, 20, false, "");
        //}
        //public static EntityList<Topic> GetHotTopicList(int count, int views)
        //{
        //	return Focuses.GetTopicList(count, views, 0, "", TopicTimeType.All, TopicOrderType.ID, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetHotTopicList(int count, int views, int fid, TopicTimeType timetype, TopicOrderType ordertype)
        //{
        //	return Focuses.GetTopicList(count, views, fid, "", timetype, ordertype, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetRecentTopicList(int count)
        //{
        //	return Focuses.GetTopicList(count, -1, 0, "", TopicTimeType.All, TopicOrderType.ID, false, 20, false, "");
        //}
        //public static EntityList<Topic> GetTopicList(int count, int views, int fid, string typeIdList, TopicTimeType timetype, TopicOrderType ordertype, bool isdigest, int cachetime, bool onlyimg)
        //{
        //	return Focuses.GetTopicList(count, views, fid, typeIdList, timetype, ordertype, isdigest, cachetime, onlyimg, "");
        //}

        public static EntityList <Topic> GetTopicList(int count, int views, int fid, string typeIdList, TopicTimeType timetype, Int32 ordertype, bool isdigest, int cachetime, bool onlyimg, string fidlist)
        {
            if (cachetime == 0)
            {
                cachetime = 1;
            }
            if (count > 50)
            {
                count = 50;
            }
            if (count < 1)
            {
                count = 1;
            }
            var order = Topic._FocusOrder[ordertype];

            string xpath        = string.Format("/Forum/TopicList-{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}", count, views, fid, timetype, order, isdigest, onlyimg, typeIdList.Replace(',', 'd'));
            var    cacheService = XCache.Current;

            var dataTable = cacheService.RetrieveObject(xpath) as EntityList <Topic>;

            if (dataTable == null)
            {
                if (String.IsNullOrEmpty(fidlist))
                {
                    fidlist = Forums.GetVisibleForum();
                }

                dataTable = Topic.GetFocusTopicList(count, views, fid, typeIdList, Focuses.GetStartDate(timetype), order, fidlist, isdigest, onlyimg);
                XCache.Add(xpath, dataTable, cachetime * 60);
            }
            return(dataTable);
        }
Beispiel #3
0
        public static string HotImagesArray(ForumHotItemInfo fi)
        {
            //string format = "<li><a href=\"{0}\" target=\"_blank\"><img src=\"{1}\" alt=\"{2}\"/></a></li>";
            //string format2 = "<a href=\"#\" rel=\"{0}\">{0}</a>";
            var sb   = new StringBuilder();
            var sb2  = new StringBuilder();
            var thum = (BaseConfigs.GetForumPath + "cache/rotatethumbnail/").EnsureDirectory();

            //string fidlist = string.IsNullOrEmpty(fi.Forumlist) ? Forums.GetVisibleForum() : fi.Forumlist;
            var fidlist = fi.Forumlist;

            if (fidlist.IsNullOrWhiteSpace())
            {
                fidlist = Forums.GetVisibleForum();
            }
            int num = 1;
            // 热点图片
            var list = ForumHots.HotImages(fi.Dataitemcount, fi.Cachetimeout, fi.Sorttype, fi.Id, fidlist, fi.Enabled);

            foreach (var att in list)
            {
                //int topicid = att["tid"].ToInt();
                string filename = (att.FileName + "").Trim();
                string title    = (att.Title + "").Trim();
                title = Utils.JsonCharFilter(title).Replace("'", "\\'");

                string format = "<li><a href=\"{0}\" target=\"_blank\"><img src=\"{1}\" alt=\"{2}\"/></a></li>";
                if (!att.IsLocal)
                {
                    ForumHots.DeleteCacheImageFile();
                    var file = Path.GetFileName(filename);
                    Thumbnail.MakeRemoteThumbnailImage(filename, thum.CombinePath("r_" + file), 360, 240);
                    sb.AppendFormat(format, Urls.ShowTopicAspxRewrite(att.Tid, 0), "cache/rotatethumbnail/r_" + file, title);
                }
                else
                {
                    string file    = att.FullFileName.Replace('\\', '/').Trim();
                    string str     = "cache/rotatethumbnail/r_" + Utils.GetFilename(file);
                    var    newFile = Utils.GetMapPath(BaseConfigs.GetForumPath + str);
                    if (!File.Exists(newFile) && File.Exists(file))
                    {
                        ForumHots.DeleteCacheImageFile();
                        Thumbnail.MakeThumbnailImage(file, newFile, 360, 240);
                    }
                    sb.AppendFormat(format, Urls.ShowTopicAspxRewrite(att.Tid, 0), str, title);
                }
                sb2.AppendFormat("<a href=\"#\" rel=\"{0}\">{0}</a>", num);
                num++;
            }
            return("<div class=\"image_reel\"><ul>" + sb.ToString() + "</ul></div><div class=\"paging\"><span></span>" + sb2.ToString() + "</div>");
        }