예제 #1
0
        public ActionResult EditNews(CompanyNoticeModel model)
        {
            JsonModel jm = new JsonModel();

            //如果表单模型验证成功
            if (ModelState.IsValid)
            {
                ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

                T_CompanyPost 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.PublishStatus = model.PublishedFlag ? 1 : 0;
                    newPost.IsOpen        = model.IsOpen ? 1 : 0;
                }
                ;
                if (model.PublishedFlag)
                {
                    newPost.PublishedTime = DateTime.Now;
                }
                // 保存到数据库,如果修改成功
                if (postBll.Update(newPost))
                {
                    //如果已发布并公开
                    if (model.PublishedFlag && model.IsOpen)
                    {
                        //推送给物业客户端
                        IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                        var PropertyUserIds = userBll.GetList(u => u.PropertyPlace.CompanyId == newPost.CompanyId && 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 flag = PropertyUtils.SendPush("总公司新闻公告", model.Title, ConstantParam.MOBILE_TYPE_PROPERTY, propertyRegistrationIds);
                        if (!flag)
                        {
                            jm.Msg = "推送发生异常";
                        }
                    }
                    //日志记录
                    jm.Content = PropertyUtils.ModelToJsonString(model);
                }
                else
                {
                    jm.Msg = "新闻公告编辑失败";
                }
            }
            else
            {
                // 保存异常日志
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ApiPageResultModel CompanyNewsList([FromUri] PagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找物业用户
                IPropertyUserBLL propertyUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

                T_PropertyUser propertyUser = propertyUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果物业用户存在
                if (propertyUser != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > propertyUser.TokenInvalidTime || model.Token != propertyUser.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    propertyUser.LatelyLoginTime  = DateTime.Now;
                    propertyUser.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    propertyUserBll.Update(propertyUser);

                    //获取指定公司发布的公开新闻公告
                    ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

                    Expression <Func <T_CompanyPost, bool> > where = u => u.CompanyId == propertyUser.PropertyPlace.CompanyId &&
                                                                     u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.PublishStatus == ConstantParam.PUBLISHED_TRUE && u.IsOpen == ConstantParam.PUBLISHED_TRUE;
                    var list = postBll.GetPageList(where, "PublishedTime", false, model.PageIndex).Select(s => new
                    {
                        ID            = s.Id,
                        CompanyName   = s.Company.Name,
                        CompanyIcon   = string.IsNullOrEmpty(s.Company.Img) ? "/Images/news_item_default.png" : s.Company.Img,
                        PublishedTime = s.PublishedTime.Value.ToString("yyyy-MM-dd HH:mm:ss"),
                        Title         = s.Title
                    }).ToList();
                    resultModel.result = list;
                    resultModel.Total  = postBll.Count(where);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
예제 #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));
        }
예제 #4
0
        public ActionResult CompanyNewsDetail(int id)
        {
            ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

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

            if (post != null)
            {
                return(View(post));
            }
            else
            {
                return(RedirectToAction("CompanyNewsList"));
            }
        }
예제 #5
0
        public ActionResult NewsList(CompanyNewsNoticeSearchModel model)
        {
            ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

            int currentCompanyId = GetSessionModel().CompanyId.Value;

            Expression <Func <T_CompanyPost, bool> > where = u => u.CompanyId == currentCompanyId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT &&
                                                             (string.IsNullOrEmpty(model.Kword) ? true : u.Title.Contains(model.Kword)) && (model.PublishedFlag == null ? true : u.PublishStatus == model.PublishedFlag.Value);

            if (model.IsOpen != null)
            {
                where = PredicateBuilder.And(where, u => u.IsOpen == model.IsOpen.Value);
            }
            //排序
            var sortModel = this.SettingSorting("Id", false);

            model.PostList   = postBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex) as PagedList <T_CompanyPost>;
            model.StatusList = getStatueList();
            model.IsOpenList = getIsOpenList();
            return(View(model));
        }
예제 #6
0
        public ActionResult EditNews(int id)
        {
            ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

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

            if (post != null)
            {
                CompanyNoticeModel postModel = new CompanyNoticeModel();
                postModel.PostId        = post.Id;
                postModel.Title         = post.Title;
                postModel.Content       = post.Content;
                postModel.PublishedFlag = post.PublishStatus == 1;
                postModel.IsOpen        = post.IsOpen == 1;
                return(View(postModel));
            }
            else
            {
                return(RedirectToAction("NewsList"));
            }
        }
예제 #7
0
        public ActionResult DeleteNews(int id)
        {
            JsonModel jm = new JsonModel();

            ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

            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));
        }
예제 #8
0
        public ActionResult CompanyNewsList(SearchModel model)
        {
            //获取当前小区所属公司ID
            int CurrentPlaceId         = GetSessionModel().PropertyPlaceId.Value;
            IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

            var place            = placeBll.GetEntity(p => p.Id == CurrentPlaceId);
            int currentCompanyId = place.CompanyId;

            //查询条件初始化
            Expression <Func <T_CompanyPost, bool> > where = u => u.CompanyId == currentCompanyId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT &&
                                                             (string.IsNullOrEmpty(model.Kword) ? true : u.Title.Contains(model.Kword)) && u.PublishStatus == ConstantParam.PUBLISHED_TRUE &&
                                                             u.IsOpen == ConstantParam.PUBLISHED_TRUE;
            //排序
            var sortModel = this.SettingSorting("Id", false);

            //获取分页数据
            ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

            var PostList = postBll.GetPageList(where, sortModel.SortName, sortModel.IsAsc, model.PageIndex);

            return(View(PostList));
        }
예제 #9
0
        public ActionResult Index()
        {
            //构造首页数据模型
            PropertyIndexModel model = new PropertyIndexModel();

            //获取物业小区
            int CurrentPlaceId = GetSessionModel().PropertyPlaceId ?? 0;

            //获取app用户统计数据
            IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            int appUserCount = userBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.UserPlaces.Any(up => up.PropertyPlaceId == CurrentPlaceId));

            model.AppUserCount = appUserCount;

            //获取物业用户统计数据
            IPropertyUserBLL pUserBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL");

            int pUserCount = pUserBll.Count(u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.PropertyPlaceId == CurrentPlaceId);

            model.PropertyUserCount = pUserCount;

            //获取新闻发布个数
            IPostBLL postBLL = BLLFactory <IPostBLL> .GetBLL("PostBLL");

            int postCount = postBLL.Count(u => u.PublishedFlag == ConstantParam.PUBLISHED_TRUE && u.PropertyPlaceId == CurrentPlaceId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            model.NoticeCount = postCount;


            //获取业主上报问题个数
            IQuestionBLL questionBLL = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL");

            int questionCount = questionBLL.Count(u => u.PropertyPlaceId == CurrentPlaceId);

            model.QuestionCount = questionCount;

            //获取业主上报本月未处理问题个数
            DateTime monthBegin             = DateTime.Today.AddDays(1 - DateTime.Today.Day);
            DateTime monthEnd               = DateTime.Now.Date.AddDays(1);
            int      notHandleQuestionCount = questionBLL.Count(u => u.Status == ConstantParam.NO_DISPOSE && u.UploadTime > monthBegin &&
                                                                u.UploadTime < monthEnd && u.PropertyPlaceId == CurrentPlaceId);

            model.NotHandleQuestionCount = notHandleQuestionCount;

            //获取本月巡检未处理问题个数
            IInspectionResultBLL resultBLL = BLLFactory <IInspectionResultBLL> .GetBLL("InspectionResultBLL");

            int notHandleExCount = resultBLL.Count(u => u.Status == ConstantParam.EXCEPTION && u.PlanDate >= monthBegin &&
                                                   u.PlanDate < monthEnd &&
                                                   (u.DisposeStatus == null || u.DisposeStatus == ConstantParam.NO_DISPOSE) && u.InspectionTimePlan.InspectionPlan.PropertyPlaceId == CurrentPlaceId);

            model.NotHandleExceptionCount = notHandleExCount;


            //获取最新的为题列表
            var list = questionBLL.GetPageList(q => q.PropertyPlaceId == CurrentPlaceId, "UploadTime", false, 1, 5);

            model.LatestQuestionList = list;


            //获取当前小区所属公司ID
            IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

            var place            = placeBll.GetEntity(p => p.Id == CurrentPlaceId);
            int currentCompanyId = place.CompanyId;

            //查询条件初始化
            Expression <Func <T_CompanyPost, bool> > where = u => u.CompanyId == currentCompanyId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT &&
                                                             u.PublishStatus == ConstantParam.PUBLISHED_TRUE && u.IsOpen == ConstantParam.PUBLISHED_TRUE;

            //获取最新的5条总公司新闻公告
            ICompanyPostBLL postBll = BLLFactory <ICompanyPostBLL> .GetBLL("CompanyPostBLL");

            model.LatestCompanyPostList = postBll.GetPageList(where, "PublishedTime", false, 1, 5);

            return(View(model));
        }