Commit f1165d314ce3ab97bbad6dc313e9c9fe9d66fffd
Exists in
master
and in
1 other branch
Merge branch 'master' of https://github.com/lightbase/cacic
Showing
8 changed files
with
397 additions
and
293 deletions
Show diff stats
app/config/config.yml
... | ... | @@ -116,7 +116,10 @@ swiftmailer: |
116 | 116 | host: "%mailer_host%" |
117 | 117 | username: "%mailer_user%" |
118 | 118 | password: "%mailer_password%" |
119 | - spool: { type: memory } | |
119 | + spool: | |
120 | + type: file | |
121 | + path: "%kernel.root_dir%/spool" | |
122 | + | |
120 | 123 | |
121 | 124 | # KNP Paginator Configuration |
122 | 125 | knp_paginator: | ... | ... |
app/config/config_dev.yml
app/config/config_prod.yml
composer.lock
... | ... | @@ -219,8 +219,7 @@ |
219 | 219 | { |
220 | 220 | "name": "Jonathan Wage", |
221 | 221 | "email": "jonwage@gmail.com", |
222 | - "homepage": "http://www.jwage.com/", | |
223 | - "role": "Creator" | |
222 | + "homepage": "http://www.jwage.com/" | |
224 | 223 | }, |
225 | 224 | { |
226 | 225 | "name": "Guilherme Blanco", |
... | ... | @@ -434,8 +433,7 @@ |
434 | 433 | { |
435 | 434 | "name": "Jonathan Wage", |
436 | 435 | "email": "jonwage@gmail.com", |
437 | - "homepage": "http://www.jwage.com/", | |
438 | - "role": "Creator" | |
436 | + "homepage": "http://www.jwage.com/" | |
439 | 437 | }, |
440 | 438 | { |
441 | 439 | "name": "Guilherme Blanco", |
... | ... | @@ -530,12 +528,12 @@ |
530 | 528 | "source": { |
531 | 529 | "type": "git", |
532 | 530 | "url": "https://github.com/doctrine/dbal.git", |
533 | - "reference": "2a37b007dda8e21bdbb8fa445be8fa0064199e13" | |
531 | + "reference": "2.3.4" | |
534 | 532 | }, |
535 | 533 | "dist": { |
536 | 534 | "type": "zip", |
537 | - "url": "https://api.github.com/repos/doctrine/dbal/zipball/2a37b007dda8e21bdbb8fa445be8fa0064199e13", | |
538 | - "reference": "2a37b007dda8e21bdbb8fa445be8fa0064199e13", | |
535 | + "url": "https://api.github.com/repos/doctrine/dbal/zipball/2.3.4", | |
536 | + "reference": "2.3.4", | |
539 | 537 | "shasum": "" |
540 | 538 | }, |
541 | 539 | "require": { |
... | ... | @@ -561,8 +559,7 @@ |
561 | 559 | { |
562 | 560 | "name": "Jonathan Wage", |
563 | 561 | "email": "jonwage@gmail.com", |
564 | - "homepage": "http://www.jwage.com/", | |
565 | - "role": "Creator" | |
562 | + "homepage": "http://www.jwage.com/" | |
566 | 563 | }, |
567 | 564 | { |
568 | 565 | "name": "Guilherme Blanco", |
... | ... | @@ -595,25 +592,25 @@ |
595 | 592 | "source": { |
596 | 593 | "type": "git", |
597 | 594 | "url": "https://github.com/doctrine/DoctrineBundle.git", |
598 | - "reference": "765b0d87fcc3e839c74817b7211258cbef3a4fb9" | |
595 | + "reference": "v1.2.0" | |
599 | 596 | }, |
600 | 597 | "dist": { |
601 | 598 | "type": "zip", |
602 | - "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/765b0d87fcc3e839c74817b7211258cbef3a4fb9", | |
603 | - "reference": "765b0d87fcc3e839c74817b7211258cbef3a4fb9", | |
599 | + "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/v1.2.0", | |
600 | + "reference": "v1.2.0", | |
604 | 601 | "shasum": "" |
605 | 602 | }, |
606 | 603 | "require": { |
607 | 604 | "doctrine/dbal": ">=2.2,<2.5-dev", |
608 | - "jdorn/sql-formatter": "~1.1", | |
605 | + "jdorn/sql-formatter": ">=1.1,<2.0", | |
609 | 606 | "php": ">=5.3.2", |
610 | - "symfony/doctrine-bridge": "~2.2", | |
611 | - "symfony/framework-bundle": "~2.2" | |
607 | + "symfony/doctrine-bridge": ">=2.2,<3.0", | |
608 | + "symfony/framework-bundle": ">=2.2,<3.0" | |
612 | 609 | }, |
613 | 610 | "require-dev": { |
614 | 611 | "doctrine/orm": ">=2.2,<2.5-dev", |
615 | - "symfony/validator": "~2.2", | |
616 | - "symfony/yaml": "~2.2" | |
612 | + "symfony/validator": ">=2.2,<3.0", | |
613 | + "symfony/yaml": ">=2.2,<3.0" | |
617 | 614 | }, |
618 | 615 | "suggest": { |
619 | 616 | "doctrine/orm": "The Doctrine ORM integration is optional in the bundle.", |
... | ... | @@ -749,8 +746,7 @@ |
749 | 746 | { |
750 | 747 | "name": "Jonathan Wage", |
751 | 748 | "email": "jonwage@gmail.com", |
752 | - "homepage": "http://www.jwage.com/", | |
753 | - "role": "Creator" | |
749 | + "homepage": "http://www.jwage.com/" | |
754 | 750 | }, |
755 | 751 | { |
756 | 752 | "name": "Guilherme Blanco", |
... | ... | @@ -766,7 +762,7 @@ |
766 | 762 | "email": "kontakt@beberlei.de" |
767 | 763 | }, |
768 | 764 | { |
769 | - "name": "Johannes Schmitt", | |
765 | + "name": "Johannes M. Schmitt", | |
770 | 766 | "email": "schmittjoh@gmail.com", |
771 | 767 | "homepage": "http://jmsyst.com", |
772 | 768 | "role": "Developer of wrapped JMSSerializerBundle" |
... | ... | @@ -1285,13 +1281,13 @@ |
1285 | 1281 | "version": "1.0.0", |
1286 | 1282 | "source": { |
1287 | 1283 | "type": "git", |
1288 | - "url": "https://github.com/schmittjoh/cg-library.git", | |
1289 | - "reference": "ce8ef43dd6bfe6ce54e5e9844ab71be2343bf2fc" | |
1284 | + "url": "git://github.com/schmittjoh/cg-library.git", | |
1285 | + "reference": "1.0.0" | |
1290 | 1286 | }, |
1291 | 1287 | "dist": { |
1292 | 1288 | "type": "zip", |
1293 | - "url": "https://api.github.com/repos/schmittjoh/cg-library/zipball/ce8ef43dd6bfe6ce54e5e9844ab71be2343bf2fc", | |
1294 | - "reference": "ce8ef43dd6bfe6ce54e5e9844ab71be2343bf2fc", | |
1289 | + "url": "https://github.com/schmittjoh/cg-library/zipball/1.0.0", | |
1290 | + "reference": "1.0.0", | |
1295 | 1291 | "shasum": "" |
1296 | 1292 | }, |
1297 | 1293 | "require": { |
... | ... | @@ -1319,7 +1315,7 @@ |
1319 | 1315 | "keywords": [ |
1320 | 1316 | "code generation" |
1321 | 1317 | ], |
1322 | - "time": "2012-01-02 20:40:52" | |
1318 | + "time": "2012-01-02 12:40:52" | |
1323 | 1319 | }, |
1324 | 1320 | { |
1325 | 1321 | "name": "jms/di-extra-bundle", |
... | ... | @@ -1328,20 +1324,20 @@ |
1328 | 1324 | "source": { |
1329 | 1325 | "type": "git", |
1330 | 1326 | "url": "https://github.com/schmittjoh/JMSDiExtraBundle.git", |
1331 | - "reference": "7fffdb6c96fb922a131af06d773e1e6c5301d070" | |
1327 | + "reference": "1.4.0" | |
1332 | 1328 | }, |
1333 | 1329 | "dist": { |
1334 | 1330 | "type": "zip", |
1335 | - "url": "https://api.github.com/repos/schmittjoh/JMSDiExtraBundle/zipball/7fffdb6c96fb922a131af06d773e1e6c5301d070", | |
1336 | - "reference": "7fffdb6c96fb922a131af06d773e1e6c5301d070", | |
1331 | + "url": "https://api.github.com/repos/schmittjoh/JMSDiExtraBundle/zipball/1.4.0", | |
1332 | + "reference": "1.4.0", | |
1337 | 1333 | "shasum": "" |
1338 | 1334 | }, |
1339 | 1335 | "require": { |
1340 | 1336 | "jms/aop-bundle": ">=1.0.0,<1.2-dev", |
1341 | 1337 | "jms/metadata": "1.*", |
1342 | - "symfony/finder": "~2.1", | |
1343 | - "symfony/framework-bundle": "~2.1", | |
1344 | - "symfony/process": "~2.1" | |
1338 | + "symfony/finder": ">=2.1,<3.0", | |
1339 | + "symfony/framework-bundle": ">=2.1,<3.0", | |
1340 | + "symfony/process": ">=2.1,<3.0" | |
1345 | 1341 | }, |
1346 | 1342 | "require-dev": { |
1347 | 1343 | "doctrine/doctrine-bundle": "*", |
... | ... | @@ -1425,7 +1421,7 @@ |
1425 | 1421 | ], |
1426 | 1422 | "authors": [ |
1427 | 1423 | { |
1428 | - "name": "Johannes M. Schmitt", | |
1424 | + "name": "Johannes Schmitt", | |
1429 | 1425 | "email": "schmittjoh@gmail.com", |
1430 | 1426 | "homepage": "http://jmsyst.com", |
1431 | 1427 | "role": "Developer of wrapped JMSSerializerBundle" |
... | ... | @@ -1445,13 +1441,13 @@ |
1445 | 1441 | "version": "1.0.0", |
1446 | 1442 | "source": { |
1447 | 1443 | "type": "git", |
1448 | - "url": "https://github.com/schmittjoh/parser-lib.git", | |
1449 | - "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d" | |
1444 | + "url": "git://github.com/schmittjoh/parser-lib", | |
1445 | + "reference": "1.0.0" | |
1450 | 1446 | }, |
1451 | 1447 | "dist": { |
1452 | 1448 | "type": "zip", |
1453 | - "url": "https://api.github.com/repos/schmittjoh/parser-lib/zipball/c509473bc1b4866415627af0e1c6cc8ac97fa51d", | |
1454 | - "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d", | |
1449 | + "url": "https://github.com/schmittjoh/parser-lib/archive/1.0.0.zip", | |
1450 | + "reference": "1.0.0", | |
1455 | 1451 | "shasum": "" |
1456 | 1452 | }, |
1457 | 1453 | "require": { |
... | ... | @@ -1482,20 +1478,20 @@ |
1482 | 1478 | "source": { |
1483 | 1479 | "type": "git", |
1484 | 1480 | "url": "https://github.com/schmittjoh/JMSSecurityExtraBundle.git", |
1485 | - "reference": "f5f6c6df69ceae8b709e57b49fcc2a42d9280bcc" | |
1481 | + "reference": "1.5.1" | |
1486 | 1482 | }, |
1487 | 1483 | "dist": { |
1488 | 1484 | "type": "zip", |
1489 | - "url": "https://api.github.com/repos/schmittjoh/JMSSecurityExtraBundle/zipball/f5f6c6df69ceae8b709e57b49fcc2a42d9280bcc", | |
1490 | - "reference": "f5f6c6df69ceae8b709e57b49fcc2a42d9280bcc", | |
1485 | + "url": "https://api.github.com/repos/schmittjoh/JMSSecurityExtraBundle/zipball/1.5.1", | |
1486 | + "reference": "1.5.1", | |
1491 | 1487 | "shasum": "" |
1492 | 1488 | }, |
1493 | 1489 | "require": { |
1494 | - "jms/aop-bundle": "~1.0", | |
1495 | - "jms/di-extra-bundle": "~1.3", | |
1496 | - "jms/metadata": "~1.0", | |
1497 | - "jms/parser-lib": "~1.0", | |
1498 | - "symfony/framework-bundle": "~2.1", | |
1490 | + "jms/aop-bundle": ">=1.0,<2.0", | |
1491 | + "jms/di-extra-bundle": ">=1.3,<2.0", | |
1492 | + "jms/metadata": ">=1.0,<2.0", | |
1493 | + "jms/parser-lib": ">=1.0,<2.0", | |
1494 | + "symfony/framework-bundle": ">=2.1,<3.0", | |
1499 | 1495 | "symfony/security-bundle": "*" |
1500 | 1496 | }, |
1501 | 1497 | "require-dev": { |
... | ... | @@ -2055,17 +2051,17 @@ |
2055 | 2051 | "source": { |
2056 | 2052 | "type": "git", |
2057 | 2053 | "url": "https://github.com/kriswallsmith/assetic.git", |
2058 | - "reference": "a826e4b96f5c607ff47ef61caf3826b2b1e840ec" | |
2054 | + "reference": "v1.1.1" | |
2059 | 2055 | }, |
2060 | 2056 | "dist": { |
2061 | 2057 | "type": "zip", |
2062 | - "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/a826e4b96f5c607ff47ef61caf3826b2b1e840ec", | |
2063 | - "reference": "a826e4b96f5c607ff47ef61caf3826b2b1e840ec", | |
2058 | + "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/v1.1.1", | |
2059 | + "reference": "v1.1.1", | |
2064 | 2060 | "shasum": "" |
2065 | 2061 | }, |
2066 | 2062 | "require": { |
2067 | 2063 | "php": ">=5.3.1", |
2068 | - "symfony/process": "~2.1" | |
2064 | + "symfony/process": ">=2.1,<3.0" | |
2069 | 2065 | }, |
2070 | 2066 | "require-dev": { |
2071 | 2067 | "cssmin/cssmin": "*", |
... | ... | @@ -2075,9 +2071,9 @@ |
2075 | 2071 | "leafo/scssphp": "*", |
2076 | 2072 | "leafo/scssphp-compass": "*", |
2077 | 2073 | "mrclay/minify": "*", |
2078 | - "phpunit/phpunit": "~3.7", | |
2074 | + "phpunit/phpunit": ">=3.7,<4.0", | |
2079 | 2075 | "ptachoire/cssembed": "*", |
2080 | - "twig/twig": "~1.6" | |
2076 | + "twig/twig": ">=1.6,<2.0" | |
2081 | 2077 | }, |
2082 | 2078 | "suggest": { |
2083 | 2079 | "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", |
... | ... | @@ -2422,13 +2418,13 @@ |
2422 | 2418 | "version": "1.0.0", |
2423 | 2419 | "source": { |
2424 | 2420 | "type": "git", |
2425 | - "url": "https://github.com/php-fig/log.git", | |
2426 | - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" | |
2421 | + "url": "https://github.com/php-fig/log", | |
2422 | + "reference": "1.0.0" | |
2427 | 2423 | }, |
2428 | 2424 | "dist": { |
2429 | 2425 | "type": "zip", |
2430 | - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", | |
2431 | - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", | |
2426 | + "url": "https://github.com/php-fig/log/archive/1.0.0.zip", | |
2427 | + "reference": "1.0.0", | |
2432 | 2428 | "shasum": "" |
2433 | 2429 | }, |
2434 | 2430 | "type": "library", |
... | ... | @@ -2654,27 +2650,27 @@ |
2654 | 2650 | "source": { |
2655 | 2651 | "type": "git", |
2656 | 2652 | "url": "https://github.com/symfony/AsseticBundle.git", |
2657 | - "reference": "146dd3cb46b302bd471560471c6aaa930483dac1" | |
2653 | + "reference": "v2.3.0" | |
2658 | 2654 | }, |
2659 | 2655 | "dist": { |
2660 | 2656 | "type": "zip", |
2661 | - "url": "https://api.github.com/repos/symfony/AsseticBundle/zipball/146dd3cb46b302bd471560471c6aaa930483dac1", | |
2662 | - "reference": "146dd3cb46b302bd471560471c6aaa930483dac1", | |
2657 | + "url": "https://api.github.com/repos/symfony/AsseticBundle/zipball/v2.3.0", | |
2658 | + "reference": "v2.3.0", | |
2663 | 2659 | "shasum": "" |
2664 | 2660 | }, |
2665 | 2661 | "require": { |
2666 | - "kriswallsmith/assetic": "~1.1", | |
2662 | + "kriswallsmith/assetic": ">=1.1,<2.0", | |
2667 | 2663 | "php": ">=5.3.0", |
2668 | - "symfony/framework-bundle": "~2.1" | |
2664 | + "symfony/framework-bundle": ">=2.1,<3.0" | |
2669 | 2665 | }, |
2670 | 2666 | "require-dev": { |
2671 | - "symfony/class-loader": "~2.1", | |
2672 | - "symfony/console": "~2.1", | |
2673 | - "symfony/css-selector": "~2.1", | |
2674 | - "symfony/dom-crawler": "~2.1", | |
2675 | - "symfony/form": "~2.1", | |
2676 | - "symfony/twig-bundle": "~2.1", | |
2677 | - "symfony/yaml": "~2.1" | |
2667 | + "symfony/class-loader": ">=2.1,<3.0", | |
2668 | + "symfony/console": ">=2.1,<3.0", | |
2669 | + "symfony/css-selector": ">=2.1,<3.0", | |
2670 | + "symfony/dom-crawler": ">=2.1,<3.0", | |
2671 | + "symfony/form": ">=2.1,<3.0", | |
2672 | + "symfony/twig-bundle": ">=2.1,<3.0", | |
2673 | + "symfony/yaml": ">=2.1,<3.0" | |
2678 | 2674 | }, |
2679 | 2675 | "suggest": { |
2680 | 2676 | "symfony/twig-bundle": "~2.1" |
... | ... | @@ -2817,23 +2813,23 @@ |
2817 | 2813 | "source": { |
2818 | 2814 | "type": "git", |
2819 | 2815 | "url": "https://github.com/symfony/MonologBundle.git", |
2820 | - "reference": "03ed73bc11367b3156cc21f22ac37c7f70fcd10a" | |
2816 | + "reference": "v2.3.0" | |
2821 | 2817 | }, |
2822 | 2818 | "dist": { |
2823 | 2819 | "type": "zip", |
2824 | - "url": "https://api.github.com/repos/symfony/MonologBundle/zipball/03ed73bc11367b3156cc21f22ac37c7f70fcd10a", | |
2825 | - "reference": "03ed73bc11367b3156cc21f22ac37c7f70fcd10a", | |
2820 | + "url": "https://api.github.com/repos/symfony/MonologBundle/zipball/v2.3.0", | |
2821 | + "reference": "v2.3.0", | |
2826 | 2822 | "shasum": "" |
2827 | 2823 | }, |
2828 | 2824 | "require": { |
2829 | - "monolog/monolog": "~1.3", | |
2825 | + "monolog/monolog": ">=1.3,<2.0", | |
2830 | 2826 | "php": ">=5.3.2", |
2831 | - "symfony/config": "~2.2-beta2", | |
2832 | - "symfony/dependency-injection": "~2.2-beta2", | |
2833 | - "symfony/monolog-bridge": "~2.2-beta2" | |
2827 | + "symfony/config": ">=2.2-beta2,<3.0", | |
2828 | + "symfony/dependency-injection": ">=2.2-beta2,<3.0", | |
2829 | + "symfony/monolog-bridge": ">=2.2-beta2,<3.0" | |
2834 | 2830 | }, |
2835 | 2831 | "require-dev": { |
2836 | - "symfony/yaml": "~2.2-beta2" | |
2832 | + "symfony/yaml": ">=2.2-beta2,<3.0" | |
2837 | 2833 | }, |
2838 | 2834 | "type": "symfony-bundle", |
2839 | 2835 | "extra": { |
... | ... | @@ -3164,7 +3160,7 @@ |
3164 | 3160 | "role": "Lead Developer" |
3165 | 3161 | }, |
3166 | 3162 | { |
3167 | - "name": "Armin Ronacher", | |
3163 | + "name": "Armin Ronacher2", | |
3168 | 3164 | "email": "armin.ronacher@active-4.com", |
3169 | 3165 | "role": "Project Founder" |
3170 | 3166 | }, | ... | ... |
src/Cacic/CommonBundle/Entity/ComputadorColetaRepository.php
... | ... | @@ -161,7 +161,8 @@ class ComputadorColetaRepository extends EntityRepository |
161 | 161 | ->innerJoin('rede.idLocal', 'local') |
162 | 162 | ->innerJoin('CacicCommonBundle:PropriedadeSoftware', 'prop', 'WITH', 'prop.classProperty = coleta.classProperty') |
163 | 163 | ->innerJoin('prop.software', 'soft') |
164 | - ->where('soft.nmSoftware = :software') | |
164 | + ->orWhere('property.nmPropertyName = :software') | |
165 | + ->orWhere('prop.displayName = :software') | |
165 | 166 | ->setParameter('software', $software); |
166 | 167 | |
167 | 168 | /** | ... | ... |
src/Cacic/WSBundle/Controller/ColetaController.php
... | ... | @@ -49,6 +49,9 @@ class ColetaController extends Controller |
49 | 49 | //$strComputerSystem = OldCacicHelper::deCrypt( $request, $request->get('ComputerSystem') ); |
50 | 50 | //$strOperatingSystem = OldCacicHelper::deCrypt( $request, $request->request->get('OperatingSystem') ); |
51 | 51 | $data = new \DateTime('NOW'); |
52 | + $data_inicio = $data->format('d/m/Y H:i:s'); | |
53 | + $data = microtime(); | |
54 | + $logger->debug("%%% Início da operação de coleta: $data_inicio %%%"); | |
52 | 55 | |
53 | 56 | $te_node_adress = TagValueHelper::getValueFromTags( 'MACAddress', $strNetworkAdapterConfiguration ); |
54 | 57 | $te_so = $request->get( 'te_so' ); |
... | ... | @@ -58,60 +61,38 @@ class ColetaController extends Controller |
58 | 61 | //vefifica se existe SO coletado se não, insere novo SO |
59 | 62 | $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->findOneBy( array('teSo'=>$te_so) ); |
60 | 63 | $computador = $this->getDoctrine()->getRepository('CacicCommonBundle:Computador')->findOneBy( array('idSo'=>$so, 'teNodeAddress'=>$te_node_adress) ); |
61 | - $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $request ); | |
64 | + $netmask = TagValueHelper::getValueFromTags( 'IPSubnet', $strNetworkAdapterConfiguration ); | |
65 | + $ip_computador = $request->get('te_ip_computador'); | |
66 | + $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $ip_computador, $netmask ); | |
62 | 67 | //$local = $this->getDoctrine()->getRepository('CacicCommonBundle:Local')->findOneBy(array( 'idLocal' => $rede->getIdLocal() )); |
63 | 68 | $strCollectType = OldCacicHelper::deCrypt($request, $request->get('CollectType')); |
64 | 69 | |
65 | 70 | // Defino os dois arrays que conterão as configurações para Coletas, Classes e Propriedades |
66 | 71 | $arrClassesNames = array(); |
67 | - $arrCollectsDefClasses[$strCollectType] = array(); | |
68 | 72 | |
69 | 73 | $detalhesClasses = $this->getDoctrine()->getRepository('CacicCommonBundle:Classe')->listaDetalhesClasseAcoes($strCollectType); |
74 | + $output = $this->arrayClasses($detalhesClasses, $arrClassesNames); | |
70 | 75 | |
71 | - foreach ($detalhesClasses as $detalhe) | |
72 | - { | |
73 | - // Adiciona classe no Array de classes que estão no banco | |
74 | - if (!in_array($detalhe['nmClassName'], $arrClassesNames)) { | |
75 | - array_push($arrClassesNames, $detalhe['nmClassName']); | |
76 | - } | |
77 | - // Primeiro cria array com as informações das propriedades | |
78 | - $property = array( | |
79 | - 'idClassProperty' => $detalhe['idClassProperty'], | |
80 | - 'nmFunctionPreDb' => $detalhe['nmFunctionPreDb'] | |
81 | - ); | |
82 | - | |
83 | - | |
84 | - $nmPropertyName = $detalhe['nmPropertyName']; | |
85 | - $logger->debug("Adicionando propriedade $nmPropertyName no array de propriedades"); | |
86 | - // Aqui o array já existe. Só substituo pelo novo valor | |
87 | - $arrCollectsDefClasses[$strCollectType][$detalhe['nmClassName']][$detalhe['nmPropertyName']] = $property; | |
76 | + if ($output) { | |
77 | + $arrCollectsDefClasses[$strCollectType] = &$output[0]; | |
78 | + $arrClassesNames = $output[1]; | |
79 | + } else { | |
80 | + $arrCollectsDefClasses[$strCollectType] = array(); | |
88 | 81 | } |
89 | 82 | |
90 | 83 | //$teste = print_r($arrCollectsDefClasses, true); |
91 | 84 | //$teste = print_r($arrClassesNames, true); |
92 | - //error_log("22222222222222222222222222222222222222222222222222222222222222 $teste"); | |
85 | + //$logger->debug("22222222222222222222222222222222222222222222222222222222222222 $teste"); | |
93 | 86 | |
94 | 87 | if ($arrCollectsDefClasses[$strCollectType]) |
95 | 88 | { |
96 | - // Obtenho configuração para notificação de alterações | |
97 | - //$resConfigsLocais = $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->listarNotificacaoPropertyLocal($rede->getIdLocal(), 'te_notificar_mudancas_properties'); | |
98 | - //$resConfigsLocaisEmail = $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->listarNotificacaoEmailLocal($rede->getIdLocal()); | |
99 | - | |
100 | - //$arrClassesAndProperties = $this->getDoctrine()->getRepository('CacicCommonBundle:Classe')->listaPorPropertyNotificacao( $resConfigsLocais->getVlConfiguracao() ) ; | |
101 | - | |
102 | - //foreach ($arrClassesAndProperties as $arrClassesAndProperty) | |
103 | - // $arrClassesPropertiesToNotificate[$arrClassesAndProperty['nmClassName'] . '.' . $arrClassesAndProperty['nmPropertyName']] = $arrClassesAndProperty['tePropertyDescription']; | |
104 | - | |
105 | - $strInsertedItems_Text = ''; | |
106 | - $strDeletedItems_Text = ''; | |
107 | - $strUpdatedItems_Text = ''; | |
108 | - | |
109 | 89 | //error_log("00000000000000000000000000000000000000000000000000000000: $strCollectType"); |
110 | 90 | |
111 | 91 | foreach( $request->request->all() as $strClassName => $strClassValues) |
112 | 92 | { |
113 | 93 | //$teste = OldCacicHelper::deCrypt($request, $strClassValues); |
114 | 94 | //$logger->debug("444444444444444444444444444444444444444444444444444444444: $strClassName | \n $teste"); |
95 | + //$logger->debug("444444444444444444444444444444444444444444444444444444444: $strClassName"); | |
115 | 96 | //error_log("444444444444444444444444444444444444444444444444444444: $strClassName"); |
116 | 97 | |
117 | 98 | |
... | ... | @@ -124,192 +105,15 @@ class ColetaController extends Controller |
124 | 105 | // A propriedade da coleta de software é multi valorada. Preciso tratar diferente |
125 | 106 | if ($strClassName == "SoftwareList") { |
126 | 107 | |
127 | - // Primeiro preciso pegar todas as tags que forem software | |
128 | - $arrSoftware = TagValueHelper::getSoftwareTags($strNewClassValues); | |
129 | - | |
130 | - // Agora insere cada registro de software individualmente | |
131 | - foreach ($arrSoftware as $software) { | |
132 | - // Armazeno todas as propriedades dessa classe enviadas pela requisição | |
133 | - $arrTags = TagValueHelper::getTagsFromValues($software); | |
134 | - | |
135 | - // Crio um array multidimensional com as tags e os valores | |
136 | - foreach ($arrTags as $tagNames) { | |
137 | - // Essa função garante que só serão retornados caracteres com UTF8 Válido | |
138 | - $texto = TagValueHelper::UTF8Sanitize(TagValueHelper::getValueFromTags($tagNames, $software)); | |
139 | - $arrTagsNames[$tagNames] = $texto; | |
140 | - } | |
141 | - | |
142 | - // Para software, cada identificador será uma propriedade | |
143 | - $softwareName = $arrTagsNames['IDSoftware']; | |
144 | - | |
145 | - // Remove o IDSoftware do array | |
146 | - unset($arrTagsNames['IDSoftware']); | |
147 | - | |
148 | - // Armazeno o IDSoftware como Propriedade | |
149 | - $idClassProperty = $arrCollectsDefClasses[$strCollectType][$strClassName][$softwareName]['idClassProperty']; | |
150 | - | |
151 | - // Se o IDSoftware não existir, cria | |
152 | - if (empty($idClassProperty)) { | |
153 | - $logger->debug("Software $softwareName não encontrado. Adicionando um novo software"); | |
154 | - // Pega o Id da classe | |
155 | - $idClass = $this->getDoctrine()->getRepository('CacicCommonBundle:Classe')->findOneBy( array('nmClassName'=>$strClassName) ); | |
156 | - | |
157 | - $property = new ClassProperty(); | |
158 | - $property->setNmPropertyName($softwareName); | |
159 | - $property->setTePropertyDescription($arrTagsNames['DisplayName']); | |
160 | - | |
161 | - // Referência à classe | |
162 | - $property->setIdClass($idClass); | |
163 | - | |
164 | - // Grava a propriedade nova | |
165 | - $this->getDoctrine()->getManager()->persist($property); | |
166 | - $this->getDoctrine()->getManager()->flush(); | |
167 | - | |
168 | - // Retorna o novo ID | |
169 | - $idClassProperty = $property->getIdClassProperty(); | |
170 | - } | |
171 | - | |
172 | - // Chama função que grava a propriedade | |
173 | - $this->gerColsSetProperty('IDSoftware', $software, $idClassProperty, $computador); | |
174 | - | |
175 | - // Agora gravo todas as propriedades para o software na tabela propriedade_software | |
176 | - $propriedadeSoftware = $this->getDoctrine()->getRepository('CacicCommonBundle:PropriedadeSoftware')->findOneBy( array('classProperty'=> $idClassProperty, 'computador' => $computador) ); | |
177 | - $classPropertyObject = $this->getDoctrine()->getRepository('CacicCommonBundle:ClassProperty')->findOneBy( array( 'idClassProperty'=> $idClassProperty ) ); | |
178 | - | |
179 | - if (empty($propriedadeSoftware)) { | |
180 | - | |
181 | - // Se não tiver nome coloco o ID Software no nome | |
182 | - if (empty($arrTagsNames['DisplayName'])) { | |
183 | - $nmSoftware = $softwareName; | |
184 | - } else { | |
185 | - $nmSoftware = $arrTagsNames['DisplayName']; | |
186 | - } | |
187 | - | |
188 | - | |
189 | - $softwareObject = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->findOneBy( array( 'nmSoftware' => $nmSoftware ) ); | |
190 | - if (empty($softwareObject)) { | |
191 | - $softwareObject = new Software(); | |
192 | - // Grava software recém inserido | |
193 | - $this->getDoctrine()->getManager()->persist($softwareObject); | |
194 | - $this->getDoctrine()->getManager()->flush(); | |
195 | - } | |
196 | - | |
197 | - // Depois adiciono as propriedades | |
198 | - $propriedadeSoftware = new PropriedadeSoftware(); | |
199 | - | |
200 | - $propriedadeSoftware->setClassProperty($classPropertyObject); | |
201 | - $propriedadeSoftware->setComputador($computador); | |
202 | - | |
203 | - // Ajusta valores coletados | |
204 | - $propriedadeSoftware->setDisplayName($arrTagsNames['DisplayName']); | |
205 | - $propriedadeSoftware->setDisplayVersion($arrTagsNames['DisplayVersion']); | |
206 | - $propriedadeSoftware->setURLInfoAbout($arrTagsNames['URLInfoAbout']); | |
207 | - $propriedadeSoftware->setSoftware($softwareObject); | |
208 | - | |
209 | - // Grava no banco de dados | |
210 | - $this->getDoctrine()->getManager()->persist($propriedadeSoftware); | |
211 | - $this->getDoctrine()->getManager()->flush(); | |
212 | - } else { | |
213 | - // Adiciona referência à tabela de softwares | |
214 | - $softwareObject = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->find( $propriedadeSoftware->getSoftware()->getIdSoftware() ); | |
215 | - | |
216 | - // Se não tiver nome coloco o ID Software no nome | |
217 | - if (empty($arrTagsNames['DisplayName'])) { | |
218 | - $softwareObject->setNmSoftware($softwareName); | |
219 | - } else { | |
220 | - $softwareObject->setNmSoftware($arrTagsNames['DisplayName']); | |
221 | - } | |
222 | - | |
223 | - // Grava software recém inserido | |
224 | - $this->getDoctrine()->getManager()->persist($softwareObject); | |
225 | - //$this->getDoctrine()->getManager()->flush(); | |
226 | - | |
227 | - // Ajusta valores coletados | |
228 | - $propriedadeSoftware->setDisplayName($arrTagsNames['DisplayName']); | |
229 | - $propriedadeSoftware->setDisplayVersion($arrTagsNames['DisplayVersion']); | |
230 | - $propriedadeSoftware->setURLInfoAbout($arrTagsNames['URLInfoAbout']); | |
231 | - $propriedadeSoftware->setSoftware($softwareObject); | |
232 | - | |
233 | - // Salva valor da coleta | |
234 | - $this->getDoctrine()->getManager()->persist($propriedadeSoftware); | |
235 | - $this->getDoctrine()->getManager()->flush(); | |
236 | - } | |
237 | - | |
238 | - } | |
108 | + $this->coletaSoftware($strNewClassValues, $arrCollectsDefClasses, $strCollectType, $strClassName, $computador); | |
239 | 109 | |
240 | 110 | } elseif (!empty($strNewClassValues)) { |
241 | - // Armazeno todas as propriedades dessa classe enviadas pela requisição | |
242 | - $arrTagsNames = TagValueHelper::getTagsFromValues($strNewClassValues); | |
243 | - | |
244 | - // Agora gravo todas as propriedades dessa classe na tabela de computadores | |
245 | - foreach ($arrTagsNames as $classPropertyName) { | |
246 | - $logger->debug("Processando a proriedade WMI $classPropertyName para a classe $strClassName"); | |
247 | - // Pega classe | |
248 | - $idClass = $this->getDoctrine()->getRepository('CacicCommonBundle:Classe')->findOneBy( array('nmClassName'=>$strClassName) ); | |
249 | - | |
250 | - // Caso a propriedade ainda não esteja cadastrada no banco, crio na hora | |
251 | - if (array_key_exists($classPropertyName, $arrCollectsDefClasses[$strCollectType][$strClassName])) { | |
252 | - // Somente armazeno o valor que já existe | |
253 | - $idClassProperty = $arrCollectsDefClasses[$strCollectType][$strClassName][$classPropertyName]['idClassProperty']; | |
254 | - $logger->debug("Propriedade encontrada: $classPropertyName id_class_property = $idClassProperty. Apenas atualizar"); | |
255 | - } else { | |
256 | - // Se não existir cria a propriedade | |
257 | - $logger->info("Criando propriedade $classPropertyName para a classe $strClassName"); | |
258 | - | |
259 | - $classPropertyObject = new ClassProperty(); | |
260 | - $classPropertyObject->setIdClass($idClass); | |
261 | - $classPropertyObject->setNmPropertyName($classPropertyName); | |
262 | - $classPropertyObject->setTePropertyDescription('On the fly created Property'); | |
263 | - | |
264 | - $this->getDoctrine()->getManager()->persist($classPropertyObject); | |
265 | - $this->getDoctrine()->getManager()->flush(); | |
266 | - | |
267 | - // Finalmente adiciono no array de classes e propriedades | |
268 | - $idClassProperty = $classPropertyObject->getIdClassProperty(); | |
269 | - $property = array( | |
270 | - 'idClassProperty' => $idClassProperty, | |
271 | - 'nmFunctionPreDb' => null | |
272 | - ); | |
273 | - $arrCollectsDefClasses[$strCollectType][$className][$classPropertyName] = $property; | |
274 | - } | |
275 | - //error_log("888888888888888888888888888888888888888888888: $strClassName | $idClassProperty | $classPropertyName"); | |
276 | - | |
277 | - // Chama função que grava a propriedade | |
278 | - $this->gerColsSetProperty($classPropertyName, $strNewClassValues, $idClassProperty, $computador); | |
279 | - } | |
111 | + | |
112 | + $this->coletaGeral($strNewClassValues, $arrCollectsDefClasses, $strCollectType, $strClassName, $computador); | |
113 | + | |
280 | 114 | } |
281 | 115 | } |
282 | 116 | } |
283 | - | |
284 | - // Caso a string acima não esteja vazia, monto o email para notificação | |
285 | - // FIXME: Detectar alteração de dispositivos de hardware e notificar o Administrador | |
286 | - if ($strDeletedItems_Text || $strInsertedItems_Text || $strUpdatedItems_Text ) | |
287 | - { | |
288 | - if ($strDeletedItems_Text) | |
289 | - $strDeletedItems_Text = chr(13) . 'Itens Removidos:' . chr(13) . $strDeletedItems_Text . chr(13); | |
290 | - | |
291 | - if ($strInsertedItems_Text) | |
292 | - $strInsertedItems_Text = chr(13) . 'Itens Inseridos:' . chr(13) . $strInsertedItems_Text . chr(13); | |
293 | - | |
294 | - if ($strUpdatedItems_Text) | |
295 | - $strUpdatedItems_Text = chr(13) . 'Itens Alterados:' . chr(13) . $strUpdatedItems_Text . chr(13); | |
296 | - | |
297 | - | |
298 | - $strCorpoMail = ''; | |
299 | - $strCorpoMail .= " Prezado Administrador,\n\n"; | |
300 | - $strCorpoMail .= " uma alteração foi identificada no computador cujos detalhes encontram-se abaixo discriminados:\n\n"; | |
301 | - $strCorpoMail .= " Nome do Host: ". $computador->getNmComputador() ."\n"; | |
302 | - $strCorpoMail .= " Endereço IP....: ".$computador->getTeIpComputador() . "\n"; | |
303 | - $strCorpoMail .= " Local...............: ". $rede['nmLocal']."\n"; | |
304 | - $strCorpoMail .= " Rede................: ". $rede['nmRede'] . ' (' . $rede['teIpRede'] .")\n\n"; | |
305 | - $strCorpoMail .= $strDeletedItems_Text . $strInsertedItems_Text . $strUpdatedItems_Text; | |
306 | - $strCorpoMail .= "\n\nPara visualizar mais informações sobre esse computador, acesse o endereço\nhttp://"; | |
307 | - $strCorpoMail .= CACIC_PATH . '/relatorios/computador/computador.php?id_computador=' . $computador->getIdComputador(); | |
308 | - $strCorpoMail .= "\n\n\n________________________________________________\n"; | |
309 | - $strCorpoMail .= "CACIC - e" . date('d/m/Y H:i') . "h \n"; | |
310 | -// Manda mail para os administradores. | |
311 | - //TODO mail($resConfigsLocais['te_notificar_mudancas_emails'], "[Sistema CACIC] Alteração Detectada - " . $arrCollectsDefClasses[$strCollectType], "$strCorpoMail", "From: cacic@{$_SERVER['SERVER_NAME']}"); | |
312 | - } | |
313 | 117 | } |
314 | 118 | $teste_object = $this->gravaTESTES($grava_teste."\nFinal"); |
315 | 119 | $em = $this->getDoctrine()->getManager(); |
... | ... | @@ -319,6 +123,11 @@ class ColetaController extends Controller |
319 | 123 | $em->flush(); |
320 | 124 | //$this->getDoctrine()->getManager()->flush(); //persistencia dos dados no BD |
321 | 125 | |
126 | + $data_fim = new \DateTime('NOW'); | |
127 | + $tempo = (microtime() - $data); | |
128 | + $data_fim = $data_fim->format('d/m/Y H:i:s'); | |
129 | + $logger->debug("%%% Final da operação de coleta: $data_fim. Tempo de execução da coleta: $tempo %%%"); | |
130 | + | |
322 | 131 | $response = new Response(); |
323 | 132 | $response->headers->set('Content-Type', 'xml'); |
324 | 133 | $cacic_helper = new OldCacicHelper( $this->get('kernel') ); |
... | ... | @@ -409,6 +218,7 @@ class ColetaController extends Controller |
409 | 218 | } else { |
410 | 219 | //error_log("444444444444444444444444444444444444444444444444: Criando histórico"); |
411 | 220 | // Caso exista, registro um histórico e atualiza o valor atual |
221 | + $coletaOld = "Classe WMI: ".$computadorColeta->getClassProperty()->getIdClass()->getNmClassName()." | "."Propriedade: ".$computadorColeta->getClassProperty()->getNmPropertyName()." | Valor: ".$computadorColeta->getTeClassPropertyValue(); | |
412 | 222 | $computadorColeta->setComputador( $computador ); |
413 | 223 | // Pega o objeto para gravar |
414 | 224 | $classPropertyObject = $this->getDoctrine()->getRepository('CacicCommonBundle:ClassProperty')->findOneBy( array( 'idClassProperty'=> $idClassProperty ) ); |
... | ... | @@ -434,6 +244,10 @@ class ColetaController extends Controller |
434 | 244 | |
435 | 245 | // Commit |
436 | 246 | $this->getDoctrine()->getManager()->flush(); |
247 | + | |
248 | + // Notifica alteração | |
249 | + $coletaNew = "Classe WMI: ".$computadorColeta->getClassProperty()->getIdClass()->getNmClassName()." | "."Propriedade: ".$computadorColeta->getClassProperty()->getNmPropertyName()." | Valor: ".$computadorColeta->getTeClassPropertyValue(); | |
250 | + //$this->notificaAlteracao($coletaOld, $coletaNew, $computador); | |
437 | 251 | } |
438 | 252 | } |
439 | 253 | |
... | ... | @@ -677,5 +491,263 @@ class ColetaController extends Controller |
677 | 491 | |
678 | 492 | } |
679 | 493 | |
494 | + /** | |
495 | + * Cria array de classes e propriedades para coletar | |
496 | + * | |
497 | + * @param $detalhesClasses | |
498 | + * @return array | |
499 | + */ | |
500 | + | |
501 | + public function arrayClasses($detalhesClasses, $arrClassesNames) { | |
502 | + $logger = $this->get('logger'); | |
503 | + $output = array(); | |
504 | + | |
505 | + foreach ($detalhesClasses as $detalhe) | |
506 | + { | |
507 | + // Adiciona classe no Array de classes que estão no banco | |
508 | + if (!in_array($detalhe['nmClassName'], $arrClassesNames)) { | |
509 | + array_push($arrClassesNames, $detalhe['nmClassName']); | |
510 | + } | |
511 | + // Primeiro cria array com as informações das propriedades | |
512 | + $property = array( | |
513 | + 'idClassProperty' => $detalhe['idClassProperty'], | |
514 | + 'nmFunctionPreDb' => $detalhe['nmFunctionPreDb'] | |
515 | + ); | |
516 | + | |
517 | + | |
518 | + $nmPropertyName = $detalhe['nmPropertyName']; | |
519 | + $logger->debug("Adicionando propriedade $nmPropertyName no array de propriedades"); | |
520 | + // Aqui o array já existe. Só substituo pelo novo valor | |
521 | + $output[0][$detalhe['nmClassName']][$detalhe['nmPropertyName']] = $property; | |
522 | + } | |
523 | + $output[1] = $arrClassesNames; | |
524 | + | |
525 | + return $output; | |
526 | + } | |
527 | + | |
528 | + /** | |
529 | + * Processa parâmetros da coleta de software | |
530 | + * | |
531 | + * @param $strNewClassValues | |
532 | + * @param $arrCollectsDefClasses | |
533 | + * @param $strCollectType | |
534 | + * @param $strClassName | |
535 | + */ | |
536 | + | |
537 | + public function coletaSoftware($strNewClassValues, $arrCollectsDefClasses, $strCollectType, $strClassName, $computador) { | |
538 | + $logger = $this->get('logger'); | |
539 | + | |
540 | + // Primeiro preciso pegar todas as tags que forem software | |
541 | + $arrSoftware = TagValueHelper::getSoftwareTags($strNewClassValues); | |
542 | + | |
543 | + // Agora insere cada registro de software individualmente | |
544 | + foreach ($arrSoftware as $software) { | |
545 | + // Armazeno todas as propriedades dessa classe enviadas pela requisição | |
546 | + $arrTags = TagValueHelper::getTagsFromValues($software); | |
547 | + | |
548 | + // Crio um array multidimensional com as tags e os valores | |
549 | + foreach ($arrTags as $tagNames) { | |
550 | + // Essa função garante que só serão retornados caracteres com UTF8 Válido | |
551 | + $texto = TagValueHelper::UTF8Sanitize(TagValueHelper::getValueFromTags($tagNames, $software)); | |
552 | + $arrTagsNames[$tagNames] = $texto; | |
553 | + } | |
554 | + | |
555 | + // Para software, cada identificador será uma propriedade | |
556 | + $softwareName = $arrTagsNames['IDSoftware']; | |
557 | + | |
558 | + // Remove o IDSoftware do array | |
559 | + unset($arrTagsNames['IDSoftware']); | |
560 | + | |
561 | + // Armazeno o IDSoftware como Propriedade | |
562 | + $idClassProperty = $arrCollectsDefClasses[$strCollectType][$strClassName][$softwareName]['idClassProperty']; | |
563 | + | |
564 | + // Se o IDSoftware não existir, cria | |
565 | + if (empty($idClassProperty)) { | |
566 | + $logger->debug("Software $softwareName não encontrado. Adicionando um novo software"); | |
567 | + // Pega o Id da classe | |
568 | + $idClass = $this->getDoctrine()->getRepository('CacicCommonBundle:Classe')->findOneBy( array('nmClassName'=>$strClassName) ); | |
569 | + | |
570 | + $property = new ClassProperty(); | |
571 | + $property->setNmPropertyName($softwareName); | |
572 | + $property->setTePropertyDescription($arrTagsNames['DisplayName']); | |
573 | + | |
574 | + // Referência à classe | |
575 | + $property->setIdClass($idClass); | |
576 | + | |
577 | + // Grava a propriedade nova | |
578 | + $this->getDoctrine()->getManager()->persist($property); | |
579 | + $this->getDoctrine()->getManager()->flush(); | |
580 | + | |
581 | + // Retorna o novo ID | |
582 | + $idClassProperty = $property->getIdClassProperty(); | |
583 | + } | |
584 | + | |
585 | + // Chama função que grava a propriedade | |
586 | + $this->gerColsSetProperty('IDSoftware', $software, $idClassProperty, $computador); | |
587 | + | |
588 | + // Agora gravo todas as propriedades para o software na tabela propriedade_software | |
589 | + $propriedadeSoftware = $this->getDoctrine()->getRepository('CacicCommonBundle:PropriedadeSoftware')->findOneBy( array('classProperty'=> $idClassProperty, 'computador' => $computador) ); | |
590 | + $classPropertyObject = $this->getDoctrine()->getRepository('CacicCommonBundle:ClassProperty')->findOneBy( array( 'idClassProperty'=> $idClassProperty ) ); | |
591 | + | |
592 | + if (empty($propriedadeSoftware)) { | |
593 | + | |
594 | + // Se não tiver nome coloco o ID Software no nome | |
595 | + if (empty($arrTagsNames['DisplayName'])) { | |
596 | + $nmSoftware = $softwareName; | |
597 | + } else { | |
598 | + $nmSoftware = $arrTagsNames['DisplayName']; | |
599 | + } | |
600 | + | |
601 | + | |
602 | + $softwareObject = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->findOneBy( array( 'nmSoftware' => $nmSoftware ) ); | |
603 | + if (empty($softwareObject)) { | |
604 | + $softwareObject = new Software(); | |
605 | + // Grava software recém inserido | |
606 | + $this->getDoctrine()->getManager()->persist($softwareObject); | |
607 | + $this->getDoctrine()->getManager()->flush(); | |
608 | + } | |
609 | + | |
610 | + // Depois adiciono as propriedades | |
611 | + $propriedadeSoftware = new PropriedadeSoftware(); | |
612 | + | |
613 | + $propriedadeSoftware->setClassProperty($classPropertyObject); | |
614 | + $propriedadeSoftware->setComputador($computador); | |
615 | + | |
616 | + // Ajusta valores coletados | |
617 | + $propriedadeSoftware->setDisplayName($arrTagsNames['DisplayName']); | |
618 | + $propriedadeSoftware->setDisplayVersion($arrTagsNames['DisplayVersion']); | |
619 | + $propriedadeSoftware->setURLInfoAbout($arrTagsNames['URLInfoAbout']); | |
620 | + $propriedadeSoftware->setSoftware($softwareObject); | |
621 | + | |
622 | + // Grava no banco de dados | |
623 | + $this->getDoctrine()->getManager()->persist($propriedadeSoftware); | |
624 | + $this->getDoctrine()->getManager()->flush(); | |
625 | + } else { | |
626 | + // Adiciona referência à tabela de softwares | |
627 | + $softwareObject = $this->getDoctrine()->getRepository('CacicCommonBundle:Software')->find( $propriedadeSoftware->getSoftware()->getIdSoftware() ); | |
628 | + | |
629 | + // Se não tiver nome coloco o ID Software no nome | |
630 | + if (empty($arrTagsNames['DisplayName'])) { | |
631 | + $softwareObject->setNmSoftware($softwareName); | |
632 | + } else { | |
633 | + $softwareObject->setNmSoftware($arrTagsNames['DisplayName']); | |
634 | + } | |
635 | + | |
636 | + // Grava software recém inserido | |
637 | + $this->getDoctrine()->getManager()->persist($softwareObject); | |
638 | + //$this->getDoctrine()->getManager()->flush(); | |
639 | + | |
640 | + // Ajusta valores coletados | |
641 | + $propriedadeSoftware->setDisplayName($arrTagsNames['DisplayName']); | |
642 | + $propriedadeSoftware->setDisplayVersion($arrTagsNames['DisplayVersion']); | |
643 | + $propriedadeSoftware->setURLInfoAbout($arrTagsNames['URLInfoAbout']); | |
644 | + $propriedadeSoftware->setSoftware($softwareObject); | |
645 | + | |
646 | + // Salva valor da coleta | |
647 | + $this->getDoctrine()->getManager()->persist($propriedadeSoftware); | |
648 | + $this->getDoctrine()->getManager()->flush(); | |
649 | + } | |
650 | + | |
651 | + } | |
652 | + } | |
653 | + | |
654 | + /** | |
655 | + * Processa informações de coleta | |
656 | + * | |
657 | + * @param $strNewClassValues | |
658 | + * @param $arrCollectsDefClasses | |
659 | + * @param $strCollectType | |
660 | + * @param $strClassName | |
661 | + * @param $computador | |
662 | + */ | |
663 | + | |
664 | + public function coletaGeral($strNewClassValues, $arrCollectsDefClasses, $strCollectType, $strClassName, $computador) { | |
665 | + $logger = $this->get('logger'); | |
666 | + $logger->debug("Processando classe WMI: $strClassName"); | |
667 | + | |
668 | + // Armazeno todas as propriedades dessa classe enviadas pela requisição | |
669 | + $arrTagsNames = TagValueHelper::getTagsFromValues($strNewClassValues); | |
670 | + | |
671 | + // Agora gravo todas as propriedades dessa classe na tabela de computadores | |
672 | + foreach ($arrTagsNames as $classPropertyName) { | |
673 | + $logger->debug("Processando a proriedade WMI $classPropertyName para a classe $strClassName"); | |
674 | + // Pega classe | |
675 | + $idClass = $this->getDoctrine()->getRepository('CacicCommonBundle:Classe')->findOneBy( array('nmClassName'=>$strClassName) ); | |
676 | + | |
677 | + // Caso a propriedade ainda não esteja cadastrada no banco, crio na hora | |
678 | + if (array_key_exists($classPropertyName, $arrCollectsDefClasses[$strCollectType][$strClassName])) { | |
679 | + // Somente armazeno o valor que já existe | |
680 | + $idClassProperty = $arrCollectsDefClasses[$strCollectType][$strClassName][$classPropertyName]['idClassProperty']; | |
681 | + $logger->debug("Propriedade encontrada: $classPropertyName id_class_property = $idClassProperty. Apenas atualizar"); | |
682 | + } else { | |
683 | + // Se não existir cria a propriedade | |
684 | + $logger->info("Criando propriedade $classPropertyName para a classe $strClassName"); | |
685 | + | |
686 | + $classPropertyObject = new ClassProperty(); | |
687 | + $classPropertyObject->setIdClass($idClass); | |
688 | + $classPropertyObject->setNmPropertyName($classPropertyName); | |
689 | + $classPropertyObject->setTePropertyDescription('On the fly created Property'); | |
690 | + | |
691 | + $this->getDoctrine()->getManager()->persist($classPropertyObject); | |
692 | + $this->getDoctrine()->getManager()->flush(); | |
693 | + | |
694 | + // Finalmente adiciono no array de classes e propriedades | |
695 | + $idClassProperty = $classPropertyObject->getIdClassProperty(); | |
696 | + $property = array( | |
697 | + 'idClassProperty' => $idClassProperty, | |
698 | + 'nmFunctionPreDb' => null | |
699 | + ); | |
700 | + | |
701 | + $arrCollectsDefClasses[$strCollectType][$strClassName][$classPropertyName] = $property; | |
702 | + } | |
703 | + //error_log("888888888888888888888888888888888888888888888: $strClassName | $idClassProperty | $classPropertyName"); | |
704 | + | |
705 | + // Chama função que grava a propriedade | |
706 | + $this->gerColsSetProperty($classPropertyName, $strNewClassValues, $idClassProperty, $computador); | |
707 | + } | |
708 | + } | |
709 | + | |
710 | + /** | |
711 | + * Envia notificação de alteração para o administrador do sistema | |
712 | + * | |
713 | + * @param $coletaOld | |
714 | + * @param $coletaNew | |
715 | + * @param $computador | |
716 | + */ | |
717 | + | |
718 | + public function notificaAlteracao($coletaOld, $coletaNew, $computador) { | |
719 | + $configuracoes = $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->findBy( array('idLocal' => $computador->getIdRede()->getIdLocal()) ); | |
720 | + $emailNotificacao = $this->container->getParameter('swiftmailer.sender_address'); | |
721 | + $organizacao = 'Administradores Cacic'; | |
722 | + | |
723 | + foreach ($configuracoes as $detalhe) { | |
724 | + if ($detalhe->getIdConfiguracao() == 'te_notificar_mudanca_hardware') { | |
725 | + $emailNotificacao = $detalhe->getVlConfiguracao(); | |
726 | + } | |
727 | + | |
728 | + if ($detalhe->getIdConfiguracao() == 'nm_organizacao') { | |
729 | + $organizacao = $detalhe->getVlConfiguracao(); | |
730 | + } | |
731 | + } | |
732 | + | |
733 | + | |
734 | + $message = \Swift_Message::newInstance() | |
735 | + ->setSubject("Notificação de alteração de configurações: $organizacao") | |
736 | + ->setFrom($this->container->getParameter('swiftmailer.sender_address')) | |
737 | + ->setTo($emailNotificacao) | |
738 | + ->setBody( | |
739 | + $this->renderView( | |
740 | + 'CacicWSBundle:Coleta:alteracaoMail.txt.twig', | |
741 | + array( | |
742 | + 'coletaOld' => $coletaOld, | |
743 | + 'coletaNew' => $coletaNew, | |
744 | + 'computador' => $computador | |
745 | + ) | |
746 | + ) | |
747 | + ) | |
748 | + ; | |
749 | + | |
750 | + $this->get('mailer')->send($message); | |
751 | + } | |
680 | 752 | |
681 | 753 | } | ... | ... |
src/Cacic/WSBundle/Helper/OldCacicHelper.php
... | ... | @@ -230,4 +230,14 @@ class OldCacicHelper |
230 | 230 | return $intPos; |
231 | 231 | } |
232 | 232 | |
233 | + public static function udate($format = 'u', $utimestamp = null) { | |
234 | + if (is_null($utimestamp)) | |
235 | + $utimestamp = microtime(true); | |
236 | + | |
237 | + $timestamp = floor($utimestamp); | |
238 | + $milliseconds = round(($utimestamp - $timestamp) * 1000000); | |
239 | + | |
240 | + return date(preg_replace('`(?<!\\\\)u`', $milliseconds, $format), $timestamp); | |
241 | + } | |
242 | + | |
233 | 243 | } | ... | ... |
src/Cacic/WSBundle/Resources/views/Coleta/alteracaoMail.txt.twig
0 → 100644
... | ... | @@ -0,0 +1,18 @@ |
1 | +Prezado Administrador, | |
2 | + | |
3 | +Uma alteração foi identificada no computador cujos detalhes encontram-se abaixo discriminados: | |
4 | + | |
5 | +Nome do Host........: {{ computador.getNmComputador() }} | |
6 | +Endereço IP.........: {{ computador.getTeIpComputador() }} | |
7 | +Local...............: {{ computador.getIdRede.getIdLocal.getNmLocal() }} | |
8 | +Rede................: {{ computador.getIdRede.getNmRede() }} ({{ computador.getIdRede.getTeIpRede() }}) | |
9 | + | |
10 | +As seguintes alterações foram detectadas: | |
11 | + | |
12 | +Coleta Anterior..: {{ coletaOld }} | |
13 | +Nova Coleta......: {{ coletaNew }} | |
14 | + | |
15 | +Para visualizar mais informações sobre esse computador, acesse o seguinte endereço: | |
16 | +{{ computador.getIdRede.getTeServCacic() }}{{ path('cacic_computador_detalhar') }}/{{ computador.getIdComputador }} | |
17 | +__________________________________________________________________________ | |
18 | +Data de envio da notificação: {{ "now"|date('d/m/Y H:i') }} | |
0 | 19 | \ No newline at end of file | ... | ... |