public function add(Task $task) { if (!$this->hasUniqueTaskName($task->name())) { throw new Exception(sprintf('Task name (%s) is not unique!', $task->name())); } $this->tasks[] = $task; }
protected function realLog($level, $message, array $context = []) { $message = self::interpolateContext($message, $context); switch ($level) { case self::DEBUG: $level = \Project::MSG_DEBUG; break; case self::INFO: $level = \Project::MSG_VERBOSE; break; case self::NOTICE: $level = \Project::MSG_VERBOSE; break; case self::WARNING: $level = \Project::MSG_WARN; break; case self::ERROR: case self::CRITICAL: case self::ALERT: case self::EMERGENCY: $level = \Project::MSG_ERR; break; default: $level = \Project::MSG_INFO; } $this->task->log($message, $level); return NULL; }
public function testIsRunning() { $task = new Task(['exec' => 'sleep 1']); $this->assertFalse($task->isRunning()); $task->run(); $this->assertTrue($task->isRunning()); }
public function process(Task $task = null) { if (empty($task)) { $task = new Task($this->path, $this->filename, $this->extension, $this->config['public_path']); } // Can we read the original file and write in the original path? if (!$task->isValid()) { return $this->halt(); } // Can we operate in this path? if (!preg_match($this->config['path_mask'], trim(str_replace($this->config['public_path'], '', $task->origPath), DIRECTORY_SEPARATOR))) { return $this->halt(); } // Is a valid task name and can we call the action? $callable = $this->getActionCallable($task->name); if ($callable === false) { return $this->halt(); } else { $task->image = \WideImage\WideImage::load($task->origFile); // Create destination path if (!file_exists($task->destPath) and !is_dir($task->destPath)) { @mkdir($task->destPath, 0775, true); } if (call_user_func($callable, $task) !== false) { // If the action does not return false explicitly... $this->reload(); // SUCCESS exit point: reload the image URL } } $this->halt(); }
public function run() { $this->db->query("UPDATE " . DB_PREFIX . "customer c \r\n SET congrats = 1 \r\n WHERE DAY(birthday) <> '" . $this->db->escape(date('d')) . "' \r\n AND MONTH(birthday) <> '" . $this->db->escape(date('m')) . "'"); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer c \r\n WHERE DAY(birthday) = '" . $this->db->escape(date('d')) . "' \r\n AND MONTH(birthday) = '" . $this->db->escape(date('m')) . "'\r\n AND congrats = 1"); if ($query->num_rows && (int) $this->config->get('marketing_email_happy_birthday')) { $params = array('job' => 'send_birthday', 'newsletter_id' => (int) $this->config->get('marketing_email_happy_birthday')); $this->load->library('task'); $task = new Task($this->registry); $task->object_id = (int) $this->config->get('marketing_email_happy_birthday'); $task->object_type = 'newsletter'; $task->task = 'happy_birthday'; $task->type = 'send'; $task->time_exec = date('Y-m-d') . ' 08:00:00'; $task->params = $params; $task->time_interval = ""; $task->time_last_exec = ""; $task->run_once = true; $task->status = 1; $task->date_start_exec = date('Y-m-d') . ' 08:00:00'; $task->date_end_exec = date('Y-m-d') . ' 23:00:00'; foreach ($query->rows as $customer) { $params = array('customer_id' => $customer['customer_id'], 'fullname' => $customer['firstname'] . " " . $customer['lastname'], 'company' => $customer['company'], 'rif' => $customer['rif'], 'telephone' => $customer['telephone'], 'email' => $customer['email']); $queue = array("params" => $params, "status" => 1, "time_exec" => date('Y-m-d') . ' 08:00:00'); $task->addQueue($queue); $this->db->query("UPDATE " . DB_PREFIX . "customer c SET congrats = 0 WHERE customer_id = '" . (int) $customer['customer_id'] . "'"); } $task->createSendTask(); } }
/** * Constructs the entity * * @access public * @param \Zepi\Core\Utils\Entity\Task $task * @param integer $pid */ public function __construct(Task $task, $pid) { $this->task = $task; $this->pid = $pid; $this->startTime = time(); $this->restartTime = time() + $task->getResetTime() + rand(1, 5); }
function get($criteria = null, $order = null) { $sql = "SELECT tasks.*, CONCAT(users.first_name, ' ', users.last_name) AS assigned_to_name\n FROM tasks\n LEFT JOIN users ON users.id = tasks.assigned_to"; if (isset($criteria) && is_numeric($criteria)) { $sql .= " WHERE tasks.id = {$criteria}"; $task = parent::get_one($sql); $this->update_status(); return $task; } else { $sql = $this->add_criteria($sql, $criteria); $sql = $this->modify_sql_for_user_type($sql); $sql = $this->add_order_by($sql, $order); $tasks = parent::get($sql); foreach ($tasks as &$task) { //create the invoice $task_object = new Task($task); //todo: i don't think this makes any sense because the invoice status will already be updated when I create the invoice using new Invoice //store the current task status as it exists in the database $old_status = $task_object->status_text; //update the task status $task_object->update_status(); //if the old status and the new status do not match, then we need to save this task back to the database. if ($old_status != (string) $task_object->status_text) { //todo:make sure this isn't saving each time $task_object->save(false); } //we need to add the status text back the task array, since we're sending the array to the client, //not the object $task['status_text'] = $task_object->status_text; } return $tasks; } }
function view($id = null) { if (is_null($id)) { echo "error: no id supplied"; return false; } $this->load->library('bitly'); $this->form_validation->set_rules('name', 'Task Name', 'required|trim'); $data = array(); $docket = new Docket(); $task = new Task(); $user = new User(); if (!$docket->where('shared', 1)->where('id', $id)->count()) { redirect('dockets'); } else { $data['docket'] = $docket->get_by_id($id); } if ($docket->short_url == '') { $docket->short_url = $this->bitly->shorten(base_url() . 'index.php/pub/view/' . $docket->id); $docket->save(); } if ($task->where('completed', 0)->where_related_docket('id', $docket->id)->count() == 0) { $data['pending_tasks'] = array(); } else { $data['pending_tasks'] = $task->where('completed', 0)->where_related_docket('id', $docket->id)->get()->all; } if ($task->where('completed', 1)->where_related_docket('id', $docket->id)->count() == 0) { $data['completed_tasks'] = array(); } else { $data['completed_tasks'] = $task->where('completed', 1)->where_related_docket('id', $docket->id)->get()->all; } $data['user'] = $user->get_by_id($docket->user_id); $this->load->view('pub/view', $data); }
public function find($id) { $events = $this->eventStore->find($id); $task = new Task(); $task->replay($events); return $task; }
public function load($clusterName) { $result = $this->awsClient->listTasks(['cluster' => $clusterName, 'serviceName' => $this->serviceName, 'maxResults' => 99, 'nextToken' => '']); //get existing tasks foreach ($result['taskArns'] as $taskArn) { $task = new Task(); $task->setArn($taskArn); if (!$task->init($this->creds)) { return false; } if (!$task->load($clusterName)) { return false; } $this->tasks[$taskArn] = $task; } //get task def $details = $this->awsClient->describeServices(['cluster' => $clusterName, 'services' => [$this->serviceName]]); $this->taskDefinition = $details['services'][0]['taskDefinition']; $this->taskDef = new TaskDef(); $this->taskDef->init($this->creds); $this->taskDef->load($this->taskDefinition); //other service items $this->status = $details['services'][0]['status']; $this->minHealthyPercent = $details['services'][0]['deploymentConfiguration']['minimumHealthyPercent']; $this->maxPercent = $details['services'][0]['deploymentConfiguration']['maximumPercent']; $this->desiredTaskCount = $details['services'][0]['desiredCount']; $this->pendingTaskCount = $details['services'][0]['pendingCount']; $this->runningTaskCount = $details['services'][0]['runningCount']; return true; }
function delete() { $delete_result = parent::delete(); $task = new Task($this->task_id); $task->update_total_time(); return $delete_result; }
function createtask_POST(Web &$w) { $w->Task->navigation($w, "Create Task"); // unserialise input from step I and store in array: arr_req $arr_req = unserialize($w->request('formone')); // set relevant dt variables with: Today. $arr_req['dt_assigned'] = Date('c'); $arr_req['dt_first_assigned'] = Date('c'); // insert Task into database $task = new Task($w); $task->fill($arr_req); $task->insert(); // if insert is successful, store additional fields as task data // we do not want to store data from step I, the task_id (as a key=>value pair) nor the FLOW_SID if ($task->id) { foreach ($_POST as $name => $value) { if ($name != "formone" && $name != "FLOW_SID" && $name != "task_id" && $name !== CSRF::getTokenID()) { $tdata = new TaskData($w); $arr = array("task_id" => $task->id, "key" => $name, "value" => $value); $tdata->fill($arr); $tdata->insert(); unset($arr); } } // return to task dashboard $w->msg("Task " . $task->title . " added", "/task/viewtask/" . $task->id); } else { // if task insert was unsuccessful, say as much $w->msg("The Task could not be created. Please inform the IT Group", "/task/index/"); } }
public function after() { echo "after\n"; $insert = 0; // 判断是否插入表 $class_name = get_class($this); $type = str_replace('Event', '', $class_name); $task = new Task(); if ($this->event_rs['err_no'] > 0) { // 代表错误 $task->is_success = 0; $this->event_rs['class'] = $this->class; $this->event_rs['param'] = $this->param; if ($this->retry_cnt >= 3) { $insert = 1; } } else { $task->is_success = 1; $insert = 1; } // 成功则入库 第一次失败则不入库 第三次失败才一起入库 $task->create_time = time(); $task->retry_cnt = $this->retry_cnt; $task->event = $type; $task->param = json_encode($this->param); if ($insert > 0) { $task->save(); } $this->event_rs['retry_cnt'] = $this->retry_cnt; }
/** * Proxies task adding. * * @param Task The task that is being added. * * @author Noah Fontes <*****@*****.**> * @since 1.0.0 */ public function addTask(Task $task) { if ($this->target === null) { throw new BuildException('Tasks can not be added to a proxy target without a concrete target'); } $task->setOwningTarget($this->target); $this->target->addTask($task); }
/** * get task information for the specified task */ function smarty_function_task($params, &$smarty) { $t = new Task(); if (!Check::digits($params['task_id'], $empty = false)) { return; } $smarty->assign('task', $t->getone($params['task_id'])); }
/** * take our raw form data and make a data structure out of it * that can be used in templates */ function smarty_function_forms($params, &$smarty) { if (!Check::digits($params['task_id'], $empty = false)) { return; } $t = new Task(); $smarty->assign('forms', $t->parseforms($params['task_id'])); }
function eventAjaxTaskCategoryDelete(EventControler $evctl) { $this->getId($evctl->id); $this->delete(); $update_task_category = new Task(); $update_task_category->updateTaskCategory($evctl->id); $evctl->addOutputValue('ok'); }
protected function runTask(Project $project, Task $task) { // Add if the client has not already done so if (!$task->getProject()) { $task->setProject($project); } $task->main(); }
public function addTask() { $projectId = $this->request_stack["arguments"][0]; $task = new Task(); $taskId = $task->setProject(ProjectQuery::create()->findOneById($projectId))->setEmployee(EmployeeQuery::create()->findOneById((new Cookie())->get("employee_id")))->save(); $redirect = new Request(); $redirect->redirect("task", "edit", array("id" => $task->getId())); }
/** * @param Task|object $proxy * @param mixed $elementTag The element to wrap. */ public function __construct($proxy, $elementTag) { $this->wrappedObject = $proxy; $this->elementTag = $elementTag; if ($proxy instanceof Task) { $proxy->setRuntimeConfigurableWrapper($this); } }
function dotaskadd($data, $form) { $submission = new Task(); $submission->write(); $form->saveInto($submission); $submission->write(); Controller::curr()->redirectBack(); }
/** * find the tasks for this particular study */ function smarty_function_tasks($params, &$smarty) { $t = new Task(); if (!Check::digits($params['study_id'])) { return; } $smarty->assign('tasks', $t->tasks($params['study_id'], $_SESSION['user']['researcher_id'], $params['all'] ? true : false)); }
/** * take our raw form data and make an xml representation of it * that should be exactly what gets sent to the phones */ function smarty_function_formhtml($params, &$smarty) { if (!Check::digits($params['task_id'], $empty = false)) { return; } # study_id is needed for the scheduling information for the task if (!Check::digits($params['study_id'], $empty = false)) { return; } $t = new Task(); if ($params['style'] == 'mobile') { if ($params['width'] > 0) { $width = (int) $params['width']; } else { $width = 400; } $rawhtml = $t->forms2html($params['task_id'], $params['study_id']); $forms = explode('<!-- split -->', $rawhtml); $numforms = count($forms) - 1; foreach ($forms as $block) { $f++; if ($f > $numforms) { break; } $spacer = ""; if ($f == 1) { $prev = "< prev"; $next = "<input type=submit value=\"next >\">"; } else { if ($f < $numforms) { $prev = "<input type=submit value=\"< prev\">"; $next = "<input type=submit value=\"next >\">"; } else { $prev = "<input type=submit value=\"< prev\">"; } } if ($f == $numforms) { $next = "<input type=submit value=\"Save data\">"; $spacer = "<br><br><br>"; } $html .= <<<HTML <h4>Form {$f}</h4> <table cellpadding=2 cellspacing=0 border=1 style="width: {$width}" width={$width} class="nobgcolor"> <tr><td> {$block} <br> {$prev} {$next} <br><br> </td></tr> </table> {$spacer} HTML; } return $html; } return htmlentities($t->forms2html($params['task_id'], $params['study_id'])); }
/** * 開始寫入資料 */ private function GetNewSEOState() { $taskModel = new Task(); $date = new DateTime(); $taskModel->attributes = array('date' => $date->format("Y-m-d H:i:s")); $taskModel->save(); $taskID = $taskModel->getPrimaryKey(); $this->GetSEOState($taskID); }
/** * A custom method within the Plugin to generate the content * * @return string : HTML form * @see class/Task.class.php */ function generateAddTaskBlock() { $output = ''; $output .= '<div class="tundra">'; $do_task_add = new Task(); $output .= $do_task_add->getTaskAddForm(); $output .= '</div>'; return $output; }
private function updateParent() { $p_id = $this->parent_id; if (!empty($p_id)) { $parent = new Task(); $parent->load($p_id); $parent->updateProperties(); } }
/** * Message to contractor that the task is reopened * * @param Task $task * @return void */ public static function taskOpened(Task $task) { $contractor = $task->lastContractor(); if (!$contractor || !$contractor->email) { return; } Mail::send("emails.task_reopened", ["contractor" => $contractor, "task" => $task], function ($message) use($contractor, $task) { $message->to($contractor->email)->subject("Задача #" . $task->id . " повторно открыта"); }); }
private function tick() { while (!$this->tick->isEmpty() && !$this->main->isFinished()) { $task = $this->nextTask(); $task->run(); if ($task->isBlocked()) { $this->addFutureTask($task); } } }
/** * Display all the tasks for a specific contract * @param $contract_id * @return string */ public function process($contract_id) { $contract = $this->contract->findWithTasks($contract_id); $contract->tasks = $this->task->appendAssignment($contract->tasks); $tasks = $this->task->getTotalByStatus($contract_id); $tasks['total_pages'] = $contract->tasks->count(); if ($tasks['total_pending_approval'] > 0) { $this->mailer->send(['email' => $contract->created_user->email, 'name' => $contract->created_user->name], sprintf("Mturk assignments for your action for [%s]", $contract->title), 'mturk.email.notify', ['task' => $tasks, 'contract' => ['id' => $contract->id, 'title' => $contract->title]]); } }
/** * @param mixed $task */ public function addTask(Task $task) { if ($this->freePlaceForTasks) { $this->tasks[] = $task; $this->setFreePlaceForTasks(); echo $task->getName() . ' is added to tasks', PHP_EOL; } else { echo 'You can\'t add more task'; } }