/** * * função encupsulada para importar arquivos para geoJson. * * @param string $inputFile * @param array $options * @param string $path * @param string $pathTemp */ public function toJson($inputFile, $options = NULL, $input = NULL, $output = NULL) { if (!$input) { $input = $this->input; } $inputFile = $input . $inputFile; if (!$output) { $output = $this->output; } if (!$options) { $options[] = 'skipfailures'; } $outputFile = $output . date('YmdHis') . '_json_temp' . '.geojson'; $result = $this->ogrToOgr($inputFile, $outputFile, 'geoJSON', $options); if ($result) { // throw exception; // falha na biblioteca GDAL \Core_Messaging_Manager::getGateway('Service')->addErrorMessage('MN087'); throw new \Core_Exception_ServiceLayer_Verification(); } $content = file_get_contents($outputFile); // remove arquivo temporário unlink($outputFile); return $content; }
public function verificaTipoPerfil($sqTipoPerfil, array $arrTipoPerfil = array(1, 2, 3)) { if (!in_array($sqTipoPerfil, $arrTipoPerfil)) { \Core_Messaging_Manager::getGateway('Service')->addErrorMessage('MN148'); throw new \Core_Exception_ServiceLayer_Verification(); } }
public function abracadabraAction() { $message = \Core_Messaging_Manager::getGateway('User'); try { $token = $this->getRequest()->getParam('token', NULL); $step = $this->getRequest()->getParam('step', 'MigrationImageRequested'); if (md5($token) != 'c73722b6f4c9637a47fb87f667582745') { throw new Exception('Token inválido.'); } if (!$step) { throw new Exception('Step não definido'); } $lockFilename = '.~robot_' . $step . '.lock'; $lockFullFilename = APPLICATION_PATH . '/../data/' . $lockFilename; if (file_exists($lockFullFilename)) { if (unlink($lockFullFilename)) { $message->addSuccessMessage($lockFilename . ' Removido.'); } else { throw new Exception('Erro ao excluir o loc: ' . $lockFullFilename); } } else { $message->addAlertMessage('File lock not found: ' . $lockFullFilename); } } catch (Exception $ex) { $message->addErrorMessage($ex->getMessage()); } $message->dispatchPackets(); $this->_redirect('log'); }
public function getSistemasPorTipoPerfil($sqTipoPerfil = 1, array $arrTipoPerfil = array(1, 2), $exc = TRUE) { $qBuilder = $this->_em->createQueryBuilder(); $query = $qBuilder->select('s.sqSistema')->from('app:UsuarioPerfil', 'up')->innerJoin('up.sqUsuario', 'u')->innerJoin('up.sqPerfil', 'p')->innerJoin('p.sqTipoPerfil', 'tp')->innerJoin('p.sqSistema', 's')->where($qBuilder->expr()->in('tp.sqTipoPerfil', ':sqTipoPerfil'))->andWhere($qBuilder->expr()->eq('u.sqUsuario', ':sqUsuario'))->setParameters(array('sqTipoPerfil' => $arrTipoPerfil, 'sqUsuario' => \Core_Integration_Sica_User::getUserId())); $result = $query->getQuery()->getResult(); $arrSistemas = array(); foreach ($result as $value) { $arrSistemas[] = $value['sqSistema']; } $arrSistemas = array_unique($arrSistemas); $sqSistema = \Core_Integration_Sica_User::getUserSystem(); if ($sqTipoPerfil == 3) { $key = array_search($sqSistema, $arrSistemas); if ($key !== FALSE) { unset($arrSistemas[$key]); } } if (!$arrSistemas || in_array($sqSistema, $arrSistemas) && count($arrSistemas) == 1) { if ($exc) { \Core_Messaging_Manager::getGateway('Service')->addErrorMessage('MN148'); throw new \Core_Exception_ServiceLayer_Verification(); } } return $arrSistemas; }
/** * Set redirect in response object * * @return void */ protected function _redirect($url) { $request = $this->getRequest(); if ($request instanceof Zend_Controller_Request_Http && $request->isXmlHttpRequest()) { return; } Core_Messaging_Manager::getGateway('User')->dispatchPackets(); parent::_redirect($url); }
/** * método que remove sequencial * @param integer $sequence * @return boolean */ public function deActivate($sequence) { $message = \Core_Messaging_Manager::getGateway('User'); $entity = $this->find($sequence); try { $this->_em->remove($entity); $this->_em->flush(); $message->addSuccessMessage('MN045'); } catch (\PDOException $e) { $message->addAlertMessage('MN067'); } $message->dispatchPackets(); return TRUE; }
public function userMessageStack() { $userMessage = ''; $gw = Core_Messaging_Manager::getGateway('User'); if (!$gw) { return ''; } $packet = $gw->retrievePackets('User'); if (0 === count($packet)) { return ''; } foreach ($packet->getMessages('error') as $message) { $userMessage .= '<div class="alert alert-error"> <button class="close" data-dismiss="alert">×</button> ' . $message . ' </div>'; } foreach ($packet->getMessages('alert') as $message) { $userMessage .= '<div class="alert"> <button class="close" data-dismiss="alert">×</button> ' . $message . ' </div>'; } foreach ($packet->getMessages('success') as $message) { $userMessage .= '<div class="alert alert-success"> <button class="close" data-dismiss="alert">×</button> ' . $message . ' </div>'; } foreach ($packet->getMessages('info') as $message) { $userMessage .= '<div class="alert alert-info"> <button class="close" data-dismiss="alert">×</button> ' . $message . ' </div>'; } return $userMessage; }
/** * Retorna o Gateway com o qual esta camada deve lidar * @return Core_Messaging_Gateway */ public function getMessaging() { return Core_Messaging_Manager::getGateway('User'); }
protected function _retriveMessages($gateway = 'Service', $type = NULL) { if (NULL === $gateway) { $gateway = 'Service'; } $gateway = Core_Messaging_Manager::getGateway($gateway); $packets = $gateway->retrievePackets(NULL, TRUE, TRUE); $messages = array(); if ($packets instanceof Core_Messaging_Packet) { $messages = $packets->getAllMessages(); } if (isset($messages[$type])) { $messages = $messages[$type]; } return $messages; }
/** * método que remove sequencial * @param integer $sequence * @return boolean */ public function deActivate($sequence) { $message = \Core_Messaging_Manager::getGateway('User'); $entity = $this->find($sequence); try { $this->_em->remove($entity); $this->_em->flush(); $message->addSuccessMessage('MN045'); } catch (\PDOException $exp) { $message->addAlertMessage('MN057'); $queryBuilder = $this->_em->createQueryBuilder()->update('app:TipoDocumento', 't')->set('t.stAtivo', 'FALSE')->where('t.sqTipoDocumento = :sqTipoDocumento')->setParameter('sqTipoDocumento', $sequence); $message->addSuccessMessage('MN055'); $res = $queryBuilder->getQuery()->execute(); } $message->dispatchPackets(); return TRUE; }
/** * Trata a mensageira para retorno ao Service. * @throws \Core_Exception */ protected function _errorMessageDispatch() { $messageError = $this->getAdapter()->getMessages(); $mm = Core_Messaging_Manager::getGateway('User'); foreach ($messageError as $error => $msg) { $mm->addErrorMessage($msg); } throw new \Core_Upload_Exception(); }
/** * * Enter description here ... * @param unknown_type $flush */ public function retrievePackets($receiver = null, $flush = true, $dispatch = FALSE) { if ($dispatch) { $this->dispatchPackets(); } if (!$receiver) { $receiver = $this->id; } $packets = $this->_getAdapter()->retrievePackets($receiver); if ($receiver !== $this->id) { $packetsGateway = Core_Messaging_Manager::getGateway($receiver)->retrievePackets(); $packets = (array) $packets; array_splice($packets, count($packetsGateway), 0, $packetsGateway); } if ($flush) { $this->_packets[$receiver] = array(); $this->_getAdapter()->flushPackets($receiver); } return $packets; }