Commit 350770d65cd3c5c351b3791f50d62c121f1699c6

Authored by Eduardo Santos
Committed by Eduardo Santos
1 parent 3b229ed6
Exists in master and in 1 other branch 3.1

Conserta pequenos bugs na coleta

app/config/config.yml
@@ -16,11 +16,7 @@ framework: @@ -16,11 +16,7 @@ framework:
16 default_locale: "%locale%" 16 default_locale: "%locale%"
17 # trusted_proxies: ~ 17 # trusted_proxies: ~
18 session: ~ 18 session: ~
19 -<<<<<<< HEAD  
20 # session: 19 # session:
21 -=======  
22 -# session:  
23 ->>>>>>> 3231c12b96a54895b98ca370973d04235b4c924d  
24 # handler_id: session.handler.pdo 20 # handler_id: session.handler.pdo
25 21
26 parameters: 22 parameters:
src/Cacic/WSBundle/Controller/ColetaController.php
@@ -644,19 +644,30 @@ class ColetaController extends Controller @@ -644,19 +644,30 @@ class ColetaController extends Controller
644 $this->getDoctrine()->getManager()->persist($propriedadeSoftware); 644 $this->getDoctrine()->getManager()->persist($propriedadeSoftware);
645 $this->getDoctrine()->getManager()->flush(); 645 $this->getDoctrine()->getManager()->flush();
646 } else { 646 } else {
647 - // Adiciona referência à tabela de softwares  
648 - $softwareObject = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->find( $propriedadeSoftware->getSoftware()->getIdSoftware() );  
649 647
650 // Se não tiver nome coloco o ID Software no nome 648 // Se não tiver nome coloco o ID Software no nome
651 if (empty($arrTagsNames['DisplayName'])) { 649 if (empty($arrTagsNames['DisplayName'])) {
652 - $softwareObject->setNmSoftware($softwareName); 650 + $nmSoftware = $softwareName;
653 } else { 651 } else {
654 - $softwareObject->setNmSoftware($arrTagsNames['DisplayName']); 652 + $nmSoftware = $arrTagsNames['DisplayName'];
655 } 653 }
656 654
657 - // Grava software recém inserido  
658 - $this->getDoctrine()->getManager()->persist($softwareObject);  
659 - //$this->getDoctrine()->getManager()->flush(); 655 + // Adiciona referência à tabela de softwares
  656 + $softwareObject = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->findOneBy( array( 'nmSoftware' => $nmSoftware ) );
  657 +
  658 + if (empty($softwareObject)) {
  659 + $softwareObject = new Software();
  660 + // Se não tiver nome coloco o ID Software no nome
  661 + if (empty($arrTagsNames['DisplayName'])) {
  662 + $softwareObject->setNmSoftware($softwareName);
  663 + } else {
  664 + $softwareObject->setNmSoftware($arrTagsNames['DisplayName']);
  665 + }
  666 +
  667 + // Grava software recém inserido
  668 + $this->getDoctrine()->getManager()->persist($softwareObject);
  669 + $this->getDoctrine()->getManager()->flush();
  670 + }
660 671
661 // Ajusta valores coletados 672 // Ajusta valores coletados
662 $propriedadeSoftware->setDisplayName($arrTagsNames['DisplayName']); 673 $propriedadeSoftware->setDisplayName($arrTagsNames['DisplayName']);
src/Cacic/WSBundle/Controller/DefaultController.php
@@ -73,7 +73,7 @@ class DefaultController extends Controller @@ -73,7 +73,7 @@ class DefaultController extends Controller
73 $te_so = $request->get( 'te_so' ); 73 $te_so = $request->get( 'te_so' );
74 $ultimo_login = TagValueHelper::getValueFromTags( 'UserName' , $strComputerSystem); 74 $ultimo_login = TagValueHelper::getValueFromTags( 'UserName' , $strComputerSystem);
75 $ip_computador = $request->get('te_ip_computador'); 75 $ip_computador = $request->get('te_ip_computador');
76 - $ip_computador = !empty( $ip_computador ) ?: $_SERVER['REMOTE_ADDR']; 76 + $ip_computador = !empty( $ip_computador ) ?: TagValueHelper::getValueFromTags( 'IPAddress', $strNetworkAdapterConfiguration );
77 77
78 //vefifica se existe SO coletado se não, insere novo SO 78 //vefifica se existe SO coletado se não, insere novo SO
79 $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->createIfNotExist( $te_so ); 79 $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->createIfNotExist( $te_so );
@@ -150,7 +150,7 @@ class DefaultController extends Controller @@ -150,7 +150,7 @@ class DefaultController extends Controller
150 $strNetworkAdapterConfiguration = OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration') ); 150 $strNetworkAdapterConfiguration = OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration') );
151 $netmask = TagValueHelper::getValueFromTags( 'IPSubnet', $strNetworkAdapterConfiguration ); 151 $netmask = TagValueHelper::getValueFromTags( 'IPSubnet', $strNetworkAdapterConfiguration );
152 $ip_computador = $request->get('te_ip_computador'); 152 $ip_computador = $request->get('te_ip_computador');
153 - $ip_computador = !empty( $ip_computador ) ?: $_SERVER['REMOTE_ADDR']; 153 + $ip_computador = !empty( $ip_computador ) ?: TagValueHelper::getValueFromTags( 'IPAddress', $strNetworkAdapterConfiguration );
154 154
155 $te_node_adress = TagValueHelper::getValueFromTags( 'MACAddress', OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration'))); 155 $te_node_adress = TagValueHelper::getValueFromTags( 'MACAddress', OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration')));
156 $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->findOneBy( array('teSo'=>$request->get( 'te_so' ))); 156 $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->findOneBy( array('teSo'=>$request->get( 'te_so' )));