Esempio n. 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);
                    }
                }
            }
        }
Esempio n. 2
0
        public async static Task <BooksObject> GetNewBook(string type, string major, string tag, string start, string limit, string gender)
        {
            BooksObject data = null;

            try
            {
                var    http = new HttpClient();
                String url  = "http://api.zhuishushenqi.com/book/by-categories?gender=" + gender + "&type=" + type + "&major=" + major + "&minor=" + tag + "&start=" + start + "&limit=" + limit;

                var response = await http.GetAsync(url);

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

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

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