Example #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"));
            }
        }
Example #2
0
        public ActionResult AddNews()
        {
            NewsNoticeModel model = new NewsNoticeModel();

            model.PublishedFlag = false;
            return(View(model));
        }
Example #3
0
        public ActionResult CompanyNewsDetail(int id)
        {
            JsonModel       jm      = new JsonModel();
            ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

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

            NewsNoticeModel postModel = new NewsNoticeModel();

            postModel.Title         = post.Title;
            postModel.Content       = post.Content;
            postModel.PuslishedTime = post.PublishedTime.Value.ToShortDateString().Replace("/", ".");
            return(View(postModel));
        }
Example #4
0
        public ActionResult AddNews(NewsNoticeModel model)
        {
            JsonModel jm = new JsonModel();

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

                T_Post newPost = new T_Post()
                {
                    Title           = model.Title,
                    Content         = model.Content,
                    PropertyPlaceId = sessionModel.PropertyPlaceId.Value,
                    SubmitUserId    = sessionModel.UserID,
                    SubmitTime      = DateTime.Now.ToLocalTime(),
                    PublishedFlag   = model.PublishedFlag ? 1 : 0,
                    PublishedTime   = DateTime.Now.ToLocalTime()
                };
                // 保存到数据库
                postBll.Save(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 = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }