Exemplo n.º 1
0
 public static void WriteAggregationHotTopicsData(string tidlist, string configPath, string topiclistnodepath, string websitetopiclistnodepath)
 {
     //得到所选择帖子信息
     DataTable dt = Data.Topics.GetTopicList(tidlist, -1);
     Discuz.Common.Xml.XmlDocumentExtender doc = new Discuz.Common.Xml.XmlDocumentExtender();
     if (File.Exists(configPath))
         doc.Load(configPath);
     //清除以前选择
     XmlNode topiclistnode = doc.InitializeNode(topiclistnodepath);
     XmlNode websitetopiclistnode = doc.InitializeNode(websitetopiclistnodepath);
     foreach (string tid in tidlist.Split(','))
     {
         foreach (DataRow dr in dt.Rows)
         {
             if (dr["tid"].ToString().Trim() != tid)
                 continue;
             //创建Topic节点
             XmlElement topic = doc.CreateElement("Topic");
             doc.AppendChildElementByDataRow(ref topic, dt.Columns, dr, "");
             ForumInfo forumInfo = Forums.GetForumInfo(TypeConverter.ObjectToInt(dr["fid"]));
             if (forumInfo != null)
             {
                 doc.AppendChildElementByNameValue(ref topic, "forumname", forumInfo.Name);
                 doc.AppendChildElementByNameValue(ref topic, "forumnamerewritename", forumInfo.Rewritename);
             }
             else
             {
                 doc.AppendChildElementByNameValue(ref topic, "forumname", "");
                 doc.AppendChildElementByNameValue(ref topic, "forumnamerewritename", "");
             };
             topiclistnode.AppendChild(topic);
             break;
         }
     }
     string selecttidlist = DNTRequest.GetString("tid");
     foreach (XmlNode node in topiclistnode)
     {
         if (("," + selecttidlist + ",").IndexOf("," + node.ChildNodes[0].InnerText + ",") >= 0)
             websitetopiclistnode.AppendChild(node.Clone());
     }
     doc.Save(configPath);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 根据主题ID列表取出主题帖子
        /// </summary>
        /// <param name="posttableid">分表ID</param>
        /// <param name="tidlist">主题ID列表</param>
        /// <returns></returns>
        public static void WriteAggregationPostData(PostInfo[] posts, string tablelist, string tidlist, string configPath)
        {
            //得到所选择帖子信息
            DataTable dt = Data.Posts.GetTopicListByTidlist(tablelist, tidlist);
            Discuz.Common.Xml.XmlDocumentExtender doc = new Discuz.Common.Xml.XmlDocumentExtender();
            doc.Load(configPath);
            //清除以前选择
            XmlNode topiclistnode = doc.InitializeNode("/Aggregationinfo/Aggregationdata/Websiteaggregationdata/Topiclist");
            XmlNode websitetopiclistnode = doc.InitializeNode("/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist");

            tidlist = DNTRequest.GetString("tid");
            foreach (DataRow dr in dt.Rows)
            {
                PostInfo newpost = null;
                foreach (PostInfo post in posts)
                {
                    if (post.Tid.ToString() == dr["tid"].ToString())
                        newpost = post;
                }
                //创建Topic节点
                XmlElement topic = doc.CreateElement("Topic");
                doc.AppendChildElementByDataRow(ref topic, dt.Columns, dr, "tid,message");
                doc.AppendChildElementByNameValue(ref topic, "topicid", dr["tid"].ToString());
                string tempubbstr = UBB.ClearUBB(dr["message"].ToString());
                if (tempubbstr.Length > 200)
                    tempubbstr = tempubbstr.Substring(0, 200) + "...";

                if (newpost != null)
                    tempubbstr = newpost.Message;

                doc.AppendChildElementByNameValue(ref topic, "shortdescription", tempubbstr, true);
                doc.AppendChildElementByNameValue(ref topic, "fulldescription", UBB.ClearUBB(dr["message"].ToString()), true);
                topiclistnode.AppendChild(topic);

                if (("," + tidlist + ",").IndexOf("," + dr["tid"].ToString() + ",") >= 0)
                    websitetopiclistnode.AppendChild(topic.Clone());
            }
            doc.Save(configPath);
        }