本文整理汇总了PHP中CAgent::GetList方法的典型用法代码示例。如果您正苦于以下问题:PHP CAgent::GetList方法的具体用法?PHP CAgent::GetList怎么用?PHP CAgent::GetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAgent
的用法示例。
在下文中一共展示了CAgent::GetList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AgentRun
public static function AgentRun($profileID, $in_agent = "N")
{
global $DB;
$agent_ID = 0;
$pr = CProfileAdmin::GetByID($profileID)->Fetch();
$datacheck = date("d.m.Y H:i:s", $pr["DATA_START"]);
$agent_period = intval($pr["PERIOD"]);
if ($agent_period <= 0) {
$agent_period = 86400;
}
if ($profileID > 0) {
if ($in_agent == "Y") {
CAgent::RemoveAgent("CGM::ReturnXMLData(" . $profileID . ");", "acrit.googlemerchant");
} else {
$arAgent = CAgent::GetList(array(), array("NAME" => "CGM::ReturnXMLData(" . $profileID . ");"))->Fetch();
if (!$arAgent) {
$agent_ID = CAgent::AddAgent("CGM::ReturnXMLData(" . $profileID . ");", "acrit.googlemerchant", "N", $agent_period, $datacheck, "Y", $datacheck, 100);
} elseif ($arAgent) {
if ($arAgent['NEXT_EXEC'] > $datacheck) {
$datacheck = $arAgent['NEXT_EXEC'];
}
CAgent::Update($arAgent['ID'], array("AGENT_INTERVAL" => $agent_period, "ACTIVE" => "Y", "NEXT_EXEC" => $datacheck));
}
}
}
return $agent_ID;
}
示例2: actualizeAgent
/**
* @param null $mailingId
* @param null $mailingChainId
* @throws \Bitrix\Main\ArgumentException
*/
public static function actualizeAgent($mailingId = null, $mailingChainId = null)
{
$agent = new \CAgent();
$isSendByTimeMethodCron = \COption::GetOptionInt("sender", "auto_method") === 'cron';
$arFilter = array();
if ($mailingId) {
$arFilter['=MAILING_ID'] = $mailingId;
}
if ($mailingChainId) {
$arFilter['=ID'] = $mailingChainId;
}
$mailingChainDb = MailingChainTable::getList(array('select' => array('ID', 'STATUS', 'AUTO_SEND_TIME', 'MAILING_ACTIVE' => 'MAILING.ACTIVE'), 'filter' => $arFilter));
while ($mailingChain = $mailingChainDb->fetch()) {
$agentName = static::getAgentName($mailingChain['ID']);
$rsAgents = $agent->GetList(array("ID" => "DESC"), array("MODULE_ID" => "sender", "NAME" => $agentName));
while ($arAgent = $rsAgents->Fetch()) {
$agent->Delete($arAgent["ID"]);
}
if ($isSendByTimeMethodCron || $mailingChain['REITERATE'] != 'Y' && empty($mailingChain['AUTO_SEND_TIME'])) {
continue;
}
if ($mailingChain['MAILING_ACTIVE'] == 'Y' && $mailingChain['STATUS'] == MailingChainTable::STATUS_SEND) {
if (!empty($mailingChain['AUTO_SEND_TIME'])) {
$dateExecute = $mailingChain['AUTO_SEND_TIME'];
} else {
$dateExecute = "";
}
$agent->AddAgent($agentName, "sender", "N", 0, null, "Y", $dateExecute);
}
}
}
示例3: checkAgentIsAlive
public static function checkAgentIsAlive($name, $interval)
{
$name = '\\' . __CLASS__ . '::' . $name . ';';
$agent = \CAgent::GetList(array(), array('MODULE_ID' => 'tasks', 'NAME' => $name))->fetch();
if (!$agent['ID']) {
\CAgent::AddAgent($name, 'tasks', 'N', $interval);
}
}
示例4: ensureAgentExists
public static function ensureAgentExists()
{
if (CTaskCountersProcessorInstaller::checkProcessIsNotActive()) {
$agent = CAgent::GetList(array(), array('MODULE_ID' => 'tasks', 'NAME' => 'CTaskCountersProcessor::agent();'))->fetch();
if (!is_array($agent) || !isset($agent['ID'])) {
CAgent::AddAgent('CTaskCountersProcessor::agent();', 'tasks', 'N', 900);
// every 15 minutes
}
}
}
示例5: deleteAgentIfExists
public function deleteAgentIfExists($moduleName, $name)
{
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$aAgent = \CAgent::GetList(array("ID" => "DESC"), array('MODULE_ID' => $moduleName, 'NAME' => $name))->Fetch();
if (!$aAgent) {
return false;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
\CAgent::RemoveAgent($name, $moduleName);
return true;
}
示例6: _addAgent
private static function _addAgent()
{
global $APPLICATION;
static $bAgentAdded = false;
if (!$bAgentAdded) {
$bAgentAdded = true;
$rsAgents = CAgent::GetList(array("ID" => "DESC"), array("NAME" => "CPHPCacheFiles::DelayedDelete(%"));
if (!$rsAgents->Fetch()) {
$res = CAgent::AddAgent("CPHPCacheFiles::DelayedDelete();", "main", "Y", 1);
if (!$res) {
$APPLICATION->ResetException();
}
}
}
}
示例7: addAgent
/**
* Adds delayed delete worker agent.
*
* @return void
*/
private static function addAgent()
{
global $APPLICATION;
static $agentAdded = false;
if (!$agentAdded) {
$agentAdded = true;
$agents = \CAgent::GetList(array("ID" => "DESC"), array("NAME" => "\\Bitrix\\Main\\Data\\CacheEngineFiles::delayedDelete(%"));
if (!$agents->Fetch()) {
$res = \CAgent::AddAgent("\\Bitrix\\Main\\Data\\CacheEngineFiles::delayedDelete();", "main", "Y", 1);
if (!$res) {
$APPLICATION->ResetException();
}
}
}
}
示例8: replaceAgent
public function replaceAgent($moduleName, $name, $interval, $nextExec)
{
/* @global $APPLICATION \CMain */
global $APPLICATION;
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$aAgent = \CAgent::GetList(array("ID" => "DESC"), array('MODULE_ID' => $moduleName, 'NAME' => $name))->Fetch();
if ($aAgent) {
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
\CAgent::RemoveAgent($name, $moduleName);
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$agentId = \CAgent::AddAgent($name, $moduleName, 'N', $interval, '', 'Y', $nextExec);
if ($agentId) {
return $agentId;
}
if ($APPLICATION->GetException()) {
$this->throwException(__METHOD__, $APPLICATION->GetException()->GetString());
} else {
$this->throwException(__METHOD__, 'Agent %s not added', $name);
}
}
示例9: AddAgent
public static function AddAgent($profileID, $setup)
{
COption::SetOptionString("main", "agents_use_crontab", "Y");
$agent_ID = 0;
$agent_period = intval($setup["PERIOD"]) * 60;
if ($agent_period <= 0) {
$agent_period = 86400;
}
$setupDateStamp = MakeTimeStamp($setup["DAT_START"]);
$currentDateStamp = time() + 120;
$runTime = date("d.m.Y H:i", $setupDateStamp < $currentDateStamp ? $currentDateStamp : $setupDateStamp);
if ($profileID > 0) {
$arAgent = CAgent::GetList(array(), array("NAME" => "CExportproAgent::StartExport(" . $profileID . ");"))->Fetch();
if (!$arAgent) {
$agent_ID = CAgent::AddAgent("CExportproAgent::StartExport(" . $profileID . ");", "acrit.exportpro", "N", $agent_period, "", "Y", $runTime);
} elseif ($arAgent) {
$agent_ID = $arAgent["ID"];
$agentNextStart = MakeTimeStamp($arAgent["NEXT_EXEC"]);
if ($agentNextStart == $setupDateStamp && $agentNextStart > $currentDateStamp) {
$runTime = date("d.m.Y H:i", $agentNextStart);
}
CAgent::Update($arAgent["ID"], array("AGENT_INTERVAL" => $agent_period != $arAgent["AGENT_INTERVAL"] ? $agent_period : $arAgent["AGENT_INTERVAL"], "NEXT_EXEC" => $runTime));
}
}
if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg")) {
$cfgFileSize = filesize($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg");
$fp = fopen($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", "rb");
$cfgData = fread($fp, $cfgFileSize);
fclose($fp);
$cfgData = preg_replace("#.*bitrix\\/modules\\/main\\/tools\\/cron_events.php(\r)*\n#i", "", $cfgData);
$cfgData = preg_replace("#.*bitrix\\/modules\\/main\\/tools\\/cron_events.php#i", "", $cfgData);
$cronTask = "* * * * * php -f {$_SERVER["DOCUMENT_ROOT"]}/bitrix/modules/main/tools/cron_events.php";
$cfgData .= PHP_EOL . $cronTask . PHP_EOL;
file_put_contents($_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg", $cfgData);
@exec("crontab " . $_SERVER["DOCUMENT_ROOT"] . "/bitrix/crontab/crontab.cfg");
}
return $agent_ID;
}
示例10: GetById
function GetById($ID)
{
return CAgent::GetList(array(), array("ID" => IntVal($ID)));
}
示例11: IntVal
}
$ID = IntVal($ID);
switch ($_REQUEST['action']) {
case "delete":
@set_time_limit(0);
$DB->StartTransaction();
if (!CPosting::Delete($ID)) {
$DB->Rollback();
$lAdmin->AddGroupError(GetMessage("post_del_err"), $ID);
}
$DB->Commit();
break;
case "stop":
$cPosting = new CPosting();
$cPosting->ChangeStatus($ID, "W");
$rsAgents = CAgent::GetList(array("ID" => "DESC"), array("MODULE_ID" => "subscribe", "NAME" => "CPosting::AutoSend(" . $ID . ",%"));
while ($arAgent = $rsAgents->Fetch()) {
CAgent::Delete($arAgent["ID"]);
}
break;
}
}
}
$lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "id", "align" => "right", "default" => true), array("id" => "TIMESTAMP_X", "content" => GetMessage("post_updated"), "sort" => "timestamp", "default" => true), array("id" => "SUBJECT", "content" => GetMessage("post_subj"), "sort" => "subject", "default" => true), array("id" => "BODY_TYPE", "content" => GetMessage("post_body_type"), "sort" => "body_type", "default" => true), array("id" => "STATUS", "content" => GetMessage("post_stat"), "sort" => "status", "default" => true), array("id" => "DATE_SENT", "content" => GetMessage("post_sent"), "sort" => "date_sent", "default" => true), array("id" => "SENT_TO", "content" => GetMessage("post_report"), "sort" => false, "default" => false), array("id" => "FROM_FIELD", "content" => GetMessage("post_from"), "sort" => "from_field", "default" => false), array("id" => "TO_FIELD", "content" => GetMessage("post_to"), "sort" => "to_field", "default" => false)));
$cData = new CPosting();
$rsData = $cData->GetList(array($by => $order), $arFilter);
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("post_nav")));
while ($arRes = $rsData->NavNext(true, "f_")) {
$row =& $lAdmin->AddRow($f_ID, $arRes);
示例12: pingAgent
/**
* Ping from the agent to inform that it still works correctly. Use this method if your agent
* works more 10 minutes, otherwise Bitrix will be consider your agent as non-working.
*
* Usage:
* ```php
* public function executeAgent($param1, $param2)
* {
* // start a heavy (big) cycle
*
* $this->pingAgent(20, ['executeAgent => [$param1, $param2]]);
*
* // end of cycle
* }
* ```
*
* @param int $interval The time in minutes after which the agent will be considered non-working.
* @param array $callChain Array with the call any methods from Agent class.
*/
protected function pingAgent($interval, array $callChain)
{
if (!$this->isAgentMode()) {
return;
}
$name = $this->getAgentName($callChain);
$model = new \CAgent();
$rsAgent = $model->GetList([], ['NAME' => $name]);
if ($agent = $rsAgent->Fetch()) {
$dateCheck = DateTime::createFromTimestamp(time() + $interval * 60);
$pingResult = $model->Update($agent['ID'], ['DATE_CHECK' => $dateCheck->toString()]);
if (!$pingResult) {
// @todo warning
}
} else {
// @todo warning
}
}
示例13: bitrix_sessid_post
?>
?lang=<?php
echo LANGUAGE_ID;
?>
&mid=<?php
echo $module_id;
?>
" name="currency_agents"><?php
echo bitrix_sessid_post();
?>
<h4><?php
echo Loc::getMessage('CURRENCY_BASE_RATE_AGENT');
?>
</h4><?php
$currencyAgent = false;
$agentIterator = CAgent::GetList(array(), array('MODULE_ID' => 'currency', '=NAME' => '\\Bitrix\\Currency\\CurrencyTable::currencyBaseRateAgent();'));
if ($agentIterator) {
$currencyAgent = $agentIterator->Fetch();
}
if (!empty($currencyAgent)) {
$currencyAgent['LAST_EXEC'] = (string) $currencyAgent['LAST_EXEC'];
$currencyAgent['NEXT_EXEC'] = (string) $currencyAgent['NEXT_EXEC'];
?>
<b><?php
echo Loc::getMessage('CURRENCY_BASE_RATE_AGENT_ACTIVE');
?>
:</b> <?php
echo $currencyAgent['ACTIVE'] == 'Y' ? Loc::getMessage('CURRENCY_AGENTS_ACTIVE_YES') : Loc::getMessage('CURRENCY_AGENTS_ACTIVE_NO');
?>
<br><?php
if ($currencyAgent['LAST_EXEC']) {
示例14: TrySendEmail
//.........这里部分代码省略.........
if ($commType !== 'EMAIL' || $commValue === '') {
continue;
}
if (!check_email($commValue)) {
$arErrors[] = array('CODE' => self::ERR_INVALID_EMAIL, 'DATA' => array('EMAIL' => $commValue));
continue;
}
$to[] = strtolower(trim($commValue));
}
unset($commDatum);
if (count($to) == 0) {
$arErrors[] = array('CODE' => self::ERR_CANT_FIND_EMAIL_TO);
}
if (!empty($arErrors)) {
return false;
}
// Try to resolve posting charset -->
$postingCharset = '';
$siteCharset = defined('LANG_CHARSET') ? LANG_CHARSET : (defined('SITE_CHARSET') ? SITE_CHARSET : 'windows-1251');
$arSupportedCharset = explode(',', COption::GetOptionString('subscribe', 'posting_charset'));
if (count($arSupportedCharset) === 0) {
$postingCharset = $siteCharset;
} else {
foreach ($arSupportedCharset as $curCharset) {
if (strcasecmp($curCharset, $siteCharset) === 0) {
$postingCharset = $curCharset;
break;
}
}
if ($postingCharset === '') {
$postingCharset = $arSupportedCharset[0];
}
}
//<-- Try to resolve posting charset
$subject = isset($arFields['SUBJECT']) ? $arFields['SUBJECT'] : '';
$description = isset($arFields['DESCRIPTION']) ? $arFields['DESCRIPTION'] : '';
$descriptionType = isset($arFields['DESCRIPTION_TYPE']) ? intval($arFields['DESCRIPTION_TYPE']) : CCrmContentType::PlainText;
$descriptionHtml = '';
if ($descriptionType === CCrmContentType::Html) {
$descriptionHtml = $description;
} elseif ($descriptionType === CCrmContentType::BBCode) {
$parser = new CTextParser();
$descriptionHtml = $parser->convertText($description);
} elseif ($descriptionType === CCrmContentType::PlainText) {
$descriptionHtml = htmlspecialcharsbx($description);
}
$postingData = array('STATUS' => 'D', 'FROM_FIELD' => $from, 'TO_FIELD' => $from, 'BCC_FIELD' => implode(',', $to), 'SUBJECT' => $subject, 'BODY_TYPE' => 'html', 'BODY' => $descriptionHtml, 'DIRECT_SEND' => 'Y', 'SUBSCR_FORMAT' => 'html', 'CHARSET' => $postingCharset);
CCrmActivity::InjectUrnInMessage($postingData, $urn, CCrmEMailCodeAllocation::GetCurrent());
$posting = new CPosting();
$postingID = $posting->Add($postingData);
if ($postingID === false) {
$arErrors[] = array('CODE' => self::ERR_CANT_ADD_POSTING, 'MESSAGE' => $posting->LAST_ERROR);
return false;
}
$arUpdateFields = array('COMPLETED' => 'Y', 'ASSOCIATED_ENTITY_ID' => $postingID, 'SETTINGS' => $settings);
$fromEmail = strtolower(trim(CCrmMailHelper::ExtractEmail($from)));
if ($crmEmail !== '' && $fromEmail !== $crmEmail) {
$arUpdateFields['SETTINGS']['MESSAGE_HEADERS'] = array('Reply-To' => "<{$fromEmail}>, <{$crmEmail}>");
}
$arUpdateFields['SETTINGS']['IS_MESSAGE_SENT'] = true;
if (!CCrmActivity::Update($ID, $arUpdateFields, false, false)) {
$arErrors[] = array('CODE' => self::ERR_CANT_UPDATE_ACTIVITY);
return false;
}
// <-- Creating Email
// Attaching files -->
$storageTypeID = isset($arFields['STORAGE_TYPE_ID']) ? intval($arFields['STORAGE_TYPE_ID']) : StorageType::Undefined;
$storageElementsID = isset($arFields['STORAGE_ELEMENT_IDS']) && is_array($arFields['STORAGE_ELEMENT_IDS']) ? $arFields['STORAGE_ELEMENT_IDS'] : array();
$arRawFiles = StorageManager::makeFileArray($storageElementsID, $storageTypeID);
foreach ($arRawFiles as &$arRawFile) {
if (!$posting->SaveFile($postingID, $arRawFile)) {
$arErrors[] = array('CODE' => self::ERR_CANT_SAVE_POSTING_FILE, 'MESSAGE' => $posting->LAST_ERROR);
return false;
}
}
unset($arRawFile);
// <-- Attaching files
// Sending Email -->
if ($posting->ChangeStatus($postingID, 'P')) {
$rsAgents = CAgent::GetList(array('ID' => 'DESC'), array('MODULE_ID' => 'subscribe', 'NAME' => 'CPosting::AutoSend(' . $postingID . ',%'));
if (!$rsAgents->Fetch()) {
CAgent::AddAgent('CPosting::AutoSend(' . $postingID . ',true);', 'subscribe', 'N', 0);
}
}
// Try add event to entity
$CCrmEvent = new CCrmEvent();
$ownerID = isset($arFields['OWNER_ID']) ? intval($arFields['OWNER_ID']) : 0;
$ownerTypeID = isset($arFields['OWNER_TYPE_ID']) ? intval($arFields['OWNER_TYPE_ID']) : 0;
if ($ownerID > 0 && $ownerTypeID > 0) {
$eventText = '';
$eventText .= GetMessage('CRM_ACTIVITY_EMAIL_SUBJECT') . ': ' . $subject . "\n\r";
$eventText .= GetMessage('CRM_ACTIVITY_EMAIL_FROM') . ': ' . $from . "\n\r";
$eventText .= GetMessage('CRM_ACTIVITY_EMAIL_TO') . ': ' . implode(',', $to) . "\n\r\n\r";
$eventText .= $description;
// Register event only for owner
$CCrmEvent->Add(array('ENTITY' => array($ownerID => array('ENTITY_TYPE' => CCrmOwnerType::ResolveName($ownerTypeID), 'ENTITY_ID' => $ownerID)), 'EVENT_ID' => 'MESSAGE', 'EVENT_TEXT_1' => $eventText, 'FILES' => $arRawFiles));
}
// <-- Sending Email
return true;
}
示例15: foreach
foreach ($amount_val as $key => $val) {
if (DoubleVal($val) > 0) {
$arAmountSer[$key] = array("AMOUNT" => DoubleVal($val), "CURRENCY" => $amount_currency[$key]);
}
}
if (!empty($arAmountSer)) {
COption::SetOptionString("sale", "pay_amount", serialize($arAmountSer));
}
CAgent::RemoveAgent("CSaleOrder::RemindPayment();", "sale");
COption::RemoveOption("sale", "pay_reminder");
if (isset($_POST["reminder"]) && is_array($_POST["reminder"]) && !empty($_POST["reminder"])) {
COption::SetOptionString("sale", "pay_reminder", serialize($_POST["reminder"]));
CAgent::AddAgent("CSaleOrder::RemindPayment();", "sale", "N", 86400, "", "Y");
}
//subscribe product
$rsAgents = CAgent::GetList(array("ID" => "DESC"), array("MODULE_ID" => "sale", "NAME" => "CSaleBasket::ClearProductSubscribe(%"));
while ($arAgent = $rsAgents->Fetch()) {
CAgent::Delete($arAgent["ID"]);
}
if (!empty($subscribProd)) {
foreach ($siteList as $vv) {
$lid = $vv["ID"];
$val = $subscribProd[$lid];
if ($val["use"] == "Y") {
if (IntVal($val["del_after"]) <= 0) {
$subscribProd[$lid]["del_after"] = 30;
}
CAgent::AddAgent("CSaleBasket::ClearProductSubscribe('" . EscapePHPString($lid) . "');", "sale", "N", IntVal($subscribProd[$lid]["del_after"]) * 24 * 60 * 60, "", "Y");
}
}
COption::SetOptionString("sale", "subscribe_prod", serialize($subscribProd));