List of current tasks
Since: 0.1
Inheritance: extends AppController
Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 public function testIsRunning()
 {
     $task = new Task(['exec' => 'sleep 1']);
     $this->assertFalse($task->isRunning());
     $task->run();
     $this->assertTrue($task->isRunning());
 }
Exemplo n.º 4
0
 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();
     }
 }
Exemplo n.º 6
0
 /**
  * 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);
 }
Exemplo n.º 7
0
 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;
     }
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 public function find($id)
 {
     $events = $this->eventStore->find($id);
     $task = new Task();
     $task->replay($events);
     return $task;
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 function delete()
 {
     $delete_result = parent::delete();
     $task = new Task($this->task_id);
     $task->update_total_time();
     return $delete_result;
 }
Exemplo n.º 12
0
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/");
    }
}
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 /**
  * 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);
 }
Exemplo n.º 15
0
/**
 * 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']));
}
Exemplo n.º 16
0
/**
 * 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']));
}
Exemplo n.º 17
0
 function eventAjaxTaskCategoryDelete(EventControler $evctl)
 {
     $this->getId($evctl->id);
     $this->delete();
     $update_task_category = new Task();
     $update_task_category->updateTaskCategory($evctl->id);
     $evctl->addOutputValue('ok');
 }
Exemplo n.º 18
0
 protected function runTask(Project $project, Task $task)
 {
     // Add if the client has not already done so
     if (!$task->getProject()) {
         $task->setProject($project);
     }
     $task->main();
 }
Exemplo n.º 19
0
 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()));
 }
Exemplo n.º 20
0
 /**
  * @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);
     }
 }
Exemplo n.º 21
0
 function dotaskadd($data, $form)
 {
     $submission = new Task();
     $submission->write();
     $form->saveInto($submission);
     $submission->write();
     Controller::curr()->redirectBack();
 }
Exemplo n.º 22
0
/**
 * 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));
}
Exemplo n.º 23
0
/**
 * 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 = "&lt; prev";
                $next = "<input type=submit value=\"next &gt;\">";
            } else {
                if ($f < $numforms) {
                    $prev = "<input type=submit value=\"&lt; prev\">";
                    $next = "<input type=submit value=\"next &gt;\">";
                } else {
                    $prev = "<input type=submit value=\"&lt; 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']));
}
Exemplo n.º 24
0
 /**
  * 開始寫入資料
  */
 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);
 }
Exemplo n.º 25
0
 /**
  * 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;
 }
Exemplo n.º 26
0
 private function updateParent()
 {
     $p_id = $this->parent_id;
     if (!empty($p_id)) {
         $parent = new Task();
         $parent->load($p_id);
         $parent->updateProperties();
     }
 }
Exemplo n.º 27
0
 /**
  * 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 . " повторно открыта");
     });
 }
Exemplo n.º 28
0
 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]]);
     }
 }
Exemplo n.º 30
0
 /**
  * @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';
     }
 }