Commit 58581dfedb8b0562917e833b6eb5d4d3478d521b

Authored by Eduardo Santos
1 parent 1aa86522
Exists in master and in 1 other branch 3.1

Coleta de log dos dispositivos USB

src/Cacic/WSBundle/Controller/ColetaController.php
... ... @@ -258,50 +258,55 @@ class ColetaController extends Controller
258 258 public function gerColsSetUsbDetectAction(Request $request)
259 259 {
260 260 OldCacicHelper::autenticaAgente( $request ) ;
261   - $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $request );
262 261 $strNetworkAdapterConfiguration = OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration') );
263 262 $data = new \DateTime('NOW');
  263 + $netmask = TagValueHelper::getValueFromTags( 'IPSubnet', $strNetworkAdapterConfiguration );
  264 + $ip_computador = $request->get('te_ip_computador');
  265 + $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $ip_computador, $netmask );
264 266  
265 267 $te_node_adress = TagValueHelper::getValueFromTags( 'MACAddress', $strNetworkAdapterConfiguration );
266 268 $te_so = $request->get( 'te_so' );
267 269  
268 270 $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->findOneBy( array('teSo'=>$te_so) );
269 271 $computador = $this->getDoctrine()->getRepository('CacicCommonBundle:Computador')->findOneBy( array('idSo'=>$so, 'teNodeAddress'=>$te_node_adress) );
270   - $local = $this->getDoctrine()->getRepository('CacicCommonBundle:Local')->findOneBy(array( 'idLocal' => $rede->getIdLocal() ));
  272 + $local = $computador->getIdRede()->getIdLocal();
271 273  
272 274 $te_usb_info = OldCacicHelper::deCrypt($request, $request->get('te_usb_info'));
273 275 if ($te_usb_info <> '')
274 276 {
275 277 $arrUsbInfo = explode('_',$te_usb_info);
276 278  
277   - $usb_log = new UsbLog();
278   - $usb_log->setIdComputador($computador);
279   - $usb_log->getCsEvent($arrUsbInfo[0]);
280   - $usb_log->setDtEvent($arrUsbInfo[1]);
281   - //$usb_log->setIdUsbVendor($arrUsbInfo[2]);
282   - $usb_log->setIdUsbDevice($arrUsbInfo[3]);
283   -
284 279 $arrTeUsbFilter = $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->listarNotificacaoPropertyLocal( $local->getIdLocal() , 'te_usb_filter' );
285 280 $arrTeNotificarUtilizacaoUSB = $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->listarNotificacaoPropertyLocal( $rede->getIdLocal(), 'te_notificar_utilizacao_usb' );
286 281  
287   - $arrDeviceData = $this->getDoctrine()->getRepository('CacicCommonBundle:UsbDevice')->findBy( array('idDevice'=>$arrUsbInfo[3], 'idVendor'=>$arrUsbInfo[2] ));
288   -
289   - if (trim($arrDeviceData[0]['nmDevice'])=='')
290   - {
291   - $usb_device = new UsbDevice();
292   - $usb_device->setIdUsbVendor($arrUsbInfo[2]);
293   - $usb_device->setIdUsbDevice($arrUsbInfo[3]);
294   - $usb_device->getNmUsbDevice('Dispositivo USB Desconhecido');
295   - }
296   -
297 282 $arrVendorData = $this->getDoctrine()->getRepository('CacicCommonBundle:UsbVendor ')->findBy( array('idVendor'=>$arrUsbInfo[2]));
298   - if (trim($arrVendorData[0]['nmVendor'])=='')
  283 + if (empty($arrVendorData))
299 284 {
300 285 $usb_vendor = new UsbVendor();
301 286 $usb_vendor->setIdUsbVendor($arrUsbInfo[2]);
302 287 $usb_vendor->setNmUsbVendor('Fabricante de Dispositivos USB Desconhecido');
  288 +
  289 + $arrVendorData = $usb_vendor;
  290 + }
  291 +
  292 + $arrDeviceData = $this->getDoctrine()->getRepository('CacicCommonBundle:UsbDevice')->findBy( array('idDevice'=>$arrUsbInfo[3], 'idVendor'=>$arrUsbInfo[2] ));
  293 + if (empty($arrDeviceData))
  294 + {
  295 + $usb_device = new UsbDevice();
  296 + $usb_device->setIdUsbVendor($arrVendorData);
  297 + $usb_device->setIdDevice($arrUsbInfo[3]);
  298 + $usb_device->setNmUsbDevice('Dispositivo USB Desconhecido');
  299 +
  300 + $arrDeviceData = $usb_device;
303 301 }
304 302  
  303 + $usb_log = new UsbLog();
  304 + $usb_log->setIdComputador($computador);
  305 + $usb_log->getCsEvent($arrUsbInfo[0]);
  306 + $usb_log->setDtEvent($arrUsbInfo[1]);
  307 + $usb_log->setIdUsbDevice($arrDeviceData);
  308 +
  309 +
305 310 if ((trim($arrTeUsbFilter[0]['teUsbFilter'])<>'') && (trim($arrTeNotificarUtilizacaoUSB[0]['teNotificarUtilizacaoUsb']) <> ''))
306 311 {
307 312 $arrUSBfilter = explode('#',$arrTeUsbFilter[0]['te_usb_filter']);
... ...