Example #1
0
        //用于初始化数据库,在项目最开始使用
        public async static void initTheDataBase()
        {
            string[] tag = { "小说同人", "动漫同人", "影视同人", "游戏同人", "耽美同人" };
            for (int i = 3; i < 5; i++)
            {
                for (int page = 0; page < 1; page++)
                {
                    string      Catalog      = "同人";
                    string      Tags         = tag[i];
                    string      compatibeMen = "female";
                    string      start        = (page * 50).ToString();
                    BooksObject myNewBook    = await GetNewBooks.GetNewBook("hot", Catalog, Tags, start, "15", compatibeMen);

                    for (int bookcount = 0; bookcount < 10; bookcount++)
                    {
                        string           bookid       = myNewBook.books[bookcount]._id;
                        BookDetailObject myBookDetail = await BookDetail.GetBookDetail(bookid);

                        ChapterObject myChapter = await Chapter.GetChapter(bookid);

                        //string link = myChapter.mixToc.chapters[0].link;
                        string Title   = myNewBook.books[bookcount].title;
                        string Info    = myNewBook.books[bookcount].shortIntro;
                        string Image   = "http://statics.zhuishushenqi.com" + myNewBook.books[bookcount].cover;
                        string author  = myNewBook.books[bookcount].author;
                        string nowChac = "1";
                        BookDB.addToBookStore(Title, Catalog, Tags, Info, Image,
                                              bookid, author, compatibeMen, nowChac);
                    }
                }
            }
        }
Example #2
0
        //获取书籍相关信息
        public async static Task <BookDetailObject> GetBookDetail(string bookid)
        {
            BookDetailObject data = null;

            try
            {
                var    http     = new HttpClient();
                string url      = "http://api.zhuishushenqi.com/book/" + bookid;
                var    response = await http.GetAsync(url);

                var result = await response.Content.ReadAsStringAsync();

                var serializer = new DataContractJsonSerializer(typeof(BookDetailObject));

                var ms = new MemoryStream(Encoding.UTF8.GetBytes(result));
                data = (BookDetailObject)serializer.ReadObject(ms);
            }
            catch (Exception e)
            {
            }
            return(data);
        }