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); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(cn.itcast.bookshop.Model.Books model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(cn.itcast.bookshop.Model.Books model) { return(dal.Add(model)); }