public static function __InsertWorkflowHack($id, $buffer)
 {
     $p = CBPWorkflowPersister::GetPersister();
     if ($p->useGZipCompression) {
         $buffer = gzcompress($buffer, 9);
     }
     $p->InsertWorkflow($id, $buffer, 1, true);
 }
Example #2
0
 /**
  * Returns existing workflow instance by its ID
  *
  * @param string $workflowId ID of the workflow instance.
  * @param bool $silent
  * @return CBPWorkflow
  * @throws Exception
  */
 public function GetWorkflow($workflowId, $silent = false)
 {
     if (strlen($workflowId) <= 0) {
         throw new Exception("workflowId");
     }
     if (!$this->isStarted) {
         $this->StartRuntime();
     }
     if (array_key_exists($workflowId, $this->arWorkflows)) {
         return $this->arWorkflows[$workflowId];
     }
     $workflow = new CBPWorkflow($workflowId, $this);
     $persister = CBPWorkflowPersister::GetPersister();
     $rootActivity = $persister->LoadWorkflow($workflowId, $silent);
     if ($rootActivity == null) {
         throw new Exception("Empty root activity");
     }
     $workflow->Reload($rootActivity);
     $this->arWorkflows[$workflowId] = $workflow;
     return $workflow;
 }
Example #3
0
 public function Terminate(Exception $e = null)
 {
     $taskService = $this->GetService("TaskService");
     $taskService->DeleteAllWorkflowTasks($this->GetInstanceId());
     $this->SetWorkflowStatus(CBPWorkflowStatus::Terminated);
     $persister = CBPWorkflowPersister::GetPersister();
     $persister->SaveWorkflow($this->rootActivity, true);
     $stateService = $this->GetService("StateService");
     $stateService->SetState($this->instanceId, array("STATE" => "Terminated", "TITLE" => GetMessage("BPCGWF_TERMINATED"), "PARAMETERS" => array()), false);
     if ($e != null) {
         $trackingService = $this->GetService("TrackingService");
         $trackingService->Write($this->instanceId, CBPTrackingType::FaultActivity, "none", CBPActivityExecutionStatus::Faulting, CBPActivityExecutionResult::Faulted, "Exception", "[" . $e->getCode() . "] " . $e->getMessage());
     }
 }