public void AddRange(ForumHotItemInfo[] value)
 {
     for (int i = 0; (i < value.Length); i = (i + 1))
     {
         this.Add(value[i]);
     }
 }
Example #2
0
        /// <summary>
        /// 获得帖子列表
        /// </summary>
        /// <param name="count">数量</param>
        /// <param name="views">最小浏览量</param>
        /// <param name="fid">板块ID</param>
        /// <param name="timetype">期限类型,一天、一周、一月、不限制</param>
        /// <param name="ordertype">排序类型,时间倒序、浏览量倒序、最后回复倒序</param>
        /// <param name="isdigest">是否精华</param>
        /// <param name="cachetime">缓存的有效期(单位:分钟)</param>
        /// <returns></returns>
        public static DataTable GetTopicList(ForumHotItemInfo forumHotItemInfo)
        {
            //防止恶意行为
            forumHotItemInfo.Cachetimeout = forumHotItemInfo.Cachetimeout == 0 ? 1 : forumHotItemInfo.Cachetimeout;
            forumHotItemInfo.Dataitemcount = forumHotItemInfo.Dataitemcount > 50 ? 50 : (forumHotItemInfo.Dataitemcount < 1 ? 1 : forumHotItemInfo.Dataitemcount);

            DataTable dt = new DataTable();

            if (forumHotItemInfo.Cachetimeout > 0)
                dt = DNTCache.GetCacheService().RetrieveObject("/Forum/ForumHostList-" + forumHotItemInfo.Id) as DataTable;

            if (dt == null)
            {
                //如果版块idlist设置为空,则默认读取所有可见板块的idlist
                string forumList = string.IsNullOrEmpty(forumHotItemInfo.Forumlist) ? Forums.GetVisibleForum() : forumHotItemInfo.Forumlist;
                string orderFieldName = Focuses.GetFieldName((TopicOrderType)Enum.Parse(typeof(TopicOrderType), forumHotItemInfo.Sorttype));

                dt = Discuz.Data.Topics.GetTopicList(forumHotItemInfo.Dataitemcount, -1, 0, "",
                    Focuses.GetStartDate((TopicTimeType)Enum.Parse(typeof(TopicTimeType), forumHotItemInfo.Datatimetype)),
                    orderFieldName, forumList, orderFieldName == "digest", false);

                if (forumHotItemInfo.Cachetimeout > 0)
                    DNTCache.GetCacheService().AddObject("/Forum/ForumHostList-" + forumHotItemInfo.Id, dt, forumHotItemInfo.Cachetimeout);
            }
            return dt;
        }
 public void Remove(ForumHotItemInfo value)
 {
     List.Remove(value);
 }
 public void Insert(int index, ForumHotItemInfo value)
 {
     List.Insert(index, value);
 }
 public int IndexOf(ForumHotItemInfo value)
 {
     return this.List.IndexOf(value);
 }
 public void CopyTo(ForumHotItemInfo[] array, int index)
 {
     this.List.CopyTo(array, index);
 }
 public bool Contains(ForumHotItemInfo value)
 {
     return this.List.Contains(value);
 }
 public int Add(ForumHotItemInfo value)
 {
     return this.List.Add(value);
 }
 public ForumHotItemInfoConllection(ForumHotItemInfo[] value)
 {
     this.AddRange(value);
 }
Example #10
0
        public static ForumHotConfigInfo CreateInstance()
        {
            ForumHotConfigInfo configInfo = new ForumHotConfigInfo();
            configInfo.Enable = true;
            //定义默认数据 最新主题
            ForumHotItemInfo newTopicSetting = new ForumHotItemInfo();
            newTopicSetting.Id = 1;
            newTopicSetting.Name = "最新主题";
            newTopicSetting.Datatype = "topics";
            newTopicSetting.Sorttype = "PostDateTime";
            newTopicSetting.Topictitlelength = 20;
            newTopicSetting.Forumnamelength = 10;
            newTopicSetting.Dataitemcount = 13;
            configInfo.ForumHotCollection.Add(newTopicSetting);

            //定义默认数据 热门主题
            ForumHotItemInfo hotTopicSetting = new ForumHotItemInfo();
            hotTopicSetting.Id = 2;
            hotTopicSetting.Name = "热门主题";
            hotTopicSetting.Datatype = "topics";
            hotTopicSetting.Sorttype = "Views";
            hotTopicSetting.Topictitlelength = 20;
            hotTopicSetting.Forumnamelength = 10;
            hotTopicSetting.Dataitemcount = 13;
            configInfo.ForumHotCollection.Add(hotTopicSetting);

            //定义默认数据 精华主题
            ForumHotItemInfo digestTopicSetting = new ForumHotItemInfo();
            digestTopicSetting.Id = 3;
            digestTopicSetting.Name = "精华主题";
            digestTopicSetting.Datatype = "topics";
            digestTopicSetting.Sorttype = "Digest";
            digestTopicSetting.Topictitlelength = 20;
            digestTopicSetting.Forumnamelength = 10;
            digestTopicSetting.Dataitemcount = 13;
            configInfo.ForumHotCollection.Add(digestTopicSetting);

            //定义默认数据 用户发帖排行
            ForumHotItemInfo userTopicRankSetting = new ForumHotItemInfo();
            userTopicRankSetting.Id = 4;
            userTopicRankSetting.Name = "用户发帖排行";
            userTopicRankSetting.Datatype = "users";
            userTopicRankSetting.Sorttype = "posts";
            userTopicRankSetting.Dataitemcount = 20;
            userTopicRankSetting.Datatimetype = "posts";
            configInfo.ForumHotCollection.Add(userTopicRankSetting);

            //定义默认数据 版块发帖排行
            ForumHotItemInfo forumTopicRankSetting = new ForumHotItemInfo();
            forumTopicRankSetting.Id = 5;
            forumTopicRankSetting.Name = "版块发帖排行";
            forumTopicRankSetting.Datatype = "forums";
            forumTopicRankSetting.Sorttype = "posts";
            forumTopicRankSetting.Forumnamelength = 20;
            forumTopicRankSetting.Dataitemcount = 20;
            configInfo.ForumHotCollection.Add(forumTopicRankSetting);

            //定义默认数据 热点图片
            ForumHotItemInfo hotPicSetting = new ForumHotItemInfo();
            hotPicSetting.Id = 6;
            hotPicSetting.Name = "热点图片";
            hotPicSetting.Datatype = "pictures";
            hotPicSetting.Sorttype = "aid";
            hotPicSetting.Dataitemcount = 5;
            configInfo.ForumHotCollection.Add(hotPicSetting);

            return configInfo;
        }
Example #11
0
        public static ForumHotConfigInfo CreateInstance()
        {
            ForumHotConfigInfo configInfo = new ForumHotConfigInfo();

            configInfo.Enable = true;
            //定义默认数据 最新主题
            ForumHotItemInfo newTopicSetting = new ForumHotItemInfo();

            newTopicSetting.Id               = 1;
            newTopicSetting.Name             = "最新主题";
            newTopicSetting.Datatype         = "topics";
            newTopicSetting.Sorttype         = "PostDateTime";
            newTopicSetting.Topictitlelength = 20;
            newTopicSetting.Forumnamelength  = 10;
            newTopicSetting.Dataitemcount    = 13;
            configInfo.ForumHotCollection.Add(newTopicSetting);

            //定义默认数据 热门主题
            ForumHotItemInfo hotTopicSetting = new ForumHotItemInfo();

            hotTopicSetting.Id               = 2;
            hotTopicSetting.Name             = "热门主题";
            hotTopicSetting.Datatype         = "topics";
            hotTopicSetting.Sorttype         = "Views";
            hotTopicSetting.Topictitlelength = 20;
            hotTopicSetting.Forumnamelength  = 10;
            hotTopicSetting.Dataitemcount    = 13;
            configInfo.ForumHotCollection.Add(hotTopicSetting);

            //定义默认数据 精华主题
            ForumHotItemInfo digestTopicSetting = new ForumHotItemInfo();

            digestTopicSetting.Id               = 3;
            digestTopicSetting.Name             = "精华主题";
            digestTopicSetting.Datatype         = "topics";
            digestTopicSetting.Sorttype         = "Digest";
            digestTopicSetting.Topictitlelength = 20;
            digestTopicSetting.Forumnamelength  = 10;
            digestTopicSetting.Dataitemcount    = 13;
            configInfo.ForumHotCollection.Add(digestTopicSetting);

            //定义默认数据 用户发帖排行
            ForumHotItemInfo userTopicRankSetting = new ForumHotItemInfo();

            userTopicRankSetting.Id            = 4;
            userTopicRankSetting.Name          = "用户发帖排行";
            userTopicRankSetting.Datatype      = "users";
            userTopicRankSetting.Sorttype      = "posts";
            userTopicRankSetting.Dataitemcount = 20;
            userTopicRankSetting.Datatimetype  = "posts";
            configInfo.ForumHotCollection.Add(userTopicRankSetting);

            //定义默认数据 版块发帖排行
            ForumHotItemInfo forumTopicRankSetting = new ForumHotItemInfo();

            forumTopicRankSetting.Id              = 5;
            forumTopicRankSetting.Name            = "版块发帖排行";
            forumTopicRankSetting.Datatype        = "forums";
            forumTopicRankSetting.Sorttype        = "posts";
            forumTopicRankSetting.Forumnamelength = 20;
            forumTopicRankSetting.Dataitemcount   = 20;
            configInfo.ForumHotCollection.Add(forumTopicRankSetting);

            //定义默认数据 热点图片
            ForumHotItemInfo hotPicSetting = new ForumHotItemInfo();

            hotPicSetting.Id            = 6;
            hotPicSetting.Name          = "热点图片";
            hotPicSetting.Datatype      = "pictures";
            hotPicSetting.Sorttype      = "aid";
            hotPicSetting.Dataitemcount = 5;
            configInfo.ForumHotCollection.Add(hotPicSetting);

            return(configInfo);
        }
Example #12
0
        /// <summary>
        /// 转换热门图片为数组
        /// </summary>
        /// <param name="topNumber">获取的数量</param>
        /// <param name="orderBy">排序方式</param>
        /// <param name="cachetime">缓存时间</param>
        /// <returns></returns>
        public static string HotImagesArray(ForumHotItemInfo forumHotItemInfo)
        {
            string imagesItemTemplate = "title:\"{0}\",img:\"{1}\",url:\"{2}\"";
            StringBuilder hotImagesArray = new StringBuilder();

            //如果没有缩略图目录,则去生成
            if (!Directory.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/")))
                Utils.CreateDir(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/"));

            //如果版块idlist设置为空,则默认读取所有可见板块的idlist
            string forumList = string.IsNullOrEmpty(forumHotItemInfo.Forumlist) ? Forums.GetVisibleForum() : forumHotItemInfo.Forumlist;

            foreach (DataRow dr in HotImages(forumHotItemInfo.Dataitemcount, forumHotItemInfo.Cachetimeout, forumHotItemInfo.Sorttype, forumHotItemInfo.Id, forumList, forumHotItemInfo.Enabled).Rows)
            {
                int tid = TypeConverter.ObjectToInt(dr["tid"]);
                string fileName = dr["filename"].ToString().Trim();
                string title = dr["title"].ToString().Trim();

                title = Utils.JsonCharFilter(title).Replace("'", "\\'");

                if (fileName.StartsWith("http://"))
                {
                    DeleteCacheImageFile();
                    Thumbnail.MakeRemoteThumbnailImage(fileName, Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName)), 360, 240);
                    hotImagesArray.Append("{");
                    hotImagesArray.AppendFormat(imagesItemTemplate, title, "cache/rotatethumbnail/r_" + Utils.GetFilename(fileName), Urls.ShowTopicAspxRewrite(tid, 0));
                    hotImagesArray.Append("},");
                    continue;
                }
                //图片文件名称
                string fullFileName = BaseConfigs.GetForumPath + "upload/" + fileName.Replace('\\', '/').Trim();
                //图片缩略后的名称
                string thumbnailFileName = "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName);

                if (!File.Exists(Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName)) && File.Exists(Utils.GetMapPath(fullFileName)))
                {
                    DeleteCacheImageFile();
                    Thumbnail.MakeThumbnailImage(Utils.GetMapPath(fullFileName), Utils.GetMapPath(BaseConfigs.GetForumPath + thumbnailFileName), 360, 240);
                }
                hotImagesArray.Append("{");
                hotImagesArray.AppendFormat(imagesItemTemplate, title, "cache/rotatethumbnail/r_" + Utils.GetFilename(fullFileName), Urls.ShowTopicAspxRewrite(tid, 0));
                hotImagesArray.Append("},");
            }

            return "[" + hotImagesArray.ToString().TrimEnd(',') + "]";
        }
Example #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (action)
            {
                case "setenabled":
                    forumHotConfigInfo.Enable = DNTRequest.GetInt("enabled", 0) == 1;
                    ForumHotConfigs.SaveConfig(forumHotConfigInfo);
                    Response.Redirect("forum_forumhot.aspx");
                    break;

                case "edit":
                    forumHotItem = forumHotConfigInfo.ForumHotCollection[id - 1];
                    break;
                case "editsave":
                    //数据来源版块设定范围
                    string forumlist = DNTRequest.GetString("forumlist");
                    //显示版块名称长度限制
                    int forumLength = DNTRequest.GetInt("forumnamelength", 0);
                    //显示主题标题长度限制
                    int titleLength = DNTRequest.GetInt("topictitlelength", 0);
                    //数据来源时间设定范围
                    string dataTimeType = DNTRequest.GetString("datatimetype");
                    //热点信息类型
                    string dataType = DNTRequest.GetString("datatype");
                    //热点信息排序类型
                    string sortType = DNTRequest.GetString("sorttype");
                    //热点信息名称
                    string forumHotName = DNTRequest.GetString("forumhotitemname");
                    //是否启用
                    int enabled = DNTRequest.GetInt("itemenabled", 0);
                    //读取最大数据条数
                    int dataCount = DNTRequest.GetInt("datacount", 0);
                    //数据缓存时间
                    int cacheTimeOut = DNTRequest.GetInt("cachetime", 0);

                    //限制enabled值在0-1之间
                    enabled = enabled < 0 ? 0 : (enabled > 1 ? 1 : enabled);

                    cacheTimeOut = cacheTimeOut < 0 ? 1 : cacheTimeOut;


                    switch (dataType)
                    {
                        case "topics":
                            forumLength = forumLength < 0 ? 0 : forumLength;
                            titleLength = titleLength < 0 ? 0 : titleLength;
                            break;
                        case "forums":
                            forumlist = string.Empty;
                            dataTimeType = string.Empty;
                            forumLength = forumLength < 0 ? 0 : forumLength;
                            titleLength = 0;
                            break;
                        case "users":
                            forumlist = string.Empty;
                            forumLength = 0;
                            titleLength = 0;
                            //如果此时sortType=posts,另外给它赋值为dataTimeType的值供前台方法调用
                            sortType = sortType == "posts" ? dataTimeType : sortType;
                            break;
                        case "pictures":
                            titleLength = titleLength < 0 ? 0 : titleLength;
                            forumLength = 0;
                            break;
                    }
                    forumHotConfigInfo.ForumHotCollection[id - 1].Name = forumHotName;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Enabled = enabled;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Datatype = dataType;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Sorttype = sortType;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Forumlist = forumlist;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Dataitemcount = dataCount;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Datatimetype = dataTimeType;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Cachetimeout = cacheTimeOut;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Forumnamelength = forumLength;
                    forumHotConfigInfo.ForumHotCollection[id - 1].Topictitlelength = titleLength;

                    ForumHotConfigs.SaveConfig(forumHotConfigInfo);
                    DNTCache.GetCacheService().RemoveObject("/Forum/ForumHot");
                    DNTCache.GetCacheService().RemoveObject("/Forum/ForumHostList-" + id);
                    DNTCache.GetCacheService().RemoveObject("/Aggregation/HotForumList" + id);
                    DNTCache.GetCacheService().RemoveObject("/Aggregation/Users_" + id + "List");
                    DNTCache.GetCacheService().RemoveObject("/Aggregation/HotImages_" + id + "List");
                    Response.Redirect("forum_forumhot.aspx");
                    break;
            }
        }