29 public static function runProcess($exportId, $processType)
35 $exportId = \EscapePHPString($exportId);
37 $currProcess = Vk\Journal::getCurrentProcess($exportId);
38 $startPosition = $currProcess ? $currProcess[
'START_POSITION'] : self::DEFAULT_START_POSITION;
39 $execCount = $currProcess ? $currProcess[
'EXEC_COUNT'] : self::DEFAULT_EXEC_COUNT;
41 $currProcessType = self::prepareType($processType);
42 if (!in_array($currProcessType,
Vk\Vk::getExportTypes()))
45 $journal =
new Vk\Journal($exportId, $currProcessType);
48 if ($startPosition == self::DEFAULT_START_POSITION)
51 $vk = Vk\Vk::getInstance();
53 TradingPlatform\Logger::LOG_LEVEL_DEBUG,
55 'FEED_' . $currProcessType,
56 "VKontakte export of " . $currProcessType .
" started. Export profile: " . $exportId .
", start position: " . $startPosition
61 $timelimit = $vk->getTimelimit($exportId);
62 $feed = Manager::createFeed($currProcessType, $exportId, $timelimit, $startPosition);
63 $feed->processData($exportId);
70 if ($startPosition == $endPosition)
73 if ($execCount >= self::MAX_EXEC_COUNT)
74 $result[
'TOO_MUCH_TIMES'] = Vk\Journal::getTooMuchTimeExportMessage();
78 $execCount = self::DEFAULT_EXEC_COUNT;
82 TradingPlatform\Logger::LOG_LEVEL_DEBUG,
83 "VK_PROCESS__TIMELIMIT",
84 'FEED_' . $currProcessType,
85 "VKontakte export of " . $currProcessType .
" for profile " . $exportId .
" takes too long and was finished at position '" . $startPosition .
"'."
92 $result[
'ERRORS_CRITICAL'] =
true;
93 $msg = $e->getFullMessage() ? $e->getFullMessage() :
Loc::getMessage(
"SALE_VK__UNKNOWN_ERROR");
94 $vk->log(TradingPlatform\Logger::LOG_LEVEL_ERROR,
"VK_FEED__FEED_ERRORS",
'FEED_' . $currProcessType, $msg);
101 TradingPlatform\Logger::LOG_LEVEL_ERROR,
102 "VK_PROCESS__ERRORS",
'FEED_' . $currProcessType,
103 "VKontakte export of " . $currProcessType .
" for profile " . $exportId .
" finished with some errors. " .
108 $journal =
new Vk\Journal($exportId, $currProcessType);
110 if (!isset($endPosition))
115 TradingPlatform\Logger::LOG_LEVEL_DEBUG,
116 "VK_PROCESS__FINISH",
117 'FEED_' . $currProcessType,
118 "VKontakte export of " . $currProcessType .
" for profile " . $exportId .
" was finished."
122 if ($currProcessType == self::FIRST_PROCESS_TYPE && $processType == self::DEFAULT_PROCESS_TYPE)
124 $processTypeToSave = self::SECOND_PROCESS_TYPE;
125 $positionToSave = self::DEFAULT_START_POSITION;
126 $execCountToSave = self::DEFAULT_EXEC_COUNT;
128 $result[
'CONTINUE'] =
true;
129 $result[
'TYPE'] = $processTypeToSave;
135 $processTypeToSave =
false;
136 $positionToSave =
false;
137 $execCountToSave =
false;
139 $result[
'CONTINUE'] =
false;
147 $processTypeToSave = $processType;
148 $positionToSave = $endPosition;
149 $execCountToSave = $execCount;
151 $result[
'CONTINUE'] =
true;
152 $result[
'TYPE'] = $processTypeToSave;
156 $journal->saveProcessParams($exportId, $processTypeToSave, $positionToSave, $execCountToSave);
172 private static function createFeed($feedType, $exportId, $timeLimit = 0, $startPosition =
'')