private function RunQueuedItem(CBPActivity $activity, $activityOperation, Exception $exception = null) { if ($activityOperation == CBPActivityExecutorOperationType::Execute) { if ($activity->executionStatus == CBPActivityExecutionStatus::Executing) { try { $trackingService = $this->GetService("TrackingService"); $trackingService->Write($this->GetInstanceId(), CBPTrackingType::ExecuteActivity, $activity->GetName(), $activity->executionStatus, $activity->executionResult, $activity->IsPropertyExists("Title") ? $activity->Title : "", ""); $newStatus = $activity->Execute(); if ($newStatus == CBPActivityExecutionStatus::Closed) { $this->CloseActivity($activity); } elseif ($newStatus != CBPActivityExecutionStatus::Executing) { throw new Exception("InvalidExecutionStatus"); } } catch (Exception $e) { throw $e; } } } elseif ($activityOperation == CBPActivityExecutorOperationType::Cancel) { if ($activity->executionStatus == CBPActivityExecutionStatus::Canceling) { try { $trackingService = $this->GetService("TrackingService"); $trackingService->Write($this->GetInstanceId(), CBPTrackingType::CancelActivity, $activity->GetName(), $activity->executionStatus, $activity->executionResult, $activity->IsPropertyExists("Title") ? $activity->Title : "", ""); $newStatus = $activity->Cancel(); if ($newStatus == CBPActivityExecutionStatus::Closed) { $this->CloseActivity($activity); } elseif ($newStatus != CBPActivityExecutionStatus::Canceling) { throw new Exception("InvalidExecutionStatus"); } } catch (Exception $e) { throw $e; } } } elseif ($activityOperation == CBPActivityExecutorOperationType::HandleFault) { if ($activity->executionStatus == CBPActivityExecutionStatus::Faulting) { try { $trackingService = $this->GetService("TrackingService"); $trackingService->Write($this->GetInstanceId(), CBPTrackingType::FaultActivity, $activity->GetName(), $activity->executionStatus, $activity->executionResult, $activity->IsPropertyExists("Title") ? $activity->Title : "", $exception != null ? "[" . $exception->getCode() . "] " . $exception->getMessage() : ""); $newStatus = $activity->HandleFault($exception); if ($newStatus == CBPActivityExecutionStatus::Closed) { $this->CloseActivity($activity); } elseif ($newStatus != CBPActivityExecutionStatus::Faulting) { throw new Exception("InvalidExecutionStatus"); } } catch (Exception $e) { throw $e; } } } }