예제 #1
0
 public function Execute()
 {
     $activityData = $this->getRestActivityData();
     if (!$activityData || !Loader::includeModule('rest')) {
         return CBPActivityExecutionStatus::Closed;
     }
     $propertiesData = array();
     if (!empty($activityData['PROPERTIES'])) {
         foreach ($activityData['PROPERTIES'] as $name => $property) {
             $propertiesData[$name] = $this->{$name};
         }
     }
     $auth = null;
     $userId = $this->AuthUserId;
     if ($userId > 0) {
         $auth = CRestUtil::getAuthForEvent($activityData['APP_ID'], $userId, array('WORKFLOW_ID' => $this->getWorkflowInstanceId(), 'ACTIVITY_NAME' => $this->name, 'CODE' => $activityData['CODE']));
     }
     $this->eventId = \Bitrix\Main\Security\Random::getString(32, true);
     $queryItems = array(Sqs::queryItem($activityData['HANDLER'], array('workflow_id' => $this->getWorkflowInstanceId(), 'code' => $activityData['CODE'], 'event_token' => self::generateToken($this->getWorkflowInstanceId(), $this->name, $this->eventId), 'properties' => $propertiesData, 'auth' => $auth, 'ts' => time())));
     Sqs::query($queryItems);
     if ($this->SetStatusMessage == 'Y') {
         $message = $this->StatusMessage;
         if (empty($message)) {
             $message = Loc::getMessage('BPRA_DEFAULT_STATUS_MESSAGE');
         }
         $this->SetStatusTitle($message);
     }
     if ($this->isInEventActivityMode || $this->UseSubscription != 'Y') {
         return CBPActivityExecutionStatus::Closed;
     }
     $this->Subscribe($this);
     $this->isInEventActivityMode = false;
     return CBPActivityExecutionStatus::Executing;
 }