17 $queueId = reset($params);
18 $scriptId = next($params);
22 $result[
'count'] = $counters[
'all'];
23 $result[
'steps'] = $counters[
'completed'];
25 if ($result[
'steps'] >= $result[
'count'])
35 ScriptQueueTable::delete($queueId);
48 return $this->executeDocument($document, $script);
51 private function executeDocument(EO_ScriptQueueDocument $document, EO_Script $script)
55 $document->fillQueue();
56 $queue = $document->getQueue();
57 $documentType = $documentId = [$script->getModuleId(), $script->getEntity(), $script->getDocumentType()];
58 $documentId[2] = $document->getDocumentId();
63 $canStart = \CBPDocument::canUserOperateDocument(
64 \CBPCanUserOperateOperation::StartWorkflow,
65 $queue->getStartedBy(),
71 $startParameters = $queue->getWorkflowParameters();
72 if (!is_array($startParameters))
74 $startParameters = [];
77 $startParameters[\CBPDocument::PARAM_TAGRET_USER] = $queue->getStartedBy();
78 $startParameters[\CBPDocument::PARAM_USE_FORCED_TRACKING] =
true;
79 $startParameters[\CBPDocument::PARAM_IGNORE_SIMULTANEOUS_PROCESSES_LIMIT] =
true;
80 $startParameters[\CBPDocument::PARAM_DOCUMENT_TYPE] = $documentType;
81 $startParameters[\CBPDocument::PARAM_DOCUMENT_EVENT_TYPE] = \CBPDocumentEventType::Script;
83 $workflowId = \CBPDocument::StartWorkflow($script->getWorkflowTemplateId(), $documentId, $startParameters, $errors);
87 $errors[] = [
'message' => Main\Localization\Loc::getMessage(
'BIZPROC_SCRIPT_QUEUE_CAN_START_ERROR')];
92 $document->setWorkflowId($workflowId);
98 $document->setStatusMessage(reset($errors)[
'message']);
107 return "Script queues";