protected void btnAddBook_Click(object sender, EventArgs e)
        {
            Model.Books model = new Model.Books();
            model.AurhorDescription = "jlkfdjf";
            model.Author = "王承伟";
            model.CategoryId = 1;
            model.Clicks = 1;
            model.ContentDescription = "老王是大好人!老王是大好人!老王是大好人!老王是大好人!老王是大好人!";
            model.EditorComment = "adfsadfsadf";
            model.ISBN = "123452222222355553003333266222";
            model.PublishDate = DateTime.Now;
            model.PublisherId = 72;
            model.Title = "老王是大好人";
            model.TOC = "aaaaaaaaaaaaaaaa";
            model.UnitPrice = 22.3m;
            model.WordsCount = 1234;
            BLL.BooksBLL bll = new BLL.BooksBLL();
            int id = bll.Add(model);

            SearchResult result = new SearchResult();
            result.Id = id;
            result.ISBN = model.ISBN;
            result.PublishDate = model.PublishDate;
            result.Title = model.Title;
            result.UnitPrice = model.UnitPrice;
            result.ContentDescription = model.ContentDescription;
            result.Author = model.Author;
            Common.IndexManage.myManage.Add(result);
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Write(Request["id"]);
            int id = Convert.ToInt32(Request["id"]);

            Book = new BLL.Books().GetModel(id);
            //new BLL.Books().CreateHtml(id);
        }
Beispiel #3
0
        protected string GetDir(object id)
        {
            BLL.Books   bll  = new BLL.Books();
            Model.Books book = bll.GetModel(Convert.ToInt32(id));
            string      str  = book.PublishDate.Year + "/" + book.PublishDate.Month + "/" + book.PublishDate.Day + "/"
                               + book.Id + ".html";

            return(str);
        }
Beispiel #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string sBid = Request.QueryString["bid"];
         if (sBid != null)
         {
             bid  = Convert.ToInt32(sBid);
             Book = bb.GetModel(bid);
         }
         else
         {
             Response.Redirect("BookList.aspx");
         }
     }
 }
        private void ShowInfo(int Id)
        {
            BLL.BooksManager bll   = new OLBookstore.BLL.BooksManager();
            Model.Books      model = bll.GetModel(Id);
            this.lblId.Text            = model.Id.ToString();
            this.txtTitle.Text         = model.Title;
            this.txtAuthor.Text        = model.Author;
            ddlCategory.SelectedValue  = model.CategoryId.ToString();
            ddlPublisher.SelectedValue = model.PublisherId.ToString();
            this.txtPublishDate.Text   = model.PublishDate.ToString();
            this.lblISBN.Text          = model.ISBN;
            this.txtUnitPrice.Text     = model.UnitPrice.ToString();
            FCKeditor1.Value           = model.ContentDescription;
            this.txtTOC.Text           = model.TOC;
            this.txtClicks.Text        = model.Clicks.ToString();

            imgBook.ImageUrl = @"~/userfiles/" + lblISBN.Text.Trim() + ".jpg";
        }
Beispiel #6
0
        private void ShowInfo(int Id)
        {
            BLL.BooksManager bll   = new OLBookstore.BLL.BooksManager();
            Model.Books      model = bll.GetModel(Id);
            this.lblId.Text     = model.Id.ToString();
            this.txtTitle.Text  = model.Title;
            this.txtAuthor.Text = model.Author;

            ddlCategory.SelectedValue       = model.CategoryId.ToString();
            ddlPublisher.SelectedValue      = model.PublisherId.ToString();
            this.txtPublishDate.Text        = model.PublishDate.ToString();
            this.lblISBN.Text               = model.ISBN;
            this.txtUnitPrice.Text          = model.UnitPrice.ToString();
            this.txtContentDescription.Text = model.ContentDescription;
            this.txtTOC.Text = model.TOC;

            this.txtClicks.Text = model.Clicks.ToString();
        }
Beispiel #7
0
 public ActionResult TestCreate()
 {
     Model.Books model = new Model.Books();
     model.AurhorDescription  = "jlkfdjf";
     model.Author             = "asfasd";
     model.CategoryId         = 1;
     model.Clicks             = 1;
     model.ContentDescription = "Ajax高级编程";
     model.EditorComment      = "adfsadfsadf";
     model.ISBN        = "111111111111111111";
     model.PublishDate = DateTime.Now;
     model.PublisherId = 72;
     model.Title       = "Ajax";
     model.TOC         = "aaaaaaaaaaaaaaaa";
     model.UnitPrice   = 22.3m;
     model.WordsCount  = 1234;
     //1.将数据先存储到数据库中。获取刚插入的数据的主键ID值。
     IndexManager.GetInstance().AddQueue(9999, model.Title, model.ContentDescription);//向队列中添加
     return(Content("ok"));
 }
Beispiel #8
0
        /// <summary>
        ///
        /// 根据图书id创建图书静态页
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool CreateHtml(int id)
        {
            Model.Books bookModel = dal.GetModel(id);
            if (bookModel == null)
            {
                return(false);
            }

            string filePath    = HttpContext.Current.Request.MapPath("/Template/BookTemplate.html");
            string fileContent = File.ReadAllText(filePath);

            fileContent = fileContent.Replace("$author", bookModel.Author).Replace("$title", bookModel.Title).Replace("$wordCount", bookModel.WordsCount.ToString()).Replace("$publishDate", bookModel.PublishDate.ToShortDateString()).Replace("$isbn", bookModel.ISBN).Replace("$unitPrice", bookModel.UnitPrice.ToString("0.00")).Replace("$toc", bookModel.TOC).Replace("$content", bookModel.ContentDescription).Replace("$authorDesc", bookModel.AurhorDescription).Replace("$bookId", bookModel.Id.ToString());
            string dir = "/BookDetails/" + bookModel.PublishDate.Year + "/" + bookModel.PublishDate.Month + "/" + bookModel.PublishDate.Day + "/";

            Directory.CreateDirectory(Path.GetDirectoryName(HttpContext.Current.Request.MapPath(dir)));
            string fullDir = dir + bookModel.Id + ".html";

            File.WriteAllText(HttpContext.Current.Request.MapPath(fullDir), fileContent, System.Text.Encoding.UTF8);
            return(true);
        }
Beispiel #9
0
        /// <summary>
        /// 创建静态html
        /// </summary>
        /// <param name="id"></param>
        public void CreateHtmlPage(int id)
        {
            Model.Books book = dal.GetModel(id);
            if (book != null)
            {
                var data = new { title = book.Title, desc = book.ContentDescription };

                //string html = Common.RenderHtml("BookTemplate.html", data);//使用NVelocity
                string temp = HttpContext.Current.Server.MapPath("/Template/BookTemplate.html");
                string html = File.ReadAllText(temp);
                html = html.Replace("$title", book.Title).Replace("$desc", book.ContentDescription).Replace
                           ("$bookId", book.Id.ToString());

                //把替换好的内容保存
                string dir = HttpContext.Current.Server.MapPath("/StaticPage/" + book.PublishDate.Year
                                                                + "/" + book.PublishDate.Month + "/" + book.PublishDate.Day + "/");
                Directory.CreateDirectory(Path.GetDirectoryName(dir));
                File.WriteAllText(dir + book.Id + ".html", html, Encoding.UTF8);
            }
        }
Beispiel #10
0
 /// <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"));
 }
Beispiel #11
0
        /// <summary>
        /// 此方法把datatable转化成List<YF.Model.Books>范型
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static List <YF.Model.Books> Dotolist(DataTable dt)
        {
            List <YF.Model.Books> list = new List <Model.Books>(); //空的泛型对象

            for (int i = 0; i < dt.Rows.Count; i++)                // 做个循环把传入的dt表对象转化为Books对象
            {
                YF.Model.Books books = new Model.Books();          //空对象

                books.Id       = int.Parse(dt.Rows[i]["id"].ToString());
                books.Isbn     = dt.Rows[i]["isbn"].ToString();
                books.Price    = float.Parse(dt.Rows[i]["price"].ToString());
                books.Num      = int.Parse(dt.Rows[i]["num"].ToString());
                books.Img      = dt.Rows[i]["img"].ToString();
                books.Detail   = dt.Rows[i]["detail"].ToString();
                books.State    = int.Parse(dt.Rows[i]["state"].ToString());
                books.Adddate  = DateTime.Parse(dt.Rows[i]["adddate"].ToString());
                books.Bookname = dt.Rows[i]["bookname"].ToString();

                list.Add(books); //把Book对象加入list中
            }
            return(list);
        }
Beispiel #12
0
        public List <Model.Books> GetPageBooks(int currentPage, int pageSize)
        {
            string             sql   = "select * from (select * ,rows=Row_Number() over (order by id) from Books) as b where b.rows between (@currentPage-1)*@pageSize+1 and @currentPage*@pageSize";
            List <Model.Books> books = new List <Model.Books>();

            using (SqlDataReader reader = SqlHelper.GetSqlDataReader(sql, new SqlParameter("@currentPage", System.Data.SqlDbType.Int)
            {
                Value = currentPage
            }, new SqlParameter("@pageSize", System.Data.SqlDbType.Int)
            {
                Value = pageSize
            }))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        Model.Books book = new Model.Books();
                        book.Id                 = reader.GetInt32(0);
                        book.Title              = reader.GetString(1);
                        book.Author             = reader.GetString(2);
                        book.PublisherId        = reader.GetInt32(3);
                        book.PublishDate        = reader.GetDateTime(4);
                        book.ISBN               = reader.GetString(5);
                        book.WordsCount         = reader.GetInt32(6);
                        book.UnitPrice          = reader.GetDecimal(7);
                        book.ContentDescription = reader.GetString(8);
                        book.AurhorDescription  = reader.GetString(9);
                        book.EditorComment      = reader.GetString(10);
                        book.CategoryId         = reader.GetInt32(12);
                        books.Add(book);
                    }
                }
                return(books);
            }
        }
Beispiel #13
0
        //
        // GET: /Test/

        public ActionResult Index()
        {
            #region 字典队列测试数据
            Model.Books model = new Model.Books();
            model.AurhorDescription = "sdhflkasjflaksdjf";
            model.Author = "老赵";
            model.CategoryId = 1;
            model.Clicks = 1;
            model.ContentDescription = "老赵的私人生活是......???";
            model.EditorComment = "adfsadfsadf";
            model.ISBN = "39u582349";
            model.PublishDate = DateTime.Now;
            model.PublisherId = 72;
            model.Title = "私生活";
            model.TOC = "aaaaaaaaaaaaaaaa";
            model.UnitPrice = 22.3m;
            model.WordsCount = 1234;

            SearchQueueManager.GetInstance().AddOrUpdateIntoQueue(model.ISBN, model.Title, model.ContentDescription);
            #endregion


            return Content("ok");
        }