update rakefile
Update rakefile to translations update Rakefile for translations update intervals in Task Schedule update insert.sql error in instalation add Translations in index.php task scheduler fix timezone in execution on task scheduler fix timezone add translation to TASKSCHEDULER control for intervals in task scheduler is last_update property PMCORE-1549 PMCORE-1542 Revert "PMCORE-1542 (pull request #7355)" This reverts pull request #7355. > PMCORE-1542 fix schedule Run command
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Maveriks\WebApplication;
|
||||
@@ -6,14 +7,16 @@ use \Illuminate\Support\Carbon;
|
||||
use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use ProcessMaker\Model\TaskScheduler;
|
||||
|
||||
class ScheduleRunCommand extends BaseCommand
|
||||
{
|
||||
|
||||
use AddParametersTrait;
|
||||
/**
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\Illuminate\Console\Scheduling\Schedule $schedule)
|
||||
@@ -24,11 +27,10 @@ class ScheduleRunCommand extends BaseCommand
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
parent::__construct($schedule);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
@@ -43,13 +45,37 @@ class ScheduleRunCommand extends BaseCommand
|
||||
$webApplication->setRootDir($this->option('processmakerPath'));
|
||||
$webApplication->loadEnvironment($workspace, false);
|
||||
}
|
||||
TaskScheduler::all()->each(function($p) use ($that){
|
||||
if($p->isDue()){
|
||||
Log::info("Si se ejecuta" . $p->expression);
|
||||
}
|
||||
if($p->enable == '1'){
|
||||
$that->schedule->exec($p->body)->cron($p->expression)->between($p->startingTime, $p->endingTime);
|
||||
}
|
||||
TaskScheduler::all()->each(function ($p) use ($that) {
|
||||
$starting = isset($p->startingTime) ? $p->startingTime : "0:00";
|
||||
$ending = isset($p->startingTime) ? $p->endingTime : "23:59";
|
||||
$timezone = isset($p->timezone) && $p->timezone != ""? $p->timezone: date_default_timezone_get();
|
||||
$that->schedule->exec($p->body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) {
|
||||
$now = Carbon::now();
|
||||
$result = false;
|
||||
$datework = Carbon::createFromFormat('Y-m-d H:i:s', $p->last_update);
|
||||
if (isset($p->everyOn)) {
|
||||
switch ($p->interval) {
|
||||
case "day":
|
||||
$interval = $now->diffInDays($datework);
|
||||
$result = ($interval !== 0 && ($interval % intval($p->everyOn)) == 0);
|
||||
break;
|
||||
case "week":
|
||||
$interval = $now->diffInDays($datework);
|
||||
$result = ($interval !== 0 && $interval % (intval($p->everyOn) * 7) == 0);
|
||||
break;
|
||||
case "month":
|
||||
$interval = $now->diffInMonths($datework);
|
||||
$result = ($interval !== 0 && $interval % intval($p->everyOn) == 0);
|
||||
break;
|
||||
case "year":
|
||||
$interval = $now->diffInYears($datework);
|
||||
$result = ($interval !== 0 && $interval % intval($p->everyOn) == 0);
|
||||
break;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
parent::handle();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user