55 !Loader::includeModule(
'calendar')
56 || !Loader::includeModule(
'dav')
64 $entriesDb = $qm::getEventListDb();
65 while ($queueItem = $entriesDb->Fetch())
67 $connection = $qm->getConnectionForQueueItem($queueItem);
69 $event = $qm->mapperFactory->getEvent()->getEntity((
int)$queueItem[
'EVENT_ID']);
75 $context = $qm->prepareEventContext(
77 'connection' => $connection,
79 'queueItem' => $queueItem,
83 if ($event->getOwner() ===
null || $event->getOwner()->getId() ===
null)
85 $eventConnection = $context->getEventConnection();
86 if ($eventConnection !==
null)
88 $qm->mapperFactory->getEventConnection()->update(
96 $factory = FactoryBuilder::create($connection->getVendor()->getCode(), $connection, $context);
102 switch ($queueItem[
'SYNC_STATUS'])
105 $result = $syncManager->createEvent($event, $context);
108 $result = $syncManager->deleteEvent($event, $context);
110 $result = $syncManager->createEvent($event, $context);
113 $result = $syncManager->updateEvent($event, $context);
116 $result = $syncManager->deleteEvent($event, $context);
124 $eventLink = $qm->mapperFactory->getEventConnection()->getMap(
126 '=EVENT_ID' => $event->getId(),
127 '=CONNECTION_ID' => $factory->getConnection()->getId(),
131 if (!is_null($eventLink))
133 $retryCount = $eventLink->getRetryCount() + 1;
134 $currentNextSyncTry = $connection->getNextSyncTry();
135 if ($result && $result->isSuccess())
137 $resultData = $result->getData();
140 is_array($resultData)
141 && (isset($resultData[$factory->getConnection()->getVendor()->getCode()])
142 && $resultData[$factory->getConnection()->getVendor()->getCode()][
'status']
149 $currentNextSyncTry =
null;
155 && $retryCount > self::MAX_RETRY_COUNT
161 $eventLink->setRetryCount($retryCount);
162 $qm->mapperFactory->getEventConnection()->update($eventLink);
167 $currentNextSyncTry =
null;
170 $connection->setNextSyncTry(
171 self::prepareNextSyncTry(
178 $qm->saveConnections();
180 return "\\Bitrix\\Calendar\\Sync\\Managers\\EventQueueManager::checkEvents();";