public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //获取用户要修改的BookID int Bookid = Convert.ToInt32(context.Request["Bookid"]); string Title = context.Request["Title"]; string Categories = context.Request["Categories"]; string Author = context.Request["Author"]; string PublisherId = context.Request["PublisherId"]; string WordsCount = context.Request["WordsCount"]; Double UnitPrice = Convert.ToDouble(context.Request["UnitPrice"]); string AurhorDescription = context.Request["AurhorDescription"]; string EditorComment = context.Request["EditorComment"]; //string TOC = context.Request["TOC"]; string ContentDescription = context.Request["ContentDescription"]; //接收文件 HttpPostedFile file = null; string imgname = ""; string imgname1 = ""; file = context.Request.Files["file"]; if (file.FileName == null || file.FileName == "") { imgname1 = context.Request["ISNB"]; } else { //重命名 imgname1 = Guid.NewGuid().ToString(); imgname1 = imgname1.Replace("-", ""); imgname = "/BookCovers/" + imgname1 + ".jpg"; string adname = context.Server.MapPath(imgname); file.SaveAs(adname); } Books books = new BooksBll().GetModel(Bookid); books.Title = Title; books.Author = Author; books.CategoryId = Convert.ToInt32(Categories); books.ISBN = imgname1; books.WordsCount = Convert.ToInt32(WordsCount); books.UnitPrice = Convert.ToDecimal(UnitPrice); books.ContentDescription = ContentDescription; books.AurhorDescription = AurhorDescription; books.EditorComment = EditorComment; books.TOC = ""; books.PublisherId = Convert.ToInt32(PublisherId); BooksBll Bll = new BooksBll(); bool model = Bll.Update(books); if (model) { context.Response.Write("ok"); } }
protected void Page_Load(object sender, EventArgs e) { int bookId = Convert.ToInt32(Request["bookId"]); BooksBll BBll = new BooksBll(); model = BBll.GetModel(bookId); CategoriesBll CBll = new CategoriesBll(); list = CBll.GetModelList(""); listPB = PBll.GetModelList(""); }
protected void Page_Load(object sender, EventArgs e) { //新品推荐 bk = new BooksBll().GetNewModel(); //热卖推荐 hotbk = new BooksBll().GetHotModel(); //优品推荐 DataSet ds = new BooksBll().GetBooksByRandom(6); youbkList = new BooksBll().DataTableToList(ds.Tables[0]); //待发货的订单数量 allcount = new OrdersBll().GetRecordCount("state=1"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //获取用户要删除的BookID int Bookid = Convert.ToInt32(context.Request["Bookid"]); BooksBll Bll = new BooksBll(); bool falg = Bll.Delete(Bookid); if (falg) { context.Response.Write("ok"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string Title = context.Request["Title"]; string Categories = context.Request["Categories"]; string Author = context.Request["Author"]; string PublisherId = context.Request["PublisherId"]; string WordsCount = context.Request["WordsCount"]; Double UnitPrice = Convert.ToDouble(context.Request["UnitPrice"]); string AurhorDescription = context.Request["AurhorDescription"]; string EditorComment = context.Request["EditorComment"]; string TOC = context.Request["TOC"]; string ContentDescription = context.Request["ContentDescription"]; //接收文件 HttpPostedFile file = context.Request.Files["file"]; //重命名 string img = Guid.NewGuid().ToString(); string imgname = "/BookCovers/" + img + ".jpg"; string adname = context.Server.MapPath(imgname); file.SaveAs(adname); Books books = new Books(); books.Title = Title; books.Author = Author; books.CategoryId = Convert.ToInt32(Categories); books.PublishDate = DateTime.Now; books.ISBN = img; books.WordsCount = Convert.ToInt32(WordsCount); books.UnitPrice = Convert.ToDecimal(UnitPrice); books.ContentDescription = ContentDescription; books.AurhorDescription = AurhorDescription; books.EditorComment = EditorComment; books.TOC = TOC; books.PublisherId = Convert.ToInt32(PublisherId); books.Clicks = 0; BooksBll Bll = new BooksBll(); int model = Bll.Add(books); if (model > 0) { context.Response.Write("ok"); } }
protected void Page_Load(object sender, EventArgs e) { BooksBll bbl = new BooksBll(); typelist = new CategoriesBll().GetModelList(""); string index = Request["index"]; if (string.IsNullOrEmpty(index)) { pageIndex = 1; } else { pageIndex = Convert.ToInt32(index); } //获得类型id string typeId = Request["typeId"]; DataSet ds; if (string.IsNullOrEmpty(typeId)) { ds = bbl.GetListByPage("", "Id", (pageIndex - 1) * pageSize + 1, pageIndex * pageSize); //总条数 total = bbl.GetRecordCount(""); } else { ds = bbl.GetListByPage("CategoryId=" + typeId, "Id", (pageIndex - 1) * pageSize + 1, pageIndex * pageSize); //总条数 total = bbl.GetRecordCount("CategoryId=" + typeId); } //总页码数 pageCount = Convert.ToInt32(Math.Ceiling((double)total / pageSize)); //每页显示的数据集 bookslist = bbl.DataTableToList(ds.Tables[0]); //随机显示3条数据 DataSet ds1 = bbl.GetBooksByRandom(3); ramdomBooks = bbl.DataTableToList(ds1.Tables[0]); }
protected void Page_Load(object sender, EventArgs e) { int id = Convert.ToInt32(Request["bookid"]); //图书详情 BooksBll bbl = new BooksBll(); books = bbl.GetModel(id); //随机显示图书 DataSet ds = bbl.GetBooksByRandom(4); booksList = bbl.DataTableToList(ds.Tables[0]); //猜你喜欢 DataSet ds1 = bbl.GetBooksByRandom(12); guestLike = bbl.DataTableToList(ds1.Tables[0]); count = new BookCommentBll().GetRecordCount("BookId=" + id); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string filepath = Server.MapPath("/BookCovers"); BooksBll bbl = new BooksBll(); var list = bbl.GetModelList(""); int i = 0; foreach (var item in list) { bool flag = File.Exists(filepath + "/" + item.ISBN + ".jpg"); if (!flag) { bbl.Delete(item.Id); i++; } } Response.Write("一共删除了" + i); } }
/// <summary> /// 测试IndexManager /// </summary> /// <returns></returns> public ActionResult TestCreate() { Model.Books model = new Model.Books(); model.AurhorDescription = "jlkfdjf"; model.Author = "asfasd"; model.CategoryId = 1; model.Clicks = 1; model.ContentDescription = "卢本伟牛逼,披着国旗在国际舞台上叱咤风云!"; model.EditorComment = "adfsadfsadf"; model.ISBN = "111111111111111111"; model.PublishDate = DateTime.Now; model.PublisherId = 72; model.Title = "卢本伟的一生"; model.TOC = "aaaaaaaaaaaaaaaa"; model.UnitPrice = 22.3m; model.WordsCount = 1234; //将数据先存储到数据库中。获取刚插入的数据的主键ID值。 IBLL.IBooksBll booksBll = new BooksBll(); model = booksBll.AddEntity(model); IndexManager.CreateInstance().AddToLucene(model.Id, model.Title, model.ContentDescription);//向队列中添加 return(Content("ok")); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //获取用户要删除的BookID int typeid = Convert.ToInt32(context.Request["typeid"]); BooksBll Bll = new BooksBll(); List <Books> books = Bll.GetModelList("CategoryId=" + typeid); if (books.Count > 0) { context.Response.Write("no"); } else { CategoriesBll cBll = new CategoriesBll(); bool falg = cBll.Delete(typeid); if (falg) { context.Response.Write("ok"); } } }
protected void Page_Load(object sender, EventArgs e) { //随机显示3条数据 DataSet ds1 = bbl.GetBooksByRandom(3); ramdomBooks = bbl.DataTableToList(ds1.Tables[0]); if (Request["zi"] != null) { searchWord = Request["zi"]; Maticsoft.Model.SearchDetails sd = new Maticsoft.Model.SearchDetails() { KeyWords = searchWord, SearchDateTime = DateTime.Now }; new SearchDetailsBll().Add(sd); } DataSet ds = new BooksBll().searchResult(searchWord); searchList = new BooksBll().DataTableToList(ds.Tables[0]); }
/// <summary> /// 创建索引 /// </summary> private void CreateIndex() { //目录最好放在配置文件中,注意和磁盘上文件夹的大小写一致,否则会报错。将创建的分词内容放在该目录下。 string indexPath = @"D:\stu\DotNet\练习\BlangenOA\lucenedir"; //指定索引文件(打开索引目录,并加锁) FS指的是就是FileSystem FSDirectory directory = FSDirectory.Open(new DirectoryInfo(indexPath), new NativeFSLockFactory()); //IndexReader:对索引进行读取的类。该语句的作用:判断索引库文件夹是否存在以及索引特征文件是否存在。 bool isUpdate = IndexReader.IndexExists(directory); if (isUpdate) { //同时只能有一段代码对索引库进行写操作。当使用IndexWriter打开directory时会自动对索引库文件上锁。 //如果索引目录被锁定(比如索引过程中程序异常退出),则首先解锁(提示一下:如果我现在正在写着已经加锁了,但是还没有写完,这时候又来一个请求,那么不就解锁了吗?这个问题后面会解决) if (IndexWriter.IsLocked(directory)) { IndexWriter.Unlock(directory); } } //向索引库中写索引。这时在这里加锁。 IndexWriter writer = new IndexWriter(directory, new PanGuAnalyzer(), !isUpdate, IndexWriter.MaxFieldLength.UNLIMITED); //读取数据库中的书籍 List <Books> list = BooksBll.LoadEntities(b => true).ToList(); foreach (Books book in list) { //表示一篇文档。 Document document = new Document(); //Field.Store.YES:表示是否存储原值。只有当Field.Store.YES在后面才能用doc.Get("number")取出值来.Field.Index. NOT_ANALYZED:不进行分词保存 document.Add(new Field("ID", book.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); //Field.Index. ANALYZED:进行分词保存:也就是要进行全文的字段要设置分词 保存(因为要进行模糊查询) //Lucene.Net.Documents.Field.TermVector.WITH_POSITIONS_OFFSETS:不仅保存分词还保存分词的距离。 document.Add(new Field("Title", book.Title, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); document.Add(new Field("Abstract", book.ContentDescription, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); writer.AddDocument(document); } writer.Close(); //会自动解锁。 directory.Close(); //不要忘了Close,否则索引结果搜不到 }
protected void Page_Load(object sender, EventArgs e) { BooksBll bbll = new BooksBll(); string index = Request["index"]; if (string.IsNullOrEmpty(index)) { pageIndex = 1; } else { pageIndex = Convert.ToInt32(index); } //总页数 int total = bbll.GetRecordCount(""); pageCount = Convert.ToInt32(Math.Ceiling((double)total / pageSize)); //集合 DataSet ds = bbll.GetListByPage("", "", (pageIndex - 1) * pageSize + 1, pageIndex * pageSize); bookList = bbll.DataTableToList(ds.Tables[0]); }