From 777333b6a41a6d26a50ff6bacee1a757a4e90da3 Mon Sep 17 00:00:00 2001 From: Bruno Noronha Date: Mon, 15 Sep 2014 15:39:48 -0300 Subject: [PATCH] modulo mapaController --- src/Cacic/WSBundle/Controller/MapaController.php | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+), 0 deletions(-) create mode 100644 src/Cacic/WSBundle/Controller/MapaController.php diff --git a/src/Cacic/WSBundle/Controller/MapaController.php b/src/Cacic/WSBundle/Controller/MapaController.php new file mode 100644 index 0000000..d45c8f8 --- /dev/null +++ b/src/Cacic/WSBundle/Controller/MapaController.php @@ -0,0 +1,96 @@ +get('logger'); + + OldCacicHelper::autenticaAgente($request); + $strNetworkAdapterConfiguration = OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration') ); + $netmask = TagValueHelper::getValueFromTags( 'IPSubnet', $strNetworkAdapterConfiguration ); + $ip_computador = $request->get('te_ip_computador'); + if ( empty($ip_computador) ){ + $ip_computador = TagValueHelper::getValueFromTags( 'IPAddress', $strNetworkAdapterConfiguration ); + } + if (empty($ip_computador)) { + $ip_computador = $request->getClientIp(); + } + + + $te_node_address = TagValueHelper::getValueFromTags( 'MACAddress', OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration'))); + + // Caso não tenha encontrado, tenta pegar a variável da requisição + if (empty($te_node_address)) { + $te_node_address = $request->get('te_node_address'); + } + + if (empty($netmask)) { + $netmask = $request->get('netmask'); + } + + $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->findOneBy( array('teSo'=>$request->get( 'te_so' ))); + $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $ip_computador, $netmask ); + $computador = $this->getDoctrine()->getRepository('CacicCommonBundle:Computador')->getComputadorPreCole( $request, $request->get( 'te_so' ),$te_node_address, $rede, $so, $ip_computador ); + $idComputador = $computador->getIdComputador(); + $logger->debug("Teste de Conexão MAPA ! Ip do computador: $ip_computador Máscara da rede: $netmask MAC Address: $te_node_address ID Computador: $idComputador"); + + $em = $this->getDoctrine()->getManager(); + + /** + * Verificar se o módulo está habilitado para o computador; + */ + $patr = $this->getDoctrine()->getRepository('CacicCommonBundle:AcaoRede')->findOneBy( array('rede'=>$rede->getIdRede(), 'acao'=>'col_patr')); + + /** + * Se o módulo estiver habilitado, verifica se existe coleta de patrimônio + */ + if (!empty($patr)){ + $query = $em->createQuery( + 'SELECT COUNT(cc) FROM CacicCommonBundle:ComputadorColeta cc INNER JOIN CacicCommonBundle:ClassProperty cp WHERE cp.idClass = 15 AND cc.computador = :id' + )->setParameter('id', $computador); + + $result = $query->getSingleResult(); + + $dadosPatrimonio = implode('',$result); + + } + + if (empty($dadosPatrimonio)) + $modPatrimonio = "True"; + else + $modPatrimonio = "False"; + + /** + * Mensagem a ser exibida na tela de Pop-Up do patrimônio + */ + $query = $em->createQuery( + 'SELECT cp.vlConfiguracao FROM CacicCommonBundle:ConfiguracaoPadrao cp WHERE cp.idConfiguracao = :idconfig' + )->setParameter('idconfig', 'msg_popup_patrimonio'); + + $result = $query->getSingleResult(); + $mensagem = implode('',$result); + + $response = new Response(); + $response->headers->set('Content-Type', 'xml'); + + return $this->render('CacicWSBundle:Default:mapa.xml.twig', array( + 'mensagem'=>$mensagem, + 'modPatrimonio' => $modPatrimonio, + ), $response); + + } +} \ No newline at end of file -- libgit2 0.21.2