/** * */ public function run() { $_job = new Tools_DataView_Job_MapperView(); $_job->setId($this->jobId)->retrieve(); try { $start = ZendT_Type_Date::nowDateTime(); $params = Tools_Interface_Job::prepareParams($_job->getParametro()->toPhp()); $procedimento = explode("::", $_job->getProcedimento()->toPhp()); $_obj = new $procedimento[0](); $_obj->{$procedimento[1]}($params); $finish = ZendT_Type_Date::nowDateTime(); $diff = $start->diff($finish); $_job->setTempoUlExec($diff->i); } catch (Exception $ex) { $message = 'Mensagem: ' . $ex->getMessage() . "\n"; $message .= 'Erro: ' . $ex->getTraceAsString() . "\n"; Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message); $_job->setTempoUlExec(0); } $_job->setDhUltExec(ZendT_Type_Date::nowDateTime()); $_job->setStatus('A'); $_job->update(); return true; }
public function run() { $_job = new Tools_DataView_Job_MapperView(); $_where = new ZendT_Db_Where(); $_where->addFilter('job.dh_pro_exec', ZendT_Type_Date::nowDateTime(), '<='); $_where->addFilter('job.dh_fim_exec', ZendT_Type_Date::nowDateTime(), '>='); $_where->addFilter('job.status', 'A'); $_job->findAll($_where, '*'); while ($_job->fetch()) { $_now = ZendT_Type_Date::nowDateTime(); while ($_job->getDhProExec()->toPhp() <= $_now->toPhp()) { if ($_job->getTpFrequencia()->toPhp() == 'H') { $_job->getDhProExec()->addHour($_job->getNumFrequencia()->toPhp()); } else { if ($_job->getTpFrequencia()->toPhp() == 'D') { $_job->getDhProExec()->addDay($_job->getNumFrequencia()->toPhp()); } else { if ($_job->getTpFrequencia()->toPhp() == 'M') { $_job->getDhProExec()->addMonth($_job->getNumFrequencia()->toPhp()); } } } } $_job->setStatus('E'); $_job->update(); try { if ($_job->getFormaExec()->toPhp() == 'C') { $_adapter = new Tools_Interface_Job_Php(); } else { $_adapter = new Tools_Interface_Job_Http(); } $_adapter->jobId = $_job->getId()->toPhp(); $_th = new ZendT_Thread(); $_th->start($_adapter, 'run'); } catch (Exception $ex) { $message = 'Mensagem: ' . $ex->getMessage() . "\n"; $message .= 'Erro: ' . $ex->getTraceAsString() . "\n"; Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message); } } }
/** * */ public function run() { $_job = new Tools_DataView_Job_MapperView(); $_job->setId($this->jobId)->retrieve(); try { $start = ZendT_Type_Date::nowDateTime(); $config = array('useragent' => 'Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/44.0', 'encodecookies' => false, 'timeout' => 60 * 60); $params = Tools_Interface_Job::prepareParams($_job->getParametro()->toPhp()); $_client = new Zend_Http_Client($_job->getProcedimento()->toPhp(), $config); if (count($params) > 0) { foreach ($params as $name => $value) { $_client->setParameterGet($name, $value); } } $response = $_client->request(); $message = $response->getBody(); if ($message == '' || $message == 'OK') { } else { Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message); } $finish = ZendT_Type_Date::nowDateTime(); $diff = $start->diff($finish); $_job->setTempoUlExec($diff->i); } catch (Exception $ex) { $message = 'Mensagem: ' . $ex->getMessage() . "\n"; $message .= 'Erro: ' . $ex->getTraceAsString() . "\n"; Tools_Model_LogErro_Mapper::log($_job->getProcedimento()->toPhp(), $message); $_job->setTempoUlExec(0); } $_job->setDhUltExec(ZendT_Type_Date::nowDateTime()); $_job->setStatus('A'); $_job->update(); return true; }