public function saveCurrentState($state, $status = null, $percent = 0) { $tx = RokGallery_Doctrine::getConnection()->transaction; $tx->setIsolation('REPEATABLE READ'); try { $tx->beginTransaction(); $this->_job->state = $state; if ($percent != 0) { $this->_job->percent = $percent; } $this->_job->status = $status; $this->_job->sm = serialize($this->_fsm); $this->_job->save(); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } }
/** * create a new Job and return the Job Info * * @param $params * @return RokCommon_Ajax_Result */ public function createJob($params) { $result = new RokCommon_Ajax_Result(); $tx = RokGallery_Doctrine::getConnection()->transaction; $tx->setIsolation('REPEATABLE READ'); try { $tx->beginTransaction(); $job = new RokGallery_Model_Job(); $job->id = RokCommon_UUID::generate(); $job->type = RokGallery_Model_Job::TYPE_UPLOAD; $job->state = RokGallery_Model_Job::STATE_PENDING; $job->percent = 0; $job->save(); $result->setPayload(array('job' => $job->id)); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } return $result; }