Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
        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);
        }