예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string zi    = context.Request["zi"];
            int    count = Convert.ToInt32(context.Request["count"]);

            List <Books> list = (List <Books>)CacheHelper.GetCache("books");

            if (list == null)
            {
                list = bbl.GetModelList("");
                CacheHelper.SetCache("books", list);
            }
            PinYin p     = new PinYin();
            var    books = list.Where(b => p.GetFirstLetter(b.Title).Contains(zi.ToUpper())).Take(count);

            //每次搜索之后都要将搜索的字存到数据库中
            SearchDetails sd = new SearchDetails()
            {
                KeyWords       = zi,
                SearchDateTime = DateTime.Now
            };

            new SearchDetailsBll().Add(sd);
            //序列化
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            string json = jss.Serialize(books);

            //输出
            context.Response.Write(json);
        }
예제 #2
0
 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);
     }
 }
        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");
                }
            }
        }