HOR-4563-A
This commit is contained in:
@@ -9,16 +9,12 @@ require_once __DIR__ . '/../../../bootstrap/app.php';
|
|||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
|
|
||||||
register_shutdown_function(
|
$fn = '
|
||||||
create_function(
|
|
||||||
'',
|
|
||||||
'
|
|
||||||
if (class_exists("Propel")) {
|
if (class_exists("Propel")) {
|
||||||
Propel::close();
|
Propel::close();
|
||||||
}
|
}
|
||||||
'
|
';
|
||||||
)
|
register_shutdown_function(create_function('', $fn));
|
||||||
);
|
|
||||||
|
|
||||||
ini_set('memory_limit', '512M');
|
ini_set('memory_limit', '512M');
|
||||||
|
|
||||||
@@ -45,8 +41,7 @@ try {
|
|||||||
$cronName = $argv[4];
|
$cronName = $argv[4];
|
||||||
$workspace = $argv[5];
|
$workspace = $argv[5];
|
||||||
$dateSystem = $argv[6];
|
$dateSystem = $argv[6];
|
||||||
$sNow = $argv[7]; //$date
|
$sNow = $argv[7]; //date
|
||||||
|
|
||||||
//Defines constants
|
//Defines constants
|
||||||
define('PATH_SEP', ($osIsLinux) ? '/' : '\\');
|
define('PATH_SEP', ($osIsLinux) ? '/' : '\\');
|
||||||
|
|
||||||
@@ -68,10 +63,7 @@ try {
|
|||||||
$classLoader->add(PATH_TRUNK . 'workflow' . PATH_SEP . 'engine' . PATH_SEP . 'src' . PATH_SEP);
|
$classLoader->add(PATH_TRUNK . 'workflow' . PATH_SEP . 'engine' . PATH_SEP . 'src' . PATH_SEP);
|
||||||
|
|
||||||
//Add vendors to autoloader
|
//Add vendors to autoloader
|
||||||
//$classLoader->add(PATH_TRUNK . 'vendor' . PATH_SEP . 'luracast' . PATH_SEP . 'restler' . PATH_SEP . 'vendor', 'Luracast');
|
$classLoader->addClass('Bootstrap', PATH_TRUNK . 'gulliver' . PATH_SEP . 'system' . PATH_SEP . 'class.bootstrap.php');
|
||||||
//$classLoader->add(PATH_TRUNK . 'vendor' . PATH_SEP . 'bshaffer' . PATH_SEP . 'oauth2-server-php' . PATH_SEP . 'src' . PATH_SEP, 'OAuth2');
|
|
||||||
$classLoader->addClass('Bootstrap',
|
|
||||||
PATH_TRUNK . 'gulliver' . PATH_SEP . 'system' . PATH_SEP . 'class.bootstrap.php');
|
|
||||||
|
|
||||||
$classLoader->addModelClassPath(PATH_TRUNK . 'workflow' . PATH_SEP . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP);
|
$classLoader->addModelClassPath(PATH_TRUNK . 'workflow' . PATH_SEP . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP);
|
||||||
|
|
||||||
@@ -89,7 +81,6 @@ try {
|
|||||||
ini_set('error_reporting', $e_all);
|
ini_set('error_reporting', $e_all);
|
||||||
ini_set('short_open_tag', 'On');
|
ini_set('short_open_tag', 'On');
|
||||||
ini_set('default_charset', 'UTF-8');
|
ini_set('default_charset', 'UTF-8');
|
||||||
//ini_set('memory_limit', $arraySystemConfiguration['memory_limit']);
|
|
||||||
ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']);
|
ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']);
|
||||||
ini_set('date.timezone', $arraySystemConfiguration['time_zone']);
|
ini_set('date.timezone', $arraySystemConfiguration['time_zone']);
|
||||||
|
|
||||||
@@ -99,9 +90,6 @@ try {
|
|||||||
define('MEMCACHED_ENABLED', $arraySystemConfiguration['memcached']);
|
define('MEMCACHED_ENABLED', $arraySystemConfiguration['memcached']);
|
||||||
define('MEMCACHED_SERVER', $arraySystemConfiguration['memcached_server']);
|
define('MEMCACHED_SERVER', $arraySystemConfiguration['memcached_server']);
|
||||||
|
|
||||||
//require_once(PATH_GULLIVER . PATH_SEP . 'class.bootstrap.php');
|
|
||||||
//define('PATH_GULLIVER_HOME', PATH_TRUNK . 'gulliver' . PATH_SEP);
|
|
||||||
|
|
||||||
spl_autoload_register(['Bootstrap', 'autoloadClass']);
|
spl_autoload_register(['Bootstrap', 'autoloadClass']);
|
||||||
|
|
||||||
//Set variables
|
//Set variables
|
||||||
@@ -168,8 +156,7 @@ try {
|
|||||||
while (!feof($fileDb)) {
|
while (!feof($fileDb)) {
|
||||||
$buffer = fgets($fileDb, 4096); //Read a line
|
$buffer = fgets($fileDb, 4096); //Read a line
|
||||||
|
|
||||||
$phpCode .= preg_replace('/define\s*\(\s*[\x22\x27](.*)[\x22\x27]\s*,\s*(\x22.*\x22|\x27.*\x27)\s*\)\s*;/i',
|
$phpCode .= preg_replace('/define\s*\(\s*[\x22\x27](.*)[\x22\x27]\s*,\s*(\x22.*\x22|\x27.*\x27)\s*\)\s*;/i', '$$1 = $2;', $buffer);
|
||||||
'$$1 = $2;', $buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($fileDb);
|
fclose($fileDb);
|
||||||
@@ -189,8 +176,6 @@ try {
|
|||||||
$dsnRbac .= '?encoding=utf8';
|
$dsnRbac .= '?encoding=utf8';
|
||||||
break;
|
break;
|
||||||
case 'mssql':
|
case 'mssql':
|
||||||
//$dsn .= '?sendStringAsUnicode=false';
|
|
||||||
//$dsnRbac .= '?sendStringAsUnicode=false';
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -203,15 +188,12 @@ try {
|
|||||||
$pro['datasources']['rbac']['adapter'] = $DB_ADAPTER;
|
$pro['datasources']['rbac']['adapter'] = $DB_ADAPTER;
|
||||||
$pro['datasources']['rp']['connection'] = $dsnRp;
|
$pro['datasources']['rp']['connection'] = $dsnRp;
|
||||||
$pro['datasources']['rp']['adapter'] = $DB_ADAPTER;
|
$pro['datasources']['rp']['adapter'] = $DB_ADAPTER;
|
||||||
//$pro['datasources']['dbarray']['connection'] = 'dbarray://user:pass@localhost/pm_os';
|
|
||||||
//$pro['datasources']['dbarray']['adapter'] = 'dbarray';
|
|
||||||
|
|
||||||
$oFile = fopen(PATH_CORE . 'config' . PATH_SEP . '_databases_.php', 'w');
|
$oFile = fopen(PATH_CORE . 'config' . PATH_SEP . '_databases_.php', 'w');
|
||||||
fwrite($oFile, '<?php global $pro; return $pro; ?>');
|
fwrite($oFile, '<?php global $pro; return $pro; ?>');
|
||||||
fclose($oFile);
|
fclose($oFile);
|
||||||
|
|
||||||
Propel::init(PATH_CORE . 'config' . PATH_SEP . '_databases_.php');
|
Propel::init(PATH_CORE . 'config' . PATH_SEP . '_databases_.php');
|
||||||
//Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
|
|
||||||
|
|
||||||
//Enable RBAC
|
//Enable RBAC
|
||||||
$rbac = RBAC::getSingleton(PATH_DATA, session_id());
|
$rbac = RBAC::getSingleton(PATH_DATA, session_id());
|
||||||
@@ -226,7 +208,7 @@ try {
|
|||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
||||||
$systemUtcTimeZone = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1;
|
$systemUtcTimeZone = (int) ($arraySystemConfiguration['system_utc_time_zone']) == 1;
|
||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
@@ -234,6 +216,12 @@ try {
|
|||||||
|
|
||||||
define('TIME_ZONE', ini_get('date.timezone'));
|
define('TIME_ZONE', ini_get('date.timezone'));
|
||||||
|
|
||||||
|
//UTC time zone
|
||||||
|
if ($systemUtcTimeZone) {
|
||||||
|
$sNow = convertToSystemUtcTimeZone($sNow);
|
||||||
|
$dateSystem = convertToSystemUtcTimeZone($dateSystem);
|
||||||
|
}
|
||||||
|
|
||||||
//Processing
|
//Processing
|
||||||
eprintln('Processing workspace: ' . $workspace, 'green');
|
eprintln('Processing workspace: ' . $workspace, 'green');
|
||||||
|
|
||||||
@@ -261,7 +249,7 @@ try {
|
|||||||
case 'timereventcron':
|
case 'timereventcron':
|
||||||
$timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
|
$timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
|
||||||
|
|
||||||
$timerEvent->startContinueCaseByTimerEvent(date('Y-m-d H:i:s'), true);
|
$timerEvent->startContinueCaseByTimerEvent($sNow, true);
|
||||||
break;
|
break;
|
||||||
case 'sendnotificationscron':
|
case 'sendnotificationscron':
|
||||||
sendNotifications();
|
sendNotifications();
|
||||||
@@ -434,7 +422,6 @@ function executePlugins()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Executing registered cron files
|
// Executing registered cron files
|
||||||
|
|
||||||
// -> Get registered cron files
|
// -> Get registered cron files
|
||||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||||
$cronFiles = $oPluginRegistry->getCronFiles();
|
$cronFiles = $oPluginRegistry->getCronFiles();
|
||||||
@@ -445,7 +432,7 @@ function executePlugins()
|
|||||||
/**
|
/**
|
||||||
* @var \ProcessMaker\Plugins\Interfaces\CronFile $cronFile
|
* @var \ProcessMaker\Plugins\Interfaces\CronFile $cronFile
|
||||||
*/
|
*/
|
||||||
foreach($cronFiles as $cronFile) {
|
foreach ($cronFiles as $cronFile) {
|
||||||
$path = PATH_PLUGINS . $cronFile->getNamespace() . PATH_SEP . 'bin' . PATH_SEP . $cronFile->getCronFile() . '.php';
|
$path = PATH_PLUGINS . $cronFile->getNamespace() . PATH_SEP . 'bin' . PATH_SEP . $cronFile->getCronFile() . '.php';
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
executeCustomCronFunction($path, $cronFile->getCronFile());
|
executeCustomCronFunction($path, $cronFile->getCronFile());
|
||||||
@@ -503,8 +490,8 @@ function calculateDuration()
|
|||||||
saveLog('calculateDuration', 'error', 'Error Calculating Duration: ' . $oError->getMessage());
|
saveLog('calculateDuration', 'error', 'Error Calculating Duration: ' . $oError->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
function calculateAppDuration()
|
function calculateAppDuration()
|
||||||
{
|
{
|
||||||
global $argvx;
|
global $argvx;
|
||||||
@@ -527,7 +514,6 @@ function calculateAppDuration()
|
|||||||
saveLog('calculateDurationByApp', 'error', 'Error Calculating Duration: ' . $oError->getMessage());
|
saveLog('calculateDurationByApp', 'error', 'Error Calculating Duration: ' . $oError->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
function executeEvents($sLastExecution, $sNow = null)
|
function executeEvents($sLastExecution, $sNow = null)
|
||||||
@@ -559,7 +545,6 @@ function executeEvents($sLastExecution, $sNow = null)
|
|||||||
|
|
||||||
setExecutionMessage("|- End Execution events");
|
setExecutionMessage("|- End Execution events");
|
||||||
setExecutionResultMessage("Processed $n");
|
setExecutionResultMessage("Processed $n");
|
||||||
//saveLog('executeEvents', 'action', $res );
|
|
||||||
} catch (Exception $oError) {
|
} catch (Exception $oError) {
|
||||||
setExecutionResultMessage('WITH ERRORS', 'error');
|
setExecutionResultMessage('WITH ERRORS', 'error');
|
||||||
eprintln(" '-" . $oError->getMessage(), 'red');
|
eprintln(" '-" . $oError->getMessage(), 'red');
|
||||||
@@ -581,10 +566,8 @@ function executeScheduledCases($sNow = null)
|
|||||||
setExecutionMessage("Executing the scheduled starting cases");
|
setExecutionMessage("Executing the scheduled starting cases");
|
||||||
setExecutionResultMessage('PROCESSING');
|
setExecutionResultMessage('PROCESSING');
|
||||||
|
|
||||||
$runDate = runDateForScheduledCases($sNow);
|
|
||||||
|
|
||||||
$oCaseScheduler = new CaseScheduler();
|
$oCaseScheduler = new CaseScheduler();
|
||||||
$oCaseScheduler->caseSchedulerCron($runDate, $log, 1);
|
$oCaseScheduler->caseSchedulerCron($sNow, $log, 1);
|
||||||
|
|
||||||
foreach ($log as $value) {
|
foreach ($log as $value) {
|
||||||
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
||||||
@@ -601,7 +584,7 @@ function executeScheduledCases($sNow = null)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function runDateForScheduledCases($sNow)
|
function convertToSystemUtcTimeZone($sNow)
|
||||||
{
|
{
|
||||||
global $arraySystemConfiguration;
|
global $arraySystemConfiguration;
|
||||||
|
|
||||||
@@ -610,7 +593,7 @@ function runDateForScheduledCases($sNow)
|
|||||||
$systemUtcTimeZone = false;
|
$systemUtcTimeZone = false;
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
|
||||||
$systemUtcTimeZone = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1;
|
$systemUtcTimeZone = (int) ($arraySystemConfiguration['system_utc_time_zone']) == 1;
|
||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
@@ -898,8 +881,8 @@ function setExecutionResultMessage($m, $t = '')
|
|||||||
|
|
||||||
eprintln("[$m]", $c);
|
eprintln("[$m]", $c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
function fillReportByUser()
|
function fillReportByUser()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -1017,7 +1000,6 @@ function synchronizeGmailLabels()
|
|||||||
saveLog("synchronizeGmailLabels", "error", "Error when synchronizing Gmail labels: " . $e->getMessage());
|
saveLog("synchronizeGmailLabels", "error", "Error when synchronizing Gmail labels: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|
||||||
function sendNotifications()
|
function sendNotifications()
|
||||||
|
|||||||
@@ -1,117 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function mktimeDate ($date)
|
use ProcessMaker\BusinessModel\Files\Cron;
|
||||||
{
|
|
||||||
$arrayAux = getdate( strtotime( $date ) );
|
|
||||||
|
|
||||||
$mktDate = mktime( $arrayAux["hours"], $arrayAux["minutes"], $arrayAux["seconds"], $arrayAux["mon"], $arrayAux["mday"], $arrayAux["year"] );
|
$option = isset($_REQUEST["option"]) ? $_REQUEST["option"] : null;
|
||||||
|
|
||||||
return $mktDate;
|
$response = [];
|
||||||
}
|
|
||||||
|
|
||||||
function cronArraySet ($str, $filter)
|
|
||||||
{
|
|
||||||
$arrayAux = explode( "|", $str );
|
|
||||||
|
|
||||||
$date = "";
|
|
||||||
$workspace = "";
|
|
||||||
$action = "";
|
|
||||||
$status = "";
|
|
||||||
$description = trim( $arrayAux[0] );
|
|
||||||
|
|
||||||
if (count( $arrayAux ) > 1) {
|
|
||||||
$date = (isset( $arrayAux[0] )) ? trim( $arrayAux[0] ) : "";
|
|
||||||
$workspace = (isset( $arrayAux[1] )) ? trim( $arrayAux[1] ) : "";
|
|
||||||
$action = (isset( $arrayAux[2] )) ? trim( $arrayAux[2] ) : "";
|
|
||||||
$status = (isset( $arrayAux[3] )) ? trim( $arrayAux[3] ) : "";
|
|
||||||
$description = (isset( $arrayAux[4] )) ? trim( $arrayAux[4] ) : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
$mktDate = (! empty( $date )) ? mktimeDate( $date ) : 0;
|
|
||||||
|
|
||||||
//Filter
|
|
||||||
$sw = 1;
|
|
||||||
|
|
||||||
if ($filter["workspace"] != "ALL" && $workspace != $filter["workspace"]) {
|
|
||||||
$sw = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filter["status"] != "ALL") {
|
|
||||||
switch ($filter["status"]) {
|
|
||||||
case "COMPLETED":
|
|
||||||
if ($status != "action") {
|
|
||||||
$sw = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "FAILED":
|
|
||||||
if ($status == "action") {
|
|
||||||
$sw = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! empty( $filter["dateFrom"] ) && $mktDate > 0) {
|
|
||||||
if (! (mktimeDate( $filter["dateFrom"] ) <= $mktDate)) {
|
|
||||||
$sw = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! empty( $filter["dateTo"] ) && $mktDate > 0) {
|
|
||||||
if (! ($mktDate <= mktimeDate( $filter["dateTo"] . " 23:59:59" ))) {
|
|
||||||
$sw = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$arrayData = array ();
|
|
||||||
|
|
||||||
if ($sw == 1) {
|
|
||||||
$arrayData = array ("DATE" => $date, "ACTION" => $action, "STATUS" => $status, "DESCRIPTION" => $description
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $arrayData;
|
|
||||||
}
|
|
||||||
|
|
||||||
function cronDataGet ($filter, $r, $i)
|
|
||||||
{
|
|
||||||
$i = $i + 1;
|
|
||||||
|
|
||||||
$arrayData = array ();
|
|
||||||
$strAux = null;
|
|
||||||
$numRec = 0;
|
|
||||||
$cont = 0;
|
|
||||||
|
|
||||||
$file = PATH_DATA . "log" . PATH_SEP . "cron.log";
|
|
||||||
|
|
||||||
if (file_exists($file)) {
|
|
||||||
$arrayFileData = file($file);
|
|
||||||
|
|
||||||
for ($k = 0; $k <= count($arrayFileData) - 1; $k++) {
|
|
||||||
$strAux = $arrayFileData[$k];
|
|
||||||
|
|
||||||
if (!empty($strAux)) {
|
|
||||||
$arrayAux = cronArraySet($strAux, $filter);
|
|
||||||
|
|
||||||
if (count($arrayAux) > 0) {
|
|
||||||
$cont = $cont + 1;
|
|
||||||
|
|
||||||
if ($cont >= $i && count($arrayData) + 1 <= $r) {
|
|
||||||
$arrayData[] = $arrayAux;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$numRec = $cont;
|
|
||||||
|
|
||||||
return array($numRec, $arrayData);
|
|
||||||
}
|
|
||||||
|
|
||||||
$option = (isset( $_REQUEST["option"] )) ? $_REQUEST["option"] : null;
|
|
||||||
|
|
||||||
$response = array ();
|
|
||||||
|
|
||||||
switch ($option) {
|
switch ($option) {
|
||||||
case "LST":
|
case "LST":
|
||||||
@@ -121,40 +14,42 @@ switch ($option) {
|
|||||||
$dateFrom = $_REQUEST["dateFrom"];
|
$dateFrom = $_REQUEST["dateFrom"];
|
||||||
$dateTo = $_REQUEST["dateTo"];
|
$dateTo = $_REQUEST["dateTo"];
|
||||||
|
|
||||||
$arrayFilter = array ("workspace" => $workspace,"status" => $status,"dateFrom" => str_replace( "T00:00:00", null, $dateFrom ),"dateTo" => str_replace( "T00:00:00", null, $dateTo )
|
$filter = [
|
||||||
);
|
"workspace" => $workspace,
|
||||||
|
"status" => $status,
|
||||||
|
"dateFrom" => str_replace("T00:00:00", null, $dateFrom),
|
||||||
|
"dateTo" => str_replace("T00:00:00", null, $dateTo)
|
||||||
|
];
|
||||||
|
|
||||||
$limit = isset( $_REQUEST["limit"] ) ? $_REQUEST["limit"] : $pageSize;
|
$start = (int) isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
|
||||||
$start = isset( $_REQUEST["start"] ) ? $_REQUEST["start"] : 0;
|
$limit = (int) isset($_REQUEST["limit"]) ? $_REQUEST["limit"] : $pageSize;
|
||||||
|
|
||||||
list ($numRec, $data) = cronDataGet( $arrayFilter, $limit, $start );
|
$cron = new Cron();
|
||||||
|
list ($count, $data) = $cron->getData($filter, $start, $limit);
|
||||||
|
|
||||||
$response = array ("success" => true,"resultTotal" => $numRec,"resultRoot" => $data
|
$response = [
|
||||||
);
|
"success" => true,
|
||||||
|
"resultTotal" => $count,
|
||||||
|
"resultRoot" => $data
|
||||||
|
];
|
||||||
break;
|
break;
|
||||||
case "EMPTY":
|
case "EMPTY":
|
||||||
$status = 1;
|
$status = 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$file = PATH_DATA . "log" . PATH_SEP . "cron.log";
|
$file = PATH_DATA . "log" . PATH_SEP . "cron.log";
|
||||||
|
if (file_exists($file)) {
|
||||||
if (file_exists( $file )) {
|
unlink($file);
|
||||||
//file_put_contents($file, null);
|
|
||||||
unlink( $file );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response["status"] = "OK";
|
$response["status"] = "OK";
|
||||||
G::auditLog("ClearCron");
|
G::auditLog("ClearCron");
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$response["message"] = $e->getMessage();
|
$response["message"] = $e->getMessage();
|
||||||
$status = 0;
|
$status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($status == 0) {
|
if ($status == 0) {
|
||||||
$response["status"] = "ERROR";
|
$response["status"] = "ERROR";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo G::json_encode( $response );
|
echo G::json_encode($response);
|
||||||
|
|
||||||
|
|||||||
146
workflow/engine/src/ProcessMaker/BusinessModel/Files/Cron.php
Normal file
146
workflow/engine/src/ProcessMaker/BusinessModel/Files/Cron.php
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ProcessMaker\BusinessModel\Files;
|
||||||
|
|
||||||
|
use ProcessMaker\Util\DateTime;
|
||||||
|
|
||||||
|
class Cron
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Cron file log path.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $filepath = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*/
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
$this->setFilepath(PATH_DATA . 'log' . PATH_SEP . 'cron.log');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the cron file log path.
|
||||||
|
*
|
||||||
|
* @param string $filepath
|
||||||
|
*/
|
||||||
|
public function setFilepath($filepath)
|
||||||
|
{
|
||||||
|
$this->filepath = $filepath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data from file.
|
||||||
|
*
|
||||||
|
* @param array $filter
|
||||||
|
* @param int $start
|
||||||
|
* @param int $limit
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getData($filter, $start = 0, $limit = 20)
|
||||||
|
{
|
||||||
|
if (!file_exists($this->filepath)) {
|
||||||
|
return [0, []];
|
||||||
|
}
|
||||||
|
$result = [];
|
||||||
|
$count = 0;
|
||||||
|
$array = file($this->filepath);
|
||||||
|
foreach ($array as $line) {
|
||||||
|
if (empty($line)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$row = $this->getRow($line, $filter);
|
||||||
|
if ($row === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$count = $count + 1;
|
||||||
|
if ($start < $count && count($result) < $limit) {
|
||||||
|
$row['DATE'] = DateTime::convertUtcToTimeZone($row['DATE']);
|
||||||
|
$result[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [$count, $result];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get registry from string line.
|
||||||
|
*
|
||||||
|
* @param string $line
|
||||||
|
* @param array $filter
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getRow($line, $filter)
|
||||||
|
{
|
||||||
|
$row = explode('|', $line);
|
||||||
|
$date = '';
|
||||||
|
$workspace = '';
|
||||||
|
$action = '';
|
||||||
|
$status = '';
|
||||||
|
$description = trim($row[0]);
|
||||||
|
|
||||||
|
if (!empty($row)) {
|
||||||
|
$date = isset($row[0]) ? trim($row[0]) : '';
|
||||||
|
$workspace = isset($row[1]) ? trim($row[1]) : '';
|
||||||
|
$action = isset($row[2]) ? trim($row[2]) : '';
|
||||||
|
$status = isset($row[3]) ? trim($row[3]) : '';
|
||||||
|
$description = isset($row[4]) ? trim($row[4]) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$isValid = true;
|
||||||
|
if ($filter['workspace'] != 'ALL' && $workspace != $filter['workspace']) {
|
||||||
|
$isValid = false;
|
||||||
|
}
|
||||||
|
if ($filter['status'] != 'ALL') {
|
||||||
|
switch ($filter['status']) {
|
||||||
|
case 'COMPLETED':
|
||||||
|
if ($status != 'action') {
|
||||||
|
$isValid = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'FAILED':
|
||||||
|
if ($status == 'action') {
|
||||||
|
$isValid = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$mktDate = !empty($date) ? $this->mktimeDate($date) : 0;
|
||||||
|
if (!empty($filter['dateFrom']) && $mktDate > 0) {
|
||||||
|
if (!($this->mktimeDate($filter['dateFrom']) <= $mktDate)) {
|
||||||
|
$isValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($filter['dateTo']) && $mktDate > 0) {
|
||||||
|
if (!($mktDate <= $this->mktimeDate($filter['dateTo'] . ' 23:59:59'))) {
|
||||||
|
$isValid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($isValid) {
|
||||||
|
return [
|
||||||
|
'DATE' => $date,
|
||||||
|
'ACTION' => $action,
|
||||||
|
'STATUS' => $status,
|
||||||
|
'DESCRIPTION' => $description
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a timestamp from a string value.
|
||||||
|
*
|
||||||
|
* @param string $date
|
||||||
|
* @return int|false
|
||||||
|
*/
|
||||||
|
public function mktimeDate($date)
|
||||||
|
{
|
||||||
|
$array = getdate(strtotime($date));
|
||||||
|
$mktime = mktime($array['hours'], $array['minutes'], $array['seconds'], $array['mon'], $array['mday'], $array['year']);
|
||||||
|
return $mktime;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user