Task scheduler
This commit is contained in:
59
app/Console/Commands/ScheduleRunCommand.php
Executable file
59
app/Console/Commands/ScheduleRunCommand.php
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Maveriks\WebApplication;
|
||||||
|
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
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(\Illuminate\Console\Scheduling\Schedule $schedule)
|
||||||
|
{
|
||||||
|
$this->startedAt = Carbon::now();
|
||||||
|
$this->signature = "schedule:run";
|
||||||
|
$this->signature .= '
|
||||||
|
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||||
|
{--processmakerPath=./ : ProcessMaker path.}
|
||||||
|
';
|
||||||
|
$this->description .= ' (ProcessMaker has extended this command)';
|
||||||
|
parent::__construct($schedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$that = $this;
|
||||||
|
$workspace = $this->option('workspace');
|
||||||
|
if (!empty($workspace)) {
|
||||||
|
$webApplication = new WebApplication();
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
parent::handle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
19
workflow/engine/classes/model/Scheduler.php
Executable file
19
workflow/engine/classes/model/Scheduler.php
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'classes/model/om/BaseScheduler.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'SCHEDULER' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package classes.model
|
||||||
|
*/
|
||||||
|
class Scheduler extends BaseScheduler {
|
||||||
|
|
||||||
|
} // Scheduler
|
||||||
23
workflow/engine/classes/model/SchedulerPeer.php
Executable file
23
workflow/engine/classes/model/SchedulerPeer.php
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// include base peer class
|
||||||
|
require_once 'classes/model/om/BaseSchedulerPeer.php';
|
||||||
|
|
||||||
|
// include object class
|
||||||
|
include_once 'classes/model/Scheduler.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'SCHEDULER' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package classes.model
|
||||||
|
*/
|
||||||
|
class SchedulerPeer extends BaseSchedulerPeer {
|
||||||
|
|
||||||
|
} // SchedulerPeer
|
||||||
94
workflow/engine/classes/model/map/SchedulerMapBuilder.php
Executable file
94
workflow/engine/classes/model/map/SchedulerMapBuilder.php
Executable file
@@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once 'propel/map/MapBuilder.php';
|
||||||
|
include_once 'creole/CreoleTypes.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class adds structure of 'SCHEDULER' table to 'workflow' DatabaseMap object.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||||
|
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||||
|
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||||
|
* (i.e. if it's a text column type).
|
||||||
|
*
|
||||||
|
* @package workflow.classes.model.map
|
||||||
|
*/
|
||||||
|
class SchedulerMapBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The (dot-path) name of this class
|
||||||
|
*/
|
||||||
|
const CLASS_NAME = 'classes.model.map.SchedulerMapBuilder';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The database map.
|
||||||
|
*/
|
||||||
|
private $dbMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells us if this DatabaseMapBuilder is built so that we
|
||||||
|
* don't have to re-build it every time.
|
||||||
|
*
|
||||||
|
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||||
|
*/
|
||||||
|
public function isBuilt()
|
||||||
|
{
|
||||||
|
return ($this->dbMap !== null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the databasemap this map builder built.
|
||||||
|
*
|
||||||
|
* @return the databasemap
|
||||||
|
*/
|
||||||
|
public function getDatabaseMap()
|
||||||
|
{
|
||||||
|
return $this->dbMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The doBuild() method builds the DatabaseMap
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function doBuild()
|
||||||
|
{
|
||||||
|
$this->dbMap = Propel::getDatabaseMap('workflow');
|
||||||
|
|
||||||
|
$tMap = $this->dbMap->addTable('SCHEDULER');
|
||||||
|
$tMap->setPhpName('Scheduler');
|
||||||
|
|
||||||
|
$tMap->setUseIdGenerator(true);
|
||||||
|
|
||||||
|
$tMap->addPrimaryKey('ID', 'Id', 'string', CreoleTypes::BIGINT, true, 20);
|
||||||
|
|
||||||
|
$tMap->addColumn('TITLE', 'Title', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||||
|
|
||||||
|
$tMap->addColumn('STARTINGTIME', 'Startingtime', 'string', CreoleTypes::VARCHAR, false, 100);
|
||||||
|
|
||||||
|
$tMap->addColumn('ENDINGTIME', 'Endingtime', 'string', CreoleTypes::VARCHAR, false, 100);
|
||||||
|
|
||||||
|
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||||
|
|
||||||
|
$tMap->addColumn('EXPRESSION', 'Expression', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||||
|
|
||||||
|
$tMap->addColumn('BODY', 'Body', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||||
|
|
||||||
|
$tMap->addColumn('TYPE', 'Type', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||||
|
|
||||||
|
$tMap->addColumn('CATEGORY', 'Category', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||||
|
|
||||||
|
$tMap->addColumn('SYSTEM', 'System', 'int', CreoleTypes::TINYINT, false, 3);
|
||||||
|
|
||||||
|
$tMap->addColumn('TIMEZONE', 'Timezone', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||||
|
|
||||||
|
$tMap->addColumn('ENABLE', 'Enable', 'int', CreoleTypes::TINYINT, false, 3);
|
||||||
|
|
||||||
|
} // doBuild()
|
||||||
|
|
||||||
|
} // SchedulerMapBuilder
|
||||||
18
workflow/engine/config/schema.xml
Normal file → Executable file
18
workflow/engine/config/schema.xml
Normal file → Executable file
@@ -6008,4 +6008,22 @@
|
|||||||
<column name="exception" type="LONGVARCHAR" required="true"/>
|
<column name="exception" type="LONGVARCHAR" required="true"/>
|
||||||
<column name="failed_at" type="TIMESTAMP" required="true"/>
|
<column name="failed_at" type="TIMESTAMP" required="true"/>
|
||||||
</table>
|
</table>
|
||||||
|
<table name="SCHEDULER" idMethod="native">
|
||||||
|
<vendor type="mysql">
|
||||||
|
<parameter name="Engine" value="InnoDB"/>
|
||||||
|
<parameter name="Collation" value="utf8"/>
|
||||||
|
</vendor>
|
||||||
|
<column name="id" type="BIGINT" size="20" required="true" autoIncrement="true" primaryKey="true"/>
|
||||||
|
<column name="title" type="VARCHAR" size="255" required="false"/>
|
||||||
|
<column name="startingTime" type="VARCHAR" size="100" required="false"/>
|
||||||
|
<column name="endingTime" type="VARCHAR" size="100" required="false"/>}
|
||||||
|
<column name="description" type="VARCHAR" size="255" required="false"/>
|
||||||
|
<column name="expression" type="VARCHAR" size="255" required="false"/>
|
||||||
|
<column name="body" type="VARCHAR" size="255" required="false"/>
|
||||||
|
<column name="type" type="VARCHAR" size="255" required="false"/>
|
||||||
|
<column name="category" type="VARCHAR" size="255" required="false"/>
|
||||||
|
<column name="system" type="TINYINT" size="3" required="false"/>
|
||||||
|
<column name="timezone" type="VARCHAR" size="255" required="false"/>
|
||||||
|
<column name="enable" type="TINYINT" size="3" required="false"/>
|
||||||
|
</table>
|
||||||
</database>
|
</database>
|
||||||
|
|||||||
31
workflow/engine/methods/scheduler/index.php
Executable file
31
workflow/engine/methods/scheduler/index.php
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
try {
|
||||||
|
$category = (isset($_GET["category"]))? $_GET["category"] : null;
|
||||||
|
/* Render page */
|
||||||
|
$oHeadPublisher = headPublisher::getSingleton();
|
||||||
|
$pmDynaform = new PmDynaform(array());
|
||||||
|
$G_MAIN_MENU = "processmaker";
|
||||||
|
$G_ID_MENU_SELECTED = "ID_SCHEDULER_MNU_01";
|
||||||
|
$dateTime = new \ProcessMaker\Util\DateTime();
|
||||||
|
if (!empty($_SESSION['USER_LOGGED'])) {
|
||||||
|
$arrayTimeZoneId = \DateTimeZone::listIdentifiers();
|
||||||
|
$js = "" .
|
||||||
|
"<script type='text/javascript'>\n" .
|
||||||
|
"var timezoneArray = " . G::json_encode($arrayTimeZoneId) . ";\n" .
|
||||||
|
"</script>\n";
|
||||||
|
echo($js);
|
||||||
|
}
|
||||||
|
$js = "" .
|
||||||
|
"<script type='text/javascript'>\n" .
|
||||||
|
"var server = '" . System::getHttpServerHostnameRequestsFrontEnd() . "';\n" .
|
||||||
|
"var credentials = " . G::json_encode($pmDynaform->getCredentials()) . ";\n" .
|
||||||
|
"var category = '" . $category . "';\n" .
|
||||||
|
"</script>\n";
|
||||||
|
echo($js);
|
||||||
|
|
||||||
|
$file = file_get_contents(PATH_HOME . 'public_html/lib/taskscheduler/index.html');
|
||||||
|
echo $file;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
253
workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBM.php
Executable file
253
workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBM.php
Executable file
@@ -0,0 +1,253 @@
|
|||||||
|
<?php
|
||||||
|
namespace ProcessMaker\BusinessModel;
|
||||||
|
|
||||||
|
use ProcessMaker\Model\TaskScheduler;
|
||||||
|
use \G;
|
||||||
|
use ProcessMaker\Plugins\Interfaces\StepDetail;
|
||||||
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
|
use \ProcessMaker\Util;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use ProcessMaker\Core\System;
|
||||||
|
|
||||||
|
class TaskSchedulerBM
|
||||||
|
{
|
||||||
|
public function executeTasks(){
|
||||||
|
TaskScheduler::all()->each(function($p){
|
||||||
|
if($p->isDue()){
|
||||||
|
Log::info("EXECUTE::" . $p->title . " -->" . $p->expression);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSchedule($category){
|
||||||
|
$tasks = TaskScheduler::all();
|
||||||
|
$count = $tasks->count();
|
||||||
|
if($count == 0){
|
||||||
|
TaskSchedulerBM::generateInitialData();
|
||||||
|
$tasks = TaskScheduler::all();
|
||||||
|
}
|
||||||
|
if(is_null($category)){
|
||||||
|
return $tasks;
|
||||||
|
}else{
|
||||||
|
return TaskScheduler::where('category', $category)->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function saveSchedule(array $request_data){
|
||||||
|
$task = TaskScheduler::find($request_data['id']);
|
||||||
|
if(isset($request_data['expression'])){
|
||||||
|
$task->expression = $request_data['expression'];
|
||||||
|
}
|
||||||
|
if(isset($request_data['enable'])){
|
||||||
|
$task->enable = $request_data['enable'];
|
||||||
|
}
|
||||||
|
if(isset($request_data['startingTime'])){
|
||||||
|
$task->startingTime = $request_data['startingTime'];
|
||||||
|
}
|
||||||
|
if(isset($request_data['endingTime'])){
|
||||||
|
$task->endingTime = $request_data['endingTime'];
|
||||||
|
}
|
||||||
|
if(isset($request_data['timezone'])){
|
||||||
|
$task->timezone = $request_data['timezone'];
|
||||||
|
}
|
||||||
|
$task->save();
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function generateInitialData(){
|
||||||
|
$arraySystemConfiguration = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||||
|
$toSave = array();
|
||||||
|
$services = array(
|
||||||
|
array(
|
||||||
|
"title" => "ProcessMaker Events",
|
||||||
|
"service" => "events",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* * * * *",
|
||||||
|
"description" => "Unpauses any case whose pause time has expired"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "ProcessMaker Scheduler",
|
||||||
|
"enable" => "1",
|
||||||
|
"service" => "scheduler",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* * */1 * *",
|
||||||
|
"description" => "Unpauses any case whose pause time has expired"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Unpause Cases",
|
||||||
|
"enable" => "0",
|
||||||
|
"service" => "unpause",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* */1 * * *",
|
||||||
|
"description" => "Unpauses any case whose pause time has expired"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Case Emails",
|
||||||
|
"enable" => "1",
|
||||||
|
"service" => "emails",
|
||||||
|
"category" => "emails_notifications",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "*/5 * * * *",
|
||||||
|
"description" => "Task, triggers, and actions by email notifications"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "ProcessMaker Plugins",
|
||||||
|
"enable" => "0",
|
||||||
|
"service" => "plugins",
|
||||||
|
"category" => "plugins",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* * */1 * *",
|
||||||
|
"description" => "Custom plugins execution"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Calculate the elapsed time",
|
||||||
|
"service" => "calculate",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* * */1 * *",
|
||||||
|
"description" => 'Calculates the elapsed time "according to the configured calendar" of all open tasks in active cases)'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Calculate App data",
|
||||||
|
"service" => "calculateapp",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* * */1 * *",
|
||||||
|
"description" => 'Calculates the elapsed time "according to the configured calendar" of all open tasks in active cases)'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Unassigned Case",
|
||||||
|
"service" => "unassigned-case",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* */1 * * *",
|
||||||
|
"description" => 'Run the trigger for self-service cases that have a configured timeout setting)'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Clean self service tables",
|
||||||
|
"service" => "clean-self-service-tables",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* * */1 * *",
|
||||||
|
"description" => 'Clean unused records for Self-Service Value-Based feature. It is a maintenance command'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Report by Users",
|
||||||
|
"enable" => "0",
|
||||||
|
"service" => "report_by_user",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* */1 * * *",
|
||||||
|
"description" => "Report by Users"
|
||||||
|
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Report by process",
|
||||||
|
"enable" => "0",
|
||||||
|
"service" => "report_by_process",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/cron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* */1 * * *",
|
||||||
|
"description" => "Report by process"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Message Events",
|
||||||
|
"enable" => "1",
|
||||||
|
"service" => "",
|
||||||
|
"category" => "emails_notifications",
|
||||||
|
"file" => "workflow/engine/bin/messageeventcron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "*/5 * * * *",
|
||||||
|
"description" => "Intermediate and End Email Event"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "ProcessMaker timer event cron",
|
||||||
|
"enable" => "0",
|
||||||
|
"service" => "",
|
||||||
|
"category" => "case_actions",
|
||||||
|
"file" => "workflow/engine/bin/timereventcron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* * */1 * *",
|
||||||
|
"description" => "ProcessMaker timer event cron"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "ProcessMaker LDAP cron",
|
||||||
|
"enable" => "0",
|
||||||
|
"service" => "",
|
||||||
|
"category" => "processmaker_sync",
|
||||||
|
"file" => "workflow/engine/bin/ldapcron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "* * */1 * *",
|
||||||
|
"description" => "Synchronize Advance LDAP Attributes from their settings"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Send notifications",
|
||||||
|
"enable" => "1",
|
||||||
|
"service" => "",
|
||||||
|
"category" => "emails_notifications",
|
||||||
|
"file" => "workflow/engine/bin/sendnotificationscron.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "*/5 * * * *",
|
||||||
|
"description" => "ProcessMaker Mobile Notifications"
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
"title" => "Action by emails response",
|
||||||
|
"enable" => "1",
|
||||||
|
"service" => "",
|
||||||
|
"category" => "emails_notifications",
|
||||||
|
"file" => "workflow/engine/bin/actionsByEmailEmailResponse.php",
|
||||||
|
"startingTime" => "0:00",
|
||||||
|
"endingTime" => "23:59",
|
||||||
|
"expression" => "*/5 * * * *",
|
||||||
|
"description" => "Actions by email response account email revision"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
for($i = 0; $i < count($services); ++$i) {
|
||||||
|
$task = new TaskScheduler;
|
||||||
|
$task->title = $services[$i]["title"];
|
||||||
|
$task->category = $services[$i]["category"];
|
||||||
|
$task->description = $services[$i]["description"];
|
||||||
|
$task->startingTime = $services[$i]["startingTime"];
|
||||||
|
$task->endingTime = $services[$i]["endingTime"];
|
||||||
|
$task->body = 'su -s /bin/sh -c "php '. PATH_TRUNK . $services[$i]["file"] . " " . $services[$i]["service"] . ' +w' . config("system.workspace") . ' +force"';
|
||||||
|
$task->expression = $services[$i]["expression"];
|
||||||
|
$task->type = "shell";
|
||||||
|
$task->system = 1;
|
||||||
|
$task->timezone = $arraySystemConfiguration['time_zone'];
|
||||||
|
$task->enable = $services[$i]["enable"];
|
||||||
|
$task->startingTime = "0:00";
|
||||||
|
$task->endingTime = "23:59";
|
||||||
|
$task->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
workflow/engine/src/ProcessMaker/Model/TaskScheduler.php
Executable file
26
workflow/engine/src/ProcessMaker/Model/TaskScheduler.php
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\Model;
|
||||||
|
|
||||||
|
use \Illuminate\Database\Eloquent\Model;
|
||||||
|
use \Illuminate\Support\Facades\DB;
|
||||||
|
use \Cron\CronExpression;
|
||||||
|
use \Illuminate\Support\Carbon;
|
||||||
|
use \Illuminate\Console\Scheduling\ManagesFrequencies;
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
/**
|
||||||
|
* Class TaskScheduler
|
||||||
|
* @package ProcessMaker\Model
|
||||||
|
*
|
||||||
|
* Represents a dynaform object in the system.
|
||||||
|
*/
|
||||||
|
class TaskScheduler extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'SCHEDULER';
|
||||||
|
public $timestamps = false;
|
||||||
|
|
||||||
|
public function isDue(){
|
||||||
|
$date = Carbon::now();
|
||||||
|
return CronExpression::factory($this->expression)->isDue($date->toDateTimeString());
|
||||||
|
}
|
||||||
|
}
|
||||||
47
workflow/engine/src/ProcessMaker/Services/Api/Scheduler.php
Executable file
47
workflow/engine/src/ProcessMaker/Services/Api/Scheduler.php
Executable file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
namespace ProcessMaker\Services\Api;
|
||||||
|
|
||||||
|
use \ProcessMaker\Services\Api;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use \Luracast\Restler\RestException;
|
||||||
|
use \ProcessMaker\Model\TaskScheduler;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use ProcessMaker\BusinessModel\TaskSchedulerBM;
|
||||||
|
/**
|
||||||
|
* TaskScheduler Controller
|
||||||
|
*
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
class Scheduler extends Api
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @url GET
|
||||||
|
*
|
||||||
|
* @param string $category
|
||||||
|
*/
|
||||||
|
public function doGet($category = null) {
|
||||||
|
try {
|
||||||
|
return TaskSchedulerBM::getSchedule($category);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url POST
|
||||||
|
* @status 200
|
||||||
|
*
|
||||||
|
* @param array $request_data
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws RestException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function doPost(array $request_data) {
|
||||||
|
try {
|
||||||
|
return TaskSchedulerBM::saveSchedule($request_data);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user