Ejemplo n.º 1
0
        /// <summary>
        /// 创建新主题
        /// </summary>
        /// <param name="topicInfo">主题信息</param>
        /// <returns>返回主题ID</returns>
        public static int CreateTopic(TopicInfo topicInfo)
        {
            topicInfo.Tid = DatabaseProvider.GetInstance().CreateTopic(topicInfo);

            if (appDBCache)
                ITopicService.CreateTopic(topicInfo);

            return topicInfo.Tid;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据主题的Tag获取相关主题(游客可见级别的)
        /// </summary>
        /// <param name="topicid">主题Id</param>
        /// <returns></returns>
        public static ASEWH.Common.Generic.List<TopicInfo> GetRelatedTopicList(int topicId, int count)
        {
            IDataReader reader = DatabaseProvider.GetInstance().GetRelatedTopics(topicId, count);

            ASEWH.Common.Generic.List<TopicInfo> topics = new ASEWH.Common.Generic.List<TopicInfo>();
            while (reader.Read())
            {
                TopicInfo topic = new TopicInfo();
                topic.Tid = TypeConverter.ObjectToInt(reader["linktid"]);
                topic.Title = reader["linktitle"].ToString();
                topics.Add(topic);
            }

            reader.Close();
            return topics;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 获得热门主题html
 /// </summary>
 /// <returns></returns>
 public static List<TopicInfo> GetHotTopicsList()
 {
     List<TopicInfo> topicInfoList = new List<TopicInfo>();
     IDataReader reader = DatabaseProvider.GetInstance().GetHotTopics(20);
     while (reader.Read())
     {
         TopicInfo topicInfo = new TopicInfo();
         topicInfo.Views = TypeConverter.ObjectToInt(reader["views"]);
         topicInfo.Tid = TypeConverter.ObjectToInt(reader["tid"]);
         topicInfo.Title = reader["title"].ToString();
         topicInfoList.Add(topicInfo);
     }
     reader.Close();
     return topicInfoList;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 加载单个主题对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private static TopicInfo LoadSingleTopicInfo(IDataReader reader)
        {
            //TODO:字段查询不同,改查询
            StringBuilder tablefield = new StringBuilder();
            tablefield.Append(",");
            foreach (DataRow dr in reader.GetSchemaTable().Rows)
            {
                tablefield.Append(dr["ColumnName"].ToString().ToLower() + ",");
            }

            TopicInfo topicInfo = new TopicInfo();
            topicInfo.Tid = TypeConverter.ObjectToInt(reader["tid"]);
            topicInfo.Fid = tablefield.ToString().IndexOf(",fid,") >= 0 ? TypeConverter.ObjectToInt(reader["fid"]) : 0;
            topicInfo.Iconid = TypeConverter.ObjectToInt(reader["iconid"]);
            topicInfo.Title = reader["title"].ToString();
            topicInfo.Typeid = TypeConverter.ObjectToInt(reader["typeid"]);
            topicInfo.Readperm = TypeConverter.ObjectToInt(reader["readperm"]);
            topicInfo.Price = TypeConverter.ObjectToInt(reader["price"]);
            topicInfo.Poster = reader["poster"].ToString();
            topicInfo.Posterid = TypeConverter.ObjectToInt(reader["posterid"]);
            topicInfo.Postdatetime = reader["postdatetime"].ToString();
            topicInfo.Lastpost = reader["lastpost"].ToString();
            topicInfo.Lastposter = reader["lastposter"].ToString();
            topicInfo.Lastposterid = TypeConverter.ObjectToInt(reader["LastposterID"]);
            topicInfo.Lastpostid = TypeConverter.ObjectToInt(reader["LastpostID"]);
            topicInfo.Views = TypeConverter.ObjectToInt(reader["views"]);
            topicInfo.Replies = TypeConverter.ObjectToInt(reader["replies"]);
            topicInfo.Displayorder = TypeConverter.ObjectToInt(reader["displayorder"]);
            topicInfo.Highlight = reader["highlight"].ToString();
            topicInfo.Digest = TypeConverter.ObjectToInt(reader["digest"]);
            topicInfo.Rate = TypeConverter.ObjectToInt(reader["rate"]);
            topicInfo.Hide = TypeConverter.ObjectToInt(reader["hide"]);
            topicInfo.Attachment = TypeConverter.ObjectToInt(reader["attachment"]);
            topicInfo.Moderated = tablefield.ToString().IndexOf(",moderated,") >= 0 ? TypeConverter.ObjectToInt(reader["moderated"]) : 0;
            topicInfo.Closed = TypeConverter.ObjectToInt(reader["closed"]);
            topicInfo.Magic = TypeConverter.ObjectToInt(reader["magic"]);
            topicInfo.Identify = tablefield.ToString().IndexOf(",identify,") >= 0 ? TypeConverter.ObjectToInt(reader["identify"]) : 0;
            topicInfo.Special = byte.Parse(reader["special"].ToString());
            topicInfo.Attention = tablefield.ToString().IndexOf(",attention,") >= 0 ? TypeConverter.ObjectToInt(reader["attention"]) : 0;

            return topicInfo;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新主题
        /// </summary>
        /// <param name="topicInfo">主题信息</param>
        /// <returns>成功返回1,否则返回0</returns>
        public static int UpdateTopic(TopicInfo topicInfo)
        {
            if (appDBCache)
                ITopicService.UpdateTopic(topicInfo);

            return DatabaseProvider.GetInstance().UpdateTopic(topicInfo);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取使用同一tag的主题列表
        /// </summary>
        /// <param name="tagId">TagId</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页大小</param>
        /// <returns></returns>
        public static List<TopicInfo> GetTopicListByTagId(int tagId, int pageIndex, int pageSize)
        {
            IDataReader reader = DatabaseProvider.GetInstance().GetTopicListByTag(tagId, pageIndex, pageSize);

            List<TopicInfo> topics = new List<TopicInfo>();

            while (reader.Read())
            {
                TopicInfo topic = new TopicInfo();
                topic.Tid = Utils.StrToInt(reader["tid"], 0);
                topic.Title = reader["title"].ToString();
                topic.Poster = reader["poster"].ToString();
                topic.Posterid = Utils.StrToInt(reader["posterid"], -1);
                topic.Fid = Utils.StrToInt(reader["fid"], 0);
                topic.Postdatetime = reader["postdatetime"].ToString();
                topic.Replies = Utils.StrToInt(reader["replies"], 0);
                topic.Views = Utils.StrToInt(reader["views"], 0);
                topic.Lastposter = reader["lastposter"].ToString();
                topic.Lastposterid = Utils.StrToInt(reader["lastposterid"], -1);
                topic.Lastpost = reader["lastpost"].ToString();
                topics.Add(topic);
            }
            reader.Close();

            return topics;
        }