, timerevent and messageEvent

add message

HOR-779

I used singleton

observations

.

json

.

I fixed some observations

HOR-779
This commit is contained in:
Paula V. Quispe
2016-07-14 16:43:56 -04:00
parent 6bd77bf6e5
commit 57dee44193
8 changed files with 602 additions and 14 deletions

View File

@@ -143,6 +143,7 @@ try {
Bootstrap::registerClass('SolrUpdateDocument', PATH_HOME . 'engine/classes/entities/SolrUpdateDocument.php');
Bootstrap::registerClass('Xml_Node', PATH_GULLIVER . 'class.xmlDocument.php');
Bootstrap::registerClass('wsResponse', PATH_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.wsResponse.php');
Bootstrap::initVendors();
/*----------------------------------********---------------------------------*/
Bootstrap::registerClass('dashboards', PATH_HOME . 'engine/classes/class.dashboards.php');
@@ -278,6 +279,9 @@ try {
define('TIME_ZONE', ini_get('date.timezone'));
//Enable Monolog
Bootstrap::LoadSystem( 'monologProvider' );
//Processing
eprintln('Processing workspace: ' . $workspace, 'green');

View File

@@ -422,17 +422,67 @@ class MessageApplication
//Start and derivate new Case
$result = $ws->newCase($processUid, $messageEventDefinitionUserUid, $taskUid, $arrayVariable);
$arrayResult = json_decode(json_encode($result), true);
$arrayResult = \G::json_decode(\G::json_encode($result), true);
if ($arrayResult["status_code"] == 0) {
$applicationUid = $arrayResult["caseId"];
$appUid = $arrayResult["caseId"];
$appNumber = $arrayResult["caseNumber"];
$this->syslog(
200
,'Case created'
,'CREATED-NEW-CASE'
,''//timeZone
,$messageEventDefinitionUserUid
,$processUid
,$taskUid
,$appUid
,$appNumber
);
$result = $ws->derivateCase($messageEventDefinitionUserUid, $applicationUid, 1);
$arrayResult = \G::json_decode(\G::json_encode($result), true);
if ($arrayResult["status_code"] == 0) {
$this->syslog(
200
,'Case routed'
,'ROUTED-NEW-CASE'
,''//timeZone
,$messageEventDefinitionUserUid
,$processUid
,$taskUid
,$appUid
,$appNumber
,'1'//Del Index
);
} else {
$this->syslog(
500
,'Failed case routed '.$arrayResult["message"]
,'ROUTED-NEW-CASE'
,''//timeZone
,$messageEventDefinitionUserUid
,$processUid
,$taskUid
,$appUid
,$appNumber
);
}
$flagCatched = true;
//Counter
$counterStartMessageEvent++;
} else {
$this->syslog(
500
,'Failed case created '.$arrayResult["message"]
,'CREATED-NEW-CASE'
,''//timeZone
,$messageEventDefinitionUserUid
,$processUid
,$taskUid
);
}
}
break;
@@ -465,8 +515,37 @@ class MessageApplication
$arrayApplicationData["APP_DATA"] = array_merge($arrayApplicationData["APP_DATA"], $arrayVariable);
$arrayResult = $case->updateCase($applicationUid, $arrayApplicationData);
$appNumber = isset($arrayApplicationData["APP_DATA"]["APP_NUMBER"]) ? $arrayApplicationData["APP_DATA"]["APP_NUMBER"] : '';
$result = $ws->derivateCase($userUid, $applicationUid, $delIndex);
$arrayResult = \G::json_decode(\G::json_encode($result), true);
if ($arrayResult["status_code"] == 0) {
$this->syslog(
200
,'Case routed'
,'ROUTED-NEW-CASE'
,''//timeZone
,$userUid
,$processUid
,$taskUid
,$applicationUid
,$appNumber
,$delIndex
);
} else {
$this->syslog(
500
,'Failed case routed'
,'ROUTED-NEW-CASE'
,''//timeZone
,$userUid
,$processUid
,$taskUid
,$applicationUid
,$appNumber
,$delIndex
);
}
$flagCatched = true;
}
@@ -497,11 +576,95 @@ class MessageApplication
$common->frontEndShow("TEXT", "Total cases started: " . $counterStartMessageEvent);
$common->frontEndShow("TEXT", "Total cases continued: " . $counterIntermediateCatchMessageEvent);
$common->frontEndShow("TEXT", "Total Message-Events pending: " . ($totalMessageEvent - ($counterStartMessageEvent + $counterIntermediateCatchMessageEvent)));
$this->syslog(
200
,'Total Message-Events unread '. $totalMessageEvent
,'RESUME'//Action
);
$this->syslog(
200
,'Total cases started '. $counterStartMessageEvent
,'RESUME'//Action
);
$this->syslog(
200
,'Total cases continued '. $counterIntermediateCatchMessageEvent
,'RESUME'//Action
);
$this->syslog(
200
,'Total Message-Events pending '. ($totalMessageEvent - ($counterStartMessageEvent + $counterIntermediateCatchMessageEvent))
,'RESUME'//Action
);
$common->frontEndShow("END");
} catch (\Exception $e) {
throw $e;
}
}
/**
* The Syslog register the information in Monolog Class
*
* @param int $level DEBUG=100 INFO=200 NOTICE=250 WARNING=300 ERROR=400 CRITICAL=500
* @param string $message
* @param string $ipClient for Context information
* @param string $action for Context information
* @param string $timeZone for Context information
* @param string $workspace for Context information
* @param string $usrUid for Context information
* @param string $proUid for Context information
* @param string $tasUid for Context information
* @param string $appUid for Context information
* @param string $delIndex for Context information
* @param string $stepUid for Context information
* @param string $triUid for Context information
* @param string $outDocUid for Context information
* @param string $inpDocUid for Context information
* @param string $url for Context information
*
* return void
*/
private function syslog(
$level,
$message,
$action='',
$timeZone='',
$usrUid='',
$proUid='',
$tasUid='',
$appUid='',
$appNumber='',
$delIndex='',
$stepUid='',
$triUid='',
$outDocUid='',
$inpDocUid='',
$url=''
)
{
try {
$aContext = array(
'ip' => \G::getIpAddress()
,'action' => $action
,'TimeZone' => $timeZone
,'workspace'=> (defined("SYS_SYS"))? SYS_SYS : "Wokspace Undefined"
,'usrUid' => $usrUid
,'proUid' => $proUid
,'tasUid' => $tasUid
,'appUid' => $appUid
,'appNumber'=> $appNumber
,'delIndex' => $delIndex
,'stepUid' => $stepUid
,'triUid' => $triUid
,'outDocUid'=> $outDocUid
,'inpDocUid'=> $inpDocUid
,'url' => $url
);
\Bootstrap::registerMonolog('MessageEventCron', $level, $message, $aContext, SYS_SYS, 'messageevent.log');
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -1153,6 +1153,70 @@ class TimerEvent
}
}
/**
* The Syslog register the information in Monolog Class
*
* @param int $level DEBUG=100 INFO=200 NOTICE=250 WARNING=300 ERROR=400 CRITICAL=500
* @param string $message
* @param string $ipClient for Context information
* @param string $action for Context information
* @param string $timeZone for Context information
* @param string $workspace for Context information
* @param string $usrUid for Context information
* @param string $proUid for Context information
* @param string $tasUid for Context information
* @param string $appUid for Context information
* @param string $delIndex for Context information
* @param string $stepUid for Context information
* @param string $triUid for Context information
* @param string $outDocUid for Context information
* @param string $inpDocUid for Context information
* @param string $url for Context information
*
* return void
*/
private function syslog(
$level,
$message,
$action='',
$timeZone='',
$usrUid='',
$proUid='',
$tasUid='',
$appUid='',
$appNumber='',
$delIndex='',
$stepUid='',
$triUid='',
$outDocUid='',
$inpDocUid='',
$url=''
)
{
try {
$aContext = array(
'ip' => \G::getIpAddress()
,'action' => $action
,'TimeZone' => $timeZone
,'workspace'=> (defined("SYS_SYS"))? SYS_SYS : "Wokspace Undefined"
,'usrUid' => $usrUid
,'proUid' => $proUid
,'tasUid' => $tasUid
,'appUid' => $appUid
,'appNumber'=> $appNumber
,'delIndex' => $delIndex
,'stepUid' => $stepUid
,'triUid' => $triUid
,'outDocUid'=> $outDocUid
,'inpDocUid'=> $inpDocUid
,'url' => $url
);
\Bootstrap::registerMonolog('TimerEventCron', $level, $message, $aContext, SYS_SYS, 'timerevent.log');
} catch (\Exception $e) {
throw $e;
}
}
/**
* Start/Continue case by Timer-Event
*
@@ -1183,6 +1247,12 @@ class TimerEvent
$common->frontEndShow("START");
$this->log("START-NEW-CASES", "Date \"$datetime (UTC +00:00)\": Start new cases");
$this->syslog(
200
,'Start new cases'
,'START-NEW-CASES'
,$datetime
);
//Query
$criteria = $this->getTimerEventCriteria();
@@ -1317,7 +1387,7 @@ class TimerEvent
//Start new case
$result = $ws->newCase($arrayTimerEventData["PRJ_UID"], "", $taskUid, array());
$arrayResult = json_decode(json_encode($result), true);
$arrayResult = \G::json_decode(\G::json_encode($result), true);
if ($arrayResult["status_code"] == 0) {
$applicationUid = $arrayResult["caseId"];
@@ -1327,25 +1397,69 @@ class TimerEvent
$common->frontEndShow("TEXT", "> Routing the case #$applicationNumber...");
$this->log("CREATED-NEW-CASE", "Case #$applicationNumber created, APP_UID: $applicationUid, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
$this->syslog(
200
,'Case created'
,'CREATED-NEW-CASE'
,$datetime
,''//UsrUid
,$arrayTimerEventData["PRJ_UID"]
,$taskUid
,$applicationUid
,$applicationNumber
);
//Derivate new case
$result = $ws->derivateCase("", $applicationUid, 1);
$arrayResult = json_decode(json_encode($result), true);
$arrayResult = \G::json_decode(\G::json_encode($result), true);
if ($arrayResult["status_code"] == 0) {
$common->frontEndShow("TEXT", " - OK");
$this->log("ROUTED-NEW-CASE", "Case #$applicationNumber routed, APP_UID: $applicationUid, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
$this->syslog(
200
,'Case routed'
,'ROUTED-NEW-CASE'
,$datetime
,''//usrUid
,$arrayTimerEventData["PRJ_UID"]
,$taskUid
,$applicationUid
,$applicationNumber
,'1'//Del Index
);
} else {
$common->frontEndShow("TEXT", " - Failed: " . $arrayResult["message"]);
$this->log("ROUTED-NEW-CASE", "Failed: " . $arrayResult["message"] . ", Case: #$applicationNumber, APP_UID: $applicationUid, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
$this->syslog(
500
,'Failed case routed'
,'ROUTED-NEW-CASE'
,$datetime
,''//usrUid
,$arrayTimerEventData["PRJ_UID"]
,$taskUid
,$applicationUid
,$applicationNumber
,'1'//Del Index
);
}
} else {
$common->frontEndShow("TEXT", " - Failed: " . $arrayResult["message"]);
$this->log("CREATED-NEW-CASE", "Failed: " . $arrayResult["message"] . ", PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
$this->syslog(
500
,'Failed case created '.$arrayResult["message"]
,'CREATED-NEW-CASE'
,$datetime
,''//usrUid
,$arrayTimerEventData["PRJ_UID"]
,$taskUid
);
}
$flagRecord = true;
@@ -1356,14 +1470,32 @@ class TimerEvent
$common->frontEndShow("TEXT", "Not exists any record to start a new case, on date \"$datetime (UTC +00:00)\"");
$this->log("NO-RECORDS", "Not exists any record to start a new case");
$this->syslog(
200
,'Not exists any record to start a new case'
,'NO-RECORDS'
,$datetime
);
}
$common->frontEndShow("END");
$this->log("END-NEW-CASES", "Date \"$datetime (UTC +00:00)\": End new cases");
$this->syslog(
200
,'End new cases'
,'END-NEW-CASES'
,$datetime
);
//Intermediate Catch Timer-Event (continue the case) ///////////////////////////////////////////////////////
$this->log("START-CONTINUE-CASES", "Date \"$datetime (UTC +00:00)\": Start continue the cases");
$this->syslog(
200
,'Start continue the cases'
,'START-CONTINUE-CASES'
,$datetime
);
//Query
$criteriaMain = $this->getTimerEventCriteria();
@@ -1533,7 +1665,7 @@ class TimerEvent
//Derivate case
$result = $ws->derivateCase("", $applicationUid, $delIndex);
$arrayResult = json_decode(json_encode($result), true);
$arrayResult = \G::json_decode(\G::json_encode($result), true);
if ($arrayResult["status_code"] == 0) {
$common->frontEndShow("TEXT", " - OK");
@@ -1543,12 +1675,34 @@ class TimerEvent
$common->frontEndShow("TEXT", " - Failed: " . $arrayResult["message"]);
$this->log("CONTINUED-CASE", "Failed: " . $arrayResult["message"] . ", Case: #$applicationNumber, APP_UID: $applicationUid, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
$this->syslog(
500
,'Failed '.$arrayResult["message"]
,'CONTINUED-CASE'
,$datetime
,''//usrUid
,$arrayTimerEventData["PRJ_UID"]
,$tasUid
,$applicationUid
,$applicationNumber
);
}
$flagRecord = true;
}
} else {
$this->log("INVALID-CONTINUE-DATE", "Continue date: $continueCaseDate, Case: #$applicationNumber, APP_UID: $applicationUid, PRO_UID: " . $arrayTimerEventData["PRJ_UID"]);
$this->syslog(
200
,'Continue date '. $continueCaseDate
,'INVALID-CONTINUE-DATE'
,$datetime
,''//usrUid
,$arrayTimerEventData["PRJ_UID"]
,$tasUid
,$applicationUid
,$applicationNumber
);
}
$counter++;
@@ -1563,6 +1717,12 @@ class TimerEvent
$common->frontEndShow("TEXT", "Not exists any record to continue a case, on date \"$datetime (UTC +00:00)\"");
$this->log("NO-RECORDS", "Not exists any record to continue a case");
$this->syslog(
200
,'Not exists any record to continue a case'
,'NO-RECORDS'
,$datetime
);
}
$common->frontEndShow("END");

View File

@@ -889,6 +889,9 @@ Bootstrap::LoadSystem( 'rbac' );
$RBAC = &RBAC::getSingleton( PATH_DATA, session_id() );
$RBAC->sSystem = 'PROCESSMAKER';
//Enable Monolog
Bootstrap::initVendors();
Bootstrap::LoadSystem( 'monologProvider' );
// define and send Headers for all pages
if (! defined( 'EXECUTE_BY_CRON' )) {
header( "Expires: " . gmdate( "D, d M Y H:i:s", mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - 1, date( 'Y' ) ) ) . " GMT" );