private void SaveDetail(string PId) { IList <string> entStrList = RequestData.GetList <string>("detail"); IList <ImgNewDetail> ocdEnts = ImgNewDetail.FindAllByProperty(ImgNewDetail.Prop_PId, ent.Id); foreach (ImgNewDetail ocdEnt in ocdEnts) { ocdEnt.DoDelete(); } if (entStrList != null && entStrList.Count > 0) { ocdEnts = entStrList.Select(tent => JsonHelper.GetObject <ImgNewDetail>(tent) as ImgNewDetail).ToList(); for (int i = 0; i < ocdEnts.Count; i++) { ocdEnts[i].PId = PId; ocdEnts[i].CreateId = UserInfo.UserID; ocdEnts[i].CreateName = UserInfo.Name; ocdEnts[i].CreateTime = DateTime.Now; ocdEnts[i].DoCreate(); if (i == 0) { ent.ShowImg = ocdEnts[i].ImgPath; ent.DoUpdate(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string Id = Request.QueryString["id"]; ImgNews news = ImgNews.TryFind(Id); if (news == null) { return; } if (news.State == "2") { news.Ext1 = news.Ext1 == null ? "1" : (Convert.ToInt32(news.Ext1) + 1) + ""; news.DoUpdate(); } if (news != null) { this.lbltitle.InnerText = news.Title; this.lblPostDeptName.InnerText = news.PostDeptName; this.lblAuthorName.InnerText = news.CreateName; this.lblPostTime.InnerText = news.PostTime != null?news.PostTime.ToString() : ""; this.lblReadCount.InnerText = news.Ext1; if ((news.Ext2 + "").Contains(UserInfo.UserID)) { lblreadstate.Attributes.Add("style", "display:none"); } ImgNewDetail[] imgdetails = ImgNewDetail.FindAllByProperty("PId", news.Id); int index = 0; foreach (ImgNewDetail ent in imgdetails) { litimg.Text += "<img src='/Document/" + ent.ImgPath + "' width='780' height='570'/>"; litcontent.Text += "<p id='p" + index + "' style='margin-top:20px;'>" + ent.Content + "</p>"; litimgs.Text += "<li><img src='/Document/" + ent.ImgPath + "'/><tt></tt></li>"; index++; } CollectionToUser[] cts = CollectionToUser.FindAllByProperties("MsgId", news.Id, "UserId", UserInfo.UserID); hidcollection.Value = cts.Length > 0 ? "on" : "off"; } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; if (context.Request["opera"] == "batchcollection") { string Id = context.Request["id"]; if (!string.IsNullOrEmpty(Id)) { //收藏 try { //object[] pram = { new SqlParameter("MsgId", RequestData["Id"]), new SqlParameter("UserId", UserInfo.UserID) }; CollectionToUser[] Ctus = CollectionToUser.FindAll("from CollectionToUser where MsgId='" + Id + "' and UserId='" + UserInfo.UserID + "'"); if (Ctus.Length == 0) { CollectionToUser Ctu = new CollectionToUser(); Ctu.MsgId = Id + ""; Ctu.UserId = UserInfo.UserID; Ctu.CreateId = UserInfo.UserID; Ctu.CreateName = UserInfo.Name; Ctu.DoSave(); context.Response.Write("已收藏"); } else { CollectionToUser.DoBatchDelete(Ctus[0].Id); context.Response.Write("已取消收藏"); } } catch (Exception ex) { context.Response.Write(ex.Message); } } } else if (context.Request["opera"] == "readstate") { string Id = context.Request["id"]; if (!string.IsNullOrEmpty(Id)) { try { ImgNews news = ImgNews.TryFind(Id); if (news != null) { if ((news.Ext2 + "").Contains(UserInfo.UserID)) { return; } news.Ext2 += UserInfo.UserID; news.DoUpdate(); context.Response.Write("标记成功!"); } } catch (Exception ex) { context.Response.Write(ex.Message); } } } }