예제 #1
0
파일: Run.php 프로젝트: stefansl/convertx
 /**
  * Create a new run
  *
  * @param $objRun
  * @param $arrParams
  * @return mixed
  */
 public static function createNewRun($objRun, $arrParams)
 {
     $objRun->setRow(array('pid' => $arrParams['job'], 'tstamp' => time(), 'begin' => time(), 'user' => $arrParams['user'] ? $arrParams['user'] : 0, 'status' => 'abort', 'simulation' => $arrParams['sim'] ? '1' : ''));
     $objRun->save();
     // find steps
     $objRun->steps = (array) ActualJob::findSteps($objRun->pid);
     // find target tables
     $objRun->targets = (array) ActualJob::findTargetTables($objRun->pid);
     $objRun->cleared = (array) $objRun->cleared;
     // find tmp source tables
     $objRun->sources = (array) ActualJob::findTmpSourceTables($objRun->pid);
     $objRun->filled = (array) $objRun->filled;
     // is child job
     if ($arrParams['jumpToRun'] && $arrParams['rootRun']) {
         // set jump back if child job
         $objRun->jumpToRun = $arrParams['jumpToRun'];
         // set root run id
         $objRun->rootRun = $arrParams['rootRun'];
         // add target and source table names to root run
         $objRootRun = self::findByPk($objRun->rootRun);
         if (!$objRootRun->id) {
             $objRun->error = true;
         }
         $objRootRun->targets = (array) $objRootRun->targets;
         $objRootRun->sources = (array) $objRootRun->sources;
         $objRootRun->targets = serialize(array_unique(array_merge($objRun->targets, $objRootRun->targets)));
         $objRootRun->sources = serialize(array_unique(array_merge($objRun->sources, $objRootRun->sources)));
         $objRootRun->save();
         if ($objRootRun->simulation) {
             $objRun->simulation = 1;
             $objRun->save();
         }
     } else {
         // is root run where target table names are stored
         $objRun->rootRun = $objRun->id;
     }
     $objRun->save();
     return $objRun;
 }
예제 #2
0
파일: Run.php 프로젝트: stefansl/convertx
 /**
  * Generate module
  *
  * @return string
  */
 protected function compile()
 {
     $this->import('BackendUser', 'User');
     // prepare template
     $this->Template = new BackendTemplate($this->strTemplate);
     $this->Template->back_href = $this->getReferer(true);
     $this->Template->back_title = specialchars($GLOBALS['TL_LANG']['MSC']['backBT']);
     $this->Template->back_button = $GLOBALS['TL_LANG']['MSC']['backBT'];
     $this->Template->action = ampersand($this->Environment->request);
     // -----------------------------------------
     // confirm job run first
     if (!Input::get('run')) {
         $objJob = Job::findJob(Input::get('id'));
         // job not found
         if ($objJob->error) {
             $this->Template->abort = true;
             $this->Template->running = false;
             $this->Template->complete = false;
             $this->Template->title = $objJob->title;
             $this->Template->error = $objJob->error;
             $this->Template->submit = $GLOBALS['TL_LANG']['tl_convertx_job']['end'];
             return $this->Template->parse();
         }
         // show confirmation form
         $this->Template->id = $objJob->id;
         $this->Template->title = sprintf($GLOBALS['TL_LANG']['tl_convertx_job']['jobTitle'], $objJob->id, $objJob->title);
         $this->Template->content = $GLOBALS['TL_LANG']['tl_convertx_job']['runNotice'];
         $this->Template->submit = $GLOBALS['TL_LANG']['tl_convertx_job']['start'];
         $this->Template->isSimulation = $GLOBALS['TL_LANG']['tl_convertx_job']['simNotice'];
         return $this->Template->parse();
     }
     $objRun = new ConvertXRun();
     $arrRun = $objRun->doRun(Input::get('run'), $this->User->id);
     foreach ($arrRun as $k => $v) {
         $this->Template->{$k} = $v;
     }
     return $this->Template->parse();
 }