Пример #1
0
        /// <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());
        }
Пример #2
0
        /// <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());
        }
Пример #3
0
        /// <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));
            }
        }
Пример #4
0
        /// <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));
            }
        }
Пример #5
0
        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));
        }
Пример #6
0
        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");
            }
        }
Пример #7
0
        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());
        }
Пример #8
0
        /// <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));
        }
Пример #9
0
        /// <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");
            }
        }
Пример #10
0
 /// <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("不存在");
     }
 }
Пример #11
0
        /// <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));
        }
Пример #12
0
        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));
        }
Пример #13
0
        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");
        }
Пример #14
0
        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);
        }
Пример #15
0
        protected void LoadInfo()
        {
            if (id > 0)
            {
                var chapter = BookChapterView.GetModelByID(id.ToS());
                lb_BookTitle.Text  = chapter.BookTitle;
                lb_ValumeName.Text = chapter.ValumeName;
                txt_Title.Text     = chapter.Title;
                string Content = Voodoo.IO.File.Read(Server.MapPath(GetBookChapterTxtUrl(chapter, BookView.GetClass(chapter))));
                txt_Content.Text           = Content;
                chk_IsVip.Checked          = chapter.IsVipChapter;
                chk_IsEnable.Checked       = chapter.Enable;
                chk_IsTemp.Checked         = chapter.IsTemp;
                chk_IsFree.Checked         = chapter.IsFree;
                chk_IsImageChapter.Checked = chapter.IsImageChapter;
            }

            if (bookid > 0)
            {
                var book = BookView.GetModelByID(bookid.ToS());
                lb_BookTitle.Text = book.Title;
            }
        }
Пример #16
0
 public BookChapter GetChapterByID(long id)
 {
     return(BookChapterView.GetModelByID(id.ToString()));
 }