예제 #1
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());
        }
예제 #2
0
        public void ChapterUpdate(BookChapter chapter, string Content)
        {
            BookChapterView.Update(chapter);
            ///保存文件
            Class  cls     = BookView.GetClass(chapter);
            string txtPath = AppDomain.CurrentDomain.BaseDirectory + BasePage.GetBookChapterTxtUrl(chapter, cls).Replace("/", "\\");

            Voodoo.IO.File.Write(txtPath, Content);

            //生成页面
            Voodoo.Basement.CreatePage.CreateBookChapterPage(chapter, BookView.GetModelByID(chapter.BookID.ToString()), cls);
        }
예제 #3
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");
            }
        }
예제 #4
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));
        }
예제 #5
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));
        }
예제 #6
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");
        }