PMCORE-1759

fix observations

u
This commit is contained in:
Henry Jordan
2020-07-07 16:06:59 +00:00
parent a6d127b77c
commit ccbd3e87d5
2 changed files with 26 additions and 18 deletions

View File

@@ -1,17 +1,12 @@
<?php
namespace App\Console\Commands;
use Illuminate\Support\Carbon;
use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand;
use Maveriks\WebApplication;
use ProcessMaker\Model\TaskScheduler;
class ScheduleRunCommand extends BaseCommand
{
use AddParametersTrait;
/**
* Create a new command instance.
*
@@ -30,7 +25,6 @@ class ScheduleRunCommand extends BaseCommand
$this->description .= ' (ProcessMaker has extended this command)';
parent::__construct($schedule);
}
/**
* Execute the console command.
*
@@ -47,12 +41,15 @@ class ScheduleRunCommand extends BaseCommand
$webApplication->loadEnvironment($workspace, false);
}
TaskScheduler::all()->each(function ($p) use ($that, $user) {
$win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
if ($p->enable == 1) {
$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();
$body = str_replace(" -c"," " . $user . " -c", $p->body);
$body = $p->body;
if (!$win) {
$body = str_replace(" -c"," " . $user . " -c", $p->body);
}
$that->schedule->exec($body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) {
$now = Carbon::now();
$result = false;
@@ -96,4 +93,4 @@ class ScheduleRunCommand extends BaseCommand
});
parent::handle();
}
}
}