Example #1
0
 /**
  * Gets the package and runs the process from within the package.
  */
 public function execute()
 {
     $start_at = time();
     $obj = unserialize($this->data);
     if ($obj instanceof Package) {
         $error = null;
         $error_msg = null;
         $exec_time = current_datetime();
         try {
             //attempt to run the process
             $obj->execute();
             $this->deRegister();
         } catch (Exception $e) {
             $error = get_class($e);
             $error_msg = $e->getMessage();
         }
         $end_at = time();
         $this->process_log->create($this->process_queue, $end_at - $start_at, $exec_time, $error, $error_msg);
     } else {
         throw new ProcessException("Specified package '{$this->package}' is not an instance of the Package Class.");
     }
 }
 /**
  * Gets the ready processes to be run in order of execution.
  */
 public function getReadyProcesses()
 {
     $list = ProcessQueue::where('exec_datetime', '<=', current_datetime())->orderBy('exec_datetime', 'asc')->get();
     return $list;
 }
Example #3
0
 /**
  * Gets the next hours in mysql datetime format
  *
  * @param int $number the number of hours
  * @param null|string $time the time of to add 1 hour
  * @return bool|string
  */
 function next_hours($number = 1, $time = null)
 {
     return date("Y-m-d H:00:00", strtotime((is_null($time) ? current_datetime() : '') . " + {$number} hours"));
 }