コード例 #1
0
 /**
  * Move the not detected links in link table to history table
  * 
  * @param integer $lang         language id
  * @param integer $currentRunId current crawler run id
  * 
  * @return null
  */
 public function updateHistory($lang, $currentRunId)
 {
     try {
         if (empty($lang) || empty($currentRunId)) {
             return;
         }
         $objCrawler = $this->crawlerRepo->findOneBy(array('id' => $currentRunId));
         if ($objCrawler) {
             $nonDetectedLinks = $this->linkRepo->getNonDetectedLinks($objCrawler->getStartTime()->format(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME), $lang);
             if ($nonDetectedLinks && $nonDetectedLinks->count() > 0) {
                 foreach ($nonDetectedLinks as $nonDetectedLink) {
                     //move the modified link to history table
                     $historyInputValues = array('lang' => $nonDetectedLink->getLang(), 'requestedPath' => $nonDetectedLink->getRequestedPath(), 'refererPath' => $nonDetectedLink->getRefererPath(), 'leadPath' => $nonDetectedLink->getLeadPath(), 'linkStatusCode' => $nonDetectedLink->getLinkStatusCode(), 'entryTitle' => $nonDetectedLink->getEntryTitle(), 'moduleName' => $nonDetectedLink->getModuleName(), 'moduleAction' => $nonDetectedLink->getModuleAction(), 'moduleParams' => $nonDetectedLink->getModuleParams(), 'detectedTime' => $nonDetectedLink->getDetectedTime(), 'flagStatus' => $nonDetectedLink->getFlagStatus(), 'linkStatus' => $nonDetectedLink->getLinkStatus(), 'linkRecheck' => $nonDetectedLink->getLinkRecheck(), 'updatedBy' => $nonDetectedLink->getUpdatedBy(), 'requestedLinkType' => $nonDetectedLink->getRequestedLinkType(), 'brokenLinkText' => $nonDetectedLink->getBrokenLinkText());
                     $this->modifyHistory($historyInputValues);
                     //removed from link table after moved to history table
                     $this->em->remove($nonDetectedLink);
                     $this->em->flush();
                 }
             }
         } else {
             return;
         }
     } catch (\Exception $error) {
         $this->updateCrawlerStatus('', self::RUN_STATUS_INCOMPLETE);
         die("Error occured:" . $error);
     }
 }
コード例 #2
0
 /**
  * Copy the non-detected links from link table to history table
  *
  * @param \DateTime $startTime
  *
  * @return null
  */
 public function moveOldLinksToHistory(\DateTime $startTime)
 {
     try {
         //Get all the non-detected links by crawler start time and lang
         $links = $this->linkRepo->getNonDetectedLinks($startTime->format(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME), $this->langId);
         //If there is no link detected then return
         if (!$links) {
             return;
         }
         foreach ($links as $link) {
             $this->copyLinkToHistory($link);
             //removed from link table after moved to history table
             $this->em->remove($link);
         }
         $this->em->flush();
     } catch (\Exception $error) {
         $this->updateCrawlerStatus('', self::RUN_STATUS_INCOMPLETE);
         die("Error occured:" . $error);
     }
 }