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)); }
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 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); }
/// <summary> /// 获取本地书籍 /// </summary> /// <param name="bac"></param> /// <returns></returns> protected BookAndChapter GetLocalBook(BookAndChapter bac) { Setting s = Book.RulesOperate.GetSetting(); BookAndChapter result = new BookAndChapter(); //分类 Class cls = BH.GetClass(bac.Class); bool bookExist = BH.BookExist(bac.BookTitle, bac.Author); Voodoo.Model.Book book = new Voodoo.Model.Book(); if (bookExist) { book = BH.GetBook(bac.BookTitle, bac.Author); } else { //添加书籍 book = BH.BookAdd(bac.BookTitle, bac.Author, cls.ID, bac.Intro, 233999); UploadBookFace(book);//设置书籍封面 } result.Url = s.PublicUrl + "Book/" + book.ClassName + "/" + book.Title + "-" + book.Author + "/"; #region 提交到百度谷歌 if (!bookExist) { googleProxy.ping("爱造人小说阅读", "http://www.aizr.net/", result.Url, "http://www.aizr.net/rss.aspx"); baiduProxy.ping("爱造人小说阅读", "http://www.aizr.net/", result.Url, "http://www.aizr.net/rss.aspx"); } #endregion result.BookTitle = book.Title; result.Class = book.ClassName; result.ClassID = book.ClassID; result.ID = book.ID; result.Intro = book.Intro; result.LastChapter = new Chapter() { Title = book.LastChapterTitle }; result.Status = book.Status; return(result); }
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); }
/// <summary> /// 为书籍设置封面 /// </summary> /// <param name="book"></param> public void UploadBookFace(Voodoo.Model.Book book) { string faceUrl = ""; string Title = book.Title.toUtf8String(); QidianRule Rule = Book.RulesOperate.GetQidianRule(); string QidianSearchUrl = string.Format(Rule.SearchPageUrl, Title); string QidianRefer = string.Format(Rule.SearchRefer, Title); //CollectStatus.Status = "正在搜索"; Status_Chage(); string SearchList = Voodoo.Net.Url.Post(new System.Collections.Specialized.NameValueCollection(), QidianSearchUrl, Encoding.GetEncoding(Rule.CharSet), new System.Net.CookieContainer(), "*.*", QidianRefer, "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.2 Safari/535.11"); //解析json数据 try { JavaScriptSerializer serializer = new JavaScriptSerializer(); var json = serializer.DeserializeObject(SearchList); var j = ((System.Collections.Generic.Dictionary <string, object>)((object[])(((object[])(json))[0]))[0]); faceUrl = string.Format("http://image.cmfu.com/books/{0}/{0}.jpg", j["BookId"].ToS()); //BH = new Voodoo.Basement.Client.BookHelper("http://localhost/"); Voodoo.Net.Url.DownFile(faceUrl, System.Environment.CurrentDirectory + "\\face.jpg"); BH.SetBookFace(book.ID, System.Environment.CurrentDirectory + "\\face.jpg"); } catch { //this.CollectStatus.Status = "起点没有这本书"; //this.Status_Chage(); } }