예제 #1
0
        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);
        }
예제 #2
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));
        }
예제 #3
0
        /// <summary>
        /// 添加章节
        /// </summary>
        /// <param name="BookID">书籍ID</param>
        /// <param name="Title">标题</param>
        /// <param name="Content">内容</param>
        /// <param name="IsImageChapter">是否图片章节</param>
        protected void ChapterAdd(int BookID, string Title, string Content, bool IsImageChapter, bool IsTemp = false)
        {
            Book        b   = BookView.GetModelByID(BookID.ToS());
            Class       cls = BookView.GetClass(b);
            BookChapter c   = BookChapterView.Find(string.Format("BookTitle=N'{0}' and Title=N'{1}'", b.Title, Title));

            if (c.ID <= 0)
            {
                c.BookID         = b.ID;
                c.BookTitle      = b.Title;
                c.ChapterIndex   = 0;
                c.ClassID        = cls.ID;
                c.ClassName      = cls.ClassName;
                c.ClickCount     = 0;
                c.Enable         = true;
                c.IsFree         = true;
                c.IsImageChapter = IsImageChapter;
                c.IsTemp         = IsTemp;
                c.IsVipChapter   = false;
                c.TextLength     = Content.Length;
                c.Title          = Title;
                c.UpdateTime     = DateTime.UtcNow.AddHours(8);//东八区时间

                BookChapterView.Insert(c);

                //创建内容txt
                Voodoo.IO.File.Write(Server.MapPath(BasePage.GetBookChapterTxtUrl(c, cls)), Content);

                b.LastChapterID    = c.ID;
                b.LastChapterTitle = c.Title;
                b.UpdateTime       = c.UpdateTime;
                BookView.Update(b);
            }
            Response.Clear();
            Response.Write(Voodoo.IO.XML.Serialize(c));
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            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 = ClassView.GetModelByID(ClassID.ToS());

            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 (BookChapterView.Exist(string.Format("BookTitle=N'{0}' and Title=N'{1}'", BookTitle, Title)))
            {
                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;

            BookChapterView.Insert(c);
            //创建内容txt
            Voodoo.IO.File.Write(Server.MapPath(BasePage.GetBookChapterTxtUrl(c, cls)), Content);

            Book b = BookView.GetModelByID(BookID.ToString());

            b.LastChapterID    = c.ID;
            b.LastChapterTitle = c.Title;
            b.UpdateTime       = c.UpdateTime;
            BookView.Update(b);

            Response.Clear();
            Response.Write(Voodoo.IO.XML.Serialize(c));
        }