Loading module/StepStar/src/StepStar/Entity/Db/Log.php +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ class Log { const OPERATION__ENVOI = 'ENVOI'; const OPERATION__GENERATION_XML = 'GENERATION_XML'; const OPERATION__SYNTHESE = 'SYNTHESE'; private int $id; private string $operation; Loading module/StepStar/src/StepStar/Facade/EnvoiFacade.php +15 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ class EnvoiFacade * (Un Log par thèse est créé.) */ $operation = Log::OPERATION__ENVOI; $nbEnvoisReussis = $nbEnvoisEchoues = $nbEnvoisInutiles = 0; $tefFilesPaths = $this->listXmlFilesInDirectory($outputDir); foreach ($tefFilesPaths as $i => $tefFilePath) { $theseId = $this->extractTheseIdFromTefFilePath($tefFilePath); Loading @@ -100,12 +101,15 @@ class EnvoiFacade $this->appendToLog($message); try { $this->envoyer($tefFilePath); $nbEnvoisReussis++; } catch (Exception $e) { $nbEnvoisEchoues++; $success = false; $this->appendToLog(" :-( " . $e->getMessage()); $this->log->setTefFileContent(file_get_contents($tefFilePath)); // conservation du TEF envoyé } } else { $nbEnvoisInutiles++; $message = sprintf( "> Envoi %d/%d inutile : These %d (%s) - Fichier '%s' - Inutile car identique au dernier envoi du %s.", $i + 1, count($tefFilesPaths), $theseId, $doctorantIdentite, $tefFilePath, $lastLog->getStartedOnToString() Loading @@ -116,6 +120,17 @@ class EnvoiFacade $this->saveCurrentLog(); yield $this->log; } $operation = Log::OPERATION__SYNTHESE; $this->newLog($operation, $command, $tag); $this->log->setSuccess(true); $message = sprintf( "Synthèse des envois : %d envois prévus / %d envois réussis / %d envois échoués / %d envois inutiles.", count($tefFilesPaths), $nbEnvoisReussis, $nbEnvoisEchoues, $nbEnvoisInutiles ); $this->appendToLog($message); $this->saveCurrentLog(); yield $this->log; } private function saveCurrentLog() Loading module/StepStar/src/StepStar/Service/Log/LogService.php +3 −3 Original line number Diff line number Diff line Loading @@ -33,13 +33,13 @@ class LogService public function newLog(?string $operation = null, ?string $command = null, ?string $tag = null): Log { $log = new Log(); if ($operation) { if ($operation !== null) { $log->setOperation($operation); } if ($command) { if ($command !== null) { $log->setCommand($command); } if ($tag) { if ($tag !== null) { $log->setTag($tag); } $log->setStartedOn(); Loading module/StepStar/src/StepStar/Service/Log/LogServiceAwareTrait.php +2 −2 Original line number Diff line number Diff line Loading @@ -14,10 +14,10 @@ trait LogServiceAwareTrait * Instancie un nouveau Log tout nu, qui devient le Log courant. * * @param string|null $operation * @param string|null $command * @param string $command * @param string|null $tag */ protected function newLog(?string $operation = null, ?string $command = null, ?string $tag = null) protected function newLog(?string $operation = null, string $command = '', ?string $tag = null) { $this->log = $this->logService->newLog($operation, $command, $tag); } Loading Loading
module/StepStar/src/StepStar/Entity/Db/Log.php +1 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ class Log { const OPERATION__ENVOI = 'ENVOI'; const OPERATION__GENERATION_XML = 'GENERATION_XML'; const OPERATION__SYNTHESE = 'SYNTHESE'; private int $id; private string $operation; Loading
module/StepStar/src/StepStar/Facade/EnvoiFacade.php +15 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,7 @@ class EnvoiFacade * (Un Log par thèse est créé.) */ $operation = Log::OPERATION__ENVOI; $nbEnvoisReussis = $nbEnvoisEchoues = $nbEnvoisInutiles = 0; $tefFilesPaths = $this->listXmlFilesInDirectory($outputDir); foreach ($tefFilesPaths as $i => $tefFilePath) { $theseId = $this->extractTheseIdFromTefFilePath($tefFilePath); Loading @@ -100,12 +101,15 @@ class EnvoiFacade $this->appendToLog($message); try { $this->envoyer($tefFilePath); $nbEnvoisReussis++; } catch (Exception $e) { $nbEnvoisEchoues++; $success = false; $this->appendToLog(" :-( " . $e->getMessage()); $this->log->setTefFileContent(file_get_contents($tefFilePath)); // conservation du TEF envoyé } } else { $nbEnvoisInutiles++; $message = sprintf( "> Envoi %d/%d inutile : These %d (%s) - Fichier '%s' - Inutile car identique au dernier envoi du %s.", $i + 1, count($tefFilesPaths), $theseId, $doctorantIdentite, $tefFilePath, $lastLog->getStartedOnToString() Loading @@ -116,6 +120,17 @@ class EnvoiFacade $this->saveCurrentLog(); yield $this->log; } $operation = Log::OPERATION__SYNTHESE; $this->newLog($operation, $command, $tag); $this->log->setSuccess(true); $message = sprintf( "Synthèse des envois : %d envois prévus / %d envois réussis / %d envois échoués / %d envois inutiles.", count($tefFilesPaths), $nbEnvoisReussis, $nbEnvoisEchoues, $nbEnvoisInutiles ); $this->appendToLog($message); $this->saveCurrentLog(); yield $this->log; } private function saveCurrentLog() Loading
module/StepStar/src/StepStar/Service/Log/LogService.php +3 −3 Original line number Diff line number Diff line Loading @@ -33,13 +33,13 @@ class LogService public function newLog(?string $operation = null, ?string $command = null, ?string $tag = null): Log { $log = new Log(); if ($operation) { if ($operation !== null) { $log->setOperation($operation); } if ($command) { if ($command !== null) { $log->setCommand($command); } if ($tag) { if ($tag !== null) { $log->setTag($tag); } $log->setStartedOn(); Loading
module/StepStar/src/StepStar/Service/Log/LogServiceAwareTrait.php +2 −2 Original line number Diff line number Diff line Loading @@ -14,10 +14,10 @@ trait LogServiceAwareTrait * Instancie un nouveau Log tout nu, qui devient le Log courant. * * @param string|null $operation * @param string|null $command * @param string $command * @param string|null $tag */ protected function newLog(?string $operation = null, ?string $command = null, ?string $tag = null) protected function newLog(?string $operation = null, string $command = '', ?string $tag = null) { $this->log = $this->logService->newLog($operation, $command, $tag); } Loading