/// <summary> /// 删除回复 /// </summary> /// <param name="id"></param> /// <param name="level"></param> /// <returns></returns> public JsonResult DelReply(int id, int level) { JsonModel jm = new JsonModel(); try { IPostBarTopicDiscussBLL topicDiscussBll = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var topicDiscuss = topicDiscussBll.GetEntity(p => p.Id == id); if (topicDiscuss == null) { jm.Msg = "该回复不存在"; } else { if (level == 1) { topicDiscussBll.DeleteLevelOneDiscuss(id); } else { topicDiscussBll.Delete(topicDiscuss); } } } catch { jm.Msg = "删除发生异常"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public JsonResult ReplyFloor(TopicFloorDetailModel model) { JsonModel jm = new JsonModel(); try { int CurrentUserId = GetCurrentUser().Id; IPostBarTopicDiscussBLL replyTopicBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var replyTopic = new T_PostBarTopicDiscuss() { Content = model.ReplyContent, ReplyId = model.ReplyId, PostUserId = CurrentUserId, PostTime = DateTime.Now, TopicId = model.TopicId, ParentId = model.FloorId }; replyTopicBLL.Save(replyTopic); } catch { jm.Msg = "回复楼层失败"; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiResultModel DeleteReply(DeleteReplyModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //根据用户ID查找业主 IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); //获取要删除的回复内容 IPostBarTopicDiscussBLL postBarTopicDiscussBll = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); T_PostBarTopicDiscuss reply = postBarTopicDiscussBll.GetEntity(u => u.Id == model.Id); //如果该回复存在 if (reply == null) { resultModel.Msg = "该回复不存在"; } else { if (reply.ParentId == null) { postBarTopicDiscussBll.DeleteLevelOneDiscuss(reply.Id); } else { postBarTopicDiscussBll.Delete(reply); } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public JsonResult DeleteReply(int id) { JsonModel jm = new JsonModel(); //获取要删除的回复内容 IPostBarTopicDiscussBLL postBarTopicDiscussBll = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); T_PostBarTopicDiscuss discuss = postBarTopicDiscussBll.GetEntity(u => u.Id == id); //如果该回复存在 if (discuss == null) { jm.Msg = "该回复不存在"; } else { if (discuss.ParentId == null) { postBarTopicDiscussBll.DeleteLevelOneDiscuss(discuss.Id); } else { postBarTopicDiscussBll.Delete(discuss); } //操作日志 jm.Content = "删除回复" + discuss.Content; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiPageResultModel GetMyLevel2RepliesList([FromUri] Level2RepliedListModel model) { ApiPageResultModel resultModel = new ApiPageResultModel(); try { //根据用户ID查找业主 IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (owner != null) { //如果验证Token不通过或已过期 if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 owner.LatelyLoginTime = DateTime.Now; owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); ownerBll.Update(owner); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var level1Disscuss = topicDiscussBLL.GetEntity(m => m.Id == model.Id); // 获取我的二级回复列表 var list = topicDiscussBLL.GetPageList(m => m.ParentId == model.Id && m.TopicId == model.TopicId, "PostTime", true, model.PageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, PostDate = m.PostTime.ToString("yyyy-MM-dd HH:mm:ss"), UserId = m.PostUserId, UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Content = m.Content, PicList = m.ImgPath, RepliedUserName = m.ReplyUser.UserName, Level2ParentId = m.ParentId }).ToList(); resultModel.result = list; resultModel.Total = topicDiscussBLL.Count(m => m.ParentId == model.Id && m.TopicId == model.TopicId); } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
/// <summary> /// 主题详细列表Json方式获取 /// </summary> /// <param name="topicId"></param> /// <param name="isTag"> 0表示所有楼层都显示 其它Id代表具体那楼层Id。</param> /// <param name="pageIndex"></param> /// <returns></returns> public JsonResult TopicDetailJsonList(int topicId, int floorId, int pageIndex) { PageResultModel model = new PageResultModel(); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); //主题下面所有的一级Ids var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicId && m.ParentId == null, "PostTime", true).Select(m => m.Id).ToList(); Expression <Func <T_PostBarTopicDiscuss, bool> > where = m => true; if (floorId > 0) { where = PredicateBuilder.And(where, m => m.TopicId == topicId && m.Id == floorId); } else { where = PredicateBuilder.And(where, m => m.TopicId == topicId && m.ParentId == null); } // 获取我的帖子回复列表 var list = topicDiscussBLL.GetPageList(where, "PostTime", true, pageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, UserId = m.PostUserId, PostDate = TimeFormat(m.PostTime), UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Content = m.Content == null ? "" : m.Content, PicList = m.ImgPath, RepliedUserName = m.ReplyUser.UserName, Level2Count = m.PostBarTopicDiscusses.Count(), PropertyPlaceId = m.PostBarTopic.PropertyPlaceId, FloorNo = level1Ids.FindIndex(l => l == m.Id) + 1, Level2DiscussList = m.PostBarTopicDiscusses.Select(o => new { Level2Id = o.Id, Level2ParentId = o.ParentId, Level2UserId = o.PostUserId, Level2UserName = o.PostUser.UserName, Level2Content = o.Content, Level2PostDate = TimeFormat(o.PostTime), Level2RepliedUserName = o.ReplyUser.UserName, Level2PicList = o.ImgPath }).OrderByDescending(o => o.Level2PostDate).Take(2).ToList(), Level2DiscussListCount = m.PostBarTopicDiscusses.Count() }).ToList(); model.Result = list; model.Total = topicDiscussBLL.Count(m => m.TopicId == topicId && m.ParentId == null); return(Json(model, JsonRequestBehavior.AllowGet)); }
public JsonResult ReplyTopic(TopicDetailModel model) { JsonModel jm = new JsonModel(); try { int CurrentUserId = GetCurrentUser().Id; IPostBarTopicDiscussBLL replyTopicBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var replyTopic = new T_PostBarTopicDiscuss() { Content = model.ReplyTopicContent, ReplyId = model.PostUserId, PostUserId = CurrentUserId, PostTime = DateTime.Now, TopicId = model.Id }; //图片上传 if (!string.IsNullOrEmpty(model.ReplyTopicImgList)) { //图片集路径保存 replyTopic.ImgPath = GetMultimedia(ConstantParam.TOPIC_DIR, model.ReplyTopicImgList); StringBuilder imgsSB = new StringBuilder(); //生成缩略图保存 foreach (var path in replyTopic.ImgPath.Split(';')) { string thumpFile = DateTime.Now.ToFileTime() + ".jpg"; string thumpPath = Path.Combine(Server.MapPath(ConstantParam.Topic_ThumPictures_DIR + model.PropertyPlaceId), thumpFile); PropertyUtils.getThumImage(Path.Combine(Server.MapPath(path)), 18, 3, thumpPath); imgsSB.Append(ConstantParam.Topic_ThumPictures_DIR + model.PropertyPlaceId + "/" + thumpFile + ";"); } replyTopic.ImgThumbnail = imgsSB.ToString(); replyTopic.ImgThumbnail = replyTopic.ImgThumbnail.Substring(0, replyTopic.ImgThumbnail.Length - 1); } replyTopicBLL.Save(replyTopic); } catch (Exception ex) { jm.Msg = "回复主题失败"; PubFunction.ErrorLogPrint("话题圈回复错误:", ex.ToString()); } return(Json(jm, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 楼层详细列表 /// </summary> /// <param name="floorId">一级回复的主键Id</param> /// <param name="replyId">准备要回复对方的Id</param> /// <returns></returns> public ActionResult FloorDetailList(int floorId, int replyId) { int CurrentUserId = GetCurrentUser().Id; WeixinApiInit(); //获取当前楼层(也就是一级回复的)信息 IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); var topicDiscuss = topicDiscussBLL.GetEntity(m => m.Id == floorId); //主题下面所有的一级Ids var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicDiscuss.TopicId && m.ParentId == null).OrderBy(m => m.PostTime).Select(m => m.Id).ToList(); //当前是第几楼 int FloorNo = level1Ids.FindIndex(m => m == floorId) + 1; ViewBag.FloorNo = string.Format("{0}楼", FloorNo); IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); var replidUserName = ""; var replyUser = userBll.GetEntity(m => m.Id == replyId); replidUserName = string.Format("回复{0}:", replyUser.UserName); var model = new TopicFloorDetailModel() { FloorId = topicDiscuss.Id, FloorNo = string.Format("第{0}楼", FloorNo), PostUserId = topicDiscuss.PostUserId, PostUserName = topicDiscuss.PostUser.UserName, PostUserHeadPath = topicDiscuss.PostUser.HeadPath, ImgPath = topicDiscuss.ImgPath, ImgThumbnail = topicDiscuss.ImgThumbnail, PostDate = string.Format("第{0}楼 {1}", FloorNo, TimeFormat(topicDiscuss.PostTime)), Content = topicDiscuss.Content, PropertyPlaceId = topicDiscuss.PostBarTopic.PropertyPlaceId, TopicId = topicDiscuss.PostBarTopic.Id, LevelTwoReplyCount = topicDiscussBLL.Count(m => m.ParentId == topicDiscuss.Id && m.TopicId == topicDiscuss.TopicId), ReplyId = replyId, ReplidUserName = replidUserName, CurrentUserId = CurrentUserId, CanDelete = topicDiscuss.PostUserId == CurrentUserId }; return(View(model)); }
/// <summary> /// 楼层详细列表Json方式获取 /// </summary> /// <param name="floorId"></param> /// <param name="topicId"></param> /// <param name="pageIndex"></param> /// <returns></returns> public JsonResult FloorDetailJsonList(int floorId, int topicId, int pageIndex) { PageResultModel model = new PageResultModel(); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); // 获取我的帖子回复列表 var list = topicDiscussBLL.GetPageList(m => m.TopicId == topicId && m.ParentId == floorId, "PostTime", true, pageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Level2Id = m.Id, Level2UserName = m.PostUser.UserName, Level2Content = m.Content, Level2PostDate = TimeFormat(m.PostTime), Level2PostUserId = m.PostUserId, Level2RepliedUserName = string.Format("回复 {0}:", m.ReplyUser.UserName), CanDelete = GetCurrentUser().Id == m.PostUserId }).ToList(); model.Result = list; model.Total = topicDiscussBLL.Count(m => m.TopicId == topicId && m.ParentId == floorId); return(Json(model, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 我的回复列表Json方式获取 /// </summary> /// <param name="pageIndex"></param> /// <returns></returns> public JsonResult MyReplyJsonList(int pageIndex) { int CurrentUserId = GetCurrentUser().Id; PageResultModel model = new PageResultModel(); //获取验证过的小区Ids var verifiedPlaceIds = GetVerifiedPlaceIds(); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); // 获取我的回复列表 var list = topicDiscussBLL.GetPageList(m => (m.ReplyId == CurrentUserId || m.PostUserId == CurrentUserId) && verifiedPlaceIds.Contains(m.PostBarTopic.PropertyPlaceId), "PostTime", false, pageIndex, ConstantParam.PAGE_SIZE).Select(m => new { Id = m.Id, PostUserId = m.PostUserId, PostDate = TimeFormat(m.PostTime), UserImage = m.PostUser.HeadPath, UserName = m.PostUser.UserName, Title = m.PostBarTopic.Title, Content = m.Content, PicList = m.ImgPath, TopicType = m.PostBarTopic.PostBarTopicType.Name, CommentCount = m.PostBarTopic.PostBarTopicDiscusss.Count(o => o.ParentId == null), ParentId = m.ParentId, TopicId = m.TopicId, PropertyPlaceId = m.PostBarTopic.PropertyPlaceId, FloorId = m.ParentId == null ? m.Id : m.ParentId, PropertyName = m.PostBarTopic.PropertyPlace.Name, ReplyId = m.ParentId == null ? m.PostUserId : m.ParentReply.PostUserId }).ToList(); model.Result = list; model.Total = topicDiscussBLL.Count(m => (m.ReplyId == CurrentUserId || m.PostUserId == CurrentUserId) && verifiedPlaceIds.Contains(m.PostBarTopic.PropertyPlaceId)); return(Json(model, JsonRequestBehavior.AllowGet)); }
public ApiResultModel GetMyReplyOneTwoLevelsList([FromUri] ReplyOneTwoLevelModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //根据用户ID查找业主 IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果业主存在 if (owner != null) { //如果验证Token不通过或已过期 if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 owner.LatelyLoginTime = DateTime.Now; owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); ownerBll.Update(owner); var collectedTopicIds = owner.UserPostBarTopics.Select(o => o.PostBarTopicId).ToList(); IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); //获取一级 var topicDiscuss = topicDiscussBLL.GetEntity(m => m.Id == model.Id); int topicId = topicDiscuss.TopicId; int level1Id = model.Id; var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicId && m.ParentId == null).OrderBy(m => m.PostTime).Select(m => m.Id).ToList(); if (topicDiscuss.ParentId.HasValue) { level1Id = topicDiscussBLL.GetEntity(m => m.TopicId == topicId && m.ParentId == null && m.Id == topicDiscuss.ParentId.Value).Id; topicDiscuss = topicDiscussBLL.GetEntity(m => m.Id == level1Id); } int FloorNo = level1Ids.FindIndex(m => m == level1Id) + 1; //根据一级获取二级 var list = new { Id = topicDiscuss.Id, PostUserId = topicDiscuss.PostUserId, PostDate = topicDiscuss.PostTime.ToString("yyyy-MM-dd HH:mm:ss"), UserImage = topicDiscuss.PostUser.HeadPath, UserName = topicDiscuss.PostUser.UserName, Content = topicDiscuss.Content, PicList = topicDiscuss.ImgPath, TopicId = topicDiscuss.PostBarTopic.Id, Title = topicDiscuss.PostBarTopic.Title, TopicContent = topicDiscuss.PostBarTopic.Content, TopicUserId = topicDiscuss.PostBarTopic.PostUserId, TopicUserName = topicDiscuss.PostBarTopic.PostUser.UserName, TopicUserImage = topicDiscuss.PostBarTopic.PostUser.HeadPath, TopicPicList = topicDiscuss.PostBarTopic.ImgPath, TopicPostDate = topicDiscuss.PostBarTopic.PostDate.ToString("yyyy-MM-dd HH:mm:ss"), Level2Count = topicDiscuss.PostBarTopicDiscusses.Count, FloorNo = FloorNo, TopicIsTop = topicDiscuss.PostBarTopic.IsTop, TopicIsCollected = collectedTopicIds.Contains(topicDiscuss.TopicId) ? 1 : 0, PropertyPlaceId = topicDiscuss.PostBarTopic.PropertyPlaceId, Level2List = topicDiscuss.PostBarTopicDiscusses.Select(o => new { Level2ParentId = o.ParentId, Level2PostUserId = o.PostUserId, Level2UserName = o.PostUser.UserName, Level2Content = o.Content, Level2PostDate = o.PostTime.ToString("yyyy-MM-dd HH:mm:ss"), Level2RepliedUserName = o.ReplyUser.UserName, Level2PicList = o.ImgPath }).OrderByDescending(o => o.Level2PostDate).Take(2).ToList() }; resultModel.result = list; } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ApiResultModel ReplyTopic(ReplyTopicModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //根据用户ID查找业主 IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL"); T_User user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); var replyTopic = new T_PostBarTopicDiscuss() { Content = model.Content, ParentId = model.ParentId, ReplyId = model.ReplyId, PostUserId = model.UserId, PostTime = DateTime.Now, TopicId = model.Topicid }; //图片上传 if (!string.IsNullOrEmpty(model.PicList)) { //话题文件资源保存目录 string dir = HttpContext.Current.Server.MapPath(ConstantParam.Topic_Pictures_DIR + model.PropertyPlaceId); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var fileName = DateTime.Now.ToFileTime().ToString() + ".zip"; string filepath = Path.Combine(dir, fileName); using (FileStream fs = new FileStream(filepath, FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] datas = Convert.FromBase64String(model.PicList); bw.Write(datas); bw.Close(); } } //图片集路径保存 replyTopic.ImgPath = PropertyUtils.UnZip(filepath, dir, ConstantParam.Topic_Pictures_DIR + model.PropertyPlaceId); StringBuilder imgsSB = new StringBuilder(); //生成缩略图保存 foreach (var path in replyTopic.ImgPath.Split(';')) { string thumpFile = DateTime.Now.ToFileTime() + ".jpg"; string thumpPath = Path.Combine(HttpContext.Current.Server.MapPath(ConstantParam.Topic_ThumPictures_DIR + model.PropertyPlaceId), thumpFile); PropertyUtils.getThumImage(Path.Combine(HttpContext.Current.Server.MapPath(path)), 18, 3, thumpPath); imgsSB.Append(ConstantParam.Topic_ThumPictures_DIR + model.PropertyPlaceId + "/" + thumpFile + ";"); } replyTopic.ImgThumbnail = imgsSB.ToString(); replyTopic.ImgThumbnail = replyTopic.ImgThumbnail.Substring(0, replyTopic.ImgThumbnail.Length - 1); } //保存话题回复 IPostBarTopicDiscussBLL replyTopicBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL"); replyTopicBLL.Save(replyTopic); if (model.ReplyId != model.UserId) { //发推送给回复人 IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL"); var userPush = userPushBLL.GetEntity(u => u.UserId == model.ReplyId); if (userPush != null) { var title = "你有一条话题圈的回复"; var content = replyTopic.Content; Property.Common.PropertyUtils.SendPush(title, content, ConstantParam.MOBILE_TYPE_OWNER, userPush.RegistrationId); } } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }