コード例 #1
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));
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取章节
        /// </summary>
        /// <param name="BookTitle">书籍标题</param>
        /// <param name="ChapterTitle">章节标题</param>
        protected void GetChapter(string BookTitle, string ChapterTitle)
        {
            BookChapter c = BookChapterView.Find(string.Format("BookTitle=N'{0}' and Title=N'{1}'", BookTitle, ChapterTitle));

            Response.Clear();
            Response.Write(XML.Serialize(c));
        }
コード例 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string ids = WS.RequestString("id");



            #region  除目录
            List <Voodoo.Model.Book> books = BookView.GetModelList(string.Format("id in ({0})", ids));
            foreach (var book in books)
            {
                BookChapter firstChapter = BookChapterView.Find(string.Format("BookID={0}", book.ID.ToS()));

                DirectoryInfo dir = new FileInfo(
                    Server.MapPath(
                        GetBookUrl(
                            book,
                            BookView.GetClass(book)
                            )
                        )
                    ).Directory;
                if (dir.Exists)
                {
                    dir.Delete(true);
                }


                DirectoryInfo dirTxt = new FileInfo(
                    Server.MapPath(
                        GetBookChapterTxtUrl(firstChapter, BookView.GetClass(book))
                        )
                    ).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(ClassView.GetModelByID(cls.ToS()), 1);
            }
            CreatePage.GreateIndexPage();
            Js.AlertAndChangUrl("删除成功!", url);
        }
コード例 #4
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);
        }
コード例 #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string ids      = WS.RequestString("id");
            var    chapters = BookChapterView.GetModelList(string.Format("id in({0})", ids));

            foreach (var chapter in chapters)
            {
                string FilePath = Server.MapPath(GetBookChapterUrl(chapter, BookView.GetClass(chapter)));
                Voodoo.IO.File.Delete(FilePath);
            }

            BookChapterView.Del(string.Format("id in ({0})", ids));

            var book = BookView.GetModelByID(id.ToS());
            var cls  = BookView.GetClass(book);

            //更新书籍的最新章节
            var lastChapter = BookChapterView.Find(string.Format("bookid={0} order by ChapterIndex,ID desc", id));

            book.LastChapterID    = lastChapter.ID;
            book.LastChapterTitle = lastChapter.Title;
            BookView.Update(book);


            chapters = BookChapterView.GetModelList(string.Format("bookid={0}", id));

            foreach (var chapter in chapters)
            {
                CreatePage.CreateBookChapterPage(chapter, book, cls);
            }

            CreatePage.CreateContentPage(book, cls);

            CreatePage.CreateListPage(cls, 0);

            CreatePage.GreateIndexPage();

            Response.Redirect(string.Format("ChapterList.aspx?bookid={0}", id));
        }
コード例 #6
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));
        }
コード例 #7
0
 public BookChapter ChapterFind(string str_sql)
 {
     return(BookChapterView.Find(str_sql));
 }