示例#1
0
文件: job.php 项目: javigomez/neno
 /**
  * Send Job
  *
  * @return bool
  */
 public function sendJob()
 {
     $this->generateJobFile();
     $this->setSentTime(new DateTime())->setState(self::JOB_STATE_SENT);
     $data = array('filename' => $this->getFileName() . '.json.zip', 'words' => $this->getWordCount(), 'translation_method' => NenoHelper::convertTranslationMethodIdToName($this->getTranslationMethod()->id), 'source_language' => $this->getFromLanguage(), 'destination_language' => $this->getToLanguage());
     list($status, $response) = NenoHelperApi::makeApiCall('job', 'POST', $data);
     if ($status === false) {
         $this->setSentTime(null)->setState(self::JOB_STATE_GENERATED);
         if ($response['code'] == 402) {
             $this->setState(self::JOB_STATE_NO_TC);
         }
     }
     $this->persist();
     return $status !== false;
 }
示例#2
0
文件: job.php 项目: andresmaeso/neno
 /**
  * Send Job
  *
  * @return bool
  */
 public function sendJob()
 {
     $this->generateJobFile();
     $this->setSentTime(new DateTime())->setState(self::JOB_STATE_SENT);
     $data = array('filename' => JUri::root() . 'tmp/' . $this->getFileName() . '.json.zip', 'words' => $this->getWordCount(), 'translation_method' => NenoHelper::convertTranslationMethodIdToName($this->getTranslationMethod()->id), 'source_language' => $this->getFromLanguage(), 'destination_language' => $this->getToLanguage());
     list($status, $response) = NenoHelperApi::makeApiCall('job', 'POST', $data);
     if ($status === false) {
         $this->setSentTime(null)->setState(self::JOB_STATE_GENERATED);
         if ($response['code'] !== 200) {
             switch ($response['code']) {
                 // System disabled
                 case 501:
                     $this->setState(self::JOB_STATE_NOT_READY);
                     break;
                     // More TC needed
                 // More TC needed
                 case 402:
                     $this->setState(self::JOB_STATE_NO_TC);
                     break;
             }
         }
     }
     $this->persist();
     return $status !== false;
 }