public function runAction()
 {
     $id = $this->params->get('id');
     $import = new Import(ImportSource::load($id, $this->db()));
     if ($runId = $import->run()) {
         Notification::success('Import succeeded');
         $this->redirectNow(Url::fromPath('director/importrun', array('id' => $runId)));
     } else {
         Notification::success('Import skipped, no changes detected');
         $this->redirectNow('director/list/importrun');
     }
 }
예제 #2
0
 protected function getRowClasses($row)
 {
     if (!$this->revalidate) {
         return array();
     }
     try {
         $import = new Import(ImportSource::load($row->id, $this->connection()));
         if ($import->providesChanges()) {
             $row->source_name = sprintf('%s (%s)', $row->source_name, $this->view()->translate('has changes'));
             return 'pending-changes';
         } else {
             return 'in-sync';
         }
     } catch (Exception $e) {
         $row->source_name = $row->source_name . ' (' . $e->getMessage() . ')';
         return 'failing';
     }
 }
예제 #3
0
 protected function runScheduledImports()
 {
     foreach (ImportSource::loadAll($this->db()) as $source) {
         Benchmark::measure('Starting with import ' . $source->source_name);
         try {
             $import = new Import($source);
             if ($import->providesChanges()) {
                 printf('Import "%s" provides changes, triggering run... ', $source->source_name);
                 Benchmark::measure('Found changes for ' . $source->source_name);
                 if ($import->run()) {
                     Benchmark::measure('Import succeeded for ' . $source->source_name);
                     print "SUCCEEDED\n";
                 }
             }
         } catch (Exception $e) {
             echo $this->screen->colorize('ERROR: ' . $e->getMessage(), 'red') . "\n";
             Benchmark::measure('FAILED');
         }
     }
     return $this;
 }