Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/html;charset=utf-8";
            b.Books bll         = new b.Books();
            int     currentPage = int.Parse((Request["currentPage"] ?? "1"));
            int     pageSize    = int.Parse(Request["pageSize"] ?? "5");

            Model             = new m.PageModel();
            Model.CurrentPage = currentPage;
            Model.PageSize    = pageSize;
            bll.GetPageModel(Model);
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            b.Books        bll  = new b.Books();
            List <m.Books> list = bll.GetModelList("");

            foreach (var item in list)
            {
                GenerateHtmlPage(item.Id);
            }
            context.Response.Write("ok");
        }
Ejemplo n.º 3
0
        private void GenerateHtmlPage(int id)
        {
            b.Books bll   = new b.Books();
            m.Books model = bll.GetModel(id);
            string  path  = HttpContext.Current.Request.MapPath("/Template/BookTemplate.html");

            string content = File.ReadAllText(path);
            string dir     = HttpContext.Current.Request.MapPath("/");

            if (!Directory.Exists(dir + "BookDetails" + "\\" + model.PublishDate.Year + "\\" + model.PublishDate.Month + "\\" + model.PublishDate.Date))
            {
                Directory.CreateDirectory(dir + "BookDetails" + "/" + model.PublishDate.Year + "/" + model.PublishDate.Month + "/" + model.PublishDate.Day);
            }
            string html = content.Replace("$title", model.Title).Replace("$id", model.Id.ToString()).Replace("$unitPrice", model.UnitPrice.ToString("0.00"))
                          .Replace("$isbn", model.ISBN).Replace("$toc", model.TOC).Replace("$content", model.ContentDescription).Replace("$authorDesc", model.AurhorDescription).Replace("author", model.Author)
                          .Replace("$wordCount", model.WordsCount.ToString()).Replace("$publishDate", model.PublishDate.ToShortDateString()).Replace("$bookid", model.Id.ToString());

            File.WriteAllText(dir + "BookDetails" + "/" + model.PublishDate.Year + "/" + model.PublishDate.Month + "/" + model.PublishDate.Day + "/" + model.Id + ".html", html);
        }