本文整理汇总了PHP中CAgent类的典型用法代码示例。如果您正苦于以下问题:PHP CAgent类的具体用法?PHP CAgent怎么用?PHP CAgent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAgent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@set_time_limit(0);
@ignore_user_abort(true);
define('CHK_EVENT', true);
$agentManager = new \CAgent();
$agentManager->CheckAgents();
define('BX_CRONTAB_SUPPORT', true);
define('BX_CRONTAB', true);
$eventManager = new \CEvent();
$eventManager->CheckEvents();
}
示例3: InstallDB
function InstallDB()
{
global $DB, $APPLICATION;
$this->errors = false;
if(!$DB->Query("SELECT 'x' FROM b_pull_stack", true))
$this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/pull/install/db/".strtolower($DB->type)."/install.sql");
if($this->errors !== false)
{
$APPLICATION->ThrowException(implode("", $this->errors));
return false;
}
RegisterModule("pull");
RegisterModuleDependences("main", "OnProlog", "main", "", "", 3, "/modules/pull/ajax_hit.php");
RegisterModuleDependences("perfmon", "OnGetTableSchema", "pull", "CPullTableSchema", "OnGetTableSchema");
RegisterModuleDependences("main", "OnAfterRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
RegisterModuleDependences("main", "OnAfterUnRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
COption::SetOptionString("pull", "path_to_listener", (CMain::IsHTTPS() ? "https" : "http")."://#DOMAIN#".(CMain::IsHTTPS() ? ":8894" : ":8893").'/bitrix/sub/');
COption::SetOptionString("pull", "path_to_websocket", (CMain::IsHTTPS() ? "wss" : "ws")."://#DOMAIN#".(CMain::IsHTTPS() ? ":8894" : ":8893").'/bitrix/subws/');
COption::SetOptionString("pull", "path_to_publish", 'http://127.0.0.1:8895/bitrix/pub/');
COption::SetOptionString("pull", "websocket", 'N');
COption::SetOptionString("pull", "nginx", 'N');
COption::SetOptionString("pull", "push", 'N');
CAgent::AddAgent("CPullOptions::ClearAgent();", "pull", "N", 30, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+30, "FULL"));
return true;
}
示例4: InstallDB
function InstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
// Database tables creation
$bDBInstall = !$DB->Query("SELECT 'x' FROM b_workflow_document WHERE 1=0", true);
if ($bDBInstall) {
$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/workflow/install/db/" . $DBType . "/install.sql");
}
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("<br>", $this->errors));
return false;
} else {
RegisterModule("workflow");
CModule::IncludeModule("workflow");
if ($bDBInstall) {
$obWorkflowStatus = new CWorkflowStatus();
$obWorkflowStatus->Add(array("~TIMESTAMP_X" => $DB->GetNowFunction(), "C_SORT" => 300, "ACTIVE" => "Y", "TITLE" => GetMessage("FLOW_INSTALL_PUBLISHED"), "IS_FINAL" => "Y", "NOTIFY" => "N"));
$obWorkflowStatus->Add(array("~TIMESTAMP_X" => $DB->GetNowFunction(), "C_SORT" => 100, "ACTIVE" => "Y", "TITLE" => GetMessage("FLOW_INSTALL_DRAFT"), "IS_FINAL" => "N", "NOTIFY" => "N"));
$obWorkflowStatus->Add(array("~TIMESTAMP_X" => $DB->GetNowFunction(), "C_SORT" => 200, "ACTIVE" => "Y", "TITLE" => GetMessage("FLOW_INSTALL_READY"), "IS_FINAL" => "N", "NOTIFY" => "Y"));
}
RegisterModuleDependences("main", "OnPanelCreate", "workflow", "CWorkflow", "OnPanelCreate", "200");
RegisterModuleDependences("main", "OnChangeFile", "workflow", "CWorkflow", "OnChangeFile");
//agents
CAgent::RemoveAgent("CWorkflow::CleanUp();", "workflow");
CAgent::AddAgent("CWorkflow::CleanUp();", "workflow", "N");
return true;
}
}
示例5: UnInstallDB
function UnInstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
if (!array_key_exists("save_tables", $arParams) || $arParams["save_tables"] != "Y") {
$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sender/install/db/" . $DBType . "/uninstall.sql");
}
CAgent::RemoveModuleAgents('sender');
UnRegisterModuleDependences("main", "OnMailEventMailRead", "sender", "bitrix\\sender\\postingmanager", "onMailEventMailRead");
UnRegisterModuleDependences("main", "OnMailEventMailClick", "sender", "bitrix\\sender\\postingmanager", "onMailEventMailClick");
UnRegisterModuleDependences("main", "OnMailEventSubscriptionDisable", "sender", "Bitrix\\Sender\\Subscription", "onMailEventSubscriptionDisable");
UnRegisterModuleDependences("main", "OnMailEventSubscriptionEnable", "sender", "Bitrix\\Sender\\Subscription", "onMailEventSubscriptionEnable");
UnRegisterModuleDependences("main", "OnMailEventSubscriptionList", "sender", "Bitrix\\Sender\\Subscription", "onMailEventSubscriptionList");
UnRegisterModuleDependences("sender", "OnConnectorList", "sender", "bitrix\\sender\\connectormanager", "onConnectorListContact");
UnRegisterModuleDependences("sender", "OnConnectorList", "sender", "bitrix\\sender\\connectormanager", "onConnectorListRecipient");
UnRegisterModuleDependences("sender", "OnPresetTemplateList", "sender", "Bitrix\\Sender\\Preset\\TemplateBase", "onPresetTemplateList");
UnRegisterModuleDependences("sender", "OnPresetTemplateList", "sender", "Bitrix\\Sender\\TemplateTable", "onPresetTemplateList");
UnRegisterModuleDependences("sender", "OnPresetMailBlockList", "sender", "Bitrix\\Sender\\Preset\\MailBlockBase", "OnPresetMailBlockList");
UnRegisterModule("sender");
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("<br>", $this->errors));
return false;
}
return true;
}
示例6: InstallDB
function InstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
// Database tables creation
if (!$DB->Query("SELECT 'x' FROM b_list_rubric WHERE 1=0", true)) {
$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/subscribe/install/db/" . $DBType . "/install.sql");
}
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("<br>", $this->errors));
return false;
} else {
RegisterModule("subscribe");
CModule::IncludeModule("subscribe");
RegisterModuleDependences("main", "OnBeforeLangDelete", "subscribe", "CRubric", "OnBeforeLangDelete");
RegisterModuleDependences("main", "OnUserDelete", "subscribe", "CSubscription", "OnUserDelete");
RegisterModuleDependences("main", "OnUserLogout", "subscribe", "CSubscription", "OnUserLogout");
RegisterModuleDependences("main", "OnGroupDelete", "subscribe", "CPosting", "OnGroupDelete");
//agents
CAgent::RemoveAgent("CSubscription::CleanUp();", "subscribe");
CTimeZone::Disable();
CAgent::Add(array("NAME" => "CSubscription::CleanUp();", "MODULE_ID" => "subscribe", "ACTIVE" => "Y", "NEXT_EXEC" => date("d.m.Y H:i:s", mktime(3, 0, 0, date("m"), date("j") + 1, date("Y"))), "AGENT_INTERVAL" => 86400, "IS_PERIOD" => "Y"));
CTimeZone::Enable();
return true;
}
}
示例7: 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;
}
示例8: UnInstallDB
function UnInstallDB($arParams = array())
{
global $APPLICATION, $DB, $DOCUMENT_ROOT;
if(!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y")
{
$errors = $DB->RunSQLBatch($DOCUMENT_ROOT."/bitrix/modules/socialservices/install/db/".strtolower($DB->type)."/uninstall.sql");
if (!empty($errors))
{
$APPLICATION->ThrowException(implode("", $errors));
return false;
}
}
UnRegisterModuleDependences("main", "OnUserDelete", "socialservices", "CSocServAuthDB", "OnUserDelete");
UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetLogEvents', 'socialservices', 'CSocServEventHandlers', 'OnFillSocNetLogEvents');
UnRegisterModuleDependences('timeman', 'OnAfterTMReportDailyAdd', 'socialservices', 'CSocServAuthDB', 'OnAfterTMReportDailyAdd');
UnRegisterModuleDependences('timeman', 'OnAfterTMDayStart', 'socialservices', 'CSocServAuthDB', 'OnAfterTMDayStart');
UnRegisterModuleDependences('timeman', 'OnTimeManShow', 'socialservices', 'CSocServEventHandlers', 'OnTimeManShow');
$dbSites = CSite::GetList(($b="sort"), ($o="asc"), array("ACTIVE" => "Y"));
while ($arSite = $dbSites->Fetch())
{
$siteId = $arSite['ID'];
CAgent::RemoveAgent("CSocServAuthManager::GetTwitMessages($siteId);", "socialservices");
}
UnRegisterModule("socialservices");
return true;
}
示例9: CheckExpireAgent
public static function CheckExpireAgent()
{
global $DB;
if (!CPullOptions::ModuleEnable())
return false;
CAgent::RemoveAgent("CPullWatch::CheckExpireAgent();", "pull");
$strSql = "SELECT count(ID) CNT FROM b_pull_watch WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 30 MINUTE)";
$dbRes = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes = $dbRes->Fetch())
{
$strSql = "DELETE FROM b_pull_watch WHERE DATE_CREATE < DATE_SUB(NOW(), INTERVAL 30 MINUTE) LIMIT 1000";
$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
if ($arRes['CNT'] > 1000)
{
CAgent::AddAgent("CPullWatch::CheckExpireAgent();", "pull", "N", 180, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+180, "FULL"));
return false;
}
}
CAgent::AddAgent("CPullWatch::CheckExpireAgent();", "pull", "N", 600, "", "Y", ConvertTimeStamp(time()+CTimeZone::GetOffset()+600, "FULL"));
return false;
}
示例10: InstallDB
function InstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
// Database tables creation
if (!$DB->Query("SELECT 'x' FROM b_sec_iprule WHERE 1=0", true)) {
$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/security/install/db/" . strtolower($DB->type) . "/install.sql");
}
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("<br>", $this->errors));
return false;
} else {
$this->InstallTasks();
RegisterModule("security");
RegisterModuleDependences("main", "OnUserDelete", "security", "CSecurityUser", "OnUserDelete");
RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "security", "CSecurityFilter", "GetAuditTypes");
RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "security", "CSecurityAntiVirus", "GetAuditTypes");
RegisterModuleDependences("main", "OnAdminInformerInsertItems", "security", "CSecurityFilter", "OnAdminInformerInsertItems");
RegisterModuleDependences("main", "OnAdminInformerInsertItems", "security", "CSecuritySiteChecker", "OnAdminInformerInsertItems");
CModule::IncludeModule("security");
//agents
CAgent::RemoveAgent("CSecuritySession::CleanUpAgent();", "security");
CAgent::Add(array("NAME" => "CSecuritySession::CleanUpAgent();", "MODULE_ID" => "security", "ACTIVE" => "Y", "AGENT_INTERVAL" => 1800, "IS_PERIOD" => "N"));
CAgent::RemoveAgent("CSecurityIPRule::CleanUpAgent();", "security");
CAgent::Add(array("NAME" => "CSecurityIPRule::CleanUpAgent();", "MODULE_ID" => "security", "ACTIVE" => "Y", "AGENT_INTERVAL" => 3600, "IS_PERIOD" => "N"));
if (!COption::GetOptionString("security", "ipcheck_disable_file")) {
COption::SetOptionString("security", "ipcheck_disable_file", "/bitrix/modules/ipcheck_disable_" . md5(mt_rand()));
}
CAgent::RemoveAgent("CSecurityFilter::ClearTmpFiles();", "security");
CSecurityFilter::SetActive(true);
CSecurityAntiVirus::SetActive(true);
return true;
}
}
示例11: InstallDB
function InstallDB()
{
global $DB, $APPLICATION;
$this->errors = false;
if (!$DB->Query("SELECT 'x' FROM b_pull_stack", true)) {
$this->errors = $DB->RunSQLBatch($_SERVER['DOCUMENT_ROOT'] . "/bitrix/modules/pull/install/db/" . strtolower($DB->type) . "/install.sql");
}
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("", $this->errors));
return false;
}
RegisterModule("pull");
RegisterModuleDependences("main", "OnProlog", "main", "", "", 3, "/modules/pull/ajax_hit.php");
RegisterModuleDependences("main", "OnEpilog", "pull", "CPullWatch", "DeferredSql");
RegisterModuleDependences("main", "OnEpilog", "pull", "CPullOptions", "OnEpilog");
RegisterModuleDependences("perfmon", "OnGetTableSchema", "pull", "CPullTableSchema", "OnGetTableSchema");
RegisterModuleDependences("main", "OnAfterRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
RegisterModuleDependences("main", "OnAfterUnRegisterModule", "pull", "CPullOptions", "ClearCheckCache");
if (IsModuleInstalled('intranet')) {
RegisterModuleDependences("main", "OnAfterUserAuthorize", "pull", "CPullChannel", "OnAfterUserAuthorize");
RegisterModuleDependences("main", "OnAfterUserLogout", "pull", "CPullChannel", "OnAfterUserLogout");
}
CAgent::AddAgent("CPullOptions::ClearAgent();", "pull", "N", 30, "", "Y", ConvertTimeStamp(time() + CTimeZone::GetOffset() + 30, "FULL"));
return true;
}
示例12: CheckAgents
function CheckAgents()
{
global $CACHE_MANAGER;
//For a while agents will execute only on primary cluster group
if (defined("NO_AGENT_CHECK") && NO_AGENT_CHECK === true || defined("BX_CLUSTER_GROUP") && BX_CLUSTER_GROUP !== 1) {
return;
}
$agents_use_crontab = COption::GetOptionString("main", "agents_use_crontab", "N");
$str_crontab = "";
if ($agents_use_crontab == "Y" || defined("BX_CRONTAB_SUPPORT") && BX_CRONTAB_SUPPORT === true) {
if (defined("BX_CRONTAB") && BX_CRONTAB === true) {
$str_crontab = " AND IS_PERIOD='N' ";
} else {
$str_crontab = " AND IS_PERIOD='Y' ";
}
}
$saved_time = 0;
if (CACHED_b_agent !== false && $CACHE_MANAGER->Read(CACHED_b_agent, $cache_id = "agents" . $str_crontab, "agents")) {
$saved_time = $CACHE_MANAGER->Get($cache_id);
if (time() < $saved_time) {
return "";
}
}
return CAgent::ExecuteAgents($str_crontab);
}
示例13: UnInstallDB
function UnInstallDB($arParams = array())
{
global $DB, $DBType, $APPLICATION;
$this->errors = false;
if (!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") {
$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/install/db/" . strtolower($DB->type) . "/uninstall.sql");
}
//delete agents
CAgent::RemoveModuleAgents("vote");
$db_res = $DB->Query("SELECT ID FROM b_file WHERE MODULE_ID = 'vote'");
while ($arRes = $db_res->Fetch()) {
CFile::Delete($arRes["ID"]);
}
// Events
include $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/install/events/del_events.php";
UnRegisterModuleDependences("im", "OnGetNotifySchema", "vote", "CVoteNotifySchema", "OnGetNotifySchema");
UnRegisterModuleDependences("main", "OnUserLogin", "vote", "CVoteUser", "OnUserLogin", 200);
UnRegisterModuleDependences("main", "OnUserTypeBuildList", "vote", "CUserTypeVote", "GetUserTypeDescription", 200);
UnRegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", "/modules/vote/keepvoting.php");
UnRegisterModule("vote");
if ($this->errors !== false) {
$APPLICATION->ThrowException(implode("<br>", $this->errors));
return false;
}
return true;
}
示例14: UnInstallDB
function UnInstallDB($arParams = array())
{
UnRegisterModuleDependences("main", "OnPrologAdminTitle", "storeassist", "CStoreAssist", "onPrologAdminTitle");
UnRegisterModuleDependences('main', 'OnBuildGlobalMenu', "storeassist", "CStoreAssist", "onBuildGlobalMenu");
CAgent::RemoveModuleAgents("storeassist");
UnRegisterModule("storeassist");
return true;
}
示例15: 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);
}
}