Commit 8eee40438e7c50fed797da67d70ecb1b02959acd
1 parent
d1c2dc1b
Exists in
master
and in
1 other branch
módulo getupdate
Showing
1 changed file
with
71 additions
and
4 deletions
Show diff stats
src/Cacic/WSBundle/Controller/DefaultController.php
... | ... | @@ -18,6 +18,8 @@ use Cacic\CommonBundle\Entity\RedeVersaoModulo; |
18 | 18 | use Cacic\WSBundle\Helper\OldCacicHelper; |
19 | 19 | use Cacic\WSBundle\Helper\TagValueHelper; |
20 | 20 | use Cacic\CommonBundle\Entity\LogAcesso; |
21 | +use Symfony\Component\HttpFoundation\RedirectResponse; | |
22 | + | |
21 | 23 | |
22 | 24 | /** |
23 | 25 | * |
... | ... | @@ -94,7 +96,7 @@ class DefaultController extends Controller |
94 | 96 | $ip_computador = $request->getClientIp(); |
95 | 97 | } |
96 | 98 | #$logger->debug("333333333333333333333333333333333333: $ip_computador"); |
97 | - $logger->debug("Teste de Conexão! Ip do computador: $ip_computador Máscara da rede: $netmask"); | |
99 | + $logger->debug("Teste de Conexão GET-TEST! Ip do computador: $ip_computador Máscara da rede: $netmask"); | |
98 | 100 | |
99 | 101 | // Caso não tenha encontrado, tenta pegar a variável da requisição |
100 | 102 | if (empty($te_node_address)) { |
... | ... | @@ -200,7 +202,14 @@ class DefaultController extends Controller |
200 | 202 | $netmask = $request->get('netmask'); |
201 | 203 | } |
202 | 204 | |
203 | - $logger->debug("Teste de Conexão! Ip do computador: $ip_computador Máscara da rede: $netmask MAC Address: $te_node_address"); | |
205 | + /** | |
206 | + * Se a máscara de subrede ou o mac address estiver vazio, força o redirecionamento para provável atualização | |
207 | + */ | |
208 | + if (empty($netmask) || (empty($te_node_address))) { | |
209 | + | |
210 | + return $this->forward('CacicWSBundle:Default:update', $this->getRequest()->request->all()); | |
211 | + | |
212 | + } | |
204 | 213 | |
205 | 214 | $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->findOneBy( array('teSo'=>$request->get( 'te_so' ))); |
206 | 215 | $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $ip_computador, $netmask ); |
... | ... | @@ -208,6 +217,7 @@ class DefaultController extends Controller |
208 | 217 | //$local = $this->getDoctrine()->getRepository('CacicCommonBundle:Local')->findOneBy(array( 'idLocal' => $rede->getIdLocal() )); |
209 | 218 | $local = $rede->getIdLocal(); |
210 | 219 | $data = new \DateTime('NOW'); |
220 | + $logger->debug("Teste de Conexão GET-CONFIG! Ip do computador: $ip_computador Máscara da rede: $netmask MAC Address: $te_node_address"); | |
211 | 221 | |
212 | 222 | //Debugging do Agente |
213 | 223 | $debugging = ( TagValueHelper::getValueFromTags('DateToDebugging',$computador->getTeDebugging() ) == date("Ymd") ? $computador->getTeDebugging() : |
... | ... | @@ -231,7 +241,6 @@ class DefaultController extends Controller |
231 | 241 | $rede_grupos_ftp->setNuHoraFim($data); |
232 | 242 | } |
233 | 243 | |
234 | - | |
235 | 244 | //Se instalação realizada com sucesso. |
236 | 245 | if (trim($request->get('in_instalacao')) == 'OK' ) |
237 | 246 | { |
... | ... | @@ -250,7 +259,6 @@ class DefaultController extends Controller |
250 | 259 | $rede_grupos_ftp = new RedeGrupoFtp(); |
251 | 260 | } |
252 | 261 | |
253 | - | |
254 | 262 | // Contagem por subrede |
255 | 263 | $rede_grupos_ftp_repository = $this->getDoctrine()->getRepository('CacicCommonBundle:RedeGrupoFtp')->findBy(array('idRede' => $rede->getIdRede())); |
256 | 264 | $soma_redes_grupo_ftp = count($rede_grupos_ftp_repository); |
... | ... | @@ -552,4 +560,63 @@ class DefaultController extends Controller |
552 | 560 | // 'modPatrimonio'=> $modPatrimonio, |
553 | 561 | ), $response); |
554 | 562 | } |
563 | + | |
564 | + /** | |
565 | + * Método responsável por verificar e e enviar os Hashes ao Agente CACIC | |
566 | + * @param Symfony\Component\HttpFoundation\Request $request | |
567 | + */ | |
568 | + public function updateAction( Request $request ) | |
569 | + { | |
570 | + $logger = $this->get('logger'); | |
571 | + OldCacicHelper::autenticaAgente( $request ) ; | |
572 | + $strNetworkAdapterConfiguration = OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration') ); | |
573 | + | |
574 | + $te_node_address = TagValueHelper::getValueFromTags( 'MACAddress', $strNetworkAdapterConfiguration ); | |
575 | + $netmask = TagValueHelper::getValueFromTags( 'IPSubnet', $strNetworkAdapterConfiguration ); | |
576 | + $ip_computador = $request->get('te_ip_computador'); | |
577 | + if ( empty($ip_computador) ){ | |
578 | + $ip_computador = TagValueHelper::getValueFromTags( 'IPAddress', $strNetworkAdapterConfiguration ); | |
579 | + } | |
580 | + if (empty($ip_computador)) { | |
581 | + $ip_computador = $request->getClientIp(); | |
582 | + } | |
583 | + | |
584 | + /** | |
585 | + * Caso não tenha encontrado, tenta pegar a variável da requisição | |
586 | + */ | |
587 | + if (empty($te_node_address)) { | |
588 | + $te_node_address = $request->get('te_node_address'); | |
589 | + } | |
590 | + | |
591 | + if (empty($netmask)) { | |
592 | + $netmask = $request->get('netmask'); | |
593 | + } | |
594 | + | |
595 | + /** | |
596 | + * Executa atualização forçada se algum dos parâmetros obrigatórios estiver vazio | |
597 | + */ | |
598 | + $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $ip_computador, $netmask ); | |
599 | + $local = $rede->getIdLocal(); | |
600 | + $configs = $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->listarPorLocal($local->getIdLocal()); | |
601 | + $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $ip_computador, $netmask ); | |
602 | + $redes_versoes_modulos = $this->getDoctrine()->getRepository('CacicCommonBundle:RedeVersaoModulo')->findBy( array( 'idRede'=>$rede->getIdRede() ) ); | |
603 | + $nm_user_login_updates = OldCacicHelper::enCrypt($request, $rede->getNmUsuarioLoginServUpdates()); | |
604 | + $senha_serv_updates = OldCacicHelper::enCrypt($request, $rede->getTeSenhaLoginServUpdates()); | |
605 | + $logger->debug("Teste de Conexão GET-UPDATE! Ip do computador: $ip_computador Máscara da rede: $netmask MAC Address: $te_node_address"); | |
606 | + | |
607 | + $response = new Response(); | |
608 | + $response->headers->set('Content-Type', 'xml'); | |
609 | + return $this->render('CacicWSBundle:Default:update.xml.twig', array( | |
610 | + 'configs'=>$configs, | |
611 | + 'rede'=> $rede, | |
612 | + 'redes_versoes_modulos'=>$redes_versoes_modulos, | |
613 | + 'main_program'=>OldCacicHelper::CACIC_MAIN_PROGRAM_NAME.'.exe', | |
614 | + 'folder_name'=>OldCacicHelper::CACIC_LOCAL_FOLDER_NAME, | |
615 | + 'nm_user_login_updates'=>$nm_user_login_updates, | |
616 | + 'senha_serv_updates'=>$senha_serv_updates, | |
617 | + 'cs_compress'=>$request->get('cs_compress'), | |
618 | + 'cs_cipher'=>$request->get('cs_cipher'), | |
619 | + 'ws_folder'=>OldCacicHelper::CACIC_WEB_SERVICES_FOLDER_NAME, | |
620 | + ), $response); | |
621 | + } | |
555 | 622 | } | ... | ... |