예제 #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 JsonResult SetQuestionDisposer(SetQuestionDisposerModel model)
        {
            JsonModel jm = new JsonModel();

            if (ModelState.IsValid)
            {
                //获取要指派处理人的上报问题结果
                IQuestionBLL resultBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL");

                T_Question result = resultBll.GetEntity(m => m.Id == model.Id);
                if (result != null)
                {
                    //指派处理人
                    result.DisposerId = model.DisposerId;
                    //保存到数据库
                    if (resultBll.Update(result))
                    {
                        //日志记录
                        jm.Content = PropertyUtils.ModelToJsonString(model);

                        //推送给处理人
                        IPropertyUserPushBLL userPushBLL = BLLFactory <IPropertyUserPushBLL> .GetBLL("PropertyUserPushBLL");

                        var userPush = userPushBLL.GetEntity(p => p.UserId == model.DisposerId);
                        if (userPush != null)
                        {
                            string registrationId = userPush.RegistrationId;
                            //通知信息
                            bool flag = PropertyUtils.SendPush("业主上报问题", "有新的问题需要您处理,请查看", ConstantParam.MOBILE_TYPE_PROPERTY, registrationId);
                            if (!flag)
                            {
                                jm.Msg = "推送发生异常";
                            }
                        }
                    }
                    else
                    {
                        jm.Msg = "指派处理人失败";
                    }
                }
            }
            else
            {
                jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
예제 #3
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));
        }
예제 #4
0
        public ApiResultModel Login(OwnerLoginModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

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

                T_PropertyUser user = propertyUserBll.GetEntity(u => u.UserName == model.UserName &&
                                                                u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                //1.判断用户名是否正确
                if (user == null)
                {
                    resultModel.Msg = APIMessage.NAME_ERROR;
                    return(resultModel);
                }

                //2.判断密码是否正确
                string md5Str = PropertyUtils.GetMD5Str(model.Password);
                if (user.Password != md5Str)
                {
                    resultModel.Msg = APIMessage.PWD_ERROR;
                    return(resultModel);
                }

                //产生随机令牌
                var token = System.Guid.NewGuid().ToString("N");
                //更新用户令牌和最近登录时间及Token失效时间
                user.Token            = token;
                user.LatelyLoginTime  = DateTime.Now;
                user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                propertyUserBll.Update(user);

                //返回登录用户的ID和用户名以及令牌
                resultModel.result = new { token = token, userId = user.Id, userName = user.UserName, isMgr = user.IsMgr };

                //推送设备管理
                IPropertyUserPushBLL userPushBll = BLLFactory <IPropertyUserPushBLL> .GetBLL("PropertyUserPushBLL");

                var userPush  = userPushBll.GetEntity(p => p.UserId == user.Id);
                var userPush1 = userPushBll.GetEntity(p => p.RegistrationId == model.RegistrationId);
                if (userPush != null)
                {
                    userPush.RegistrationId = model.RegistrationId;
                    userPushBll.Update(userPush);
                }
                else if (userPush1 != null)
                {
                    userPush1.UserId = user.Id;
                    userPushBll.Update(userPush1);
                }
                else
                {
                    userPush = new T_PropertyUserPush()
                    {
                        UserId         = user.Id,
                        RegistrationId = model.RegistrationId
                    };
                    userPushBll.Save(userPush);
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }