예제 #1
0
        public ActionResult EditNews(int id)
        {
            IPostBLL postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL");

            var post = postBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (post != null)
            {
                NewsNoticeModel postModel = new NewsNoticeModel();
                postModel.PostId             = post.Id;
                postModel.Title              = post.Title;
                postModel.Content            = post.Content;
                postModel.SubmitUserId       = post.SubmitUserId;
                postModel.SubmitUser         = post.SubmitUser.TrueName;
                postModel.SubmitTime         = post.SubmitTime.ToString();
                postModel.SubmitUserHeadPath = post.SubmitUser.HeadPath;
                postModel.PublishedFlag      = post.PublishedFlag == 1 ? true : false;
                postModel.PuslishedTime      = post.PublishedTime.ToString();
                return(View(postModel));
            }
            else
            {
                return(RedirectToAction("NoticeList"));
            }
        }
예제 #2
0
        public ApiResultModel NewsDetail([FromUri] NewsDetailModel 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);

                    IPostBLL postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL");

                    var post = postBll.GetEntity(p => p.Id == model.PostId && p.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && p.PublishedFlag == 1);
                    if (post != null)
                    {
                        // 返回详细页面url
                        resultModel.result = new
                        {
                            PlaceTel = post.PropertyPlace.Tel,
                            Url      = "MobilePage/NewsDetail?id=" + model.PostId
                        };
                    }
                    else
                    {
                        resultModel.Msg = "新闻公告不存在";
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
예제 #3
0
        public ActionResult NewsDetail(int id)
        {
            JsonModel jm      = new JsonModel();
            IPostBLL  postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL");

            var post = postBll.GetEntity(p => p.Id == id && p.DelFlag == ConstantParam.DEL_FLAG_DEFAULT &&
                                         p.PublishedFlag == ConstantParam.PUBLISHED_TRUE);

            NewsNoticeModel postModel = new NewsNoticeModel();

            postModel.Title         = post.Title;
            postModel.Content       = post.Content;
            postModel.PuslishedTime = post.PublishedTime.Value.ToShortDateString().Replace("/", ".");
            return(View(postModel));
        }
예제 #4
0
        /// <summary>
        /// 物业公告详细
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult PropertyNoticeDetail(int id)
        {
            IPostBLL postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL");

            var post  = postBll.GetEntity(m => m.Id == id);
            var model = new PropertyNoticeDetailModel()
            {
                Id            = post.Id,
                PlaceName     = post.PropertyPlace.Name,
                Content       = post.Content,
                Title         = post.Title,
                PublishedTime = post.PublishedTime.HasValue ? post.PublishedTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
            };

            return(View(model));
        }
예제 #5
0
        public ActionResult DeletePost(int id)
        {
            JsonModel jm = new JsonModel();

            IPostBLL postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL");

            // 根据指定id值获取实体对象
            var post = postBll.GetEntity(index => index.Id == id && index.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (post != null)
            {
                // 修改指定用户记录中的已删除标识
                post.DelFlag = ConstantParam.DEL_FLAG_DELETE;
                postBll.Update(post);
                //操作日志
                jm.Content = "删除公告 " + post.Title;
            }
            else
            {
                jm.Msg = "该公告不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public ActionResult EditNews(NewsNoticeModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                var      sessionModel = GetSessionModel();
                IPostBLL postBll      = BLLFactory <IPostBLL> .GetBLL("PostBLL");

                T_Post newPost = postBll.GetEntity(m => m.Id == model.PostId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (newPost != null)
                {
                    newPost.Title           = model.Title;
                    newPost.Content         = model.Content;
                    newPost.PropertyPlaceId = sessionModel.PropertyPlaceId.Value;
                    newPost.SubmitUserId    = sessionModel.UserID;
                    newPost.PublishedTime   = DateTime.Now.ToLocalTime();
                    newPost.PublishedFlag   = model.PublishedFlag ? 1 : 0;
                }
                ;
                // 保存到数据库
                if (postBll.Update(newPost))
                {
                    // 若选中“发布选项”则即时推送
                    if (model.PublishedFlag)
                    {
                        // 公告推送
                        //推送给业主客户端
                        IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

                        var userIds = placeBll.GetEntity(p => p.Id == newPost.PropertyPlaceId).UserPlaces.Select(m => m.UserId);
                        if (userIds != null)
                        {
                            userIds = userIds.ToList();
                        }
                        IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL");

                        var  registrationIds = userPushBLL.GetList(p => userIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray();
                        bool flag            = PropertyUtils.SendPush("新闻公告", model.Title, ConstantParam.MOBILE_TYPE_OWNER, registrationIds);

                        //推送给物业客户端
                        IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                        var PropertyUserIds = userBll.GetList(u => u.PropertyPlaceId == newPost.PropertyPlaceId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT).Select(u => u.Id);
                        if (PropertyUserIds != null)
                        {
                            PropertyUserIds = PropertyUserIds.ToList();
                        }
                        IPropertyUserPushBLL propertyUserPushBLL = BLLFactory <IPropertyUserPushBLL> .GetBLL("PropertyUserPushBLL");

                        var  propertyRegistrationIds = propertyUserPushBLL.GetList(p => PropertyUserIds.Contains(p.UserId)).Select(p => p.RegistrationId).ToArray();
                        bool flag1 = PropertyUtils.SendPush("新闻公告", model.Title, ConstantParam.MOBILE_TYPE_PROPERTY, propertyRegistrationIds);
                        if (!flag || !flag1)
                        {
                            jm.Msg = "推送发生异常";
                        }
                    }
                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "新闻公告编辑失败";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }