Пример #1
0
 /// <summary>
 /// 根据json保存文章全文并下载图片
 /// </summary>
 /// <param name="json"></param>
 /// <returns></returns>
 public Article.Model.Article getModelFromJson(string json)
 {
     if ((!json.Contains("该稿件未审核")) || json == "")
     {
         JObject jsonObj = JObject.Parse(json);
         JObject data    = ((JObject)jsonObj["data"]);
         JObject tempo   = ((JObject)data["fullArticle"]);
         Article.Model.Article article = new Article.Model.Article();
         article.setChannelId(tempo["channelId"].ToString());
         article.setComments(tempo["comments"].ToString());
         article.setContentId(tempo["contentId"].ToString());
         article.setCover(tempo["cover"].ToString());
         article.setDescription(ReplaceHtmlTag(tempo["description"].ToString()));
         article.setIsArticle(tempo["isArticle"].ToString());
         article.setIsRecommend(tempo["isRecommend"].ToString());
         article.setReleaseDate(tempo["releaseDate"].ToString());
         article.setStows(tempo["stows"].ToString());
         article.setTitle(tempo["title"].ToString());
         article.setToplevel(tempo["toplevel"].ToString());
         article.setTxt(ReplaceHtmlTag(tempo["txt"].ToString()));
         JObject user = ((JObject)tempo["user"]);
         article.setUser(user["userId"].ToString());
         article.setViewOnly(tempo["viewOnly"].ToString());
         article.setViews(tempo["views"].ToString());
         SavePostImg(GetHtmlImageUrlList(tempo["txt"].ToString()), article.getContentId());
         getUserByArticle(json);
         return(article);
     }
     else
     {
         return(null);
     }
 }
Пример #2
0
 /// <summary>
 /// 构造数据源
 /// </summary>
 public AcfunDataSource()
 {
     for (int count = 1; count < 11; count++)
     {
         //页码
         dataCore.CreateGroup(" 第-" + count + "-页 ",
                              "Group Title: " + count,
                              "Group Subtitle: " + count,
                              typeof(MainForm).Namespace + ".Assets.DarkGray.png",
                              "哈哈哈哈哈哈哈哈哈哈");
         //数据库分页查10个
         string sql = "";
         dt = conn.ExecuteDataTable(sql);
         //循环写入
         for (int dtcount = 0; dtcount < dt.Rows.Count; dtcount++)
         {
             Article.Model.Article article = new Model.Article();
             article.setComments(dt.Rows[dtcount]["comments"].ToString());
             article.setTitle(dt.Rows[dtcount]["title"].ToString());
             article.setContentId(dt.Rows[dtcount]["contentId"].ToString());
             article.setDescription(dt.Rows[dtcount]["description"].ToString());
             article.setTxt(dt.Rows[dtcount]["txt"].ToString());
             dataCore.AddItem(new ArticleDataItem(article.getTitle(),
                                                  "  评论数:  " + article.getComments(),
                                                  typeof(MainForm).Namespace + ".Assets.LightGray.png",
                                                  "Description: " + article.getDescription(),
                                                  article.getTxt(),
                                                  " 第-" + count + "-页 ", article.getComments(), article.getContentId()));
         }
     }
 }
Пример #3
0
        /// <summary>
        /// 根据页码获取文章列表
        /// </summary>
        /// <param name="pageNo"></param>
        /// <returns></returns>
        public List <Article.Model.Article> getArticleList(int pageNo)
        {
            List <Article.Model.Article> articleList = new List <Model.Article>();
            WebUtil util = new WebUtil();
            //获取该页中所有的文章编号
            string articleNoList = util.GetArticleList(20, pageNo);

            if (articleNoList != "")
            {
                JObject jsonObj = JObject.Parse(articleNoList);
                string  list    = ((JObject)((JObject)jsonObj["data"])["page"])["list"].ToString();
                JArray  alist   = JArray.Parse(list);
                for (int i = 0; i < alist.Count; ++i)  //遍历JArray
                {
                    Article.Model.Article article = new Article.Model.Article();
                    JObject tempo = JObject.Parse(alist[i].ToString());
                    article.setChannelId(tempo["channelId"].ToString());
                    article.setComments(tempo["comments"].ToString());
                    article.setContentId(tempo["contentId"].ToString());
                    article.setCover(tempo["cover"].ToString());
                    article.setDescription(tempo["description"].ToString());
                    article.setIsArticle(tempo["isArticle"].ToString());
                    article.setIsRecommend(tempo["isRecommend"].ToString());
                    article.setReleaseDate(tempo["releaseDate"].ToString());
                    article.setStows(tempo["stows"].ToString());
                    article.setTitle(tempo["title"].ToString());
                    article.setToplevel(tempo["toplevel"].ToString());
                    article.setTxt(tempo["description"].ToString());
                    article.setUser(tempo["user"].ToString());
                    article.setViewOnly(tempo["viewOnly"].ToString());
                    article.setViews(tempo["views"].ToString());
                    getCommentByArticle(article);
                    articleList.Add(article);
                }
            }
            return(articleList);
        }