From 350770d65cd3c5c351b3791f50d62c121f1699c6 Mon Sep 17 00:00:00 2001 From: Eduardo Santos Date: Mon, 16 Jun 2014 16:30:36 -0300 Subject: [PATCH] Conserta pequenos bugs na coleta --- app/config/config.yml | 4 ---- src/Cacic/WSBundle/Controller/ColetaController.php | 25 ++++++++++++++++++------- src/Cacic/WSBundle/Controller/DefaultController.php | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/config/config.yml b/app/config/config.yml index 4048c0f..be50683 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -16,11 +16,7 @@ framework: default_locale: "%locale%" # trusted_proxies: ~ session: ~ -<<<<<<< HEAD # session: -======= -# session: ->>>>>>> 3231c12b96a54895b98ca370973d04235b4c924d # handler_id: session.handler.pdo parameters: diff --git a/src/Cacic/WSBundle/Controller/ColetaController.php b/src/Cacic/WSBundle/Controller/ColetaController.php index c1e3056..0105b57 100644 --- a/src/Cacic/WSBundle/Controller/ColetaController.php +++ b/src/Cacic/WSBundle/Controller/ColetaController.php @@ -644,19 +644,30 @@ class ColetaController extends Controller $this->getDoctrine()->getManager()->persist($propriedadeSoftware); $this->getDoctrine()->getManager()->flush(); } else { - // Adiciona referência à tabela de softwares - $softwareObject = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->find( $propriedadeSoftware->getSoftware()->getIdSoftware() ); // Se não tiver nome coloco o ID Software no nome if (empty($arrTagsNames['DisplayName'])) { - $softwareObject->setNmSoftware($softwareName); + $nmSoftware = $softwareName; } else { - $softwareObject->setNmSoftware($arrTagsNames['DisplayName']); + $nmSoftware = $arrTagsNames['DisplayName']; } - // Grava software recém inserido - $this->getDoctrine()->getManager()->persist($softwareObject); - //$this->getDoctrine()->getManager()->flush(); + // Adiciona referência à tabela de softwares + $softwareObject = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->findOneBy( array( 'nmSoftware' => $nmSoftware ) ); + + if (empty($softwareObject)) { + $softwareObject = new Software(); + // Se não tiver nome coloco o ID Software no nome + if (empty($arrTagsNames['DisplayName'])) { + $softwareObject->setNmSoftware($softwareName); + } else { + $softwareObject->setNmSoftware($arrTagsNames['DisplayName']); + } + + // Grava software recém inserido + $this->getDoctrine()->getManager()->persist($softwareObject); + $this->getDoctrine()->getManager()->flush(); + } // Ajusta valores coletados $propriedadeSoftware->setDisplayName($arrTagsNames['DisplayName']); diff --git a/src/Cacic/WSBundle/Controller/DefaultController.php b/src/Cacic/WSBundle/Controller/DefaultController.php index ceaea03..caffb53 100755 --- a/src/Cacic/WSBundle/Controller/DefaultController.php +++ b/src/Cacic/WSBundle/Controller/DefaultController.php @@ -73,7 +73,7 @@ class DefaultController extends Controller $te_so = $request->get( 'te_so' ); $ultimo_login = TagValueHelper::getValueFromTags( 'UserName' , $strComputerSystem); $ip_computador = $request->get('te_ip_computador'); - $ip_computador = !empty( $ip_computador ) ?: $_SERVER['REMOTE_ADDR']; + $ip_computador = !empty( $ip_computador ) ?: TagValueHelper::getValueFromTags( 'IPAddress', $strNetworkAdapterConfiguration ); //vefifica se existe SO coletado se não, insere novo SO $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->createIfNotExist( $te_so ); @@ -150,7 +150,7 @@ class DefaultController extends Controller $strNetworkAdapterConfiguration = OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration') ); $netmask = TagValueHelper::getValueFromTags( 'IPSubnet', $strNetworkAdapterConfiguration ); $ip_computador = $request->get('te_ip_computador'); - $ip_computador = !empty( $ip_computador ) ?: $_SERVER['REMOTE_ADDR']; + $ip_computador = !empty( $ip_computador ) ?: TagValueHelper::getValueFromTags( 'IPAddress', $strNetworkAdapterConfiguration ); $te_node_adress = TagValueHelper::getValueFromTags( 'MACAddress', OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration'))); $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->findOneBy( array('teSo'=>$request->get( 'te_so' ))); -- libgit2 0.21.2