public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; int ciShu = int.Parse(context.Request["ciShu"] ?? "0"); //取数据 Picture.BLL.PictureMoreInfoBLL pictureInfoBll = new Picture.BLL.PictureMoreInfoBLL(); //var models = bllPictureInfo.QueryList(ciShu + 1, 20,new {}, "UploadDate"); User user=context.Session["current_user"] as User; var models = pictureInfoBll.GetPictureInfoWithTagAndUserInfo(ciShu + 1, 20, "UploadDate", true, user != null ? user.UId : -1); //pictureInfoBll.GetPictureInfoWithTagAndUserInfo(ciShu + 1, 20, null, "UploadDate"); IUcClient client = new UcClient(); //构建要发送到前端的数据 List<Model.Picture> list = new List<Model.Picture>(); foreach (var item in models) { list.Add(new Model.Picture() { id=item.PId, imgUrl = CommonHelper.GetSmallImgPath(item.LargeImgPath), //userName = item.UInfo.UserName, userName=item.UserName, //userFace = client.AvatarUrl(item.UInfo.Uid, AvatarSize.Small),//@"assets/img/face/face1.jpg", userFace=client.AvatarUrl(item.UId, AvatarSize.Small), label = item.Tags.Select(t => t.TagName).ToList(), width = item.Width, height = item.Height, uploadDate = item.UploadDate, title = item.ImgSummary, isCollect=item.isCollect>0?1:0 }); } System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer(); context.Response.Write(jss.Serialize(list)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int pId = int.Parse(context.Request["pId"]); Picture.BLL.CommentMore commentBll = new Picture.BLL.CommentMore(); Picture.BLL.PictureMoreInfoBLL pictureInfoBll = new Picture.BLL.PictureMoreInfoBLL(); IUcClient client = new UcClient(); User user = context.Session["current_user"] as User; object commentlist = null; //构建评论信息 if (user != null) { commentlist = commentBll.GetCommentWithUserInfo(new { PId = pId }, "PostDate").Select(c => new { userFace = client.AvatarUrl(c.UId, AvatarSize.Small), content = c.Content, postDate = c.PostDate, userName = c.UserName, cId = c.CId, isMe = c.UId == user.UId ? true : false }); } else { commentlist = commentBll.GetCommentWithUserInfo(new { PId = pId }, "PostDate").Select(c => new { userFace = client.AvatarUrl(c.UId, AvatarSize.Small), content = c.Content, postDate = c.PostDate, cId = c.CId, userName = c.UserName, }); } //获得图片信息 var pictureInfo = pictureInfoBll.GetSinglePictureInfoWithTagAndUserInfo(pId, user==null?-1:user.UId); //把数据整合并返回 var result = new { url = pictureInfo.LargeImgPath, uploadDate = pictureInfo.UploadDate, tags = pictureInfo.Tags, summary = pictureInfo.ImgSummary, collectCount=pictureInfo.CollectCount, userInfo = new { //userName = pictureInfo.UInfo.UserName, //userStatus = pictureInfo.UInfo.UserStatus, //userFace = client.AvatarUrl(pictureInfo.UInfo.Uid, AvatarSize.Small) userName = pictureInfo.UserName, userStatus = pictureInfo.UserStatus, userFace = client.AvatarUrl(pictureInfo.UId, AvatarSize.Small) }, commentlist = commentlist, isCollect = pictureInfo.isCollect }; context.Response.Write(JSONHelper.ToJSONString(result)); }