public Book BookInsert(Book book) { using (DataEntities ent = new DataEntities()) { ent.AddToBook(book); ent.SaveChanges(); return book; } }
public void BookUpdate(Book book) { using (DataEntities ent = new DataEntities()) { var b = (from l in ent.Book where l.ID == book.ID select l).FirstOrDefault(); b = book; ent.SaveChanges(); } }
protected void btn_Save_Click(object sender, EventArgs e) { DataEntities ent = new DataEntities(); var books = (from l in ent.Book where l.ID == id select l).ToList(); Voodoo.Basement.Book book = new Voodoo.Basement.Book(); if (books.Count > 0) { book = books.FirstOrDefault(); } book.Title = txt_Title.Text; book.Author = txt_Author.Text; book.ClassID = ddl_CLass.SelectedValue.ToInt32(); book.ClassName = ddl_CLass.SelectedItem.Text; book.ClickCount = txt_ClickCount.Text.ToInt32(); book.CorpusID = 0; book.CorpusTitle = ""; book.Enable = chk_Enable.Checked; //book.FaceImage= book.Intro = txt_Intro.Text; book.IsFirstPost = chk_IsFirstpost.Checked; book.IsVip = chk_IsVip.Checked; book.Length = txt_Length.Text.ToInt32(); book.ReplyCount = txt_Replycount.Text.ToInt32(); book.SaveCount = txt_SaveCount.Text.ToInt32(); book.Status = ddl_Status.SelectedValue.ToByte(); book.TjCount = txt_TjCount.Text.ToInt32(); book.ZtID = 0; book.ZtName = ""; if (books.Count == 0) { book.Addtime = DateTime.UtcNow.AddHours(8); book.UpdateTime = DateTime.UtcNow.AddHours(8); book.VipUpdateTime = DateTime.UtcNow.AddHours(8); ent.AddToBook(book); ent.SaveChanges(); } //Deal Book face image if (file_Bookfacefile.FileName.IsNullOrEmpty() == false) { file_Bookfacefile.SaveAs(Server.MapPath("/Book/BookFace/" + book.ID + ".jpg")); book.FaceImage = "/Book/BookFace/" + book.ID + ".jpg"; ent.SaveChanges(); } CreatePage.CreateContentPage(book, book.GetClass()); Response.Redirect("BookList.aspx?class=" + cls.ToS()); }
/// <summary> /// 添加书籍 /// </summary> /// <param name="Title">标题</param> /// <param name="Author">作者</param> /// <param name="ClassID">类别ID</param> /// <param name="Intro">简介</param> /// <param name="Length">长度</param> protected void BookAdd(string Title, string Author, int ClassID, string Intro, long Length) { string ClassName = ObjectExtents.Class(ClassID).ClassName; DataEntities ent=new DataEntities(); Book b = new Book(); if (Title.IsNullOrEmpty() && (from l in ent.Book where l.Title==Title && l.Author==Author select l).Count()>0) { b.ID = int.MinValue; Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(b)); return; } b.Addtime = DateTime.UtcNow.AddHours(8); b.Author = Author; b.ClassID = ClassID; b.ClassName = ClassName; b.ClickCount = 0; b.CorpusID = 0; b.Enable = true; b.FaceImage = ""; b.Intro = Intro; b.IsFirstPost = false; b.IsVip = false; b.LastChapterID = 0; b.LastVipChapterID = 0; b.Length = Length; b.ReplyCount = 0; b.SaveCount = 0; b.Status = 0;//连载中 b.Title = Title; b.UpdateTime = DateTime.UtcNow.AddHours(8); b.VipUpdateTime = DateTime.UtcNow.AddHours(8); b.ZtID = 0; var books = (from l in ent.Book where l.Title == Title && l.Author == Author select l).ToList(); if (books.Count == 0) { ent.AddToBook(b); ent.SaveChanges(); } else { b = books.FirstOrDefault(); } ent.Dispose(); Response.Clear(); Response.Write(Voodoo.IO.XML.Serialize(b)); }
protected void GetBook(int id) { DataEntities ent = new DataEntities(); if (id > 0) { b = (from l in ent.Book where l.ID == id select l).FirstOrDefault(); } else { b = (from l in ent.Book orderby l.ID descending select l).FirstOrDefault(); } b.ClickCount++; cls = b.GetClass(); cs = (from l in ent.BookChapter where l.BookID == id orderby l.ChapterIndex descending orderby l.ID descending select l).ToList(); ent.Dispose(); }
protected void GetBookInfo() { int id = WS.RequestInt("id"); using (DataEntities ent = new DataEntities()) { var bs = from l in ent.Book where l.ID == id select l; if (bs.Count() > 0) { book = bs.First(); } else { book = new Voodoo.Basement.Book(); } } Cls = book.GetClass(); ParentCls = ClassAction.Classes.Where(p => p.ID == Cls.ParentID).First(); }
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 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 btn_createPage_Click(object sender, EventArgs e) { DataEntities ent = new DataEntities(); string[] ids = WS.RequestString("id").Split(','); foreach (string id in ids) { int int_id = id.ToInt32(); Voodoo.Basement.Book b = (from l in ent.Book where l.ID == int_id select l).FirstOrDefault(); Voodoo.Basement.CreatePage.CreateContentPage(b, b.GetClass()); var chapters = (from l in ent.BookChapter where l.BookID == int_id select l).ToList(); foreach (var c in chapters) { Voodoo.Basement.CreatePage.CreateBookChapterPage(c, c.GetBook(), c.GetClass()); } } CreatePage.GreateIndexPage(); Js.Jump(url); }
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)); }
/// <summary> /// 替换小说 /// </summary> /// <param name="TempString"></param> /// <param name="q"></param> /// <param name="c"></param> /// <returns></returns> public string ReplaceContent(TemplateList temp, string TempString, Book b, Class c) { string str_lst = TempString; str_lst = str_lst.Replace("[!--class.name--]", c.ClassName); str_lst = str_lst.Replace("[!--class.id--]", c.ID.ToS()); str_lst = str_lst.Replace("[!--class.url--]", BasePage.GetClassUrl(c)); str_lst = str_lst.Replace("[!--book.url--]", BasePage.GetBookUrl(b, b.GetClass()));//书籍 str_lst = str_lst.Replace("[!--book.lastchapterurl--]", BasePage.GetBookChapterUrl(ObjectExtents.Chapter(b.LastChapterID), b.GetClass()));//书籍 str_lst = str_lst.Replace("[!--book.id--]", b.ID.ToString()); str_lst = str_lst.Replace("[!--book.classid--]", b.ClassID.ToS()); str_lst = str_lst.Replace("[!--book.classname--]", b.ClassName); str_lst = str_lst.Replace("[!--book.ztid--]", b.ZtID.ToS()); str_lst = str_lst.Replace("[!--book.ztname--]", b.ZtName); str_lst = str_lst.Replace("[!--book.title--]", temp.CutTitle > 0 ? b.Title.CutString(temp.CutTitle.ToInt32()) : b.Title); str_lst = str_lst.Replace("[!--book.oldtitle--]", b.Title); str_lst = str_lst.Replace("[!--book.author--]", b.Author); str_lst = str_lst.Replace("[!--book.intro--]", b.Intro.HtmlDeCode()); str_lst = str_lst.Replace("[!--book.length--]", b.Length.ToS()); str_lst = str_lst.Replace("[!--book.replycount--]", b.ReplyCount.ToS()); str_lst = str_lst.Replace("[!--book.addtime--]", b.Addtime.ToDateTime().ToString(temp.TimeFormat)); str_lst = str_lst.Replace("[!--book.status--]", b.Status.ToS()); str_lst = str_lst.Replace("[!--book.isvip--]", b.IsVip.ToBoolean().ToChinese()); str_lst = str_lst.Replace("[!--book.faceimage--]", b.FaceImage); str_lst = str_lst.Replace("[!--book.savecount--]", b.SaveCount.ToS()); str_lst = str_lst.Replace("[!--book.enable--]", b.Enable.ToBoolean().ToChinese()); str_lst = str_lst.Replace("[!--book.isfirstpost--]", b.IsFirstPost.ToBoolean().ToChinese()); str_lst = str_lst.Replace("[!--book.lastchapterid--]", b.LastChapterID.ToS()); str_lst = str_lst.Replace("[!--book.lastchaptertitle--]", b.LastChapterTitle); str_lst = str_lst.Replace("[!--book.updatetime--]", b.UpdateTime.ToDateTime().ToString(temp.TimeFormat)); str_lst = str_lst.Replace("[!--book.lastvipchapterid--]", b.LastVipChapterID.ToS()); str_lst = str_lst.Replace("[!--book.lastvipchaptertitle--]", b.LastVipChapterTitle); str_lst = str_lst.Replace("[!--book.vipupdatetime--]", b.VipUpdateTime.ToDateTime().ToString(temp.TimeFormat)); str_lst = str_lst.Replace("[!--book.corpusid--]", b.CorpusID.ToS()); str_lst = str_lst.Replace("[!--book.corpustitle--]", b.CorpusTitle); str_lst = str_lst.Replace("[!--book.clickcount--]", b.ClickCount.ToS()); str_lst = str_lst.Replace("[!--book.tjcount--]", b.TjCount.ToS()); return str_lst; }
public void CreateBookPage(Book book) { Voodoo.Basement.CreatePage.CreateContentPage(book, book.GetClass()); }
public string ReplaceContent(string TempString, Book n, Class c) { return ReplaceContent(new TemplateList() { TimeFormat = "yyyy-MM-dd HH:mm:ss", CutTitle = 0 }, TempString, n, c); }
/// <summary> /// 生成内容页--图片 /// </summary> /// <param name="album"></param> /// <param name="cls"></param> public string CreateContentPage(Book b, Class cls) { DataEntities ent = new DataEntities(); TemplateContent temp = GetContentTemplate(cls); string Content = temp.Content; Content = ReplacePublicTemplate(Content); Content = ReplacePublicTemplate(Content); Content = ReplacePublicTemplate(Content); Content = ReplaceSystemSetting(Content); #region 替换内容 Content = ReplaceContent(Content, b, cls); List<BookChapter> chapters = (from l in ent.BookChapter where l.BookID == b.ID orderby l.ChapterIndex orderby l.ID descending select l).ToList(); StringBuilder sb = new StringBuilder(); string list_tmp = GetTempateString(1, TempType.小说章节列表); foreach (BookChapter cp in chapters) { string row = list_tmp.Replace("[!--chapter.url--]", BasePage.GetBookChapterUrl(cp, cls)); row = row.Replace("[!--chapter.title--]", cp.Title); sb.AppendLine(row); } Content = Content.Replace("[!--chapter.list--]", sb.ToS()); #endregion Content = ReplaceTagContent(Content); #region 上一篇 下一篇 链接 Book news_pre = BasePage.GetPreBook(b, cls); Book news_next = BasePage.GetNextBook(b, cls); //上一篇 string pre_link = "<a href=\"javascript:void(0)\">没有了</a>"; if (news_pre != null) { pre_link = string.Format("<a id=\"btn_pre\" href=\"{0}\" title=\"{1}\">{2}</a>", BasePage.GetBookUrl(news_pre, cls), news_pre.Title, news_pre.Title.CutString(20)); } Content = Content.Replace("[!--news.prelink--]", pre_link); //下一篇 string next_link = "<a href=\"javascript:void(0)\">没有了</a>"; if (news_next != null) { next_link = string.Format("<a id=\"btn_next\" href=\"{0}\" title=\"{1}\">{2}</a>", BasePage.GetBookUrl(news_next, cls), news_next.Title, news_next.Title.CutString(20)); } Content = Content.Replace("[!--news.nextlink--]", next_link); #endregion //替换导航条 Content = Content.Replace("[!--newsnav--]", BuildClassNavString(cls)); return Content; }
/// <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; }