/// <summary> /// 处理业主上报问题 /// </summary> /// <param name="status">问题新状态</param> /// <param name="QuestionDispose">处理记录对象</param> public void DisposeQuestion(T_Question Question, T_QuestionDispose QuestionDispose) { //使用事务进行数据库操作 using (var tran = this.nContext.Database.BeginTransaction()) { try { //更新上报问题 base.Update(Question); //添加处理记录 IDisposeQuestionBLL questionBll = BLLFactory <IDisposeQuestionBLL> .GetBLL("DisposeQuestionBLL"); var qd = questionBll.GetEntity(dq => dq.QuestionId == Question.Id); if (qd == null) { questionBll.Save(QuestionDispose); } else { qd.DisposeDesc = QuestionDispose.DisposeDesc; qd.DisposeTime = DateTime.Now; questionBll.Update(qd); } //提交事务 tran.Commit(); } catch { tran.Rollback(); } } }
public JsonResult DisposeQuestion(DisposeQuestionModel model) { JsonModel jm = new JsonModel(); if (ModelState.IsValid) { //获取要处理的上报问题 IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question question = questionBll.GetEntity(m => m.Id == model.Id); if (question != null) { //修改处理状态并添加处理记录 question.Status = ConstantParam.DISPOSED; question.IsPublish = model.IsPublish ? 1 : 0; T_QuestionDispose questionDispose = new T_QuestionDispose() { DisposeDesc = model.DisposeDesc, DisposeUserId = GetSessionModel().UserID, QuestionId = model.Id, DisposeTime = DateTime.Now }; //保存到数据库 questionBll.DisposeQuestion(question, questionDispose); IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL"); var userPush = userPushBLL.GetEntity(p => p.UserId == question.UploadUserId); if (userPush != null) { string registrationId = userPush.RegistrationId; string alert = "您" + question.UploadTime.ToString("yyyy-MM-dd HH:mm") + "上报的问题已处理"; //通知信息 bool flag = PropertyUtils.SendPush("上报问题处理", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId); 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)); }
/// <summary> /// 处理业主上报问题 /// </summary> /// <param name="Question">问题新状态</param> /// <param name="QuestionDispose">处理记录对象</param> public void DisposeQuestion(T_Question Question, T_QuestionDispose QuestionDispose) { this._Dal.DisposeQuestion(Question, QuestionDispose); }
public ApiResultModel DisposeQuestion(DisposerModel model) { ApiResultModel resultModel = new ApiResultModel(); try { IPropertyUserBLL userBll = BLLFactory <IPropertyUserBLL> .GetBLL("PropertyUserBLL"); T_PropertyUser 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); //获取要处理的问题 IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL"); T_Question question = questionBll.GetEntity(m => m.Id == model.Id); if (question != null) { //修改处理状态并添加处理记录 question.Status = ConstantParam.DISPOSED; question.IsPublish = model.IsPublish; T_QuestionDispose questionDispose = new T_QuestionDispose() { DisposeDesc = model.DisposeDesc, DisposeUserId = user.Id, QuestionId = model.Id, DisposeTime = DateTime.Now }; //保存到数据库 questionBll.DisposeQuestion(question, questionDispose); //推送通知 IUserPushBLL userPushBLL = BLLFactory <IUserPushBLL> .GetBLL("UserPushBLL"); var userPush = userPushBLL.GetEntity(p => p.UserId == question.UploadUserId); if (userPush != null) { string registrationId = userPush.RegistrationId; string alert = "您" + question.UploadTime.ToString("yyyy-MM-dd HH:mm") + "上报的问题已处理"; //通知信息 bool flag = PropertyUtils.SendPush("上报问题处理", alert, ConstantParam.MOBILE_TYPE_OWNER, registrationId); if (!flag) { resultModel.Msg = "问题处理完成,推送失败"; } } } else { resultModel.Msg = APIMessage.QUESTION_NOEXIST; } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }