Exemplo n.º 1
0
        private void getNewChapter(object sender, System.EventArgs e)
        {
            lock (lockObj) {
                //获取更新的书籍信息
                List <Book> bookList = ReadXml.GetBooksData();

                //遍历每一本书籍
                foreach (Book book in bookList)
                {
                    //起点最新章节
                    Chapter newChapter = getCatalog(book.Id);

                    //本地存储的最新章节
                    Chapter latestChapter = readLatestChapter(book.Code);

                    //如果起点的最新章节发布时间要大于本地的最新章节发布时间,说明已更新
                    if (latestChapter == null || DateTime.Parse(newChapter.ChapterTime) > DateTime.Parse(latestChapter.ChapterTime))
                    {
                        foreach (Group g in book.Group)
                        {
                            CQApi.SendGroupMessage(long.Parse(g.GroupNo), (g.IsAtAll ? CQApi.CQCode_AtAll().ToSendString() + "\n" : string.Empty) + (g.IsSendImage ? CQApi.CQCode_Image(g.ImageName).ToSendString() + "\n" : string.Empty) + "最新章节:\"" + newChapter.ChapterName + "\" \n发布时间:" + newChapter.ChapterTime + " \n本章字数:" + newChapter.WordNumber);
                        }
                        //把最新章节信息写入本地
                        writeLatestChapter(newChapter, book.Code);
                    }

                    //本次获取的最新章节名称
                    LogHelper.WriteMsgInLog("书名:" + book.Name + ",章节名称:" + newChapter.ChapterName, book.Code);
                }
            }
        }