public ApiResultModel DisposeException(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); //获取要处理的巡检异常 IInspectionResultBLL resultBll = BLLFactory <IInspectionResultBLL> .GetBLL("InspectionResultBLL"); T_InspectionResult result = resultBll.GetEntity(m => m.Id == model.Id); if (result != null) { //修改处理状态并添加处理记录 result.DisposeStatus = ConstantParam.DISPOSED; T_InspectionExceptionDispose exceptionDispose = new T_InspectionExceptionDispose() { DisposeDesc = model.DisposeDesc, DisposeUserId = user.Id, ExceptionResultId = model.Id, DisposeTime = DateTime.Now }; //保存到数据库 resultBll.DisposeException(result, exceptionDispose); } else { resultModel.Msg = APIMessage.EXCEPTION_NOEXIST; } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
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); }