public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; CY.UME.Core.Business.Account CurrentAccount = CY.UME.Core.Global.GetCurrentAccount(); if (CurrentAccount == null) { context.Response.Write("{success:false,msg:'用户登录超时,请重新登录'}"); return; } string activeId = context.Request.Params["activeid"]; string strFriendId = context.Request.Params["straccountids"];// iFriendId.Value.Trim();//待邀请的人 string[] friendIdArray = strFriendId.Split(','); long friendId = 0; if (string.IsNullOrEmpty(activeId)) { context.Response.Write("{success:false,msg:'邀请加入的活动不存在或已被删除'}"); return; } IList<CY.UME.Core.Business.Notice> noticeList = CY.UME.Core.Business.Notice.GetNoticeByTypeAndInstanceId(CurrentAccount, null, "activeInviteFriend", activeId, new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = int.MaxValue }); for (int i = 0; i < friendIdArray.Length; i++) { if (!long.TryParse(friendIdArray[i].Trim(), out friendId)) continue; CY.UME.Core.Business.Account friend = CY.UME.Core.Business.Account.Load(friendId); if (friend == null) continue; foreach (CY.UME.Core.Business.Notice Notice in noticeList) {//判断是否已经邀请过了。 if (Notice.AuthorId == friend.Id) continue; } CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AccountId = friend.Id; notice.AuthorId = CurrentAccount.Id; notice.Content = "邀请您加入活动"; notice.DateCreated = DateTime.Now; notice.InstanceId = activeId; notice.Type = "activeInviteFriend"; notice.IsReaded = false; notice.Save(); //加入活动ActivitiesInvite表 CY.UME.Core.Business.ActivitiesInvite activeInvite = new CY.UME.Core.Business.ActivitiesInvite(); activeInvite.ActiveitesID = CY.Utility.Common.ConvertUtility.ConvertToInt(activeId, 0); activeInvite.AccountID = CurrentAccount.Id; activeInvite.InviteID = friendId; activeInvite.InviteaTime = DateTime.Now; activeInvite.Save(); } context.Response.Write("{success:true,msg:'邀请完毕页面将自动刷新。'}"); }
/// <summary> /// 审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCheck_Click(object sender, EventArgs e) { try { int id = CY.Utility.Common.ConvertUtility.ConvertToInt(ViewState["id"].ToString(), 0); CY.UME.Core.Business.Activities ac = CY.UME.Core.Business.Activities.Load(id); if (ac != null) { ac.IsCheck = true; ac.Save(); } CY.UME.Core.Business.Notice no = new CY.UME.Core.Business.Notice(); no.AccountId = ac.Sponsor; no.Content = "你发起的活动:" + ac.Name + " 审核通过"; no.Type = "activeCheck"; no.InstanceId = ac.Id.ToString(); no.DateCreated = DateTime.Now; no.Save(); CY.UME.Core.Business.Account Current = CY.UME.Core.Business.Account.Load(ac.Sponsor); if (Current != null) { Current.SendNoticeToAllFriendAndFollower("activites", Current.Name + "创建了新活动:" + ac.Name, ac.Id.ToString()); } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('审核成功');window.location.href='Detail.aspx?id="+id+"'</script>"); } catch (Exception ex) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"","<script>alert('"+ex.Message+"')</script>"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; int groupId = CY.Utility.Common.ConvertUtility.ConvertToInt(context.Request.Form["groupid"], 0); string strFriendId = context.Request.Form["straccountids"].ToString(); CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(groupId); CY.UME.Core.Business.Account CurrentAccount = CY.UME.Core.Global.GetCurrentAccount(); if (group == null) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } string[] friendIdArray = strFriendId.Split(','); long friendId = 0; IList<CY.UME.Core.Business.Notice> noticeList = CY.UME.Core.Business.Notice.GetNoticeByTypeAndInstanceId(CurrentAccount, null, "groupinvite", groupId.ToString(), new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = int.MaxValue }); for (int i = 0; i < friendIdArray.Length; i++) { if (!long.TryParse(friendIdArray[i].Trim(), out friendId)) continue; CY.UME.Core.Business.Account friend = CY.UME.Core.Business.Account.Load(friendId); if (friend == null) continue; foreach (CY.UME.Core.Business.Notice Notice in noticeList) {//判断是否已经邀请过了。 if (Notice.AuthorId == friend.Id) continue; } CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AccountId = friend.Id; notice.AuthorId = CurrentAccount.Id; notice.Content = "邀请您加入群组"; notice.DateCreated = DateTime.Now; notice.InstanceId = group.Id.ToString(); notice.Type = "groupinvite"; notice.IsReaded = false; notice.Save(); } context.Response.Write("{success:true,msg:'邀请好友成功'}"); }
/// <summary> /// 审核不通过,不删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(tbReason.Text.Trim())) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('请填写审核不通过原因');</script>"); tbReason.Focus(); return; } else { //发通知 int id = CY.Utility.Common.ConvertUtility.ConvertToInt(ViewState["id"].ToString(), 0); CY.UME.Core.Business.Activities ac = CY.UME.Core.Business.Activities.Load(id); CY.UME.Core.Business.Notice no = new CY.UME.Core.Business.Notice(); no.AccountId = ac.Sponsor; no.Content = "你发起的活动:" + ac.Name + ",审核不通过,原因:"+tbReason.Text.Trim(); no.Type = "activeCheckNo"; no.DateCreated = DateTime.Now; no.InstanceId = ac.Id.ToString(); no.Save(); //CY.UME.Core.Business.Account Current = CY.UME.Core.Business.Account.Load(ac.Sponsor); //if (Current != null) //{ // Current.SendNoticeToAllFriendAndFollower("activites", Current.Name + "创建了新活动:" + ac.Name, ac.Id.ToString()); //} //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('审核成功');window.location.href='Detail.aspx?id=" + id + "'</script>"); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('审核完成');window.location.href='Detail.aspx?id=" + id + "'</script>"); //int id = CY.Utility.Common.ConvertUtility.ConvertToInt(ViewState["id"].ToString(), 0); //CY.UME.Core.Business.Activities ac = CY.UME.Core.Business.Activities.Load(id); //if (id != null) //{ // ac.DeleteOnSave(); // ac.Save(); //} //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('删除成功');window.location.href='CheckActive.aspx'</script>"); } } catch (Exception ex) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('" + ex.Message + "')</script>"); } }
/// <summary> /// 审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCheck_Click(object sender, EventArgs e) { try { for (int i = 0; i < gvActive.Rows.Count; i++) { CheckBox cb = (CheckBox)gvActive.Rows[i].FindControl("chkState"); if (cb.Checked) { int id = int.Parse(gvActive.DataKeys[i].Value.ToString()); CY.UME.Core.Business.Activities active = CY.UME.Core.Business.Activities.Load(id); if (active != null) { active.IsCheck = true; active.Save(); } CY.UME.Core.Business.Notice no = new CY.UME.Core.Business.Notice(); no.AccountId = active.Sponsor; no.Content ="你发起的活动:"+active.Name+"审核通过"; no.Type = "activeCheck"; no.InstanceId = active.Id.ToString(); no.DateCreated = DateTime.Now; no.Save(); CY.UME.Core.Business.Account Current = CY.UME.Core.Business.Account.Load(active.Sponsor); if (Current != null) { Current.SendNoticeToAllFriendAndFollower("activites", Current.Name + "创建了新活动:" + active.Name, active.Id.ToString()); } } } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('审核成功');window.location.href='CheckActive.aspx'</script>"); } catch (Exception ex) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('" + ex.Message + "');window.location.href='Login.aspx'</script>"); } }
protected void CreatAlbum_OnClick(object sebder, EventArgs e) { int groupId = 0; CY.UME.Core.Business.Group group; #region validate if (TBXAlbumName.Text.Trim().Length == 0) { ShowAlert("提示", "相册名不能为空"); return; } if (HF_groupId.Value != "" && int.TryParse(HF_groupId.Value.ToString(), out groupId)) { group = CY.UME.Core.Business.Group.Load(groupId); if (group == null) { throw new Exception("该群组不存在或已被删除"); } } else { throw new Exception("参数错误"); } #endregion #region creat album int viewPermission = 1; int.TryParse(selViewPermission.Value, out viewPermission); long albumId = 0; CY.UME.Core.Business.Album album = new CY.UME.Core.Business.Album(); if (HF_albumId.Value != "" && long.TryParse(HF_albumId.Value.ToString(), out albumId)) { album = CY.UME.Core.Business.Album.Load(albumId); if (album == null) { album = group.CreateGroupAlbum(TBXAlbumName.Text.Trim(), viewPermission); Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '创建相册成功' });window.location.href='PictureList.aspx?albumId=" + album.Id + "'</script>"); } else { album.Name = TBXAlbumName.Text.Trim(); album.ViewPermission = int.Parse(selViewPermission.Value); album.Save(); Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '修改相册成功' });window.location.href='PictureList.aspx?albumId=" + album.Id + "'</script>"); } } else { album = group.CreateGroupAlbum(TBXAlbumName.Text.Trim(), viewPermission); Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '创建相册成功' });window.location.href='PictureList.aspx?albumId=" + album.Id + "'</script>"); } #endregion #region upload pic string strPicId = String.Empty; List<HttpPostedFile> hfList = new List<HttpPostedFile>(); if (PortugueseFileUpload1.HasFile) { hfList.Add(PortugueseFileUpload1.PostedFile); } if (PortugueseFileUpload2.HasFile) { hfList.Add(PortugueseFileUpload2.PostedFile); } if (PortugueseFileUpload3.HasFile) { hfList.Add(PortugueseFileUpload3.PostedFile); } if (PortugueseFileUpload4.HasFile) { hfList.Add(PortugueseFileUpload4.PostedFile); } if (PortugueseFileUpload5.HasFile) { hfList.Add(PortugueseFileUpload5.PostedFile); } for (int i = 0; i < hfList.Count; i++) { HttpPostedFile imgFile = hfList[i]; if (imgFile == null || imgFile.ContentLength == 0) { break; } string imgExtention = CY.Utility.Common.FileUtility.GetFileExtension(imgFile.FileName).ToLower(); string imgName = CY.Utility.Common.FileUtility.GetFileName(imgFile.FileName); string appPath = CY.Utility.Common.RequestUtility.CurPhysicalApplicationPath; string dirPath = appPath + "/Content/Group/Album/" + groupId + "/"; string fileName = "/Content/Group/Album/" + groupId + "/" + DateTime.Now.ToString("yyyMMddhhmmss") + DateTime.Now.Millisecond.ToString();//相册图片以加时间命名 System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(dirPath); if (!di.Exists) { di.Create(); } string bImgName = appPath + fileName + "_big" + imgExtention; string mImgName = appPath + fileName + "_middle" + imgExtention; string sImgName = appPath + fileName + "_small" + imgExtention; imgFile.SaveAs(appPath + fileName + imgExtention);//临时保存原始图片 Bitmap bmp = new Bitmap(appPath + fileName + imgExtention); int width = bmp.Width; int height = bmp.Height; bmp.Dispose(); if (height <= width && width >= 600) { height = Convert.ToInt32(width > 600 ? (600f / width) * height : height); width = 600; } else if (width < height && height > 600) { width = Convert.ToInt32(height > 600 ? (600f / height) * width : height); height = 600; } // 将原始图压缩为大缩略图 using (StreamReader reader = new StreamReader(appPath + fileName + imgExtention)) { CY.Utility.Common.ImageUtility.ThumbAsJPG(reader.BaseStream, bImgName, width, height); } if (width > 200) { height = Convert.ToInt32(width > 200 ? (200f / width) * height : height); width = 200; } // 生成图片(好友上传图片最新通知中显示) using (StreamReader reader = new StreamReader(appPath + fileName + imgExtention)) { CY.Utility.Common.ImageUtility.ThumbAsJPG(reader.BaseStream, sImgName, width, height); } if (height <= width && width >= 100) { height = Convert.ToInt32(width > 100 ? (100f / width) * height : height); width = 100; } else if (width < height && height > 100) { width = Convert.ToInt32(height > 100 ? (100f / height) * width : height); height = 100; } // 将大图片压缩为中等缩略图 using (StreamReader reader = new StreamReader(appPath + fileName + imgExtention)) { CY.Utility.Common.ImageUtility.ThumbAsJPG(reader.BaseStream, mImgName, width, height); } try { File.Delete(appPath + fileName + imgExtention); } catch { ; } //更换相册封面 if (album.PhotoCount == 0 || album.CoverPath.Trim().Length == 0) { album.CoverPath = fileName + "_middle" + imgExtention; album.Save(); } //将路径及图片信息保存到数据库 CY.UME.Core.Business.Picture pic = new CY.UME.Core.Business.Picture(); pic.AlbumId = album.Id; pic.BigPath = fileName + "_big" + imgExtention; pic.DateCreated = DateTime.Now; pic.MiddlePath = fileName + "_middle" + imgExtention; pic.Name = CY.Utility.Common.StringUtility.HTMLEncode(imgName.Substring(0, imgName.Length > 30 ? 30 : imgName.Length)); pic.SmallPath = fileName + "_small" + imgExtention; pic.Save(); strPicId += pic.Id.ToString() + ","; //保存pictureextend CY.UME.Core.Business.PictureExtend pe = new CY.UME.Core.Business.PictureExtend(); pe.Id = pic.Id; pe.AccountId = CurrentAccount.Id; pe.ActivityId = "group"; pe.ActivityPicId = "0"; pe.Save(); } if (viewPermission == 0 && strPicId.Length > 0) { IList<CY.UME.Core.Business.Friendship> fsList = CurrentAccount.GetFriendships(); foreach (CY.UME.Core.Business.Friendship fs in fsList) { CY.UME.Core.Business.Notice n = new CY.UME.Core.Business.Notice(); n.AccountId = fs.FriendId; n.AuthorId = fs.AccountId; n.Content = "上传了新照片"; n.DateCreated = DateTime.Now; n.InstanceId = strPicId.Remove(strPicId.Length - 1); n.IsReaded = false; n.Type = "grouppicture"; n.Save(); } } #endregion }
/// <summary> /// 添加图片回复 /// </summary> /// <param name="context"></param> /// <returns>0登录失败 -1 请求失败 -2异常错误 -3该图片不存在或已被删除</returns> public string AddPictureComment(HttpContext context) { string email = String.Empty; CY.UME.Core.Business.AccountExtend accountExtend; CY.UME.Core.Business.Picture picture; long pictureId = 0; long referedId = 0; string content = String.Empty; #region validate if (context.Request.QueryString["email"] == null || context.Request.QueryString["Content"] == null || context.Request.QueryString["PictureId"] == null || !long.TryParse(context.Request.QueryString["PictureId"].ToString(), out pictureId)) { return "-1"; } email = context.Request.QueryString["email"].ToString(); accountExtend = CY.UME.Core.Business.AccountExtend.Load(email); if (accountExtend == null) { return "-1"; } content = context.Request.QueryString["Content"].ToString(); picture = CY.UME.Core.Business.Picture.Load(pictureId); if (picture == null) { return "-3"; } if (context.Request.QueryString["ReferedId"] != null) { long.TryParse(context.Request.QueryString["ReferedId"].ToString(), out referedId); } CY.UME.Core.Business.Album album = CY.UME.Core.Business.Album.Load(picture.AlbumId); if (album == null) { return "-3"; } #endregion try { CY.UME.Core.Business.PictureComment pc = new CY.UME.Core.Business.PictureComment(); pc.AccountId = album.AccountId; pc.AuthorId = accountExtend.Id; pc.Content = CY.Utility.Common.StringUtility.HTMLEncode(content); pc.DateCreated = DateTime.Now; pc.InstanceId = pictureId; if (referedId != 0) { pc.ReferedId = referedId; } pc.Save(); //添加通知 if (accountExtend.Id != album.AccountId || referedId > 0) { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); if (referedId > 0) { CY.UME.Core.Business.PictureComment pcTemp = CY.UME.Core.Business.PictureComment.Load(referedId); if (pcTemp != null) { notice.AccountId = pcTemp.AuthorId; notice.Content = "评论了您的照片"; } else { notice.AccountId = pcTemp.AccountId; notice.Content = "回复了您的照片评论"; } } else { notice.AccountId = album.AccountId; notice.Content = "回复了您的照片评论"; } notice.AuthorId = accountExtend.Id; notice.DateCreated = DateTime.Now; notice.InstanceId = picture.Id.ToString(); notice.IsReaded = false; notice.Type = "picreply"; notice.Save(); } return pc.Id.ToString(); } catch { return "-2"; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; long referedId; // 回复留言的标识 long InstanceId; long msg_accountId;//短信接受者 string content; CY.UME.Core.Business.Account currentAccount; // 留言的用户 CY.UME.Core.Business.Account spaceAccount; // 所在个人主页的用户 CY.UME.Core.Business.FavoritesComment comment = new CY.UME.Core.Business.FavoritesComment(); CY.UME.Core.Business.FavoritesComment referedComment = new CY.UME.Core.Business.FavoritesComment(); // 所回复的留言 if (!CY.Utility.Common.ParseUtility.TryParseInt64(context.Request.Form["referedId"], out referedId) || !CY.Utility.Common.ParseUtility.TryParseInt64(context.Request.Form["InstanceId"], out InstanceId)) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } currentAccount = CY.UME.Core.Global.GetCurrentAccount(); if (currentAccount == null) { context.Response.Write("{success:false,IsLoginOut:true,msg:'登录超时,请重新登录'}"); return; } // 所回复的留言 if (referedId > 0) { referedComment = CY.UME.Core.Business.FavoritesComment.Load(referedId); if (referedComment == null) { context.Response.Write("{success:false,msg:'所回复的用户已被删除'}"); return; } } // 留言内容 content = context.Request.Form["content"]; if (string.IsNullOrEmpty(content)) { context.Response.Write("{success:false,msg:'留言内容不能为空'}"); return; } #region Leave Msg,Notice // 将留言或者回复信息发送给空间主人 CY.UME.Core.Business.Favorites favorite = CY.UME.Core.Business.Favorites.Load(InstanceId); if (favorite == null) { context.Response.Write("{success:false,msg:'该状态不存在或已被删除'}"); return; } spaceAccount = CY.UME.Core.Business.Account.Load(favorite.AccountId); if (spaceAccount == null) { return; } comment.AccountId = favorite.AccountId; comment.Content = content; comment.ReferedId = referedId; comment.AuthorId = currentAccount.Id; comment.DateCreated = DateTime.Now; comment.InstanceId = InstanceId; comment.IP = CY.Utility.Common.RequestUtility.ClientIP; comment.Save(); msg_accountId = comment.AccountId; if (favorite.AccountId != currentAccount.Id) { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AuthorId = comment.AuthorId; notice.IsReaded = false; notice.DateCreated = DateTime.Now; notice.InstanceId = InstanceId.ToString(); notice.Type = "favoritereply"; if (referedComment.Id > 0) { notice.AccountId = referedComment.AuthorId; if (referedComment.AuthorId == favorite.AccountId) { notice.Content = "回复了您的评论"; } else { notice.Content = "回复了您在 " + spaceAccount.Name + " 处的评论"; } } else { notice.AccountId = favorite.AccountId; notice.Content = "评论了您的收藏"; } notice.Save(); } else //对自己的状态回复 { if (referedComment != null && referedComment.Id > 0 && referedComment.AuthorId != currentAccount.Id) // 为回复他人 { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AuthorId = comment.AuthorId; notice.IsReaded = false; notice.DateCreated = DateTime.Now; notice.Type = "favoritereply"; notice.AccountId = referedComment.AuthorId; notice.Content = "回复了您的评论"; notice.InstanceId = InstanceId.ToString(); notice.Save(); } } favorite.ReplyNum += 1;//更新回复数 favorite.Save(); #endregion StringBuilder sb = new StringBuilder(); sb.Append("{success:true, msg: '添加成功!', account: {"); sb.Append("Id: " + comment.AuthorId); sb.Append(", Name:'"); sb.Append(currentAccount.Name); sb.Append("'}, commentId: "); sb.Append(comment.Id); sb.Append("}"); context.Response.Write(sb.ToString()); }
/// <summary> /// 提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InviteFriend_OnClick(object sender, EventArgs e) { string strFriendId = iFriendId.Value.Trim();//待邀请的人 string[] friendIdArray = strFriendId.Split(','); long friendId = 0; if (ViewState["ActiveID"] == null) { ShowAlert("提示", "邀请加入的活动不存在或已被删除"); return; } for (int i = 0; i < friendIdArray.Length; i++) { if (!long.TryParse(friendIdArray[i].Trim(), out friendId)) { continue; } CY.UME.Core.Business.Account friend = CY.UME.Core.Business.Account.Load(friendId); if (friend == null) { continue; } IList<CY.UME.Core.Business.Notice> noticeList = CY.UME.Core.Business.Notice.GetNoticeByTypeAndInstanceId(CurrentAccount, null, "activeInviteFriend", ViewState["ActiveID"].ToString(), new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = int.MaxValue }); if (noticeList.Count > 0) { continue; } CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AccountId = friend.Id; notice.AuthorId = CurrentAccount.Id; notice.Content = "邀请您加入活动"; notice.DateCreated = DateTime.Now; notice.InstanceId = ViewState["ActiveID"].ToString(); notice.Type = "activeInviteFriend"; notice.IsReaded = false; notice.Save(); //加入活动ActivitiesInvite表 CY.UME.Core.Business.ActivitiesInvite activeInvite = new CY.UME.Core.Business.ActivitiesInvite(); activeInvite.ActiveitesID = CY.Utility.Common.ConvertUtility.ConvertToInt(ViewState["ActiveID"].ToString(), 0); activeInvite.AccountID = CurrentAccount.Id; activeInvite.InviteID = friendId; activeInvite.InviteaTime = DateTime.Now; activeInvite.Save(); } Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '提示', content: '邀请好友成功'});window.location.href='ActiveDetail2.aspx?aid=" +ViewState["ActiveID"].ToString() + "'</script>"); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; try { long instanceId; // 空间用户的标识 || 群Id long referedId; // 回复留言的标识 string content; string type = String.Empty;//类型(SpaceCommentExtend) CY.UME.Core.Business.Account currentAccount; // 留言的用户 CY.UME.Core.Business.Account spaceAccount = new CY.UME.Core.Business.Account(); // 所在个人主页的用户 CY.UME.Core.Business.SpaceComment referedComment = new CY.UME.Core.Business.SpaceComment(); // 所回复的留言 CY.UME.Core.Business.SpaceComment comment = new CY.UME.Core.Business.SpaceComment(); // 留言 CY.UME.Core.Business.Group group = new CY.UME.Core.Business.Group();//群组 CY.UME.Core.Business.Activities active = new CY.UME.Core.Business.Activities();//活动 #region Validateion and Get Basic Data if (!CY.Utility.Common.ParseUtility.TryParseInt64(context.Request.Form["uid"], out instanceId) || !CY.Utility.Common.ParseUtility.TryParseInt64(context.Request.Form["referedId"], out referedId)) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } if (context.Request.Form["type"] != null) { type = context.Request.Form["type"].ToString(); } currentAccount = CY.UME.Core.Global.GetCurrentAccount(); if (currentAccount == null) { context.Response.Write("{success:false,msg:'登录超时,请重新登录'}"); return; } // 所在个人主页的用户 if (instanceId == 0 && type.Length == 0) { instanceId = currentAccount.Id; spaceAccount = currentAccount; } else if (type.Length == 0) { spaceAccount = CY.UME.Core.Business.Account.Load(instanceId); if (spaceAccount == null) { context.Response.Write("{success:false,msg:'用户不存在'}"); return; } } else if (type == "group") { group = CY.UME.Core.Business.Group.Load((int)instanceId); if (group == null) { context.Response.Write("{success:false,msg:'该群组不存在或已被删除'}"); return; } } else if (type == "active") { active = CY.UME.Core.Business.Activities.Load((int)instanceId); if (active == null) { context.Response.Write("{success:false,msg:'该活动不存在或已被删除'}"); return; } } // 所回复的留言 if (referedId > 0) { referedComment = CY.UME.Core.Business.SpaceComment.Load(referedId); if (referedComment == null) { context.Response.Write("{success:false,msg:'所回复的留言已被删除'}"); return; } } // 留言内容 content = context.Request.Form["content"]; if (string.IsNullOrEmpty(content)) { context.Response.Write("{success:false,msg:'留言内容不能为空'}"); return; } #endregion #region Leave Msg,Notice if (type.Length == 0)//个人空间留言 { // 将留言或者回复信息发送给空间主人 comment.AccountId = spaceAccount.Id; comment.Content = content; comment.IsPublic = (context.Request.Form["isPublic"] == "0") ? false : true; comment.ReferedId = referedId; comment.AuthorId = currentAccount.Id; comment.DateCreated = DateTime.Now; comment.InstanceId = 0; comment.IP = CY.Utility.Common.RequestUtility.ClientIP; comment.Save(); if (spaceAccount.Id != currentAccount.Id) // 不是在自己空间,留言则通知空间主人,回复则通知所回复的留言的作者 { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AuthorId = comment.AuthorId; notice.IsReaded = false; notice.DateCreated = DateTime.Now; notice.InstanceId = comment.Id.ToString(); if (comment.ReferedId < 1) // 留言 { notice.Type = "info"; notice.AccountId = instanceId; //notice.Content = currentAccount.Name + "给您留言了"; notice.Content = "给您留言了"; notice.Save(); } else // 回复 { if (referedComment.Id > 0) { notice.Type = "inforeply"; notice.AccountId = referedComment.AuthorId; if (referedComment.AuthorId == spaceAccount.Id) // 回复空间主人 { //notice.Content = currentAccount.Name + "回复了您的留言"; notice.Content = "回复了您的留言"; } else // 在别人页面回复了另外一个人 { //notice.Content = currentAccount.Name + "回复了您在 " + spaceAccount.Name + " 处的留言"; notice.Content = "回复了您在 " + spaceAccount.Name + " 处的留言"; // 在所引用的留言的作者处添加一条回复副本 CY.UME.Core.Business.SpaceComment commentCopy = new CY.UME.Core.Business.SpaceComment(); commentCopy.AccountId = referedComment.AuthorId; commentCopy.AuthorId = currentAccount.Id; commentCopy.Content = comment.Content; commentCopy.DateCreated = comment.DateCreated; commentCopy.InstanceId = comment.InstanceId; commentCopy.IP = comment.IP; commentCopy.IsPublic = comment.IsPublic; commentCopy.ReferedId = comment.ReferedId; commentCopy.Save(); notice.InstanceId = commentCopy.Id.ToString(); } notice.Save(); } } } else // 在自己空间内 { if (referedComment.Id > 0 && referedComment.AuthorId != currentAccount.Id) // 为回复他人 { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AuthorId = comment.AuthorId; notice.IsReaded = false; notice.DateCreated = DateTime.Now; notice.Type = "inforeply"; notice.AccountId = referedComment.AuthorId; //notice.Content = currentAccount.Name + "回复了您的留言"; notice.Content = "回复了您的留言"; // 在所引用的留言的作者处添加一条回复副本,方便其在他的个人空间内查看到 CY.UME.Core.Business.SpaceComment commentCopy = new CY.UME.Core.Business.SpaceComment(); commentCopy.AccountId = referedComment.AuthorId; commentCopy.AuthorId = currentAccount.Id; commentCopy.Content = comment.Content; commentCopy.DateCreated = comment.DateCreated; commentCopy.InstanceId = comment.InstanceId; commentCopy.IP = comment.IP; commentCopy.IsPublic = comment.IsPublic; commentCopy.ReferedId = comment.ReferedId; commentCopy.Save(); notice.InstanceId = commentCopy.Id.ToString(); notice.Save(); } } } else if (type == "group")//群留言 { //保存留言 comment.AuthorId = currentAccount.Id; comment.AccountId = 0; comment.Content = content; comment.DateCreated = DateTime.Now; comment.InstanceId = group.Id; comment.IP = CY.Utility.Common.RequestUtility.ClientIP; comment.IsPublic = true; comment.ReferedId = referedId; comment.Save(); //保存到留言扩展信息 CY.UME.Core.Business.SpaceCommentExtend spaceCommentExtend = new CY.UME.Core.Business.SpaceCommentExtend(); spaceCommentExtend.AccountId = group.CreatorId; spaceCommentExtend.Id = comment.Id; spaceCommentExtend.InstanceId = group.Id.ToString(); spaceCommentExtend.Type = "group"; spaceCommentExtend.Save(); //留言回复通知 if (referedId > 0 && referedComment.AuthorId != currentAccount.Id) { CY.UME.Core.Business.Notice groupLeaveWordsNotice = new CY.UME.Core.Business.Notice(); groupLeaveWordsNotice.AccountId = referedComment.AuthorId; groupLeaveWordsNotice.AuthorId = comment.AuthorId; groupLeaveWordsNotice.Content = "回复了您的留言"; groupLeaveWordsNotice.DateCreated = DateTime.Now; groupLeaveWordsNotice.InstanceId = comment.InstanceId.ToString(); groupLeaveWordsNotice.IsReaded = false; groupLeaveWordsNotice.Type = "groupinforeply"; groupLeaveWordsNotice.Save(); } } else if (type == "active")//活动留言 { //保存留言 comment.AuthorId = currentAccount.Id; comment.AccountId = active.Sponsor; comment.Content = content; comment.DateCreated = DateTime.Now; comment.InstanceId = active.Id; comment.IP = CY.Utility.Common.RequestUtility.ClientIP; comment.IsPublic = true; comment.ReferedId = referedId; comment.Save(); //保存到留言扩展信息 CY.UME.Core.Business.SpaceCommentExtend spaceCommentExtend = new CY.UME.Core.Business.SpaceCommentExtend(); spaceCommentExtend.AccountId = active.Sponsor; spaceCommentExtend.Id = comment.Id; spaceCommentExtend.InstanceId = active.Id.ToString(); spaceCommentExtend.Type = "active"; spaceCommentExtend.Save(); //留言回复通知 if (referedId > 0 && referedComment.AuthorId != currentAccount.Id) { CY.UME.Core.Business.Notice groupLeaveWordsNotice = new CY.UME.Core.Business.Notice(); groupLeaveWordsNotice.AccountId = referedComment.AuthorId; groupLeaveWordsNotice.AuthorId = comment.AuthorId; groupLeaveWordsNotice.Content = "回复了您的留言"; groupLeaveWordsNotice.DateCreated = DateTime.Now; groupLeaveWordsNotice.InstanceId = comment.InstanceId.ToString(); groupLeaveWordsNotice.IsReaded = false; groupLeaveWordsNotice.Type = "activeinforeply"; groupLeaveWordsNotice.Save(); } } #endregion StringBuilder sb = new StringBuilder(); sb.Append("{success:true, msg: '添加成功!', account: {"); sb.Append("Id: " + comment.AuthorId); sb.Append(", Name: '"); sb.Append(currentAccount.Name); sb.Append("'}, commentId: "); sb.Append(comment.Id); sb.Append("}"); context.Response.Write(sb.ToString()); } catch (Exception ex) { context.Response.Write("{success:false, msg:'添加失败!错误信息:" + CY.Utility.Common.StringUtility.RemoveIllegalCharacters(ex.Message) + "'}"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; CY.UME.Core.Business.Account account; CY.UME.Core.Business.MiniBlog miniBlog; long miniBlogId = 0; string content = String.Empty; string strReplyedId = String.Empty; #region validate if (context.Request.Form["MiniBlogId"] == null || !long.TryParse(context.Request.Form["MiniBlogId"].ToString(), out miniBlogId)) { context.Response.Write("{success:false,msg:'操作失败'}"); return; } if (context.Request.Form["Content"] != null) { content = context.Request.Form["Content"].ToString().Trim(); content = Utility.Common.StringUtility.HTMLEncode(content); content = Regex.Replace(content, @"(http:\/\/[\w.]+\/?)([^\u4e00-\u9fa5|\u0020]*)", "<a href=\"$1$2\">$1$2</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline); } if (context.Request.Form["strReplyedMinBlogId"] != null) { strReplyedId = context.Request.Form["strReplyedMinBlogId"].ToString().Trim(); } account = CY.UME.Core.Global.GetCurrentAccount(); if (account == null) { context.Response.Write("{success:false,msg:'登录超时失败'}"); return; } miniBlog = CY.UME.Core.Business.MiniBlog.Load(miniBlogId); if (miniBlog == null) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } if (account.Id == miniBlog.AccountId) { context.Response.Write("{success:false,msg:'不能转发自己的博文'}"); return; } CY.UME.Core.Business.Account accountRefered = CY.UME.Core.Business.Account.Load(miniBlog.AccountId); if (accountRefered == null) { context.Response.Write("{success:false,msg:'您无法转发该篇博文'}"); return; } if (miniBlog.HasTransedByThisAccount(account)) { context.Response.Write("{success:false,msg:'您已经转发过该篇博文'}"); return; } #endregion try { CY.UME.Core.Business.MiniBlog newMiniBlog = new CY.UME.Core.Business.MiniBlog(); newMiniBlog.AccountId = account.Id; newMiniBlog.Content = content; newMiniBlog.DatePublish = DateTime.Now; newMiniBlog.IP = CY.Utility.Common.RequestUtility.ClientIP; newMiniBlog.Save(); string imgPath = String.Empty; string flashPath = String.Empty; CY.UME.Core.Business.MiniBlogExtend miniBlogExtend = CY.UME.Core.Business.MiniBlogExtend.Load(miniBlog.Id); if (miniBlogExtend != null) { imgPath = miniBlogExtend.ImgPath; flashPath = miniBlogExtend.Video; } CY.UME.Core.Business.MiniBlogExtend newMiniBlogExtend = new CY.UME.Core.Business.MiniBlogExtend(); newMiniBlogExtend.AccountId = newMiniBlog.AccountId; newMiniBlogExtend.Id = newMiniBlog.Id; newMiniBlogExtend.ImgPath = imgPath; newMiniBlogExtend.Video = flashPath; newMiniBlogExtend.IsMsgReceived = false; newMiniBlogExtend.IsPhoneSended = false; newMiniBlogExtend.ReferedId = miniBlog.Id; newMiniBlogExtend.ReferedName = accountRefered.Name; newMiniBlogExtend.ReferedAuthorId = accountRefered.Id; newMiniBlogExtend.TransferedNum = 0; newMiniBlogExtend.Save(); account.SendNoticeToAllFriendAndFollower("miniblog", "转发了一篇微博", newMiniBlog.Id.ToString()); CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AccountId = newMiniBlogExtend.AccountId; notice.AuthorId = newMiniBlogExtend.AccountId; notice.Content = "转发了一篇微博"; notice.DateCreated = DateTime.Now; notice.InstanceId = newMiniBlogExtend.Id.ToString(); notice.IsReaded = false; notice.Type = "miniblog"; notice.Save(); #region Reply string strReplyedIdTemp = String.Empty; string[] arrReplyedId = strReplyedId.Split(','); for (int i = 0; i < arrReplyedId.Length; i++) { strReplyedIdTemp = arrReplyedId[i]; long replyedId = 0; if (long.TryParse(strReplyedIdTemp, out replyedId)) { CY.UME.Core.Business.MiniBlog replyedMiniBlog = CY.UME.Core.Business.MiniBlog.Load(replyedId); if (replyedMiniBlog != null) { CY.UME.Core.Business.MiniBlogComment mbc = new CY.UME.Core.Business.MiniBlogComment(); mbc.AccountId = replyedMiniBlog.AccountId; mbc.AuthorId = account.Id; mbc.Content = content; mbc.DateCreated = DateTime.Now; mbc.IP = Utility.Common.RequestUtility.ClientIP; mbc.InstanceId = replyedMiniBlog.Id; mbc.Save(); CY.UME.Core.Business.Notice noticeTemp = new CY.UME.Core.Business.Notice(); noticeTemp.AccountId = replyedMiniBlog.AccountId; noticeTemp.AuthorId = mbc.AuthorId; noticeTemp.Content = "评论了您的微博"; noticeTemp.DateCreated = DateTime.Now; noticeTemp.InstanceId = replyedId.ToString(); noticeTemp.IsReaded = false; noticeTemp.Type = "miniblogreply"; noticeTemp.Save(); } } } #endregion context.Response.Write("{success:true}"); } catch { context.Response.Write("{success:false,msg:'服务器忙,请稍后再试'}"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; long spaceId; // 空间用户的标识 long referedId; // 回复留言的标识 long InstanceId; long msg_accountId;//短信接受者 string content; CY.UME.Core.Business.Account currentAccount; // 留言的用户 CY.UME.Core.Business.Account spaceAccount; // 所在个人主页的用户 CY.UME.Core.Business.MiniBlogComment comment = new CY.UME.Core.Business.MiniBlogComment(); CY.UME.Core.Business.MiniBlogComment referedComment = new CY.UME.Core.Business.MiniBlogComment(); // 所回复的留言 if (!CY.Utility.Common.ParseUtility.TryParseInt64(context.Request["spaceId"], out spaceId) || !CY.Utility.Common.ParseUtility.TryParseInt64(context.Request["referedId"], out referedId) || !CY.Utility.Common.ParseUtility.TryParseInt64(context.Request["InstanceId"], out InstanceId)) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } currentAccount = CY.UME.Core.Business.Account.Load(spaceId); if (currentAccount == null) { context.Response.Write("{success:false,msg:'用户不存在'}"); return; } // 所在个人主页的用户 if (spaceId == 0) { spaceId = currentAccount.Id; spaceAccount = currentAccount; } else { spaceAccount = CY.UME.Core.Business.Account.Load(spaceId); if (spaceAccount == null) { context.Response.Write("{success:false,msg:'用户不存在'}"); return; } } // 所回复的留言 if (referedId > 0) { referedComment = CY.UME.Core.Business.MiniBlogComment.Load(referedId); if (referedComment == null) { context.Response.Write("{success:false,msg:'所回复的用户已被删除'}"); return; } } // 留言内容 content = context.Request["content"]; if (string.IsNullOrEmpty(content)) { context.Response.Write("{success:false,msg:'留言内容不能为空'}"); return; } #region Leave Msg,Notice // 将留言或者回复信息发送给空间主人 CY.UME.Core.Business.MiniBlog miniblog = CY.UME.Core.Business.MiniBlog.Load(InstanceId); if (miniblog == null) { context.Response.Write("{success:false,msg:'该状态不存在或已被删除'}"); return; } comment.AccountId = miniblog.AccountId; comment.Content = content; comment.ReferedId = referedId; comment.AuthorId = currentAccount.Id; comment.DateCreated = DateTime.Now; comment.InstanceId = InstanceId; comment.IP = CY.Utility.Common.RequestUtility.ClientIP; comment.Save(); msg_accountId = comment.AccountId; if (miniblog.AccountId != currentAccount.Id) // 回复其他人 { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AuthorId = comment.AuthorId; notice.IsReaded = false; notice.DateCreated = DateTime.Now; notice.InstanceId = InstanceId.ToString(); notice.Type = "miniblogreply"; if (referedComment.Id > 0) { notice.AccountId = referedComment.AuthorId; if (referedComment.AuthorId == miniblog.AccountId) // 回复空间主人 { notice.Content = "回复了您的评论"; } else // 在别人页面回复了另外一个人 { notice.Content = "回复了您在 " + spaceAccount.Name + " 处的评论"; // 在所引用的作者处添加一条回复副本 CY.UME.Core.Business.MiniBlogComment commentCopy = new CY.UME.Core.Business.MiniBlogComment(); commentCopy.AccountId = referedComment.AuthorId; commentCopy.AuthorId = currentAccount.Id; commentCopy.Content = comment.Content; commentCopy.DateCreated = comment.DateCreated; commentCopy.InstanceId = comment.InstanceId; commentCopy.IP = comment.IP; commentCopy.ReferedId = comment.ReferedId; commentCopy.Save(); msg_accountId = commentCopy.AccountId; } } else { notice.AccountId = miniblog.AccountId; notice.Content = "评论了您的状态"; } notice.Save(); } else //对自己的状态回复 { if (referedComment != null && referedComment.Id > 0 && referedComment.AuthorId != currentAccount.Id) // 为回复他人 { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AuthorId = comment.AuthorId; notice.IsReaded = false; notice.DateCreated = DateTime.Now; notice.Type = "miniblogreply"; notice.AccountId = referedComment.AuthorId; notice.Content = "回复了您的评论"; notice.InstanceId = InstanceId.ToString(); notice.Save(); } } #endregion StringBuilder sb = new StringBuilder(); sb.Append("{success:true, msg: '添加成功!', account: {"); sb.Append("Id: " + comment.AuthorId); sb.Append(", Name:'"); sb.Append(currentAccount.Name); sb.Append("'}, commentId: "); sb.Append(comment.Id); sb.Append("}"); context.Response.Write(sb.ToString()); //发送短信给被回复者 if (miniblog.MiniBlogExtend.IsMsgReceived) { CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(msg_accountId); if (ae != null) { string msgcontent = currentAccount.Name + "回复了您:" + comment.Content; string flag = String.Empty; try { CY.UME.Core.Global.TrySendMessage(ae.Telephone, msgcontent, out flag); } catch { } } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; string result = string.Empty; if (context.Request.Params["activeID"] == null) { result = "{success:false,msg:'活动不能为空'}"; } else if (context.Request.Params["accountID"] == null) { result = "{success:false,msg:'用户不能为空'}"; } else { try { int ActiveID = CY.Utility.Common.ConvertUtility.ConvertToInt(context.Request.Params["activeID"].ToString(), 0); long AccountID = CY.Utility.Common.ConvertUtility.ConvertToLong(context.Request.Params["accountID"].ToString(), 0); CY.UME.Core.Business.Activities active = CY.UME.Core.Business.Activities.Load(ActiveID); if (active != null) { if (active.Sponsor == AccountID) { //删除活动 active.DeleteOnSave(); active.Save(); //发送通知 CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(AccountID); if (account != null) { account.SendNoticeToAllFriendAndFollower("delactivites", account.Name + "删除了活动:" + active.Name, active.Id.ToString()); } //删除海报 if (!string.IsNullOrEmpty(active.Pic)) { string pic = active.Pic; if (System.IO.File.Exists(context.Request.MapPath(pic))) { System.IO.File.Delete(context.Request.MapPath(pic)); } string ex = CY.Utility.Common.FileUtility.GetFileExtension(pic);//图片后缀 string nameTemp = CY.Utility.Common.FileUtility.GetFileName(pic); nameTemp = nameTemp.Substring(0, nameTemp.Length - 7); if (System.IO.File.Exists(context.Server.MapPath((nameTemp + "_big" + ex)))) { System.IO.File.Delete(context.Server.MapPath((nameTemp + "_big" + ex))); } if (System.IO.File.Exists(context.Server.MapPath((nameTemp + "_small" + ex)))) { System.IO.File.Delete(context.Server.MapPath((nameTemp + "_small" + ex))); } } //删除活动参与人和感兴趣人 List<CY.UME.Core.Business.ActivitieParticipants> apList = CY.UME.Core.Business.ActivitieParticipants.GetListByActiveID(ActiveID).ToList(); if (apList != null && apList.Count > 0) { for (int i = 0; i < apList.Count; i++) { CY.UME.Core.Business.ActivitieParticipants ap = CY.UME.Core.Business.ActivitieParticipants.Load(apList[i].Id); ap.DeleteOnSave(); ap.Save(); if (apList[i].AccountId != AccountID) { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AuthorId = AccountID; notice.AccountId = ap.AccountId; notice.Type = "delactivites"; notice.InstanceId = ActiveID.ToString(); notice.DateCreated = DateTime.Now; notice.Content = account.Name + "删除了活动:" + active.Name; notice.Save(); } } } //删除活动邀请人 List<CY.UME.Core.Business.ActivitiesInvite> aiList = CY.UME.Core.Business.ActivitiesInvite.GetByActiveID(ActiveID).ToList(); if (aiList != null && aiList.Count > 0) { for (int m = 0; m < aiList.Count; m++) { CY.UME.Core.Business.ActivitiesInvite ai = CY.UME.Core.Business.ActivitiesInvite.Load(aiList[m].Id); ai.DeleteOnSave(); ai.Save(); } } result = "{success:true}"; } else { result = "{success:false,msg:'删除出错,只有发起人才可以删除'}"; return; } } else { result = "{success:false,msg:'删除出错,该活动在其它地方被删除'}"; return; } } catch (Exception ex) { result = "{success:false,msg:'" + ex.Message + "'}"; } } context.Response.Write(result); }
/// <summary> /// 添加回复 /// </summary> /// <returns>0登录失败 -1 请求失败 -2异常错误 -3该微博不存在或已被删除</returns> public string AddMiniBlogComment(HttpContext context) { string email = String.Empty; string content = String.Empty; long referedId = 0; long instanceId = 0; CY.UME.Core.Business.AccountExtend ae; CY.UME.Core.Business.MiniBlog miniBlog; #region validate if (context.Request.QueryString["email"] == null || context.Request.QueryString["Content"] == null || context.Request.QueryString["MiniBlogId"] == null || !long.TryParse(context.Request.QueryString["MiniBlogId"].ToString(), out instanceId)) { return "-1"; } email = context.Request.QueryString["email"].ToString(); ae = CY.UME.Core.Business.AccountExtend.Load(email); if (ae == null) { return "-1"; } content = context.Request.QueryString["Content"].ToString(); miniBlog = CY.UME.Core.Business.MiniBlog.Load(instanceId); if (miniBlog == null) { return "-3"; } if (context.Request.QueryString["referedId"] != null) { long.TryParse(context.Request.QueryString["referedId"].ToString(), out referedId); } #endregion try { CY.UME.Core.Business.MiniBlogComment mbc = new CY.UME.Core.Business.MiniBlogComment(); mbc.AccountId = miniBlog.AccountId; mbc.AuthorId = ae.Id; mbc.DateCreated = DateTime.Now; mbc.Content = content; mbc.InstanceId = instanceId; mbc.ReferedId = referedId; mbc.Save(); //添加通知 if (ae.Id != miniBlog.AccountId || referedId > 0) { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); if (referedId > 0) { CY.UME.Core.Business.MiniBlogComment mbcTemp = CY.UME.Core.Business.MiniBlogComment.Load(referedId); if (mbcTemp != null) { notice.AccountId = mbcTemp.AuthorId; notice.Content = "回复了您的评论"; } else { notice.AccountId = miniBlog.AccountId; notice.Content = "回复了您"; } } else { notice.AccountId = miniBlog.AccountId; notice.Content = "回复了您"; } notice.AuthorId = ae.Id; notice.DateCreated = DateTime.Now; notice.InstanceId = miniBlog.Id.ToString(); notice.IsReaded = false; notice.Type = "miniblogreply"; notice.Save(); } return mbc.Id.ToString(); } catch { return "-2"; } }
private string Creatjson(CY.UME.Core.Business.Account currentAccount, string pageSize, string pageNum) { StringBuilder json = new StringBuilder(); try { currentAccount.GetUnreadNotice("inforeply"); CY.UME.Core.PagingInfo pageInfo1 = new CY.UME.Core.PagingInfo(); pageInfo1.CurrentPage = 1; pageInfo1.PageSize = int.MaxValue; string[] type = { "friend", "groupinvite", "activeInviteFriend" }; List<CY.UME.Core.Business.Notice> NoticeList = CY.UME.Core.Business.Notice.GetNoticeGroupByType(currentAccount, type, false, pageInfo1) as List<CY.UME.Core.Business.Notice>; int infonum = CY.UME.Core.Business.Notice.GetInfoNoticeCount(currentAccount); if (infonum != 0) { CY.UME.Core.Business.Notice newNotice = new CY.UME.Core.Business.Notice(); newNotice.Id = infonum; newNotice.Type = "info"; NoticeList.Add(newNotice); } CY.UME.Core.PagingInfo pageInfo = new CY.UME.Core.PagingInfo(); pageInfo.CurrentPage = int.Parse(pageNum); pageInfo.PageSize = int.Parse(pageSize); string[] type1 = { "activitesinforeply", "blogreply", "miniblogreply", "picreply", "firstpicreply", "topicreply", "groupinforeply", "activeTopicReply", "relativegroup" }; List<CY.UME.Core.Business.Notice> NoticeList1 = CY.UME.Core.Business.Notice.GetNoticeGroupByType(currentAccount, type1, false, pageInfo) as List<CY.UME.Core.Business.Notice>; NoticeList.AddRange(NoticeList1); string[] type2 = { "activeCheckNo" };//审核不通过 List<CY.UME.Core.Business.Notice> NoticeList2 = CY.UME.Core.Business.Notice.GetNoticeGroupByType(currentAccount, type2, false, pageInfo) as List<CY.UME.Core.Business.Notice>; NoticeList.AddRange(NoticeList2); string[] type3 = { "activeCheck" };//审核通过 List<CY.UME.Core.Business.Notice> NoticeList3 = CY.UME.Core.Business.Notice.GetNoticeGroupByType(currentAccount, type3, false, pageInfo) as List<CY.UME.Core.Business.Notice>; NoticeList.AddRange(NoticeList3); if (NoticeList != null && NoticeList.Count > 0) { bool check = false; json.Append("{success:true,"); if (NoticeList.Count < int.Parse(pageSize)) { json.Append("toend:true,"); } else { json.Append("toend:false,"); } json.Append("list:"); json.Append("["); for (int i = 0; i < NoticeList.Count; i++) { switch (NoticeList[i].Type) { case "friend": json.Append("{Count:'" + NoticeList[i].Id + "',Type:'" + NoticeList[i].Type + "'"); break; case "groupinvite": json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); break; case "activeInviteFriend": json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); break; case "info": json.Append("{Count:'" + NoticeList[i].Id + "',Type:'" + NoticeList[i].Type + "'"); break; //case "inforeply": // long inforId; // if (CY.Utility.Common.ParseUtility.TryParseInt64(NoticeList[i].InstanceId, out inforId)) // { // CY.UME.Core.Business.SpaceComment spacecomm = CY.UME.Core.Business.SpaceComment.Load(inforId); // CY.UME.Core.Business.SpaceComment spacecomm2 = CY.UME.Core.Business.SpaceComment.Load(spacecomm.ReferedId); // if (spacecomm2 == null) // { // NoticeList[i].DeleteOnSave(); // NoticeList[i].Save(); // continue; // } // else // { // json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); // json.Append(",SpaceComment:'"); // json.Append(CY.Utility.Common.StringUtility.EscapeString( // CY.Utility.Common.StringUtility.CutString(spacecomm2.Content, 50, "..."))); // json.Append("',SpaceOwerId:'"); // json.Append(spacecomm2.AccountId); // json.Append("'"); // } // } // break; case "blogreply": long blogId; if (CY.Utility.Common.ParseUtility.TryParseInt64(NoticeList[i].InstanceId, out blogId)) { CY.UME.Core.Business.Blog blog = CY.UME.Core.Business.Blog.Load(blogId); if (blog == null) { NoticeList[i].DeleteOnSave(); NoticeList[i].Save(); continue; } else { json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); json.Append(",blogSubject:'"); json.Append(CY.Utility.Common.StringUtility.EscapeString( CY.Utility.Common.StringUtility.CutString(blog.Subject, 50, "..."))); json.Append("',blogOwerId:'"); json.Append(blog.AccountId); json.Append("'"); } } break; case "miniblogreply": long miniblogId; if (CY.Utility.Common.ParseUtility.TryParseInt64(NoticeList[i].InstanceId, out miniblogId)) { CY.UME.Core.Business.MiniBlog miniblog = CY.UME.Core.Business.MiniBlog.Load(miniblogId); if (miniblog == null) { NoticeList[i].DeleteOnSave(); NoticeList[i].Save(); continue; } else { json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); json.Append(",MiniBlogContent:'"); json.Append(CY.Utility.Common.StringUtility.EscapeString( CY.Utility.Common.StringUtility.CutString(miniblog.Content, 50, "..."))); json.Append("',SpaceOwerId:'"); json.Append(miniblog.AccountId); json.Append("'"); } } break; case "picreply": long picId; if (CY.Utility.Common.ParseUtility.TryParseInt64(NoticeList[i].InstanceId, out picId)) { CY.UME.Core.Business.Picture pic = CY.UME.Core.Business.Picture.Load(picId); if (pic == null) { NoticeList[i].DeleteOnSave(); NoticeList[i].Save(); continue; } else { json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); json.Append(",pictureId:'"); json.Append(pic.Id); json.Append("',pictureName:'"); json.Append(CY.Utility.Common.StringUtility.EscapeString(CY.Utility.Common.StringUtility.CutString(pic.Name, 30, "..."))); json.Append("'"); } } break; case "topicreply": if (NoticeList[i].InstanceId.Length > 0) { Guid topicId = new Guid(NoticeList[i].InstanceId); CY.UME.Core.Business.Topic topic = CY.UME.Core.Business.Topic.Load(topicId); CY.UME.Core.Business.TopicExtend topicex = CY.UME.Core.Business.TopicExtend.Load(topicId); CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(int.Parse(topicex.InstanceId)); if (topic == null) { NoticeList[i].DeleteOnSave(); NoticeList[i].Save(); continue; } else { json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); json.Append(",groupId:'"); json.Append(group.Id); json.Append("',groupName:'"); json.Append(CY.Utility.Common.StringUtility.EscapeString(CY.Utility.Common.StringUtility.CutString(group.Name, 30, "...")) + "'"); json.Append(",topicId:'"); json.Append(topicId); json.Append("',topicName:'"); json.Append(CY.Utility.Common.StringUtility.EscapeString(CY.Utility.Common.StringUtility.CutString(topic.Title, 30, "...")) + "'"); } } break; case "groupinforeply": if (NoticeList[i].InstanceId.Length > 0) { int groupinfoId = 0; if (!int.TryParse(NoticeList[i].InstanceId, out groupinfoId)) { continue; } CY.UME.Core.Business.Group groupInfo = CY.UME.Core.Business.Group.Load(groupinfoId); if (groupInfo == null) { continue; } json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); json.Append(",groupId:'" + groupinfoId); json.Append("',groupName:'" + CY.Utility.Common.StringUtility.EscapeString(groupInfo.Name) + "'"); } break; /**************************************************废除的代码/************************************************* case "firstpicreply": if (NoticeList[i].InstanceId.Length > 0) { Guid firstpicId = new Guid(NoticeList[i].InstanceId); CY.UME.Core.Business.FirstDayAccountPic firstpic = CY.UME.Core.Business.FirstDayAccountPic.Load(firstpicId); if (firstpic == null) { NoticeList[i].DeleteOnSave(); NoticeList[i].Save(); continue; } else { json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); json.Append(",firstPictureId:'"); json.Append(firstpicId); json.Append("'"); } } break;*/ case "activitesinforeply": if (NoticeList[i].InstanceId.Length > 0) { int activeId = 0; if (!int.TryParse(NoticeList[i].InstanceId, out activeId)) { continue; } CY.UME.Core.Business.Activities active = CY.UME.Core.Business.Activities.Load(activeId); if (active == null) { continue; } json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); json.Append(",activeId:'" + activeId); json.Append("',activeName:'" + CY.Utility.Common.StringUtility.EscapeString(active.Name) + "'"); } break; case "activeTopicReply": if (NoticeList[i].InstanceId.Length > 0) { Guid topicId = new Guid(); topicId = new Guid(NoticeList[i].InstanceId.ToString()); CY.UME.Core.Business.Topic topic = CY.UME.Core.Business.Topic.Load(topicId); if (topic == null) continue; CY.UME.Core.Business.TopicExtend te = CY.UME.Core.Business.TopicExtend.Load(topicId); if (te == null) continue; CY.UME.Core.Business.Activities active = CY.UME.Core.Business.Activities.Load(int.Parse(te.InstanceId)); if (active == null) { continue; } json.Append("{Count:'" + NoticeList[i].Id + "',InstanceId:'" + NoticeList[i].InstanceId + "',Type:'" + NoticeList[i].Type + "'"); json.Append(",activeId:'" + active.Id); json.Append("',activeName:'" + CY.Utility.Common.StringUtility.EscapeString(active.Name) + "'"); json.Append(",topicID:'" + topic.Id + "'"); json.Append(",topicTitle:'" + CY.Utility.Common.StringUtility.EscapeString(topic.Title) + "'"); } break; case "activeCheck": if (NoticeList[i].InstanceId.Length > 0) { int id = CY.Utility.Common.ConvertUtility.ConvertToInt(NoticeList[i].InstanceId, 0); CY.UME.Core.Business.Activities active = CY.UME.Core.Business.Activities.Load(id); if (active == null) continue; json.Append("{Count:1,InstanceId:'" + NoticeList[i].InstanceId + "'"); json.Append(",Type:'" + NoticeList[i].Type + "'"); json.Append(",activeId:" + active.Id); json.Append(",activeName:'" + CY.Utility.Common.StringUtility.EscapeString(active.Name) + "'"); } break; case "activeCheckNo": if (NoticeList[i].InstanceId.Length > 0) { int id = CY.Utility.Common.ConvertUtility.ConvertToInt(NoticeList[i].InstanceId, 0); CY.UME.Core.Business.Activities active = CY.UME.Core.Business.Activities.Load(id); if (active == null) continue; json.Append("{Count:1,InstanceId:'" + NoticeList[i].InstanceId + "'"); json.Append(",Type:'" + NoticeList[i].Type + "'"); json.Append(",activeId:" + active.Id); json.Append(",activeName:'" + CY.Utility.Common.StringUtility.EscapeString(active.Name) + "'"); json.Append(",content:'" + CY.Utility.Common.StringUtility.EscapeString(NoticeList[i].Content) + "'"); } break; case "relativegroup"://友情小组 if (NoticeList[i].InstanceId.Length > 0) { Guid id = new Guid(NoticeList[i].InstanceId); CY.UME.Core.Business.RelativeGroup rg = CY.UME.Core.Business.RelativeGroup.Load(id); if (rg == null || rg.IsChecked) continue; CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(rg.GroupId); CY.UME.Core.Business.Group relativeGroup = CY.UME.Core.Business.Group.Load(rg.RelativeGroupId); if (group == null || relativeGroup == null) continue; json.Append("{Count:1,InstanceId:'" + NoticeList[i].InstanceId + "'"); json.Append(",Type:'" + NoticeList[i].Type + "'"); json.Append(",groupId:" + rg.GroupId); json.Append(",relativeGroupId:" + rg.RelativeGroupId); json.Append(",content:'" + CY.Utility.Common.StringUtility.EscapeString(NoticeList[i].Content) + "'"); json.Append(",groupName:'" + CY.Utility.Common.StringUtility.EscapeString(group.Name) + "'"); json.Append(",relativeGroupName:'" + CY.Utility.Common.StringUtility.EscapeString(relativeGroup.Name) + "'"); json.Append(",Id:" + NoticeList[i].Id); } break; } json.Append("},"); check = true; } if (check) { json.Remove(json.Length - 1, 1); } json.Append("]}"); } else { json.Append("{success: false, msg: '没有新的回复通知'}"); } } catch { json.Append("{success: false, msg: '服务器忙,请稍后再试'}"); } return json.ToString(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "applicaiton/json"; Guid topicId = Guid.Empty; long referedId = 0; string content = String.Empty; CY.UME.Core.Business.Topic topic; CY.UME.Core.Business.Account currentAccount; if (context.Request.Form["topicId"] == null || context.Request.Form["content"] == null) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } content = context.Request.Form["content"].ToString(); if (context.Request.Form["topicId"].ToString().Length == 0) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } topicId = new Guid(context.Request.Form["topicId"].ToString().Trim()); currentAccount = CY.UME.Core.Global.GetCurrentAccount(); if (currentAccount == null) { context.Response.Write("{success:false,msg:'用户登录超时失败,请重新登录'}"); return; } if (context.Request.Form["referedId"] != null) { long.TryParse(context.Request.Form["referedId"].ToString(), out referedId); } if (referedId != 0) { CY.UME.Core.Business.TopicReply tReply = CY.UME.Core.Business.TopicReply.Load(referedId); if (tReply == null) { context.Response.Write("{success:false,msg:'您所回复的话题评论不存在或已被删除'}"); return; } } topic = CY.UME.Core.Business.Topic.Load(topicId); if (topic == null) { context.Response.Write("{success:false,msg:'您所回复的话题评论不存在或已被删除'}"); return; } CY.UME.Core.Business.TopicExtend teTemp = CY.UME.Core.Business.TopicExtend.Load(topic.Id); int groupId = 0; if (context.Request.Form["TypeInfo"] == null) { if (!int.TryParse(teTemp.InstanceId, out groupId)) { context.Response.Write("{success:false,msg:'您无权回复此话题'}"); return; } CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(groupId); if (group == null) { context.Response.Write("{success:false,msg:'您无权回复此话题'}"); return; } if (group.AddTopicReplyPermission == 1 && !group.CheckIsGroupMember(currentAccount)) { context.Response.Write("{success:false,msg:'您无权回复此话题'}"); return; } } try { //修改最后更新 topic.LastAuthorId = currentAccount.Id; topic.LastReplyDate = DateTime.Now;//最后回复时间 topic.Save(); CY.UME.Core.Business.TopicReply topicReply = new CY.UME.Core.Business.TopicReply(); topicReply.AccountId = topic.AccountId; topicReply.AuthorId = currentAccount.Id; topicReply.Content = content; topicReply.DateCreated = DateTime.Now; topicReply.InstanceId = topic.Id; topicReply.IP = CY.Utility.Common.RequestUtility.ClientIP; if (referedId != 0) { topicReply.ReferedId = referedId; } topicReply.Save(); context.Response.Write("{success:true,Id:" + topicReply.Id + ",AccountName:'" + currentAccount.Name + "',AccountId:" + currentAccount.Id + ",PubDate:'" + topicReply.DateCreated.ToString("yy-MM-dd HH:mm") + "',r:'" + (topic.ReplyNum + 1) + "'}"); CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AuthorId = currentAccount.Id; notice.DateCreated = DateTime.Now; notice.InstanceId = topic.Id.ToString(); notice.IsReaded = false; string typeName = string.Empty; if (context.Request.Form["TypeInfo"] != null) { typeName = "activeTopicReply"; } else { typeName = "topicreply"; } notice.Type = typeName; if (referedId != 0)//回复话题评论 { CY.UME.Core.Business.TopicReply te = CY.UME.Core.Business.TopicReply.Load(topicReply.ReferedId); if (te == null) { return; } notice.AccountId = te.AuthorId; notice.Content = "回复了您的回帖"; } else { notice.AccountId = topic.AccountId; notice.Content = "回复了您的话题"; } if (notice.AccountId != notice.AuthorId) { notice.Save(); } } catch { context.Response.Write("{success:false,msg:'系统忙,请稍后再试'}"); return; } }
/// <summary> /// 0 登录失败 -1请求失败 -2系统错误 1成功 /// </summary> /// <param name="context"></param> /// <returns></returns> public string LeaveWords(HttpContext context) { string email; string content; long accountId = 0; CY.UME.Core.Business.Account spaceAccount; CY.UME.Core.Business.AccountExtend accountExtend; #region validate if (context.Request.QueryString["AccountId"] == null || !long.TryParse(context.Request.QueryString["AccountId"].ToString(), out accountId) || context.Request.QueryString["Content"]==null || context.Request.QueryString["email"]==null) { return "-1"; } content = context.Request.QueryString["Content"].ToString().Trim(); spaceAccount = CY.UME.Core.Business.Account.Load(accountId); email = context.Request.QueryString["email"].ToString().Trim(); accountExtend = CY.UME.Core.Business.AccountExtend.Load(email); if (accountExtend == null) { return "-1"; } #endregion try { CY.UME.Core.Business.SpaceComment spaceComment = new CY.UME.Core.Business.SpaceComment(); spaceComment.AccountId = spaceAccount.Id; spaceComment.AuthorId = accountExtend.Id; spaceComment.Content = context.Server.UrlDecode(content); spaceComment.DateCreated = DateTime.Now; spaceComment.IsPublic = true; spaceComment.Save(); if (accountExtend.Id != spaceAccount.Id) { CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AccountId = spaceAccount.Id; notice.AuthorId = accountExtend.Id; notice.Content = "给您留言了"; notice.DateCreated = DateTime.Now; notice.InstanceId = spaceComment.Id.ToString(); notice.IsReaded = false; notice.Type = "inforeply"; notice.Save(); } return spaceComment.Id.ToString(); } catch { return "-2"; } }
protected void Save_OnClick(object sender, EventArgs e) { string strFriendId = iFriendId.Value.Trim(); string[] friendIdArray = strFriendId.Split(','); long friendId = 0; if (ViewState["groupId"] == null) { ShowAlert("提示", "邀请加入的群组不存在或已被删除"); return; } for (int i = 0; i < friendIdArray.Length; i++) { if (!long.TryParse(friendIdArray[i].Trim(), out friendId)) { continue; } CY.UME.Core.Business.Account friend = CY.UME.Core.Business.Account.Load(friendId); if (friend == null) { continue; } IList<CY.UME.Core.Business.Notice> noticeList = CY.UME.Core.Business.Notice.GetNoticeByTypeAndInstanceId(CurrentAccount, null, "groupinvite", ViewState["groupId"].ToString(), new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = int.MaxValue }); if (noticeList.Count > 0) { continue; } CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice(); notice.AccountId = friend.Id; notice.AuthorId = CurrentAccount.Id; notice.Content = "邀请您加入群组"; notice.DateCreated = DateTime.Now; notice.InstanceId = ViewState["groupId"].ToString(); notice.Type = "groupinvite"; notice.IsReaded = false; notice.Save(); } Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '提示', content: '邀请好友成功'});window.location.href='Group.aspx?groupId=" + ViewState["groupId"].ToString() + "'</script>"); }