26 private const SETTING_ACTION_STATUS_CODE =
'ACTION_STATUS_CODE';
49 private $context =
'';
50 private $contextEntity =
'';
52 abstract protected function run(): bool;
74 $this->setting =
null;
75 $this->notification =
null;
105 return !empty($this->context) ? $this->context : static::CONTEXT_PREFIX . static::ACTION .
$this->processId;
116 if ($context !== $this->context)
118 $this->context = (string) $context;
134 return !empty($this->contextEntity) ? $this->contextEntity : static::CONTEXT_PREFIX . static::ACTION .
$this->processId;
145 $id = $appId > 0 ? (int) $appId : 0;
146 $this->contextEntity = Helper::getInstance()->getContextAction($id);
179 if (mb_strpos(
$path,
'https://') ===
false)
187 $httpClient->get(
$path);
225 $file = CRestUtil::saveFile(base64_encode(Json::encode(
$data)));
226 $file[
'MODULE_ID'] = static::MODULE_ID;
229 'configuration/' . static::ACTION
253 if (!empty($appCode))
270 static::class .
'::runAgent(' .
$processId .
');',
276 ConvertTimeStamp(time() + CTimeZone::GetOffset() + 60,
'FULL')
288 $result[
'error'] = static::ERROR_PROCESS_DID_NOT_CREATE;
304 if (isset(
$data[self::PROPERTY_STRUCTURE]) && is_array(
$data[self::PROPERTY_STRUCTURE]))
306 foreach (
$data[self::PROPERTY_STRUCTURE] as
$type => $item)
308 if (
$type === Helper::STRUCTURE_FILES_NAME)
312 if (is_array(
$data[self::PROPERTY_STRUCTURE][
$type]))
315 foreach (
$data[self::PROPERTY_STRUCTURE][
$type] as $value)
317 if (is_string($value))
319 $path = array_filter(explode(
'/', $value));
320 $list[end(
$path)] = $value;
324 $data[self::PROPERTY_STRUCTURE][
$type] = array_values($list);
339 'error' => static::ERROR_PROCESS_NOT_FOUND,
340 'error_description' =>
'Process doesn\'t found.',
342 if ($this->processId > 0)
356 $res = CAgent::getList(
359 'MODULE_ID' => static::MODULE_ID,
360 'NAME' => static::class .
'::runAgent(' .
$data[
'ID'] .
');',
363 while ($agent =
$res->fetch())
365 CAgent::Delete($agent[
'ID']);
380 if (!$this->notification)
395 if (!in_array(
$status, self::STATUSES))
410 return $this->
getSetting()->get(self::SETTING_ACTION_STATUS_CODE) ?? self::STATUS_UNKNOWN;
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getByClientId($clientId)
__construct($processId=0)
getNotificationInstance()
setStatus(string $status)
setContextEntity($appId=0)
static runAgent(int $processId)
setProcessId(int $processId)
const ERROR_PROCESS_DID_NOT_CREATE
const ERROR_PROCESS_NOT_FOUND
const SETTING_ACTION_ADDITIONAL_OPTION
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]