protected void btn_Save_Click(object sender, EventArgs e) { DataEntities ent = new DataEntities(); var chapters = (from l in ent.BookChapter where l.ID == id select l).ToList(); var chapter = new Voodoo.Basement.BookChapter(); if (chapters.Count > 0) { chapter = chapters.FirstOrDefault(); } 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 (chapters.Count== 0) { Voodoo.Basement.Book book = (from l in ent.Book where l.ID == bookid select l).FirstOrDefault(); chapter.BookID = book.ID; chapter.BookTitle = book.Title; chapter.ClassID = book.ClassID; chapter.ClassName = book.ClassName; chapter.UpdateTime = DateTime.UtcNow.AddHours(8); ent.AddToBookChapter(chapter); ent.SaveChanges(); book.LastChapterID = chapter.ID; book.LastChapterTitle = chapter.Title; book.UpdateTime = chapter.UpdateTime; if (SystemSetting.EnableStatic) { CreatePage.CreateContentPage(book, book.GetClass()); } } if (chapter.TxtPath.IsNullOrEmpty()) { chapter.TxtPath = BasePage.GetChapterTxtStorePath(chapter, chapter.GetBook()); } ent.SaveChanges(); ent.Dispose(); Voodoo.IO.File.Write( Server.MapPath(chapter.TxtPath), txt_Content.Text); //生成章节页面 if (SystemSetting.EnableStatic) { CreatePage.CreateBookChapterPage(chapter, chapter.GetBook(), chapter.GetClass()); } Response.Redirect(string.Format("ChapterList.aspx?bookid={0}",chapter.BookID)); }
protected void Button1_Click(object sender, EventArgs e) { var ids = WS.RequestString("id").Split(',').ToList(); DataEntities ent = new DataEntities(); #region 除目录 List <Voodoo.Basement.Book> books = (from l in ent.Book where ids.IndexOf(l.ID.ToString()) > 0 select l).ToList(); foreach (var book in books) { Voodoo.Basement.BookChapter firstChapter = (from l in ent.BookChapter where l.BookID == book.ID select l).FirstOrDefault(); DirectoryInfo dir = new FileInfo( Server.MapPath( GetBookUrl( book, book.GetClass() ) ) ).Directory; if (dir.Exists) { dir.Delete(true); } DirectoryInfo dirTxt = new FileInfo( Server.MapPath( GetBookChapterTxtUrl(firstChapter, book.GetClass()) ) ).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(ObjectExtents.Class(cls), 1); } CreatePage.GreateIndexPage(); Js.AlertAndChangUrl("删除成功!", url); }
protected void GetChapter(long id) { DataEntities ent = new DataEntities(); if (id > 0) { c = (from l in ent.BookChapter where l.ID == id select l).FirstOrDefault(); } else { c = (from l in ent.BookChapter orderby id select l).FirstOrDefault(); } b = (from l in ent.Book where l.ID==c.BookID select l).FirstOrDefault(); cls = b.GetClass(); 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); ent.Dispose(); }
protected void Page_Load(object sender, EventArgs e) { DataEntities ent = new DataEntities(); int BookID = WS.RequestInt("bookid"); string BookTitle = WS.RequestString("booktitle"); int ClassID = WS.RequestInt("classid"); string ClassName = WS.RequestString("classname"); string Content = WS.RequestString("content").HtmlDeCode(); string Title=WS.RequestString("title"); Class cls = ObjectExtents.Class(ClassID); BookChapter c = new BookChapter(); if (Title.Trim().Length == 0) { c.ID = -1; c.Title = "采集失败"; Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(c)); return; } if ((from l in ent.BookChapter where l.Title==Title && l.BookTitle ==BookTitle select l).Count()>0) { c.Title = "已经存在"; Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(c)); return; } c.BookID = BookID; c.BookTitle = BookTitle; c.ChapterIndex = 0; c.ClassID = ClassID; c.ClassName = ClassName; c.ClickCount = 0; //c.Content = Content; c.Enable = true; c.IsFree = true; c.IsImageChapter = false; c.IsTemp = false; c.IsVipChapter = false; c.TextLength = Content.TrimHTML().Length; c.Title = Title; c.UpdateTime = DateTime.Now; c.ValumeID = 0; ent.AddToBookChapter(c); //创建内容txt Voodoo.IO.File.Write(Server.MapPath(BasePage.GetBookChapterTxtUrl(c, cls)), Content); Book b = (from l in ent.Book where l.ID == BookID select l).FirstOrDefault(); b.LastChapterID = c.ID; b.LastChapterTitle = c.Title; b.UpdateTime = c.UpdateTime; ent.SaveChanges(); Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(c)); }
public string GetChapterText(BookChapter chapter) { return Voodoo.IO.File.Read(System.Web.HttpContext.Current.Server.MapPath(BasePage.GetBookChapterTxtUrl(chapter, chapter.GetClass()))); }
public void ChapterUpdate(BookChapter chapter, string Content) { using (DataEntities ent = new DataEntities()) { var cpt = (from l in ent.BookChapter where l.ID == chapter.ID select l).FirstOrDefault(); cpt = chapter; ent.SaveChanges(); } ///保存文件 Class cls = chapter.GetClass(); string txtPath = AppDomain.CurrentDomain.BaseDirectory + BasePage.GetBookChapterTxtUrl(chapter, cls).Replace("/", "\\"); Voodoo.IO.File.Write(txtPath, Content); //生成页面 Voodoo.Basement.CreatePage.CreateBookChapterPage(chapter, chapter.GetBook(), cls); }
public void ChapterInsert(BookChapter chapter, string Content) { DataEntities ent = new DataEntities(); ent.AddToBookChapter(chapter); ent.SaveChanges(); ent.Dispose(); ///保存文件 Class cls = chapter.GetClass(); ; string txtPath = HttpContext.Current.Server.MapPath(BasePage.GetBookChapterTxtUrl(chapter, cls)); Voodoo.IO.File.Write(txtPath, Content); //生成页面 Voodoo.Basement.CreatePage.CreateBookChapterPage(chapter,chapter.GetBook(), cls); }
/// <summary> /// 创建章节页面 /// </summary> /// <param name="cp"></param> /// <param name="b"></param> /// <param name="cls"></param> public string CreateBookChapterPage(BookChapter cp, Book b, Class cls) { string bookurl = BasePage.GetBookUrl(b, cls); string Content = GetTempateString(1, TempType.小说章节); Content = ReplacePublicTemplate(Content); Content = ReplacePublicTemplate(Content); Content = ReplacePublicTemplate(Content); Content = ReplaceSystemSetting(Content); string ChapterContent = Voodoo.IO.File.Read(System.Web.HttpContext.Current.Server.MapPath(BasePage.GetBookChapterTxtUrl(cp, cls))); ChapterContent = ChapterContent.Replace("<<", "<br />"); ChapterContent = ReplaceContentKey(ChapterContent);//伪原创 //如果章节正在处理中,则填入自定义内容 if (cp.IsTemp == true) { ChapterContent = string.Format("{0}的小说{1}最新章节-{2}正在处理中,请稍后访问阅读。同时推荐您阅读以下精品小说<ul id=\"ul_tjlist\">{3}</ul>,<br /><br />阅读{1}最新章节{2},尽在<a href=\"{4}\">{5}</a>", b.Author, b.Title, cp.Title, Functions.Getnovellist("Enable=1 order by clickcount desc", 10, 100, "<li><a href=\"{url}\" title=\"{title}\">{title}</a></li>"), BasePage.SystemSetting.SiteUrl, BasePage.SystemSetting.SiteName ); } PageAttribute pa = new PageAttribute() { Title = string.Format("{0}-{1}-{2}", b.Title, cp.Title, b.Author), UpdateTime = DateTime.Now.ToString(), Description = ChapterContent.TrimHTML().Replace("\n", "").CutString(100), Keyword = string.Format("{0},{1}最新章节,{1}txt下载,{1}在线阅读", cp.Title, b.Title) }; Content = ReplacePageAttribute(Content, pa); #region 替换内容 //替换栏目 Content = Content.Replace("[!--class.id--]", cls.ID.ToString()); Content = Content.Replace("[!--class.name--]", cls.ClassName); Content = Content.Replace("[!--class.url--]", BasePage.GetClassUrl(cls)); Content = Content.Replace("[!--book.url--]", bookurl); //替换书籍信息 Content = ReplaceContent(Content, b, cls); //替换章节信息 Content = Content.Replace("[!--chapter.id--]", cp.ID.ToS()); Content = Content.Replace("[!--chapter.bookid--]", cp.BookID.ToS()); Content = Content.Replace("[!--chapter.booktitle--]", cp.BookTitle); Content = Content.Replace("[!--chapter.classid--]", cp.ClassID.ToS()); Content = Content.Replace("[!--chapter.classname--]", cp.ClassName); Content = Content.Replace("[!--chapter.valumeid--]", cp.ValumeID.ToS()); Content = Content.Replace("[!--chapter.valumename--]", cp.ValumeName); Content = Content.Replace("[!--chapter.title--]", cp.Title); Content = Content.Replace("[!--chapter.isvipchapter--]", cp.IsVipChapter.ToBoolean().ToChinese()); Content = Content.Replace("[!--chapter.textlength--]", cp.TextLength.ToS()); Content = Content.Replace("[!--chapter.updatetime--]", cp.UpdateTime.ToS()); Content = Content.Replace("[!--chapter.enable--]", cp.Enable.ToBoolean().ToChinese()); Content = Content.Replace("[!--chapter.istemp--]", cp.IsTemp.ToBoolean().ToChinese()); Content = Content.Replace("[!--chapter.isfree--]", cp.IsFree.ToBoolean().ToChinese()); Content = Content.Replace("[!--chapter.chapterindex--]", cp.ChapterIndex.ToS()); Content = Content.Replace("[!--chapter.isimagechapter--]", cp.IsImageChapter.ToBoolean().ToChinese()); Content = Content.Replace("[!--chapter.content--]", ChapterContent); Content = Content.Replace("[!--chapter.clickcount--]", cp.ClickCount.ToS()); #endregion Content = ReplaceTagContent(Content); #region 上一篇 下一篇 链接 BookChapter news_pre = BasePage.GetPreChapter(cp, b); BookChapter news_next = BasePage.GetNextChapter(cp, b); string preurl = news_pre == null ? bookurl : BasePage.GetBookChapterUrl(news_pre, cls); string nexturl = news_next == null ? bookurl : BasePage.GetBookChapterUrl(news_next, cls); Content = Content.Replace("[!--chapter.preurl--]", preurl); Content = Content.Replace("[!--chapter.nexturl--]", nexturl); Content = Content.Replace("[!--chapter.pretitle--]", news_pre == null ? b.Title : news_pre.Title); Content = Content.Replace("[!--chapter.nexttitle--]", news_next == null ? b.Title : news_next.Title); //上一篇 string pre_link = "<a href=\"#\">上章:没有了</a>"; if (news_pre != null) { pre_link = string.Format("<a id=\"btn_pre\" href=\"{0}\" title=\"{1}\">上章:{2}</a>", nexturl, news_pre.Title, news_pre.Title.CutString(20)); } Content = Content.Replace("[!--news.prelink--]", pre_link); //下一篇 string next_link = "<a href=\"#\">下章:没有了</a>"; if (news_next != null) { next_link = string.Format("<a id=\"btn_next\" href=\"{0}\" title=\"{1}\">下章:{2}</a>", nexturl, news_next.Title, news_next.Title.CutString(20)); } Content = Content.Replace("[!--news.nextlink--]", next_link); #endregion //替换导航条 Content = Content.Replace("[!--newsnav--]", BuildClassNavString(cls)); return Content; }
protected void btn_Save_Click(object sender, EventArgs e) { DataEntities ent = new DataEntities(); var chapters = (from l in ent.BookChapter where l.ID == id select l).ToList(); var chapter = new Voodoo.Basement.BookChapter(); if (chapters.Count > 0) { chapter = chapters.FirstOrDefault(); } 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 (chapters.Count == 0) { Voodoo.Basement.Book book = (from l in ent.Book where l.ID == bookid select l).FirstOrDefault(); chapter.BookID = book.ID; chapter.BookTitle = book.Title; chapter.ClassID = book.ClassID; chapter.ClassName = book.ClassName; chapter.UpdateTime = DateTime.UtcNow.AddHours(8); ent.AddToBookChapter(chapter); ent.SaveChanges(); book.LastChapterID = chapter.ID; book.LastChapterTitle = chapter.Title; book.UpdateTime = chapter.UpdateTime; if (SystemSetting.EnableStatic) { CreatePage.CreateContentPage(book, book.GetClass()); } } if (chapter.TxtPath.IsNullOrEmpty()) { chapter.TxtPath = BasePage.GetChapterTxtStorePath(chapter, chapter.GetBook()); } ent.SaveChanges(); ent.Dispose(); Voodoo.IO.File.Write( Server.MapPath(chapter.TxtPath), txt_Content.Text); //生成章节页面 if (SystemSetting.EnableStatic) { CreatePage.CreateBookChapterPage(chapter, chapter.GetBook(), chapter.GetClass()); } Response.Redirect(string.Format("ChapterList.aspx?bookid={0}", chapter.BookID)); }