コード例 #1
0
 /**
  * @return ReplicationContext
  */
 public function beginUpdate()
 {
     $initialDateTime = new \DateTime();
     $beginObjectsDateTime = new \DateTime('1970-01-01');
     $lastUpdate = $this->_dataReplicationRepository->readLastUpdate();
     if ($lastUpdate !== null) {
         if ($lastUpdate->endDateTime === null) {
             $lastUpdate->endDateTime = $initialDateTime;
             $this->_dataReplicationRepository->endUpdate($lastUpdate);
             if ($lastUpdate->boundaryDateTime !== null) {
                 $beginObjectsDateTime = clone $lastUpdate->boundaryDateTime;
             } else {
                 $beginObjectsDateTime = clone $lastUpdate->startDateTime;
             }
         } else {
             $beginObjectsDateTime = clone $lastUpdate->endDateTime;
         }
     }
     $beginObjectsDateTimeString = $beginObjectsDateTime->format('Y-m-d H:i:s');
     $endObjectsDateTimeString = $initialDateTime->format('Y-m-d H:i:s');
     Yii::info("UpdateService::beginUpdate() - Read history objects by date from {$beginObjectsDateTimeString} to {$endObjectsDateTimeString}", Logger::LEVEL_INFO, self::SERVICE_CATEGORY);
     $objectsToUpdate = $this->_objectHistoryRepository->read($beginObjectsDateTime, $initialDateTime);
     $currentUpdate = $this->_dataReplicationRepository->startUpdate($initialDateTime);
     $this->_updateContext = new ReplicationContext();
     $this->_updateContext->currentUpdate = $currentUpdate;
     $this->_updateContext->objectsToUpdate = $objectsToUpdate;
     return $this->_updateContext;
 }
コード例 #2
0
 /**
  * Список изменённых объектов с заданного времени и интервалом времени
  *
  * @param \DateTime $startDateTime Начальное время, с которого возвращается список изменённых объектов
  * @param \DateTime $endDateTime
  *
  * @internal param \DateInterval $dateInterval Интервал времени
  *
  * @return ObjectHistoryItem[]
  */
 function retrieve(\DateTime $startDateTime, \DateTime $endDateTime)
 {
     return $this->_objectHistoryRepository->read($startDateTime, $endDateTime);
 }