/// <summary> /// 添加一条申请书操作日志 /// </summary> /// <param name="ctx">数据库上下文对象</param> /// <param name="logDTO">需要添加的日志信息</param> /// <returns> /// 成功,返回TRUE /// 否则,抛出一个异常 /// </returns> public static bool AddApplicationLog(AspodesDB ctx, AddApplicationLogDTO logDTO) { ApplicationLog log = Mapper.Map <ApplicationLog>(logDTO); log.Time = DateTime.Now; ctx.ApplicationLogs.Add(log); return(true); }
public HttpResponseMessage RejectApplication(AddApplicationLogDTO logDTO) { try { var userInfo = UserHelper.GetCurrentUser(); logDTO.Operation = ActionType.REJECT_APPLICATION; logDTO.UserId = userInfo.UserId; repository.ChangeApplicationStatus(logDTO.ApplicationId, ApplicationStatus.CHECK, ApplicationStatus.REJECT, a => a.InstituteId == userInfo.InstId, logDTO); //单位管理员审核申请书驳回 //通知打点:发给单位普通用户 //_noticeService.AddNotice(_noticeService.GetUserIdByApplicationId(logDTO.ApplicationId), 3); return(ResponseWrapper.SuccessResponse()); } catch (Exception e) { return(ResponseWrapper.ExceptionResponse(e)); } }
public HttpResponseMessage RejectApplication(AddApplicationLogDTO logDTO) { try { var userInfo = UserHelper.GetCurrentUser(); logDTO.Operation = ActionType.REFUSE_APPLICATION; logDTO.UserId = userInfo.UserId; repository.ChangeApplicationStatus(logDTO.ApplicationId, ApplicationStatus.ACCEPT, ApplicationStatus.REFUSE, a => true, logDTO); //院管理员不受理申请书 //通知打点:发给提交申请书的用户 //_noticeService.AddNotice( // _noticeService.GetUserIdByApplicationId(logDTO.ApplicationId), 5); //通知打点:发给审核通过申请书的单位 //_noticeService.AddNoticeList( // _noticeService.GetInstManagerIdsbyAppId(logDTO.ApplicationId), 10); return(ResponseWrapper.SuccessResponse()); } catch (Exception e) { return(ResponseWrapper.ExceptionResponse(e)); } }
/// <summary> /// 更改申请书状态 /// </summary> /// <param name="applicationId">申请书ID</param> /// <param name="from">修改前的状态</param> /// <param name="to">修改后的状态</param> /// <param name="privilege">修改权限</param> /// <param name="logDTO">操作日志</param> /// <returns></returns> public void ChangeApplicationStatus(string applicationId, ApplicationStatus from, ApplicationStatus to, Func <Application, bool> privilege, AddApplicationLogDTO logDTO = null) { using (var ctx = new AspodesDB()) { //取出申请书 var application = ctx.Applications.FirstOrDefault(a => a.ApplicationId == applicationId); if (null == application) { throw new NotFoundException("未找到申请书"); } //验证权限 if (!privilege(application)) { throw new OtherException("您没有权限或操作时间有误"); } //修改状态 if (application.Status != from) { throw new OtherException("申请书状态错误"); } application.Status = to; //添加日志 if (logDTO != null) { ApplicationLogRepository.AddApplicationLog(ctx, logDTO); } ctx.SaveChanges(); } }