//[PPTAuthrize(permission = (int)p.Modify)] public ActionResult PPTItemEdit() { PPTItem PPTItem = new PPTItem(); List <PPTItem> PPTItemList = new List <PPTItem>(); List <PPTClass> PPTClassList = new List <PPTClass>(); //List<ProductClass> productClassList = new List<ProductClass>(); PPTItem = this.WebUnity.PPTItemRepository.GetById(Convert.ToInt32(Request.QueryString["id"])); PPTClassList = this.WebUnity.PPTClassRepository.Get(/*orderBy: q => q.OrderBy(t => t.displayOrder)*/) .ToList <PPTClass>(); //productClassList = this.WebUnity.ProductClassRepository // .Get(filter: t => t.classLevel == 1, orderBy: q => q.OrderBy(t => t.displayOrder)) // .ToList<ProductClass>(); //List<ProductCmsClass> productCmsClassList = this.WebUnity.ProductCmsClassRepository // .Get(orderBy: q => q.OrderBy(t => t.displayOrder)) // .ToList<ProductCmsClass>(); //ViewData["productCmsClassList"] = productCmsClassList; ViewData["label"] = "service"; ViewData["state"] = "edit"; ViewData["PPTItem"] = PPTItem; ViewData["PPTItemList"] = PPTItemList; ViewData["PPTClassList"] = PPTClassList; //ViewData["productClassList"] = productClassList; ViewData["pageCount"] = 0; ViewData["pageIndex"] = 0; ViewData["kw"] = ""; return(View("~/views/cms/PPTManager.cshtml")); }
//[PPTAuthrize(permission = (int)p.Add)] public ActionResult CreatePPTItem() { PPTItem PPTItem = new PPTItem(); List <PPTItem> PPTItemList = new List <PPTItem>(); List <PPTClass> PPTClassList = new List <PPTClass>(); //List<ProductClass> productClassList = new List<ProductClass>(); PPTItem.updateDate = DateTime.Now; PPTClassList = this.WebUnity.PPTClassRepository.Get() .ToList <PPTClass>(); //productClassList = this.WebUnity.ProductClassRepository // .Get(filter: t => t.classLevel == 1, orderBy: q => q.OrderBy(t => t.displayOrder)) // .ToList<ProductClass>(); //List<ProductCmsClass> productCmsClassList = this.WebUnity.ProductCmsClassRepository // .Get(orderBy: q => q.OrderBy(t => t.displayOrder)) // .ToList<ProductCmsClass>(); //ViewData["productCmsClassList"] = productCmsClassList; ViewData["label"] = "service"; ViewData["state"] = "create"; ViewData["PPTItem"] = PPTItem; ViewData["PPTItemList"] = PPTItemList; ViewData["PPTClassList"] = PPTClassList; //ViewData["productClassList"] = productClassList; ViewData["pageCount"] = 0; ViewData["pageIndex"] = 0; ViewData["kw"] = ""; return(View("~/views/cms/PPTManager.cshtml")); }
//[PPTAuthrize(permission = (int)p.Modify)] public ActionResult PPTItemDelete() { PPTItem PPTItem = new PPTItem(); List <PPTItem> PPTItemList = new List <PPTItem>(); PPTItem = this.WebUnity.PPTItemRepository.GetById(Convert.ToInt32(Request.QueryString["id"])); string pathPPT = string.Empty; string pathThumbnail = string.Empty; try { pathPPT = Server.MapPath(PPTItem.pptSrc); pathThumbnail = Server.MapPath(PPTItem.thumbnailSrc); if (System.IO.File.Exists(pathPPT)) { //如果存在则删除 System.IO.File.Delete(pathPPT); } if (System.IO.File.Exists(pathThumbnail)) { //如果存在则删除 System.IO.File.Delete(pathThumbnail); } } catch { } //lucene //IndexManager.bookIndex.Del(PPTItem.id, "PPTItem"); this.WebUnity.PPTItemRepository.Delete(Convert.ToInt32(Request.QueryString["id"])); this.WebUnity.Save(); int pageIndex = null == Request.QueryString["p"] ? 1 : Convert.ToInt32(Request.QueryString["p"]); string keyword = null == Request.QueryString["kw"] ? "" : Request.QueryString["kw"].ToString(); int recordCount = WebUnity.PPTItemRepository.Get(filter: t => keyword.Length > 0 ? t.title.IndexOf(keyword) > -1 : true).Count(); PPTItemList = WebUnity.PPTItemRepository .Get(pageIndex, 15, orderBy: q => q.OrderByDescending(t => t.updateDate), filter: t => keyword.Length > 0 ? t.title.IndexOf(keyword) > -1 : true) .ToList <PPTItem>(); int pageCount = recordCount % 15 == 0 ? recordCount / 15 : recordCount / 15 + 1; ViewData["label"] = "service"; ViewData["state"] = "list"; ViewData["PPTItem"] = PPTItem; ViewData["PPTItemList"] = PPTItemList; ViewData["PPTItemClassList"] = null; ViewData["productClassList"] = null; ViewData["pageCount"] = pageCount; ViewData["pageIndex"] = pageIndex; ViewData["kw"] = ""; return(View("~/views/cms/PPTManager.cshtml")); }
private bool overrideUpdate(T entityToUpdate, bool isInsert) { string typeWholeName = entityToUpdate.GetType().ToString(); string typeName = typeWholeName.IndexOf("Proxies") > -1 ? entityToUpdate.GetType().ToString().Substring( typeWholeName.IndexOf("Proxies") + 8, typeWholeName.LastIndexOf("_") - typeWholeName.IndexOf("Proxies") - 8 ) : typeWholeName.Substring(typeWholeName.LastIndexOf(".") + 1); //System.IO.File.AppendAllText("/apps/data.txt", "判断中:" + typeName + "----" + typeWholeName + "\r\n"); if (!isInsert) { #region 特殊处理Update方法 switch (typeName) { case "PPTItem": PPTItem pptItem = entityToUpdate as Web.Mvc.Model.PPTItem; context.Database.ExecuteSqlCommand( @"update PPTItem set classId=@p0,title=@p1,author=@p2,validDate=@p3,description=@p4,pptSrc=@p5,thumbnailSrc=@p6,visible=@p7,updateDate=@p8,updateUser=@p9 where id=@p10", pptItem.classId, pptItem.title, pptItem.author, pptItem.validDate, pptItem.description, pptItem.pptSrc, pptItem.thumbnailSrc, pptItem.visible, pptItem.updateDate, pptItem.updateUser, pptItem.id ); break; default: return(false); } #endregion context.Entry(entityToUpdate).State = System.Data.Entity.EntityState.Unchanged; } else { #region 特殊处理Insert方法 switch (typeName) { case "PPTItem": PPTItem entity1 = entityToUpdate as PPTItem; context.Database.ExecuteSqlCommand( @"insert into PPTItem(classId,title,author,validDate,description,pptSrc,thumbnailSrc,visible,updateDate,updateUser) values(@p0,@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9)", entity1.classId, entity1.title, entity1.author, entity1.validDate, entity1.description, entity1.pptSrc, entity1.thumbnailSrc, entity1.visible, entity1.updateDate, entity1.updateUser ); break; default: return(false); } #endregion } return(true); }
//[PPTAuthrize(permission = (int)p.Modify)] public ActionResult PPTItemShow() { PPTItem PPTItem = new PPTItem(); List <PPTItem> PPTItemList = new List <PPTItem>(); PPTItem = this.WebUnity.PPTItemRepository.GetById(Convert.ToInt32(Request.QueryString["id"])); bool state = true; PPTItem.visible = state; PPTItem.updateUser = "******";//Session["uid"].ToString();//Convert.ToInt32(Session["uid"]); PPTItem.updateDate = DateTime.Now; this.WebUnity.PPTItemRepository.Update(PPTItem); this.WebUnity.Save(); //lucene //SearchUnit su = new SearchUnit(PPTItem.id.ToString(), PPTItem.showName, PPTItem.suitableModels, PPTItem.description, PPTItem.classId.ToString(), PPTItem.publishDate, PPTItem.hits.ToString(), iscommon); //IndexManager.bookIndex.Add(su, "PPTItem"); int pageIndex = null == Request.QueryString["p"] ? 1 : Convert.ToInt32(Request.QueryString["p"]); string keyword = null == Request.QueryString["kw"] ? "" : Request.QueryString["kw"].ToString().FilterHttpGet(); int recordCount = WebUnity.PPTItemRepository.Get(filter: t => keyword.Length > 0 ? t.title.IndexOf(keyword) > -1 : true).Count(); PPTItemList = WebUnity.PPTItemRepository .Get(pageIndex, 15, orderBy: q => q.OrderByDescending(t => t.updateDate), filter: t => keyword.Length > 0 ? t.title.IndexOf(keyword) > -1 : true) .ToList <PPTItem>(); int pageCount = recordCount % 15 == 0 ? recordCount / 15 : recordCount / 15 + 1; ViewData["label"] = "service"; ViewData["state"] = "list"; ViewData["PPTItem"] = PPTItem; ViewData["PPTItemList"] = PPTItemList; ViewData["PPTItemClassList"] = null; ViewData["productClassList"] = null; ViewData["pageCount"] = pageCount; ViewData["pageIndex"] = pageIndex; ViewData["kw"] = ""; return(View("~/views/cms/PPTManager.cshtml")); }
public ActionResult PPTItemSave() { PPTItem PPTItem = new PPTItem(); //保存到数据库 if (Request.Form["PPTItemid"].ToString() == "0") { //新建下载 //插入记录 PPTItem.classId = Convert.ToInt32(Request.Form["classid"]); PPTItem.visible = false;//默认先隐藏ppt PPTItem.title = Request.Form["title"].ToString().FilterHttpGet(); PPTItem.pptSrc = Request.Form["pptSrc"].ToString().FilterHttpGet(); //PPTItem.thumbnailSrc = Request.Form["thumbnailSrc"].ToString().FilterHttpGet(); PPTItem.description = Request.Form["description"].ToString().FilterHttpGet(); //PPTItem.author = Request.Form["author"].ToString().FilterHttpGet(); PPTItem.updateUser = "******"; PPTItem.author = "test"; PPTItem.updateDate = DateTime.Now; try { PPTItem.validDate = DateTime.Parse(Request.Form["validDate"].ToString()); } catch { PPTItem.validDate = DateTime.Now; } //PPTItem.author = Session["uid"].ToString();//Convert.ToInt32(Session["uid"]); try { //if (PPTItem.classId == 3) //{ HttpPostedFileBase file = Request.Files[0]; string imageName = PPTItem.title + ".jpg"; string path = Server.MapPath(@"/content/thumbnail"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Image img = Image.FromStream(file.InputStream); img.Save(path + @"/" + imageName); PPTItem.thumbnailSrc = @"/content/thumbnail/" + imageName; //} } catch (Exception) { } this.WebUnity.PPTItemRepository.Insert(PPTItem); this.WebUnity.Save(); //lucene //SearchUnit su = new SearchUnit(PPTItem.id.ToString(), PPTItem.showName, PPTItem.suitableModels, PPTItem.description, PPTItem.classId.ToString(), PPTItem.publishDate, PPTItem.hits.ToString(), iscommon); //IndexManager.bookIndex.Add(su, "PPTItem"); } else { //修改原有 //修改记录 PPTItem = this.WebUnity.PPTItemRepository.GetById(Convert.ToInt32(Request.Form["PPTItemid"])); PPTItem.classId = Convert.ToInt32(Request.Form["classid"]); //PPTItem.visible = false;//默认先隐藏ppt PPTItem.title = Request.Form["title"].ToString().FilterHttpGet(); PPTItem.pptSrc = Request.Form["pptSrc"].ToString().FilterHttpGet(); //PPTItem.thumbnailSrc = Request.Form["thumbnailSrc"].ToString().FilterHttpGet(); PPTItem.description = Request.Form["description"].ToString().FilterHttpGet(); //PPTItem.author = Request.Form["author"].ToString().FilterHttpGet(); PPTItem.updateUser = "******"; PPTItem.author = "test"; PPTItem.updateDate = DateTime.Now; try { PPTItem.validDate = DateTime.Parse(Request.Form["validDate"].ToString()); } catch { PPTItem.validDate = DateTime.Now; } //PPTItem.author = Session["uid"].ToString();//Convert.ToInt32(Session["uid"]); try { //if (PPTItem.classId == 3) //{ HttpPostedFileBase file = Request.Files[0]; string imageName = PPTItem.title + ".jpg"; string path = Server.MapPath(@"/content/thumbnail"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Image img = Image.FromStream(file.InputStream); img.Save(path + @"/" + imageName); PPTItem.thumbnailSrc = @"/content/thumbnail/" + imageName; //} } catch (Exception) { } this.WebUnity.PPTItemRepository.Update(PPTItem); this.WebUnity.Save(); //lucene //SearchUnit su = new SearchUnit(PPTItem.id.ToString(), PPTItem.showName, PPTItem.suitableModels, PPTItem.description, PPTItem.classId.ToString(), PPTItem.publishDate, PPTItem.hits.ToString(), iscommon); //IndexManager.bookIndex.Mod(su, "PPTItem"); } ViewData["label"] = "service"; ViewData["state"] = "editPPTItemSuccess"; ViewData["msg"] = "操作成功"; return(View("~/views/cms/PPTItemSave.cshtml")); }