CBPWorkflow::terminate

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPWorkflow
  4. terminate
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/workflow.php
  • Класс: CBPWorkflow
  • Вызов: CBPWorkflow::terminate
public function terminate(Exception $e = null, $stateTitle = '')
{
	/** @var CBPTaskService $taskService */
	$taskService = $this->GetService("TaskService");
	$taskService->DeleteByWorkflow($this->GetInstanceId(), CBPTaskStatus::Running);

	$this->SetWorkflowStatus(CBPWorkflowStatus::Terminated);

	$this->persister->SaveWorkflow($this->rootActivity, true);

	/** @var CBPStateService $stateService */
	$stateService = $this->GetService("StateService");
	$stateService->SetState(
		$this->instanceId,
		array(
			"STATE" => "Terminated",
			"TITLE" => $stateTitle ? $stateTitle : GetMessage("BPCGWF_TERMINATED"),
			"PARAMETERS" => array()
		),
		false//array()
	);

	if ($e != null)
	{
		$trackingService = $this->GetService("TrackingService");
		$trackingService->Write(
			$this->instanceId,
			CBPTrackingType::FaultActivity,
			"none",
			CBPActivityExecutionStatus::Faulting,
			CBPActivityExecutionResult::Faulted,
			GetMessage('BPCGWF_EXCEPTION_TITLE'),
			($e->getCode()? "[".$e->getCode()."] " : '').$e->getMessage()
		);
	}
}

Добавить комментарий