private void SaveBookCover(string bookid) { string strBookUrl = "../Book/" + bookid + "/cover.htm"; BookBLL objBill = new BookBLL(); objBill.UpdateBookUrl(Convert.ToInt32(bookid), strBookUrl); string srcPath = "../Online/Book/" + bookid + "/cover.htm"; RailExam.Model.Book obj = objBill.GetBook(Convert.ToInt32(bookid)); if (File.Exists(Server.MapPath(srcPath))) { File.Delete(Server.MapPath(srcPath)); } string str = "<link href='book.css' type='text/css' rel='stylesheet' />" + "<body oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' oncopy='document.selection.empty()' onbeforecopy='return false'>" + "<br><br><br><br><br><br><br>" + "<div id='booktitle'>" + obj.bookName + "</div>" + "<br>" + "<br><br><br><br><br><br><br><br><br><br><br>" + "<div id='orgtitle'>" + obj.publishOrgName + "</div>" + "<br>" + "<div id='authortitle'>" + obj.authors + "</div>" + "</body>"; File.AppendAllText(Server.MapPath(srcPath), str, System.Text.Encoding.UTF8); BookChapterBLL objChapterBll = new BookChapterBLL(); objChapterBll.GetIndex(bookid); }
/// <summary> /// 添加试题 /// </summary> /// <returns>受影响的行数</returns> public int AddItem(Item item) { int id = dal.AddItem(item); BookChapterBLL objChapterBll = new BookChapterBLL(); string strChapterName = objChapterBll.GetBookChapter(item.ChapterId).ChapterName; BookBLL objBookBll = new BookBLL(); string strBookName = objBookBll.GetBook(item.BookId).bookName; objLogBll.WriteLog("新增教材《" + strBookName + "》中“" + strChapterName + "”的试题信息"); return(id); }
public void UpdateBookChapter(BookChapter bookChapter) { dal.UpdateBookChapter(bookChapter, SessionSet.EmployeeName); BookBLL objBll = new BookBLL(); if (bookChapter.IsEdit) { objBll.UpdateBookVersion(bookChapter.BookId); } string strBookName = objBll.GetBook(bookChapter.BookId).bookName; GetIndex(bookChapter.BookId.ToString()); objLogBill.WriteLog("修改教材《" + strBookName + "》中“" + bookChapter.ChapterName + "”章节基本信息"); }
public void DeleteBookChapter(BookChapter bookChapter) { ItemBLL objItemBll = new ItemBLL(); objItemBll.UpdateItemEnabled(bookChapter.BookId, bookChapter.ChapterId, 2); string strChapterName = GetBookChapter(bookChapter.ChapterId).ChapterName; BookBLL objBookBll = new BookBLL(); string strBookName = objBookBll.GetBook(bookChapter.BookId).bookName; objLogBill.WriteLog("删除教材《" + strBookName + "》中“" + strChapterName + "”章节基本信息"); dal.DeleteBookChapter(bookChapter.ChapterId); GetIndex(bookChapter.BookId.ToString()); }
/// <summary> /// 修改教材或章节所属试题的状态 /// </summary> /// <param name="bookId"></param> /// <param name="ChapterId"></param> /// <param name="statusId"></param> /// <returns></returns> public int UpdateItemEnabled(int bookId, int ChapterId, int statusId) { string bookName, chapterName; BookBLL objBookBll = new BookBLL(); bookName = objBookBll.GetBook(bookId).bookName; if (ChapterId == 0) { objLogBll.WriteLog("将教材《" + bookName + "》试题全部禁用"); } else { BookChapterBLL objChapterBll = new BookChapterBLL(); BookChapter objChapter = objChapterBll.GetBookChapter(ChapterId); chapterName = objChapter.ChapterName; objLogBll.WriteLog("将教材《" + bookName + "》中“" + chapterName + "”试题全部禁用"); } return(dal.UpdateItemEnabled(bookId, ChapterId, statusId)); }
/// <summary> /// 发布教材 /// </summary> /// <param name="strID"></param> public void GetIndex(string strID) { string strItem, strChapter; BookBLL objBll = new BookBLL(); RailExam.Model.Book objBook = objBll.GetBook(Convert.ToInt32(strID)); string strBookName = objBook.bookName; string strBookUrl = objBook.url; string strVersion = objBook.Version.ToString(); WriteXml(strID, strVersion); strItem = "var TREE_ITEMS = [ ['" + strBookName + "', 'common.htm?url=cover.htm&chapterid=0&bookid=" + strID + "',"; strChapter = "var Tree_Chapter=['0','cover.htm','" + strBookName + "'"; IList <RailExam.Model.BookChapter> objBookChapter = GetBookChapterByBookID(Convert.ToInt32(strID)); foreach (RailExam.Model.BookChapter chapter in objBookChapter) { if (chapter.ParentId == 0) { if (chapter.Url == "" || chapter.Url == null) { strItem += "['" + chapter.ChapterName + "', 'common.htm?url=empty.htm&chapterid=" + chapter.ChapterId + "&bookid=" + strID + "'"; strChapter += ",'" + chapter.ChapterId + "','empty.htm','" + chapter.NamePath + "'"; } else { strItem += "['" + chapter.ChapterName + "', 'common.htm?url=" + chapter.ChapterId + ".htm&chapterid=" + chapter.ChapterId + "&bookid=" + strID + "'"; strChapter += ",'" + chapter.ChapterId + "','" + chapter.ChapterId + ".htm','" + chapter.NamePath + "'"; } if (GetBookChapterByParentID(chapter.ChapterId).Count > 0) { strItem += ","; } strItem = Get(chapter.ChapterId, strItem); strChapter = GetChapter(chapter.ChapterId, strChapter); } } strItem += "]];"; string strPath = "../Online/Book/" + strID + "/tree_items.js"; File.Delete(HttpContext.Current.Server.MapPath(strPath)); File.AppendAllText(HttpContext.Current.Server.MapPath(strPath), strItem, System.Text.Encoding.UTF8); strChapter += "];"; strPath = "../Online/Book/" + strID + "/tree_chapter.js"; if (File.Exists(HttpContext.Current.Server.MapPath(strPath))) { File.Delete(HttpContext.Current.Server.MapPath(strPath)); } File.AppendAllText(HttpContext.Current.Server.MapPath(strPath), strChapter, System.Text.Encoding.UTF8); string[] strIndex = File.ReadAllLines(HttpContext.Current.Server.MapPath("../Online/Book/" + strID + "/index.html"), System.Text.Encoding.Default); for (int i = 0; i < strIndex.Length; i++) { if (strIndex[i].IndexOf("<title>") != -1) { strIndex[i] = "\t<title> " + strBookName + " </title>"; } if (strIndex[i].IndexOf("common.htm?url=cover.htm&chapterid=0") != -1) { strIndex[i] = strIndex[i].Replace("common.htm?url=cover.htm&chapterid=0", "common.htm?url=cover.htm&chapterid=0&bookid=" + strID); } } File.WriteAllLines(HttpContext.Current.Server.MapPath("../Online/Book/" + strID + "/index.html"), strIndex, System.Text.Encoding.UTF8); }