/// <summary> /// 更新Job执行结果(插入日志,更新上次/下次执行时间,执行次数)(事务) /// </summary> /// <param name="nextFireTime">下次执行时间</param> /// <param name="logEntity">JobLog实体</param> /// <returns>是否成功</returns> public bool UpdateJobFireResult(DateTime nextFireTime, JobLogEntity logEntity) { int r = 0; using (TransactionScope trans = TransactionScopeBuilder.CreateReadCommitted(false)) { JobInfoEntity job = _jobRepository.Get(logEntity.JobId); r = _jobRepository.Update(logEntity.JobId, new List <DbUpdate <JobInfoEntity> > { new DbUpdate <JobInfoEntity>(j => j.LastFireTime, logEntity.FireTime), new DbUpdate <JobInfoEntity>(j => j.NextFireTime, nextFireTime), new DbUpdate <JobInfoEntity>(j => j.FireCount, job.FireCount + 1) }); r += _logRepository.Insert(logEntity) > 0 ? 1 : 0; if (r >= 2) { trans.Complete(); } } return(r >= 2); }