/// <summary> /// 获取最新更新的书籍 Metro风格 /// </summary> /// <param name="top"></param> /// <returns></returns> public string getnoveltopmetroupdate(string top) { int i_top = top.ToInt32(); List <Book> bs = BookView.GetModelList("Enable=1 order by UpdateTime desc", i_top); StringBuilder sb = new StringBuilder(); int i = 1; foreach (Book b in bs) { Class c = BookView.GetClass(b); sb.AppendLine(string.Format("<li style=\" background-color:{0};\"><div class=\"item\"><h1><a href=\"{1}\">" + i + ".{2}</a></h1><div><div class=\"lastchapter\"><a href=\"{5}\">{6}</a></div></div></div><div class=\"item\"><h1><a href=\"{1}\">阅读书籍</a></h1><div><div class=\"lastchapter\"><a href=\"{5}\" title=\"{6}\">阅读最新章节</a></div><div class=\"class\">分类:<a href=\"{3}\">{4}</a></div><div class=\"author\">作者:{8}</div><div class=\"time\">更新时间:{9}</div></div></div></li>", BasePage.RandomBGColor(), BasePage.GetBookUrl(b, c), b.Title, BasePage.GetClassUrl(c), b.ClassName, BasePage.GetBookChapterUrl(BookChapterView.GetModelByID(b.LastChapterID.ToS()), c), b.LastChapterTitle, b.LastChapterTitle.CutString(12), b.Author, b.UpdateTime.ToString("MM-dd HH:mm") )); i++; } return(sb.ToS()); }
protected void Page_Load(object sender, EventArgs e) { var chapters = BookChapterView.GetModelList("enable=1 order by UpdateTime desc", 500); var items = new List <Voodoo.other.SEO.RssItem>(); foreach (var chapter in chapters) { items.Add(new Voodoo.other.SEO.RssItem() { Title = chapter.BookTitle + "-" + chapter.Title, PutTime = chapter.UpdateTime, Link = SystemSetting.SiteUrl + GetBookChapterUrl(chapter, BookView.GetClass(chapter)), Description = chapter.BookTitle + "Update to chapter:" + chapter.Title + ", from chanel" + chapter.ClassName }); } var movies = MovieInfoView.GetModelList(); foreach (var m in movies) { items.Add(new Voodoo.other.SEO.RssItem() { Title = m.Title, PutTime = m.UpdateTime, Link = SystemSetting.SiteUrl + GetMovieUrl(m, MovieInfoView.GetClass(m)),// GetBookChapterUrl(chapter, BookView.GetClass(chapter)), Description = m.Title + "Update to :" + m.LastDramaTitle + ", from chanel" + m.ClassName + ", Intro:" + m.Intro }); } Response.Clear(); Voodoo.other.SEO.Rss.GetRss(items, SystemSetting.SiteName, SystemSetting.SiteUrl, SystemSetting.Description, SystemSetting.Copyright); }
protected void BindList() { var cpl = BookChapterView.GetModelList(string.Format("BookId={0}", id)); rp_List.DataSource = cpl; rp_List.DataBind(); }
/// <summary> /// 获取章节 /// </summary> /// <param name="BookTitle">书籍标题</param> /// <param name="ChapterTitle">章节标题</param> protected void GetChapter(string BookTitle, string ChapterTitle) { BookChapter c = BookChapterView.Find(string.Format("BookTitle=N'{0}' and Title=N'{1}'", BookTitle, ChapterTitle)); Response.Clear(); Response.Write(XML.Serialize(c)); }
/// <summary> /// 搜索章节 /// </summary> /// <param name="BookTitle">书籍标题</param> /// <param name="ChapterTitle">章节标题</param> /// <param name="IsImagechapter">是否图片章节</param> protected void ChapterSearch(string BookTitle, string ChapterTitle, bool IsImagechapter) { var cs = BookChapterView.GetModelList(string.Format("BookTitle like N'%{0}%' and Title like N'%{1}%' and IsImageChapter={2}", BookTitle, ChapterTitle, IsImagechapter.BoolToShort())); Response.Clear(); Response.Write(XML.Serialize(cs)); }
/// <summary> /// 生成章节 /// </summary> /// <param name="bookid">书籍ID</param> protected void CreateChapters(long chapterid) { try { var chapter = BookChapterView.GetModelByID(chapterid.ToS()); var book = BookView.GetModelByID(chapter.BookID.ToS()); var cls = BookView.GetClass(book); var pre = BasePage.GetPreChapter(chapter, book); Voodoo.Basement.CreatePage.CreateBookChapterPage(chapter, book, cls); if (pre != null && pre.ID > 0) { Voodoo.Basement.CreatePage.CreateBookChapterPage(pre, book, cls); } //var chapters = BookChapterView.GetModelList(string.Format("bookid={0}", bookid)); //foreach (var c in chapters) //{ // Voodoo.Basement.CreatePage.CreateBookChapterPage(c, BookView.GetBook(c), BookView.GetClass(c)); //} Response.Clear(); Response.Write(XML.Serialize(true)); } catch (System.Exception e) { Response.Clear(); Response.Write(XML.Serialize(false)); } }
/// <summary> /// 删除章节 /// </summary> /// <param name="id">章节ID</param> protected void ChapterDelete(long id) { try { var c = BookChapterView.GetModelByID(id.ToS()); var b = BookView.GetModelByID(c.BookID.ToS()); Class cls = BookView.GetClass(b); Voodoo.IO.File.Delete(Server.MapPath(BasePage.GetBookChapterTxtUrl(c, cls))); BookChapterView.DelByID(id); var lastChapter = BookChapterView.Find("BookId={0} order by ChapterIndex,id desc"); b.UpdateTime = lastChapter.UpdateTime; b.LastChapterID = lastChapter.ID; b.LastChapterTitle = lastChapter.Title; BookView.Update(b); Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(true)); } catch (System.Exception e) { Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(false)); } }
protected void GetReadHistory() { string chapters = ""; if (Voodoo.Cookies.Cookies.GetCookie("history") != null) { chapters = Voodoo.Cookies.Cookies.GetCookie("history").Value; } string[] cs = chapters.Split(','); List <Cook> cookie = new List <Cook>(); string ids = ""; foreach (string chapter in cs) { string[] Arr_chapter = chapter.Split('|'); cookie.Add(new Cook() { id = Arr_chapter[0].ToInt64(), time = Arr_chapter[1].ToDateTime() }); ids += Arr_chapter[0] + ","; } ids = ids.TrimEnd(','); ReadingChapters = BookChapterView.GetModelList(string.Format("id in({0})", ids)); }
/// <summary> /// 获取最新更新的书籍 /// </summary> /// <param name="top"></param> /// <returns></returns> public string getnoveltopupdate(string top) { int i_top = top.ToInt32(); List <Book> bs = BookView.GetModelList("Enable=1 order by UpdateTime desc", i_top); StringBuilder sb = new StringBuilder(); //foreach (Book b in bs) for (int i = 0; i < bs.Count; i++) { Book b = bs[i]; Class c = BookView.GetClass(b); string str_style = ""; if (i % 2 == 0) { str_style = " style=\"background-color: #f5f5f5\""; } sb.AppendLine(string.Format("<tr" + str_style + "><td>[<a target=\"_blank\" href=\"{0}\" class=\"sort\">{1}</a>]</td><td><a class=\"name\" target=\"_blank\" href=\"{2}\">{3}</a> <a target=\"_blank\" href=\"{4}\" class=\"chapter\">{5}</a></td><td><a target=\"_blank\" href=\"/Search.aspx?m=4&key={6}\" class=\"author\">{6}</a></td><td style=\"color: #666666\">{7}</td></tr>", BasePage.GetClassUrl(c), b.ClassName, BasePage.GetBookUrl(b, c), b.Title, BasePage.GetBookChapterUrl(BookChapterView.GetModelByID(b.LastChapterID.ToS()), c), b.LastChapterTitle, b.Author, b.UpdateTime.ToString("MM-dd HH:mm") )); } return(sb.ToS()); }
protected void Page_Load(object sender, EventArgs e) { int id = WS.RequestInt("id"); BookChapter c = BookChapterView.GetModelByID(id.ToS()); Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(c)); }
protected void CreateChapters(int bookid) { var chapters = BookChapterView.GetModelList(string.Format("bookid={0}", bookid)); foreach (var c in chapters) { Voodoo.Basement.CreatePage.CreateBookChapterPage(c, BookView.GetBook(c), BookView.GetClass(c)); } }
protected void Page_Load(object sender, EventArgs e) { try { string chapters = ""; if (Voodoo.Cookies.Cookies.GetCookie("history") != null) { chapters = Voodoo.Cookies.Cookies.GetCookie("history").Value; } string[] cs = chapters.Split(','); List <Cook> cookie = new List <Cook>(); string ids = ""; foreach (string chapter in cs) { string[] Arr_chapter = chapter.Split('|'); cookie.Add(new Cook() { id = Arr_chapter[0].ToInt64(), time = Arr_chapter[1].ToDateTime() }); ids += Arr_chapter[0] + ","; } ids = ids.TrimEnd(','); List <BookChapter> list_chapter = BookChapterView.GetModelList(string.Format("id in({0})", ids)); StringBuilder sb = new StringBuilder(); sb.Append("document.write('"); foreach (BookChapter bc in list_chapter) { Book b = BookView.GetModelByID(bc.BookID.ToString()); Class c = ClassView.GetModelByID(bc.ClassID.ToString()); BookChapter new_Chapter = BookChapterView.GetModelByID(b.LastChapterID.ToString()); sb.Append(string.Format("<a href=\"{0}\">{1}</a>(<a href=\"{2}\">{3}</a>) 最新:<a href=\"{4}\">{5}</a><br />", BasePage.GetBookUrl(b, c), bc.BookTitle, BasePage.GetBookChapterUrl(bc, c), bc.Title, BasePage.GetBookChapterUrl(new_Chapter, c), b.LastChapterTitle )); } sb.Append("');"); Response.Clear(); Response.Write(sb.ToS()); }// end try catch { Voodoo.Cookies.Cookies.Remove("history"); } }
/// <summary> /// 获取章节内容 /// </summary> /// <param name="chapterID">章节id</param> protected void GetChapterContent(long chapterID) { BookChapter chapter = BookChapterView.GetModelByID(chapterID.ToS()); string path = BasePage.GetBookChapterTxtUrl(chapter, BookView.GetClass(chapter)); string content = Voodoo.IO.File.Read(Server.MapPath(path)); Response.Clear(); Response.Write(XML.Serialize(content)); }
protected void ChapterError(string ChapterID) { BookChapter chapter = BookChapterView.GetModelByID(ChapterID); chapter.IsTemp = true; chapter.IsImageChapter = true; BookChapterView.Update(chapter); Response.Clear(); Response.Write(chapter.ToJsonStr()); }
public void ChapterUpdate(BookChapter chapter, string Content) { BookChapterView.Update(chapter); ///保存文件 Class cls = BookView.GetClass(chapter); string txtPath = AppDomain.CurrentDomain.BaseDirectory + BasePage.GetBookChapterTxtUrl(chapter, cls).Replace("/", "\\"); Voodoo.IO.File.Write(txtPath, Content); //生成页面 Voodoo.Basement.CreatePage.CreateBookChapterPage(chapter, BookView.GetModelByID(chapter.BookID.ToString()), cls); }
public void ChapterInsert(BookChapter chapter, string Content) { BookChapterView.Insert(chapter); ///保存文件 Class cls = BookView.GetClass(chapter); string txtPath = HttpContext.Current.Server.MapPath(BasePage.GetBookChapterTxtUrl(chapter, cls)); Voodoo.IO.File.Write(txtPath, Content); //生成页面 Voodoo.Basement.CreatePage.CreateBookChapterPage(chapter, BookView.GetModelByID(chapter.BookID.ToString()), cls); }
/// <summary> /// 获取下一章节 /// </summary> /// <param name="cp"></param> /// <param name="b"></param> /// <returns></returns> public static BookChapter GetNextChapter(BookChapter cp, Book b) { List <BookChapter> lresult = BookChapterView.GetModelList(string.Format("BookID={0} and ID>{1} order by ID Asc", b.ID, cp.ID), 1); if (lresult.Count == 0) { return(null); } else { return(lresult.First()); } }
/// <summary> /// 设置阅读记录 /// </summary> /// <param name="id"></param> protected void ProcessHistory(long id) { try { long chapterid = id; BookChapter bc = BookChapterView.GetModelByID(chapterid.ToS()); bc.ClickCount = bc.ClickCount > 0 ? bc.ClickCount + 1 : 1; BookChapterView.Update(bc); //写入Cookie List <Cook> cookies = new List <Cook>(); if (Voodoo.Cookies.Cookies.GetCookie("history") != null) { string[] chapters = Voodoo.Cookies.Cookies.GetCookie("history").Value.Split(','); foreach (string chapter in chapters) { string[] arr_chapter = chapter.Split('|'); cookies.Add(new Cook() { id = arr_chapter[0].ToInt64(), time = arr_chapter[1].ToDateTime(), bookid = arr_chapter[2].ToInt32() }); } } cookies = cookies.Where(p => p.bookid != bc.BookID).OrderByDescending(p => p.time).Take(4).ToList(); cookies.Add(new Cook() { id = chapterid, time = DateTime.Now, bookid = bc.BookID }); StringBuilder sb = new StringBuilder(); foreach (Cook c in cookies) { sb.Append(string.Format("{0}|{1}|{2},", c.id, c.time.ToString(), c.bookid.ToS())); } sb = sb.TrimEnd(','); HttpCookie _cookie = new HttpCookie("history", sb.ToString()); _cookie.Expires = DateTime.Now.AddYears(1); Voodoo.Cookies.Cookies.SetCookie(_cookie); }//end try catch { Voodoo.Cookies.Cookies.Remove("history"); } }
/// <summary> /// 生成章节 /// </summary> /// <param name="id"></param> protected void CreateChapter(long id) { BookChapter cp = BookChapterView.GetModelByID(id.ToS()); if (cp.ID > 0) { Class c = BookView.GetClass(cp); Book b = BookView.GetModelByID(cp.BookID.ToS()); Voodoo.Basement.CreatePage.CreateBookChapterPage(cp, b, c); Response.Write(string.Format("书籍《{0}》-章节《{1}》完成", cp.BookTitle, cp.Title)); } else { Response.Write("不存在"); } }
/// <summary> /// 编辑章节 /// </summary> /// <param name="ChapterID">章节ID</param> /// <param name="Title">标题</param> /// <param name="Content">内容</param> /// <param name="IsImageChapter">是否图片章节</param> protected void ChapterEdit(long ChapterID, string Title, string Content, bool IsImageChapter, bool IsTemp = false) { var chapter = BookChapterView.GetModelByID(ChapterID.ToS()); var cls = ClassView.GetModelByID(chapter.ClassID.ToS()); chapter.Title = Title.IsNull(chapter.Title); chapter.IsImageChapter = IsImageChapter; chapter.IsTemp = IsTemp; BookChapterView.Update(chapter); if (!Content.IsNullOrEmpty()) { Voodoo.IO.File.Write(Server.MapPath(BasePage.GetBookChapterTxtUrl(chapter, cls)), Content); } Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(chapter)); }
/// <summary> /// 生成站点地图 /// </summary> protected void CreateSitemap() { Voodoo.other.SEO.SiteMap sm = new Voodoo.other.SEO.SiteMap(); sm.url = new List <PageInfo>(); sm.url.Add(new PageInfo() { changefreq = "always", lastmod = DateTime.Now, loc = Voodoo.Basement.BasePage.SystemSetting.SiteUrl, priority = "1.0" }); List <Voodoo.Model.Book> bs = BookView.GetModelList("id>0 order by UpdateTime desc", 100); foreach (Voodoo.Model.Book b in bs) { sm.url.Add(new PageInfo() { changefreq = "daily", lastmod = b.UpdateTime, loc = (Voodoo.Basement.BasePage.SystemSetting.SiteUrl + BasePage.GetBookUrl(b, BookView.GetClass(b))).Replace("//Book/", "/Book/"), priority = "0.8" }); } List <BookChapter> bcs = BookChapterView.GetModelList("id>0 order by UpdateTime desc", 500); foreach (BookChapter bc in bcs) { sm.url.Add(new PageInfo() { changefreq = "monthly", lastmod = bc.UpdateTime, loc = (Voodoo.Basement.BasePage.SystemSetting.SiteUrl + BasePage.GetBookChapterUrl(bc, BookView.GetClass(bc))).Replace("//Book/", "/Book/"), priority = "0.7" }); } try { sm.SaveSiteMap(Server.MapPath("~/sitemapxml/index.xml")); Response.Clear(); Response.Write(XML.Serialize(true)); } catch { Response.Clear(); Response.Write(XML.Serialize(false)); } }
protected void GetBook(int id) { if (id > 0) { b = BookView.GetModelByID(id.ToS()); } else { b = BookView.Find("id>0 order by id desc"); } b.ClickCount++; BookView.Update(b); cls = BookView.GetClass(b); cs = BookChapterView.GetModelList(string.Format("bookid={0} order by ChapterIndex,id desc", b.ID)); }
public void ChapterDelete(string str_sql) { //删除文件 var chapters = BookChapterView.GetModelList(str_sql); foreach (var chapter in chapters) { string htmlPath = HttpContext.Current.Server.MapPath(BasePage.GetBookChapterUrl(chapter, BookView.GetClass(chapter))); string txtPath = HttpContext.Current.Server.MapPath(BasePage.GetBookChapterTxtUrl(chapter, BookView.GetClass(chapter))); Voodoo.IO.File.Delete(htmlPath); Voodoo.IO.File.Delete(txtPath); } BookChapterView.Del(str_sql); }
protected void Button1_Click(object sender, EventArgs e) { string ids = WS.RequestString("id"); #region 除目录 List <Voodoo.Model.Book> books = BookView.GetModelList(string.Format("id in ({0})", ids)); foreach (var book in books) { BookChapter firstChapter = BookChapterView.Find(string.Format("BookID={0}", book.ID.ToS())); DirectoryInfo dir = new FileInfo( Server.MapPath( GetBookUrl( book, BookView.GetClass(book) ) ) ).Directory; if (dir.Exists) { dir.Delete(true); } DirectoryInfo dirTxt = new FileInfo( Server.MapPath( GetBookChapterTxtUrl(firstChapter, BookView.GetClass(book)) ) ).Directory; if (dirTxt.Exists) { dirTxt.Delete(true); } } #endregion 除目录 GetHelper().ExecuteNonQuery(CommandType.Text, string.Format("delete from Book where id in({0}); delete from BookChapter where BookId in({0})", ids)); if (cls > 0) { CreatePage.CreateListPage(ClassView.GetModelByID(cls.ToS()), 1); } CreatePage.GreateIndexPage(); Js.AlertAndChangUrl("删除成功!", url); }
protected void btn_Save_Click(object sender, EventArgs e) { var chapter = BookChapterView.GetModelByID(id.ToS()); chapter.Title = txt_Title.Text; chapter.IsVipChapter = chk_IsVip.Checked; chapter.Enable = chk_IsEnable.Checked; chapter.IsTemp = chk_IsTemp.Checked; chapter.IsFree = chk_IsFree.Checked; chapter.IsImageChapter = chk_IsImageChapter.Checked; if (id > 0) { BookChapterView.Update(chapter); } else { Voodoo.Model.Book book = BookView.GetModelByID(bookid.ToS()); chapter.BookID = book.ID; chapter.BookTitle = book.Title; chapter.ClassID = book.ClassID; chapter.ClassName = book.ClassName; chapter.UpdateTime = DateTime.UtcNow.AddHours(8); BookChapterView.Insert(chapter); //update Book's Last chapter book.LastChapterID = chapter.ID; book.LastChapterTitle = chapter.Title; book.UpdateTime = chapter.UpdateTime; BookView.Update(book); //如果是添加,则同时生成书籍信息页面 CreatePage.CreateContentPage(book, BookView.GetClass(book)); } Voodoo.IO.File.Write( Server.MapPath(GetBookChapterTxtUrl(chapter, BookView.GetClass(chapter))), txt_Content.Text); //生成章节页面 CreatePage.CreateBookChapterPage(chapter, BookView.GetModelByID(chapter.BookID.ToS()), BookView.GetClass(chapter)); Response.Redirect(string.Format("ChapterList.aspx?bookid={0}", chapter.BookID)); }
protected void SaveContent(long ChapterID, string Content) { BookChapter chapter = BookChapterView.GetModelByID(ChapterID.ToS()); Book book = BookView.GetModelByID(chapter.BookID.ToS()); Class cls = ClassView.GetModelByID(chapter.ClassID.ToS()); string txtPath = GetBookChapterTxtUrl(chapter, cls); chapter.IsImageChapter = false; chapter.IsTemp = false; BookChapterView.Update(chapter); Voodoo.IO.File.Write(Server.MapPath(txtPath), Content); CreatePage.CreateBookChapterPage(chapter, book, cls); Response.Clear(); Response.Write("true"); }
protected void GetChapter(long id) { if (id > 0) { c = BookChapterView.GetModelByID(id.ToS()); } else { c = BookChapterView.Find("id>0 order by id"); } b = BookView.GetModelByID(c.BookID.ToS()); cls = BookView.GetClass(b); Content = Voodoo.IO.File.Read(Server.MapPath(Voodoo.Basement.BasePage.GetBookChapterTxtUrl(c, cls))); pre = Voodoo.Basement.BasePage.GetPreChapter(c, b); next = Voodoo.Basement.BasePage.GetNextChapter(c, b); }
protected void btn_createPage_Click(object sender, EventArgs e) { string[] ids = WS.RequestString("id").Split(','); foreach (string id in ids) { Voodoo.Model.Book b = BookView.GetModelByID(id); Voodoo.Basement.CreatePage.CreateContentPage(b, BookView.GetClass(b)); var chapters = BookChapterView.GetModelList(string.Format("bookid={0}", b.ID)); foreach (var c in chapters) { Voodoo.Basement.CreatePage.CreateBookChapterPage(c, BookView.GetBook(c), BookView.GetClass(c)); } } CreatePage.GreateIndexPage(); Js.Jump(url); }
protected void CreateTxt(int Bookid) { Book b = BookView.GetModelByID(Bookid.ToS()); Class cls = BookView.GetClass(b); var cs = BookChapterView.GetModelList(string.Format("bookid={0} order by ChapterIndex,id", b.ID)); StringBuilder sb = new StringBuilder(); foreach (var c in cs) { sb.AppendLine(c.Title); sb.AppendLine(Voodoo.IO.File.Read(Server.MapPath(BasePage.GetBookChapterTxtUrl(c, cls)), Voodoo.IO.File.EnCode.UTF8).TrimHTML()); } HttpContext.Current.Response.ContentType = "application/text"; HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.txt", b.Title)); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.BinaryWrite(sb.ToS().ToByteArray(Encoding.UTF8)); HttpContext.Current.Response.End(); }
protected void btn_Chapter_Click(object sender, EventArgs e) { Response.Buffer = false; var chapters = BookChapterView.GetModelList(); foreach (var c in chapters) { try { Response.Write(string.Format("正在生成章节:{0}<br/>", c.Title)); CreatePage.CreateBookChapterPage(c, BookView.GetBook(c), BookView.GetClass(c)); Js.ScrollEndStart(); } catch (Exception ex) { Response.Write(string.Format("{0}<br/>", ex.Message)); } } Js.AlertAndGoback("成功!"); }