BUG 5737 Add logs to new case with CaseScheduler SOLVED
I add logs to CaseScheduler I add logs to executeEvents
This commit is contained in:
@@ -8,7 +8,7 @@ error_reporting(E_ALL);
|
|||||||
ini_set('memory_limit', '128M');
|
ini_set('memory_limit', '128M');
|
||||||
|
|
||||||
if (!defined('SYS_LANG')) {
|
if (!defined('SYS_LANG')) {
|
||||||
define('SYS_LANG', 'en');
|
define('SYS_LANG', 'en');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('PATH_HOME')) {
|
if (!defined('PATH_HOME')) {
|
||||||
@@ -169,7 +169,7 @@ if (!defined('SYS_SYS')) {
|
|||||||
unlink(PATH_CORE . 'config/_databases_.php');
|
unlink(PATH_CORE . 'config/_databases_.php');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
processWorkspace();
|
processWorkspace();
|
||||||
}
|
}
|
||||||
|
|
||||||
//finally update the file
|
//finally update the file
|
||||||
@@ -206,8 +206,8 @@ function resendEmails() {
|
|||||||
$aSpoolWarnings = $oSpool->getWarnings();
|
$aSpoolWarnings = $oSpool->getWarnings();
|
||||||
if( $aSpoolWarnings !== false ) {
|
if( $aSpoolWarnings !== false ) {
|
||||||
foreach($aSpoolWarnings as $sWarning){
|
foreach($aSpoolWarnings as $sWarning){
|
||||||
print('MAIL SPOOL WARNING: ' . $sWarning."\n");
|
print('MAIL SPOOL WARNING: ' . $sWarning."\n");
|
||||||
saveLog('resendEmails', 'warning', 'MAIL SPOOL WARNING: ' . $sWarning);
|
saveLog('resendEmails', 'warning', 'MAIL SPOOL WARNING: ' . $sWarning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setExecutionResultMessage('DONE');
|
setExecutionResultMessage('DONE');
|
||||||
@@ -289,6 +289,8 @@ function executeEvents($sLastExecution, $sNow=null) {
|
|||||||
|
|
||||||
global $sFilter;
|
global $sFilter;
|
||||||
global $sNow;
|
global $sNow;
|
||||||
|
$log = array();
|
||||||
|
|
||||||
if($sFilter!='' && strpos($sFilter, 'events') === false) return false;
|
if($sFilter!='' && strpos($sFilter, 'events') === false) return false;
|
||||||
|
|
||||||
setExecutionMessage("Executing events");
|
setExecutionMessage("Executing events");
|
||||||
@@ -296,7 +298,10 @@ function executeEvents($sLastExecution, $sNow=null) {
|
|||||||
try {
|
try {
|
||||||
$oAppEvent = new AppEvent();
|
$oAppEvent = new AppEvent();
|
||||||
saveLog('executeEvents', 'action', "Executing Events $sLastExecution, $sNow ");
|
saveLog('executeEvents', 'action', "Executing Events $sLastExecution, $sNow ");
|
||||||
$n = $oAppEvent->executeEvents($sNow);
|
$n = $oAppEvent->executeEvents($sNow, false, $log);
|
||||||
|
foreach ($log as $value) {
|
||||||
|
saveLog('executeEvents', 'action', "Execute Events : $value, $sNow ");
|
||||||
|
}
|
||||||
setExecutionMessage("|- End Execution events");
|
setExecutionMessage("|- End Execution events");
|
||||||
setExecutionResultMessage("Processed $n");
|
setExecutionResultMessage("Processed $n");
|
||||||
//saveLog('executeEvents', 'action', $res );
|
//saveLog('executeEvents', 'action', $res );
|
||||||
@@ -312,6 +317,8 @@ function executeScheduledCases($sNow=null){
|
|||||||
try{
|
try{
|
||||||
global $sFilter;
|
global $sFilter;
|
||||||
global $sNow;
|
global $sNow;
|
||||||
|
$log = array();
|
||||||
|
|
||||||
if($sFilter!='' && strpos($sFilter, 'scheduler') === false) return false;
|
if($sFilter!='' && strpos($sFilter, 'scheduler') === false) return false;
|
||||||
|
|
||||||
setExecutionMessage("Executing the scheduled starting cases");
|
setExecutionMessage("Executing the scheduled starting cases");
|
||||||
@@ -319,10 +326,11 @@ function executeScheduledCases($sNow=null){
|
|||||||
|
|
||||||
$sNow = isset($sNow)? $sNow: date('Y-m-d H:i:s');
|
$sNow = isset($sNow)? $sNow: date('Y-m-d H:i:s');
|
||||||
$oCaseScheduler = new CaseScheduler;
|
$oCaseScheduler = new CaseScheduler;
|
||||||
$oCaseScheduler->caseSchedulerCron($sNow);
|
|
||||||
$log = array();
|
$oCaseScheduler->caseSchedulerCron($sNow, $log);
|
||||||
foreach ($log as $value){
|
|
||||||
saveLog('executeScheduledCases', 'action', "OK Case# $value");
|
foreach ($log as $value) {
|
||||||
|
saveLog('executeScheduledCases', 'action', "OK Case# $value");
|
||||||
}
|
}
|
||||||
setExecutionResultMessage('DONE');
|
setExecutionResultMessage('DONE');
|
||||||
} catch(Exception $oError){
|
} catch(Exception $oError){
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class AppEvent extends BaseAppEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeEvents($sNow, $debug=false) {
|
function executeEvents($sNow, $debug=false, &$log=array()) {
|
||||||
|
|
||||||
require_once 'classes/model/Configuration.php';
|
require_once 'classes/model/Configuration.php';
|
||||||
require_once 'classes/model/Triggers.php';
|
require_once 'classes/model/Triggers.php';
|
||||||
@@ -240,8 +240,9 @@ class AppEvent extends BaseAppEvent {
|
|||||||
require_once 'classes/model/Application.php';
|
require_once 'classes/model/Application.php';
|
||||||
$oApp = ApplicationPeer::retrieveByPk($aRow['APP_UID']);
|
$oApp = ApplicationPeer::retrieveByPk($aRow['APP_UID']);
|
||||||
$oEv = EventPeer::retrieveByPk($aRow['EVN_UID']);
|
$oEv = EventPeer::retrieveByPk($aRow['EVN_UID']);
|
||||||
|
$log[] = 'Event ' . $oEv->getEvnDescription() . ' with ID ' . $aRow['EVN_UID'];
|
||||||
println("\nOK+ event \"".$oEv->getEvnDescription()."\" with ID {$aRow['EVN_UID']} was found");
|
|
||||||
|
println("\nOK+ event \"".$oEv->getEvnDescription()."\" with ID {} was found");
|
||||||
println(" - PROCESS................".$aRow['PRO_UID']);
|
println(" - PROCESS................".$aRow['PRO_UID']);
|
||||||
println(" - APPLICATION............".$aRow['APP_UID']." CASE #".$oApp->getAppNumber());
|
println(" - APPLICATION............".$aRow['APP_UID']." CASE #".$oApp->getAppNumber());
|
||||||
println(" - ACTION DATE............".$aRow['APP_EVN_ACTION_DATE']);
|
println(" - ACTION DATE............".$aRow['APP_EVN_ACTION_DATE']);
|
||||||
@@ -251,6 +252,7 @@ class AppEvent extends BaseAppEvent {
|
|||||||
|
|
||||||
if ($aRow['TRI_UID'] == '') {
|
if ($aRow['TRI_UID'] == '') {
|
||||||
//a rare case when the tri_uid is not set.
|
//a rare case when the tri_uid is not set.
|
||||||
|
$log[] = " (!) Any trigger was set................................SKIPPED and will be CLOSED";
|
||||||
if($debug) println(" (!) Any trigger was set................................SKIPPED and will be CLOSED");
|
if($debug) println(" (!) Any trigger was set................................SKIPPED and will be CLOSED");
|
||||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
$oAppEvent->setAppEvnStatus('CLOSE');
|
||||||
$oAppEvent->save();
|
$oAppEvent->save();
|
||||||
@@ -260,6 +262,7 @@ class AppEvent extends BaseAppEvent {
|
|||||||
$oTrigger = TriggersPeer::retrieveByPk($aRow['TRI_UID']);
|
$oTrigger = TriggersPeer::retrieveByPk($aRow['TRI_UID']);
|
||||||
if( !is_object($oTrigger) ){
|
if( !is_object($oTrigger) ){
|
||||||
//the trigger record doesn't exist..
|
//the trigger record doesn't exist..
|
||||||
|
$log[] = ' (!) The trigger ' . $aRow['TRI_UID'] . ' ' . $oTrigger->getTriTitle() . " doesn't exist.......SKIPPED and will be CLOSED";
|
||||||
if($debug) println(" (!) The trigger {$aRow['TRI_UID']} {$oTrigger->getTriTitle()} doesn't exist.......SKIPPED and will be CLOSED");
|
if($debug) println(" (!) The trigger {$aRow['TRI_UID']} {$oTrigger->getTriTitle()} doesn't exist.......SKIPPED and will be CLOSED");
|
||||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
$oAppEvent->setAppEvnStatus('CLOSE');
|
||||||
$oAppEvent->save();
|
$oAppEvent->save();
|
||||||
@@ -276,6 +279,7 @@ class AppEvent extends BaseAppEvent {
|
|||||||
$oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
|
$oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
|
||||||
|
|
||||||
if( sizeof($_SESSION['TRIGGER_DEBUG']['ERRORS']) == 0 ){
|
if( sizeof($_SESSION['TRIGGER_DEBUG']['ERRORS']) == 0 ){
|
||||||
|
$log[] = ' - The trigger ' . $oTrigger->getTriTitle() . ' was executed successfully!';
|
||||||
if($debug) println(" - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!");
|
if($debug) println(" - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!");
|
||||||
//g::pr($aFields);
|
//g::pr($aFields);
|
||||||
$aFields['APP_DATA'] = $oPMScript->aFields;
|
$aFields['APP_DATA'] = $oPMScript->aFields;
|
||||||
@@ -283,6 +287,7 @@ class AppEvent extends BaseAppEvent {
|
|||||||
$oAppEvent->setAppEvnStatus('CLOSE');
|
$oAppEvent->setAppEvnStatus('CLOSE');
|
||||||
} else {
|
} else {
|
||||||
if($debug) {
|
if($debug) {
|
||||||
|
$log[] = ' - The trigger ' . $aRow['TRI_UID'] . ' throw some errors!';
|
||||||
println(" - The trigger {$aRow['TRI_UID']} throw some errors!");
|
println(" - The trigger {$aRow['TRI_UID']} throw some errors!");
|
||||||
print_r($_SESSION['TRIGGER_DEBUG']['ERRORS']);
|
print_r($_SESSION['TRIGGER_DEBUG']['ERRORS']);
|
||||||
}
|
}
|
||||||
@@ -297,6 +302,7 @@ class AppEvent extends BaseAppEvent {
|
|||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
catch (Exception $oError) {
|
catch (Exception $oError) {
|
||||||
|
$log[] = ' Error execute event : ' . $oError->getMessage();
|
||||||
die($oError->getMessage());
|
die($oError->getMessage());
|
||||||
return $oError->getMessage();
|
return $oError->getMessage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -462,7 +462,7 @@ class CaseScheduler extends BaseCaseScheduler {
|
|||||||
|
|
||||||
$caseId = $result->caseId;
|
$caseId = $result->caseId;
|
||||||
$caseNumber = $result->caseNumber;
|
$caseNumber = $result->caseNumber;
|
||||||
$log[]=$caseNumber. ' was created!, ProcessID: '.$aRow['PRO_UID'];
|
$log[] = $caseNumber. ' was created!, ProcessID: '.$aRow['PRO_UID'];
|
||||||
$paramsLog ['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags ( $result->message );
|
$paramsLog ['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags ( $result->message );
|
||||||
$paramsLogResult = 'SUCCESS';
|
$paramsLogResult = 'SUCCESS';
|
||||||
|
|
||||||
@@ -585,7 +585,7 @@ class CaseScheduler extends BaseCaseScheduler {
|
|||||||
eprintln("OK+ CASE #{$result->caseNumber} was created!", 'green');
|
eprintln("OK+ CASE #{$result->caseNumber} was created!", 'green');
|
||||||
$caseId = $result->caseId;
|
$caseId = $result->caseId;
|
||||||
$caseNumber = $result->caseNumber;
|
$caseNumber = $result->caseNumber;
|
||||||
$log[]=$caseNumber. ' was created!, ProcessID: '.$aRow['PRO_UID'];
|
$log[] = $caseNumber. ' was created!, ProcessID: '.$aRow['PRO_UID'];
|
||||||
$paramsLog ['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags ( $result->message );
|
$paramsLog ['WS_CREATE_CASE_STATUS'] = "Case " . $caseNumber . " " . strip_tags ( $result->message );
|
||||||
$paramsLogResult = 'SUCCESS';
|
$paramsLogResult = 'SUCCESS';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user