public void GetNovelChaptersByThread(NovelInfo novel) { _currentNovel = novel; _threadMain = new Thread(new System.Threading.ThreadStart(GetNovelChapters)); _threadMain.IsBackground = true; _threadMain.Start(); }
private void GetNovelList() { TryCatchBlock th = new TryCatchBlock(delegate { _module = Constants.MODULE_NOVELLIST; SetMessage("刷新小说列表...", true); Collection<NovelInfo> novels = new Collection<NovelInfo>(); string originaltext = HH.Get(_categoryurl); if (string.IsNullOrEmpty(originaltext)) { LogHelper.Write("GetNovelListByCategory()" + _categoryurl, "Empty http response!!!", LogSeverity.Warn); return; } string content = originaltext; content = StringHelper.GetMid(content, "<table width=950px>", "<div align=\"center\">"); if (content != null) { int num; for (string info = StringHelper.GetMid(content, "<tr>", "</tr>", out num); info != null; info = StringHelper.GetMid(content, "<tr>", "</tr>", out num)) { content = content.Substring(num); NovelInfo novel = new NovelInfo(); novel.Name = StringHelper.GetMid(info, "style=\"font-size:14px\">", "</font>"); novel.ChapterUrl = StringHelper.GetMid(info, "<A href=\"", "\" target=_blank"); novel.Id = ParseNovelId(novel.ChapterUrl); if (info.Contains(" 待续")) novel.State = PublishStatus.ToBeContinued; else if (info.Contains(" 全文完")) novel.State = PublishStatus.Finished; novel.Author = StringHelper.GetMid(info, "<td width=20% class=Hot><A title=", " href=\"search.asp?"); if (!String.IsNullOrEmpty(novel.Name) && !String.IsNullOrEmpty(novel.ChapterUrl)) novels.Add(novel); } } PagingInfo paging = new PagingInfo(); content = StringHelper.GetMid(originaltext, "<tr><td colspan=4 align=right", "页</td></tr>"); if (!String.IsNullOrEmpty(content)) { paging.Required = true; paging.Total = StringHelper.GetMidInteger(originaltext, " / ", " 页 "); paging.Current = StringHelper.GetMidInteger(originaltext, "第 ", " / "); paging.Category = StringHelper.GetMidInteger(originaltext, "window.location='", "_'+this.value+'"); } SetMessage("小说列表获取成功!", true); if (NovelListFetched != null) NovelListFetched(novels, paging); }); base.ExecuteTryCatchBlock(th, "发生异常,获取小说列表失败!"); }
private void lstNovels_SelectedIndexChanged(object sender, EventArgs e) { try { foreach (ListViewItem item in lstNovels.SelectedItems) { StartLoading(); _currentNovel = item.Tag as NovelInfo; panelChapters.Text = _currentNovel.Name; _requestHandler.GetNovelChaptersByThread(_currentNovel); break; } } catch (Exception ex) { Program.ShowMessageBox("MainForm.lstNovels_SelectedIndexChanged", ex); StopLoading(); } }