public function readTasks() { if ($handle = opendir(__DIR__ . '/Task/')) { require_once __DIR__ . '/Task/BaseTask.php'; $util = new BaseTask(); $util->consoleLog('Learning Phalcon CLI', 'grey'); $util->consoleLog(str_repeat('-', 80), 'grey'); while (false !== ($entry = readdir($handle))) { if ($entry != '.' && $entry != '..' && $entry != 'BaseTask.php' && preg_match("/\\.php\$/", $entry)) { $entries[] = $entry; } } asort($entries); $charCountActionName = 0; foreach ($entries as $entry) { $task = str_replace('Task.php', '', $entry); require_once __DIR__ . '/Task/' . $entry; $tmp_className = str_replace('.php', '', $entry); $tmp = new $tmp_className(); $taskName = PHP_EOL . strtolower(preg_replace('/\\B([A-Z])/', '_$1', $task)); $taskDescription = ''; $util->consoleLog(str_pad($taskName, 25) . $taskDescription, 'yellow'); $st_classMethods = get_class_methods($tmp); asort($st_classMethods); foreach ($st_classMethods as $value) { if (preg_match('/Action/', $value)) { $theActionName = str_pad(str_replace('Action', '', $value), 6); if (strlen($theActionName) > $charCountActionName) { $charCountActionName = strlen($theActionName); } } } foreach ($st_classMethods as $value) { if (preg_match('/Action/', $value)) { $theActionName = str_replace('Action', '', $value); $theActionDescription = ''; $annotations = Extractor::getMethodAnnotations($tmp_className, $value); if (count($annotations) > 0) { foreach ($annotations as $key => $st_values) { if ($key == 'Description') { $theActionDescription .= implode(', ', $st_values); } } } $util->consoleLog(str_pad($theActionName, $charCountActionName + 5) . "[0;28m" . $theActionDescription, 'green'); } } } closedir($handle); } }
public function init() { parent::init(); $this->helper = new \WikiGetDataForVisualizationHelper(); $this->model = new \CityVisualization(); $this->corporatePageIds = $this->model->getVisualizationWikisIds(); }
protected function batchEnqueue(array $tasks) { if (!empty($tasks)) { $this->info('BatchRefreshLinksForTemplate::batchEnqueue', ['tasks' => count($tasks), 'title' => $this->title->getText(), 'start' => $this->getStart(), 'end' => $this->getEnd()]); BaseTask::batch($tasks); } }
private function handleByTaskStatus($next_time) { switch ($this->status) { case 0: // 不执行 $diff = $next_time != $this->runTime; $absTime = $this->runTime - time(); if ($diff && $absTime > 5) { BaseTask::addIgnoreButUpdateTime($this->redis_key, $next_time); } break; case 1: // 新任务 BaseTask::addNewTask($this->redis_key, $next_time); break; case 2: // 执行中 break; case 3: // 本次即将执行 BaseTask::addHandleTaskTime($this->redis_key, $next_time); break; default: break; } }
public function callOnLoad(array $curlResult) { $result = \curl_getinfo($curlResult['handle']); $content = \curl_multi_getcontent($curlResult['handle']); $result['response_header'] = \substr($content, 0, $result['header_size']); $result['response_content'] = \substr($content, $result['header_size']); parent::callOnLoad($result); }
public function addTask($type, $name, $params, $queue = null) { if ($queue) { $this->queues->validateQueueId($queue); } else { $queue = rand(1, TaskQueue::LIMIT); } try { $task = new BaseTask($type, $name, $params, $queue); $task->save(); //Guardo en BD //if(!$this->queues[self::STANDARD][$queue]) $this->queues[self::STANDARD][$queue] = new TaskQueue(); //$this->queues[self::STANDARD][$queue]->addTask($task);//Guardo en Memoria } catch (Exception $e) { $this->logger->logToFile("tasks/logs/taks_manager.log", "[SUCCESS] The task {$name} was added succesfully."); return -1; } }
public function init() { parent::init(); ini_set('memory_limit', '768M'); // there is probably a much faster way to do this, using a manual query. all we really need is ids and titles. $criteria = craft()->elements->getCriteria(ElementType::Entry); $criteria->limit = 1000; $this->entries = $criteria->find(); }
public function call() { global $wgCityId; switch (func_num_args()) { case 2: // command, title, no params list($command, $title) = func_get_args(); break; case 3: // command, title, params list($command, $title, $this->params) = func_get_args(); break; default: throw new \InvalidArgumentException(); } $this->wikiId($wgCityId); // jobs always run in the context of the wiki in which they're called $this->title($title); return parent::call('wrap', $command); }
/** * @return array black list of method names to hide on Special:Tasks */ public function getAdminNonExecuteables() { $blacklist = parent::getAdminNonExecuteables(); $blacklist[] = 'purge'; return $blacklist; }
/** * Returns a peer instance associated with this om. * * Since Peer classes are not to have any instance attributes, this method returns the * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * * @return TaskPeer */ public function getPeer() { if (self::$peer === null) { self::$peer = new TaskPeer(); } return self::$peer; }
public function save(Doctrine_Connection $conn = null) { if ($this->isNew()) { if ($this->getCurrentEstimate() == 0) { $this->setCurrentEstimate($this->getOriginalEstimate()); } } $this->updateStatus(); return parent::save($conn); }
/** * Check if an entry has been translated * @param string $key * @param string $value * @return boolean */ protected function isTranslated($key, $value) { if (is_null(self::$exceptions)) { self::$exceptions = file(dirname(__FILE__) . DS . 'exceptions.txt', FILE_IGNORE_NEW_LINES); } return in_array(trim($key), self::$exceptions) || $key != $value; }
public function ajaxGenerateContactDoctorCsvFile($request, $response) { /*{{{*/ $taskStr = urldecode($request->getPost('taskstr')); $taskList = json_decode($taskStr, true); $firstLine = array('省', '市', '地区', '医院', '科室', '医生', '性别', '职称', '门诊时间', '擅长', '开通网站', '开通时间', '开通服务', '最后上线时间', '文章数'); $lines = array(); $lines[] = $firstLine; foreach ($taskList as $item) { $line = array(); $line['province'] = XString::convertToGbk($item['province']); $line['city'] = XString::convertToGbk($item['city']); $line['district'] = XString::convertToGbk($item['district']); $line['hospitalName'] = XString::convertToGbk($item['hospitalName']); $line['hospitalFacultyName'] = XString::convertToGbk($item['hospitalFacultyName']); $line['doctorName'] = XString::convertToGbk($item['doctorName']); $line['sex'] = XString::convertToGbk($item['sex']); $line['grade'] = XString::convertToGbk($item['grade']); $line['schedule'] = XString::convertToGbk($item['schedule']); $taskId = $item['taskId']; $task = BaseTask::find($taskId); $line['specialize'] = $this->filterSpecialChars($task->source->specialize); $line['spaceOpen'] = XString::convertToGbk($item['spaceOpen']); $line['spaceCtime'] = XString::convertToGbk($item['spaceCtime']); $line['service'] = XString::convertToGbk($item['service']); $line['lastOnline'] = XString::convertToGbk($item['lastOnline']); $line['articleCount'] = XString::convertToGbk($item['articleCount']); $lines[] = $line; } $fileName = $this->generateCsvFile(count($firstLine), $lines); echo json_encode(array('success' => 1, 'msg' => $fileName)); return parent::DIRECT_OUTPUT; }
/** * Initializes internal state of Task object. * @see parent::__construct() */ public function __construct() { // Make sure that parent constructor is always invoked, since that // is where any default values for this object are set. parent::__construct(); }
public function getStatus() { $now = new sfDate(); $dt = new sfDate($this->getFinish()); if (parent::getStatus() == sfConfig::get('app_task_status_open') && $this->getFinish() < date('Y-m-d H:i:s')) { return sfConfig::get('app_task_status_overdue'); } if (parent::getStatus() == sfConfig::get('app_task_status_open') && ($now <= $dt && $now->addDay(sfConfig::get('app_task_status_upcoming_days')) >= $dt)) { return sfConfig::get('app_task_status_upcoming'); } if (parent::getStatus() == sfConfig::get('app_task_status_open')) { return sfConfig::get('app_task_status_open'); } if (parent::getStatus() == sfConfig::get('app_task_status_completed')) { return sfConfig::get('app_task_status_completed'); } return sfConfig::get('app_task_status_unknown'); }