/**
  * Use either the passed datetime stamp or the current timestamp to lookup in
  * sy_tsched_schedule if any tasks are scheduled to be run at this time. If
  * so, put them on the queue.
  *
  * @param <type> $dateTime Optional date time to use for lookup. This can be
  *                         used for debuging and development purposes. If no
  *                         parameter is passed then the current time is used.
  */
 public function run($dateTime = null)
 {
     try {
         if ($dateTime == null) {
             $dateTime = uDateTime::now();
         }
         $timeStamp = uDateTime::strtotime($dateTime);
         $minute = intval(date("i", $timeStamp));
         $hour = date("G", $timeStamp);
         $day = date("j", $timeStamp);
         $tasks = TschedScheduleTable::getScheduledTasks($minute, $hour, $day);
         foreach ($tasks as $task) {
             $queue = $this->newTaskQueue();
             $queue->setScheduleId($task->getId());
             $queue->save();
             $msg = 'TASK SCHEDULER|Queued task: ' . $task->getDescription() . ' (id=' . $task->getId() . ')';
             $this->logNotice($msg);
         }
     } catch (Exception $e) {
         $msg = 'TASK SCHEDULER|' . __METHOD__ . ':' . __LINE__ . '|' . $e->getMessage();
         $this->logError($msg);
     }
 }
Пример #2
0
 /**
  * Convert a date time string into the components of a cron configuration
  * string.
  *
  * @param string $dateString
  * @return array
  */
 protected static function timeStampToArray($dateString)
 {
     $parts = self::getCronPartsArray();
     $timeStamp = uDateTime::strtotime($dateString);
     $parts['minute'] = intval(date("i", $timeStamp));
     $parts['hour'] = date("G", $timeStamp);
     $parts['day'] = date("j", $timeStamp);
     $parts['month'] = date("n", $timeStamp);
     $parts['day_of_week'] = date("N", $timeStamp);
     return $parts;
 }