/// <summary> /// 替换整本书的图片章节 /// </summary> /// <param name="Title">标题</param> public void RepalceImageChapter(string Title) { status.Status = "正在从无错小说搜索书籍"; status.BookTitle = Title; Status_Chage(); var AllChapter = GetChapterTitleAndUrl(Title); status.Status = "正在检查本地图片章节"; Status_Chage(); var ChapterNeedCollect = chapterNeedCollect(Title); var c = from a in AllChapter from b in ChapterNeedCollect where a.Title == b.Title select new { SourceUrl = a.Url, a.Title, chapter = b }; foreach (var d in c) { status.Status = "采集章节"; status.ChapterTitle = d.Title; Status_Chage(); string content = GetContent(d.SourceUrl); ClientServices.ClientServiceClient csc = new ClientServices.ClientServiceClient(); status.Status = "保存"; Status_Chage(); var newchapter = d.chapter; newchapter.IsImageChapter = false; csc.ChapterUpdate(newchapter, content); status.ChapterTitle = ""; Status_Chage(); csc.Close(); } }
/// <summary> /// 处理整站书籍 /// </summary> public void Main() { ClientServices.ClientServiceClient csc = new ClientServices.ClientServiceClient(); var books = csc.BookSearch("id in(select distinct bookid from bookchapter where IsImageChapter=1) and id>464"); csc.Close(); foreach (var book in books) { RepalceImageChapter(book.Title); } }
/// <summary> /// 搜索需要替换的章节 /// </summary> /// <param name="BookTitle">书籍名称</param> /// <returns></returns> public List <BookChapter> chapterNeedCollect(string BookTitle) { ClientServices.ClientServiceClient cs = new ClientServices.ClientServiceClient(); try { return(cs.ChapterSearch(string.Format("BookTitle=N'{0}' and IsImageChapter=1", BookTitle)).ToList()); } catch { return(null); } finally { cs.Close(); } }