Пример #1
0
        public JsonResult DelTopic(int id)
        {
            JsonModel jm = new JsonModel();

            try
            {
                //获取要删除的帖子
                IPostBarTopicBLL postBarTopicBll = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL");

                T_PostBarTopic topic = postBarTopicBll.GetEntity(u => u.Id == id);

                if (topic != null)
                {
                    postBarTopicBll.DeleteTopic(id);
                }
                else
                {
                    jm.Msg = "该主题不存在";
                }
            }
            catch
            {
                jm.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ApiResultModel DeleteTopic(DeleteTopicModel 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);

                    //获取要删除的帖子
                    IPostBarTopicBLL postBarTopicBll = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL");

                    T_PostBarTopic topic = postBarTopicBll.GetEntity(u => u.Id == model.TopicId);

                    if (topic != null)
                    {
                        postBarTopicBll.DeleteTopic(model.TopicId);
                    }
                    else
                    {
                        resultModel.Msg = "该主题不存在";
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
Пример #3
0
        public ActionResult LinkupTypeContent(int id)
        {
            var propertyplaceId = GetSessionModel().PropertyPlaceId.Value;

            IPostBarTopicBLL postBarTopicBll = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL");

            //获取要查看的主题表
            T_PostBarTopic postBarTopic = postBarTopicBll.GetEntity(u => u.Id == id && u.PropertyPlaceId == propertyplaceId);

            if (postBarTopic != null)
            {
                return(View(postBarTopic));
            }

            return(RedirectToAction("LinkupTypeList"));
        }
Пример #4
0
        public ActionResult TopicReport(T_PostBarTopic model)
        {
            //点击图片input触发的提交事件,不进行提交
            if (model.Id == 1)
            {
                return(null);
            }
            else
            {
                int       userId = GetCurrentUser().Id;
                JsonModel jm     = new JsonModel();
                try
                {
                    IPostBarTopicBLL topicBll = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL");

                    T_PostBarTopic topic = new T_PostBarTopic();
                    topic.PostUserId      = userId;
                    topic.PostDate        = DateTime.Now;
                    topic.Title           = model.Title;
                    topic.IsTop           = 0;
                    topic.PropertyPlaceId = model.PropertyPlaceId;
                    if (string.IsNullOrEmpty(model.ImgPath))
                    {
                        topic.ImgPath = "";
                    }
                    else
                    {
                        topic.ImgPath = GetMultimedia(ConstantParam.TOPIC_DIR, model.ImgPath);
                    }
                    topic.Content     = model.Content;
                    topic.TopicTypeId = model.TopicTypeId;
                    topic.IsTop       = 0;

                    topicBll.Save(topic);
                }
                catch
                {
                    jm.Msg = "发布失败";
                }
                return(Json(jm, JsonRequestBehavior.AllowGet));
            }
        }
Пример #5
0
        public JsonResult CancelTopicTop(int id)
        {
            JsonModel jm = new JsonModel();

            //获取要操作的主题
            IPostBarTopicBLL postBarTopicBll = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL");

            T_PostBarTopic post = postBarTopicBll.GetEntity(u => u.Id == id);

            if (post != null)
            {
                post.IsTop = 0;
                postBarTopicBll.Update(post);
                //操作日志
                jm.Content = "置顶主题" + post.Title;
            }
            else
            {
                jm.Msg = "该主题不存在";
            }

            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        public JsonResult DeleteLinkupType(int id)
        {
            JsonModel jm = new JsonModel();

            //获取要删除的帖子
            IPostBarTopicBLL postBarTopicBll = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL");

            T_PostBarTopic post = postBarTopicBll.GetEntity(u => u.Id == id);

            //如果该帖子存在
            if (post == null)
            {
                jm.Msg = "该沟通不存在";
            }
            else
            {
                postBarTopicBll.DeleteTopic(id);

                //操作日志
                jm.Content = "删除沟通 " + post.Title;
            }

            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Пример #7
0
        public ApiResultModel PostTopic(PostTopicModel 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 postTopic = new T_PostBarTopic()
                    {
                        PostUserId      = model.UserId,
                        PostDate        = DateTime.Now,
                        PropertyPlaceId = model.PropertyPlaceId,
                        TopicTypeId     = model.TopicTypeId,
                        Title           = model.Title,
                        Content         = model.Content
                    };

                    //图片上传
                    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();
                            }
                        }
                        //图片集路径保存
                        postTopic.ImgPath = PropertyUtils.UnZip(filepath, dir, ConstantParam.Topic_Pictures_DIR + model.PropertyPlaceId);

                        StringBuilder imgsSB = new StringBuilder();
                        //生成缩略图保存
                        foreach (var path in postTopic.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 + ";");
                        }

                        postTopic.ImgThumbnail = imgsSB.ToString();
                        postTopic.ImgThumbnail = postTopic.ImgThumbnail.Substring(0, postTopic.ImgThumbnail.Length - 1);
                    }

                    //保存话题
                    IPostBarTopicBLL postTopicBLL = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL");

                    postTopicBLL.Save(postTopic);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }