Exemplo n.º 1
0
        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            var chapters = (from l in ent.BookChapter where l.ID == id select l).ToList();

            var chapter = new Voodoo.Basement.BookChapter();
            if (chapters.Count > 0)
            {
                chapter = chapters.FirstOrDefault();
            }
            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 (chapters.Count== 0)
            {
                Voodoo.Basement.Book book = (from l in ent.Book where l.ID == bookid select l).FirstOrDefault();
                chapter.BookID = book.ID;
                chapter.BookTitle = book.Title;
                chapter.ClassID = book.ClassID;
                chapter.ClassName = book.ClassName;
                chapter.UpdateTime = DateTime.UtcNow.AddHours(8);

                ent.AddToBookChapter(chapter);
                ent.SaveChanges();

                book.LastChapterID = chapter.ID;
                book.LastChapterTitle = chapter.Title;
                book.UpdateTime = chapter.UpdateTime;
                if (SystemSetting.EnableStatic)
                {
                    CreatePage.CreateContentPage(book, book.GetClass());
                }
            }

            if (chapter.TxtPath.IsNullOrEmpty())
            {
                chapter.TxtPath = BasePage.GetChapterTxtStorePath(chapter, chapter.GetBook());
            }

            ent.SaveChanges();
            ent.Dispose();

            Voodoo.IO.File.Write(
                Server.MapPath(chapter.TxtPath),
                txt_Content.Text);
            //生成章节页面
            if (SystemSetting.EnableStatic)
            {
                CreatePage.CreateBookChapterPage(chapter, chapter.GetBook(), chapter.GetClass());
            }

            Response.Redirect(string.Format("ChapterList.aspx?bookid={0}",chapter.BookID));
        }
Exemplo n.º 2
0
        public void ChapterInsert(BookChapter chapter, string Content)
        {
            DataEntities ent = new DataEntities();
            ent.AddToBookChapter(chapter);
            ent.SaveChanges();
            ent.Dispose();

            ///保存文件
            Class cls = chapter.GetClass(); ;
            string txtPath = HttpContext.Current.Server.MapPath(BasePage.GetBookChapterTxtUrl(chapter, cls));
            Voodoo.IO.File.Write(txtPath, Content);

            //生成页面
            Voodoo.Basement.CreatePage.CreateBookChapterPage(chapter,chapter.GetBook(), cls);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();

            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 = ObjectExtents.Class(ClassID);

            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 ((from l in ent.BookChapter where l.Title==Title && l.BookTitle ==BookTitle select l).Count()>0)
            {
                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;

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

            Book b = (from l in ent.Book where l.ID == BookID select l).FirstOrDefault();
            b.LastChapterID = c.ID;
            b.LastChapterTitle = c.Title;
            b.UpdateTime = c.UpdateTime;

            ent.SaveChanges();

            Response.Clear();
            Response.Write(Voodoo.IO.XML.Serialize(c));
        }
Exemplo n.º 4
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)
        {
            DataEntities ent = new DataEntities();

            Book b = (from l in ent.Book where l.ID == BookID select l).FirstOrDefault();
            Class cls = b.GetClass();
            BookChapter c = //BookChapterView.Find(string.Format("BookTitle=N'{0}' and Title=N'{1}'", b.Title, Title));
                (from l in ent.BookChapter where l.BookTitle == b.Title && l.Title == Title select l).FirstOrDefault();
            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);//东八区时间

                ent.AddToBookChapter(c);
                ent.SaveChanges();

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

                b.LastChapterID = c.ID;
                b.LastChapterTitle = c.Title;
                b.UpdateTime = c.UpdateTime;
                ent.SaveChanges();
            }
            ent.Dispose();
            Response.Clear();
            Response.Write(Voodoo.IO.XML.Serialize(c));
        }