/** * {@internaldoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $logger = new OutputLogger($output); /** @var EmailFlagManager $emailFlagManager */ $emailFlagManager = $this->getContainer()->get('oro_email.email.flag.manager'); $seenStatus = $input->getOption('seen') === 'true'; $emailUserIds = $input->getOption('ids'); foreach ($emailUserIds as $emailUserId) { $emailUser = $this->getContainer()->get('doctrine')->getRepository('OroEmailBundle:EmailUser')->find($emailUserId); if ($emailUser) { try { if ($seenStatus) { $emailFlagManager->setSeen($emailUser); } else { $emailFlagManager->setUnseen($emailUser); } $msg = sprintf('Email flag synced for email user - %s', $emailUser->getId()); $output->writeln('<info>' . $msg . '</info>'); } catch (Exception $e) { $warn = sprintf('Email flag cannot be synced for email user - %s', $emailUser->getId()); $output->writeln('<info>' . $warn . '</info>'); $logger->warning($warn); } $emailUser->decrementUnsyncedFlagCount(); } else { $warn = sprintf('Not found email user - %s', $emailUser->getId()); $output->writeln('<info>' . $warn . '</info>'); $logger->warning($warn); } } $this->getEmailUserManager()->flush(); }
/** * {@inheritdoc} */ public function execute(InputInterface $input, OutputInterface $output) { if ($output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); } /** @var ChannelRepository $repository */ /** @var SyncProcessor $processor */ /** @var BlockingJob $blockedJobsManager */ $connector = $input->getOption('connector'); $integrationId = $input->getOption('integration-id'); $batchSize = $input->getOption('transport-batch-size'); $connectorParameters = $this->getConnectorParameters($input); $entityManager = $this->getService('doctrine.orm.entity_manager'); $repository = $entityManager->getRepository('OroIntegrationBundle:Channel'); $logger = new OutputLogger($output); $entityManager->getConnection()->getConfiguration()->setSQLLogger(null); $blockedJobsManager = $this->getService('oro_integration.manager.blocking_job'); if ($this->isJobRunning($integrationId)) { $logger->warning('Job already running. Terminating....'); return self::STATUS_SUCCESS; } if ($integrationId) { $integration = $repository->getOrLoadById($integrationId); if (!$integration) { $logger->critical(sprintf('Integration with given ID "%d" not found', $integrationId)); return self::STATUS_FAILED; } if ($this->isBlockingJobRunning($integration, $blockedJobsManager)) { $logger->warning('Blocking jobs already running. Terminating....'); return self::STATUS_SUCCESS; } $exitCode = $this->processIntegration($logger, $integration, $batchSize, $connector, $connectorParameters); } else { $integrations = $repository->getConfiguredChannelsForSync(null, true); $exitCode = $this->processIntegrations($integrations); } $logger->notice('Completed'); return $exitCode; }
/** * {@inheritdoc} */ public function execute(InputInterface $input, OutputInterface $output) { if ($output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) { $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); } /** @var ChannelRepository $repository */ /** @var SyncProcessor $processor */ $connector = $input->getOption('connector'); $integrationId = $input->getOption('integration-id'); $batchSize = $input->getOption('transport-batch-size'); $connectorParameters = $this->getConnectorParameters($input); $entityManager = $this->getService('doctrine.orm.entity_manager'); $repository = $entityManager->getRepository('OroIntegrationBundle:Channel'); $logger = new OutputLogger($output); $entityManager->getConnection()->getConfiguration()->setSQLLogger(null); $exitCode = self::STATUS_SUCCESS; if ($this->isJobRunning($integrationId)) { $logger->warning('Job already running. Terminating....'); return self::STATUS_SUCCESS; } if ($integrationId) { $integration = $repository->getOrLoadById($integrationId); if (!$integration) { $logger->critical(sprintf('Integration with given ID "%d" not found', $integrationId)); return self::STATUS_FAILED; } $integrations = [$integration]; } else { $integrations = $repository->getConfiguredChannelsForSync(null, true); } /* @var Integration $integration */ foreach ($integrations as $integration) { try { $logger->notice(sprintf('Run sync for "%s" integration.', $integration->getName())); $this->updateToken($integration); if ($batchSize) { $integration->getTransport()->getSettingsBag()->set('page_size', $batchSize); } $processor = $this->getSyncProcessor($integration, $logger); $result = $processor->process($integration, $connector, $connectorParameters); $exitCode = $result ?: self::STATUS_FAILED; } catch (\Exception $e) { $logger->critical($e->getMessage(), ['exception' => $e]); $exitCode = self::STATUS_FAILED; continue; } } $logger->notice('Completed'); return $exitCode; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $logger = new OutputLogger($output); if ($this->getContainer()->get('oro_cron.job_manager')->getRunningJobsCount(self::COMMAND_NAME) > 1) { $logger->warning('Parsing job already running. Terminating current job.'); return self::STATUS_SUCCESS; } /** @var TrackingProcessor $processor */ $processor = $this->getContainer()->get('oro_tracking.processor.tracking_processor'); $maxExecutionTime = $input->getOption('max-execution-time'); if ($maxExecutionTime && is_numeric($maxExecutionTime)) { $processor->setMaxExecutionTime($maxExecutionTime); } $processor->setLogger($logger); $processor->process(); return self::STATUS_SUCCESS; }
/** * {@internaldoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $logger = new OutputLogger($output); /** @var EmailCacheManager $emailCacheManager */ $emailCacheManager = $this->getContainer()->get('oro_email.email.cache.manager'); $emailId = $input->getOption('id'); $email = $this->getContainer()->get("doctrine")->getRepository('OroEmailBundle:Email')->find($emailId); if ($email) { try { $emailCacheManager->ensureEmailBodyCached($email); $output->writeln(sprintf('<info>Email body synced for email - %s</info>', $email->getId())); } catch (LoadEmailBodyException $e) { $warn = sprintf('Email body cannot be loaded for email - %s', $email->getId()); $output->writeln('<info>' . $warn . '</info>'); $logger->warning($warn); } } }
/** * {@inheritdoc} */ public function execute(InputInterface $input, OutputInterface $output) { /** @var ChannelRepository $repository */ $channelId = $input->getOption('channel-id'); $logger = new OutputLogger($output); if ($this->isJobRunning($channelId)) { $logger->warning('Job already running. Terminating....'); return 0; } /** @var CartExpirationProcessor $processor */ $processor = $this->getService('orocrm_magento.provider.cart_expiration_processor'); $repository = $this->getService('doctrine.orm.entity_manager')->getRepository('OroIntegrationBundle:Channel'); if ($channelId) { $channel = $repository->getOrLoadById($channelId); if (!$channel) { throw new \InvalidArgumentException('Channel with given ID not found'); } $channels = [$channel]; } else { $channels = $repository->getConfiguredChannelsForSync(ChannelType::TYPE); } $channels = array_filter($channels, function (Channel $channel) { $connectors = $channel->getConnectors() ?: []; return in_array('cart', $connectors); }); /** @var Channel $channel */ foreach ($channels as $channel) { try { $logger->info(sprintf('Run sync for "%s" channel.', $channel->getName())); $processor->process($channel); } catch (\Exception $e) { $logger->critical($e->getMessage(), ['exception' => $e]); //process another channel even in case if exception thrown continue; } } $logger->info('Completed'); return 0; }