Loading bin/oscar-worker.php +20 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ function getServiceManager(){ function oscarJob_indexActivity(GearmanJob $job){ $params = json_decode($job->workload()); try { if( !property_exists($params, 'activityid') ){ throw new Exception("Paramètres manquant ID"); Loading @@ -56,12 +58,15 @@ function oscarJob_indexActivity(GearmanJob $job){ /** @var \Oscar\Service\ProjectGrantService $activityService */ $activityService = getServiceManager()->get(\Oscar\Service\ProjectGrantService::class); $activityid = $params->activityid; $activityService->getLoggerService()->info("[GEARMAN] Indexation de Activity $activityid"); $activity = $activityService->getActivityById($activityid); echo date('y-m-d H:i:s')." Rebuid Index [$activityid] $activity\n"; $activityService->searchUpdate($activity); } catch (Exception $e) { $activityService->getLoggerService()->info("[GEARMAN] Error " . $e->getMessage()); echo "[ERR] " . $e->getMessage() ."\n"; } } Loading @@ -77,11 +82,14 @@ function oscarJob_indexPerson(GearmanJob $job){ $personService = getServiceManager()->get(\Oscar\Service\PersonService::class); $personId = $params->personid; getServiceManager()->get('Logger')->info("[GEARMAN] Indexation de Person $personId"); $person = $personService->getPerson($personId); echo date('y-m-d H:i:s')." Rebuid Index [$personId] $person\n"; $personService->getSearchEngineStrategy()->update($person); } catch (Exception $e) { getServiceManager()->get('Logger')->info("[GEARMAN] Error " . $e->getMessage()); echo "[ERR] " . $e->getMessage() ."\n"; } } Loading Loading @@ -109,11 +117,14 @@ function oscarJob_notificationActivityPerson(GearmanJob $job){ $activityId = $params->activityid; $activity = $projectGrantService->getActivityById($activityId); getServiceManager()->get('Logger')->info("[GEARMAN] Notification Person:$personId - Activity:$activityId"); echo date('y-m-d H:i:s')." Notification Activity Person [$activityId, $personId] $activity > $person\n"; $notificationService->generateNotificationsForActivity($activity, $person); } catch (Exception $e) { echo "[ERR] " . $e->getMessage() ."\n"; getServiceManager()->get('Logger')->info("[GEARMAN] Error " . $e->getMessage()); } } Loading Loading @@ -141,10 +152,13 @@ function oscarJob_purgeNotificationsPersonActivity(GearmanJob $job){ $activityId = $params->activityid; $activity = $projectGrantService->getActivityById($activityId); getServiceManager()->get('Logger')->info("[GEARMAN] Purge notification Person:$personId Activity:$activityId"); echo date('y-m-d H:i:s')." PURGE Notification Activity Person [$activityId, $personId] $activity > $person\n"; $notificationService->purgeNotificationsPersonActivity($activity, $person); } catch (Exception $e) { getServiceManager()->get('Logger')->info("[GEARMAN] Error " . $e->getMessage()); echo "[ERR] " . $e->getMessage() ."\n"; } } Loading @@ -164,8 +178,14 @@ function oscarJob_hello(GearmanJob $job){ /** @var \Oscar\Service\NotificationService $notificationService */ $notificationService = getServiceManager()->get(\Oscar\Service\NotificationService::class); /** @var \Monolog\Logger $loggerService */ $loggerService = getServiceManager()->get('Logger'); echo "Hello with " . print_r($params) . "\n"; // Envoi d'un log vers OSCAR $loggerService->info("[GEARMAN] a bien reçu la tâche HELLO"); $job->sendComplete("TRAITEMENT RÉUSSI"); } catch (Exception $e) { Loading module/Oscar/src/Oscar/Command/OscarCheckConfigCommand.php +10 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ namespace Oscar\Command; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Tools\SchemaValidator; use Moment\Moment; use Monolog\Logger; use Oscar\Connector\AbstractConnectorOscar; use Oscar\Entity\Authentification; use Oscar\Entity\LogActivity; Loading Loading @@ -54,6 +55,13 @@ class OscarCheckConfigCommand extends OscarCommandAbstract return $this->getServicemanager()->get(OscarConfigurationService::class); } /** * @return Logger */ protected function getLogger(){ return $this->getServicemanager()->get('Logger'); } protected function checkConnectorPerson(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); Loading Loading @@ -145,6 +153,8 @@ class OscarCheckConfigCommand extends OscarCommandAbstract /** @var OscarUserContext $oscaruserContext */ $oscaruserContext = $this->getServicemanager()->get(OscarUserContext::class); $this->getLogger()->info("[COMMAND] check:config"); $io = new SymfonyStyle($input, $output); Loading module/Oscar/src/Oscar/Service/NotificationService.php +10 −1 Original line number Diff line number Diff line Loading @@ -244,6 +244,11 @@ class NotificationService implements UseServiceContainer public function generateMilestonesNotificationsForActivity(Activity $activity, $person = null) { $msg = "Génération des notifications pour l'activité $activity"; if ($person ){ $msg .= " pour $person"; } $this->getLoggerService()->info("[NOTIF] $msg"); /** @var ActivityDate $milestone */ foreach ($activity->getMilestones() as $milestone) { $this->generateMilestoneNotifications($milestone, $person); Loading Loading @@ -398,7 +403,7 @@ class NotificationService implements UseServiceContainer $context = "milestone-" . $milestone->getId(); $notifications = $this->getEntityManager()->getRepository(Notification::class) ->findBy(['context' => $context]); $this->getLoggerService()->info(sprintf('Purge milestone : %s jalon(s) vont être supprimé(s)', count($notifications))); $this->getLoggerService()->info(sprintf('[NOTIFICATION] Purge du jalon : %s notification(s) vont être supprimé(s)', count($notifications))); foreach ($notifications as $notification) { $this->getEntityManager()->remove($notification); } Loading Loading @@ -506,6 +511,8 @@ class NotificationService implements UseServiceContainer $client = new \GearmanClient(); $client->addServer($this->getOrganizationService()->getOscarConfigurationService()->getGearmanHost()); $this->getLoggerService()->info("[NOTIFICATIONS] Envoi à Gearman des notifications à générer pour $person dans l'activité $activity"); $client->doBackground('notificationActivityPerson', json_encode([ 'activityid' => $activity->getId(), 'personid' => $person->getId(), Loading Loading @@ -541,6 +548,8 @@ class NotificationService implements UseServiceContainer public function purgeNotificationPayment(ActivityPayment $payment) { $this->getLoggerService()->info("[NOTIFICATIONS] Purge pour le payment $payment"); $context = "payment:" . $payment->getId(); $notifications = $this->getEntityManager() ->getRepository(Notification::class) Loading module/Oscar/src/Oscar/Service/ProjectGrantService.php +14 −3 Original line number Diff line number Diff line Loading @@ -821,6 +821,7 @@ class ProjectGrantService implements UseOscarConfigurationService, UseEntityMana { $this->searchIndex_reset(); $activities = $this->getEntityManager()->getRepository(Activity::class)->findAll(); $this->getLoggerService()->info('[INDEX ACTIVITY] Reindex de ' . count($activities) . ' activité(s)'); return $this->getSearchEngineStrategy()->rebuildIndex($activities); } Loading Loading @@ -874,27 +875,37 @@ class ProjectGrantService implements UseOscarConfigurationService, UseEntityMana public function searchDelete($id) { $this->getLoggerService()->info("[INDEX ACTIVTY] Suppression de l'index '$id'"); $this->getSearchEngineStrategy()->searchDelete($id); } public function searchUpdate(Activity $activity) { $this->getLoggerService()->info("[INDEX ACTIVTY] Réindexation de l'activité '$activity'"); $this->getSearchEngineStrategy()->searchUpdate($activity); } public function testGearmanError(){ throw new OscarException("Erreur envoyée depuis un service OSCAR."); } public function jobSearchUpdate(Activity $activity) { $client = new \GearmanClient(); $client->addServer($this->getOscarConfigurationService()->getGearmanHost()); $gearmanid = sprintf('activitysearchupdate-%s', $activity->getId()); $this->getLoggerService()->info("[INDEX ACTIVTY] Envoi à gearman : Réindexation de l'activité '$activity'"); $client->doBackground('activitySearchUpdate', json_encode([ 'activityid' => $activity->getId() ]), sprintf('activitysearchupdate-%s', $activity->getId()) ); ]),$gearmanid); } public function searchIndex_reset() { $this->getLoggerService()->info("[INDEX ACTIVITY] Remise à zéro de l'index"); $this->getSearchEngineStrategy()->resetIndex(); } Loading Loading
bin/oscar-worker.php +20 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ function getServiceManager(){ function oscarJob_indexActivity(GearmanJob $job){ $params = json_decode($job->workload()); try { if( !property_exists($params, 'activityid') ){ throw new Exception("Paramètres manquant ID"); Loading @@ -56,12 +58,15 @@ function oscarJob_indexActivity(GearmanJob $job){ /** @var \Oscar\Service\ProjectGrantService $activityService */ $activityService = getServiceManager()->get(\Oscar\Service\ProjectGrantService::class); $activityid = $params->activityid; $activityService->getLoggerService()->info("[GEARMAN] Indexation de Activity $activityid"); $activity = $activityService->getActivityById($activityid); echo date('y-m-d H:i:s')." Rebuid Index [$activityid] $activity\n"; $activityService->searchUpdate($activity); } catch (Exception $e) { $activityService->getLoggerService()->info("[GEARMAN] Error " . $e->getMessage()); echo "[ERR] " . $e->getMessage() ."\n"; } } Loading @@ -77,11 +82,14 @@ function oscarJob_indexPerson(GearmanJob $job){ $personService = getServiceManager()->get(\Oscar\Service\PersonService::class); $personId = $params->personid; getServiceManager()->get('Logger')->info("[GEARMAN] Indexation de Person $personId"); $person = $personService->getPerson($personId); echo date('y-m-d H:i:s')." Rebuid Index [$personId] $person\n"; $personService->getSearchEngineStrategy()->update($person); } catch (Exception $e) { getServiceManager()->get('Logger')->info("[GEARMAN] Error " . $e->getMessage()); echo "[ERR] " . $e->getMessage() ."\n"; } } Loading Loading @@ -109,11 +117,14 @@ function oscarJob_notificationActivityPerson(GearmanJob $job){ $activityId = $params->activityid; $activity = $projectGrantService->getActivityById($activityId); getServiceManager()->get('Logger')->info("[GEARMAN] Notification Person:$personId - Activity:$activityId"); echo date('y-m-d H:i:s')." Notification Activity Person [$activityId, $personId] $activity > $person\n"; $notificationService->generateNotificationsForActivity($activity, $person); } catch (Exception $e) { echo "[ERR] " . $e->getMessage() ."\n"; getServiceManager()->get('Logger')->info("[GEARMAN] Error " . $e->getMessage()); } } Loading Loading @@ -141,10 +152,13 @@ function oscarJob_purgeNotificationsPersonActivity(GearmanJob $job){ $activityId = $params->activityid; $activity = $projectGrantService->getActivityById($activityId); getServiceManager()->get('Logger')->info("[GEARMAN] Purge notification Person:$personId Activity:$activityId"); echo date('y-m-d H:i:s')." PURGE Notification Activity Person [$activityId, $personId] $activity > $person\n"; $notificationService->purgeNotificationsPersonActivity($activity, $person); } catch (Exception $e) { getServiceManager()->get('Logger')->info("[GEARMAN] Error " . $e->getMessage()); echo "[ERR] " . $e->getMessage() ."\n"; } } Loading @@ -164,8 +178,14 @@ function oscarJob_hello(GearmanJob $job){ /** @var \Oscar\Service\NotificationService $notificationService */ $notificationService = getServiceManager()->get(\Oscar\Service\NotificationService::class); /** @var \Monolog\Logger $loggerService */ $loggerService = getServiceManager()->get('Logger'); echo "Hello with " . print_r($params) . "\n"; // Envoi d'un log vers OSCAR $loggerService->info("[GEARMAN] a bien reçu la tâche HELLO"); $job->sendComplete("TRAITEMENT RÉUSSI"); } catch (Exception $e) { Loading
module/Oscar/src/Oscar/Command/OscarCheckConfigCommand.php +10 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ namespace Oscar\Command; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Tools\SchemaValidator; use Moment\Moment; use Monolog\Logger; use Oscar\Connector\AbstractConnectorOscar; use Oscar\Entity\Authentification; use Oscar\Entity\LogActivity; Loading Loading @@ -54,6 +55,13 @@ class OscarCheckConfigCommand extends OscarCommandAbstract return $this->getServicemanager()->get(OscarConfigurationService::class); } /** * @return Logger */ protected function getLogger(){ return $this->getServicemanager()->get('Logger'); } protected function checkConnectorPerson(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); Loading Loading @@ -145,6 +153,8 @@ class OscarCheckConfigCommand extends OscarCommandAbstract /** @var OscarUserContext $oscaruserContext */ $oscaruserContext = $this->getServicemanager()->get(OscarUserContext::class); $this->getLogger()->info("[COMMAND] check:config"); $io = new SymfonyStyle($input, $output); Loading
module/Oscar/src/Oscar/Service/NotificationService.php +10 −1 Original line number Diff line number Diff line Loading @@ -244,6 +244,11 @@ class NotificationService implements UseServiceContainer public function generateMilestonesNotificationsForActivity(Activity $activity, $person = null) { $msg = "Génération des notifications pour l'activité $activity"; if ($person ){ $msg .= " pour $person"; } $this->getLoggerService()->info("[NOTIF] $msg"); /** @var ActivityDate $milestone */ foreach ($activity->getMilestones() as $milestone) { $this->generateMilestoneNotifications($milestone, $person); Loading Loading @@ -398,7 +403,7 @@ class NotificationService implements UseServiceContainer $context = "milestone-" . $milestone->getId(); $notifications = $this->getEntityManager()->getRepository(Notification::class) ->findBy(['context' => $context]); $this->getLoggerService()->info(sprintf('Purge milestone : %s jalon(s) vont être supprimé(s)', count($notifications))); $this->getLoggerService()->info(sprintf('[NOTIFICATION] Purge du jalon : %s notification(s) vont être supprimé(s)', count($notifications))); foreach ($notifications as $notification) { $this->getEntityManager()->remove($notification); } Loading Loading @@ -506,6 +511,8 @@ class NotificationService implements UseServiceContainer $client = new \GearmanClient(); $client->addServer($this->getOrganizationService()->getOscarConfigurationService()->getGearmanHost()); $this->getLoggerService()->info("[NOTIFICATIONS] Envoi à Gearman des notifications à générer pour $person dans l'activité $activity"); $client->doBackground('notificationActivityPerson', json_encode([ 'activityid' => $activity->getId(), 'personid' => $person->getId(), Loading Loading @@ -541,6 +548,8 @@ class NotificationService implements UseServiceContainer public function purgeNotificationPayment(ActivityPayment $payment) { $this->getLoggerService()->info("[NOTIFICATIONS] Purge pour le payment $payment"); $context = "payment:" . $payment->getId(); $notifications = $this->getEntityManager() ->getRepository(Notification::class) Loading
module/Oscar/src/Oscar/Service/ProjectGrantService.php +14 −3 Original line number Diff line number Diff line Loading @@ -821,6 +821,7 @@ class ProjectGrantService implements UseOscarConfigurationService, UseEntityMana { $this->searchIndex_reset(); $activities = $this->getEntityManager()->getRepository(Activity::class)->findAll(); $this->getLoggerService()->info('[INDEX ACTIVITY] Reindex de ' . count($activities) . ' activité(s)'); return $this->getSearchEngineStrategy()->rebuildIndex($activities); } Loading Loading @@ -874,27 +875,37 @@ class ProjectGrantService implements UseOscarConfigurationService, UseEntityMana public function searchDelete($id) { $this->getLoggerService()->info("[INDEX ACTIVTY] Suppression de l'index '$id'"); $this->getSearchEngineStrategy()->searchDelete($id); } public function searchUpdate(Activity $activity) { $this->getLoggerService()->info("[INDEX ACTIVTY] Réindexation de l'activité '$activity'"); $this->getSearchEngineStrategy()->searchUpdate($activity); } public function testGearmanError(){ throw new OscarException("Erreur envoyée depuis un service OSCAR."); } public function jobSearchUpdate(Activity $activity) { $client = new \GearmanClient(); $client->addServer($this->getOscarConfigurationService()->getGearmanHost()); $gearmanid = sprintf('activitysearchupdate-%s', $activity->getId()); $this->getLoggerService()->info("[INDEX ACTIVTY] Envoi à gearman : Réindexation de l'activité '$activity'"); $client->doBackground('activitySearchUpdate', json_encode([ 'activityid' => $activity->getId() ]), sprintf('activitysearchupdate-%s', $activity->getId()) ); ]),$gearmanid); } public function searchIndex_reset() { $this->getLoggerService()->info("[INDEX ACTIVITY] Remise à zéro de l'index"); $this->getSearchEngineStrategy()->resetIndex(); } Loading