PMCORE-2185

This commit is contained in:
Paula Quispe
2020-09-28 15:14:09 -04:00
committed by Julio Cesar Laura Avendaño
parent f44f3ae565
commit 041434aa42
3 changed files with 65 additions and 29 deletions

View File

@@ -305,7 +305,9 @@ try {
executeEvents();
executeScheduledCases();
executeUpdateAppTitle();
executeCaseSelfService();
if (empty($argvx) || strpos($argvx, "unassigned-case") !== false) {
$task->executeCaseSelfService();
}
if (empty($argvx) || strpos($argvx, "clean-self-service-tables") !== false) {
$task->cleanSelfServiceTables();
}
@@ -493,34 +495,6 @@ function executeUpdateAppTitle()
}
}
/**
* Check if some task unassigned has enable the setting timeout and execute the trigger related
*
* @link https://wiki.processmaker.com/3.2/Tasks#Self-Service
*/
function executeCaseSelfService()
{
try {
global $argvx;
if ($argvx != "" && strpos($argvx, "unassigned-case") === false) {
return false;
}
setExecutionMessage("Unassigned case");
saveLog("unassignedCase", "action", "Unassigned case", "c");
$casesExecuted = Cases::executeSelfServiceTimeout();
foreach ($casesExecuted as $caseNumber) {
saveLog("unassignedCase", "action", "OK Executed trigger to the case $caseNumber");
}
setExecutionResultMessage(count($casesExecuted) . " Cases");
} catch (Exception $e) {
setExecutionResultMessage("WITH ERRORS", "error");
saveLog("unassignedCase", "action", "Unassigned case", "c");
eprintln(" '-" . $e->getMessage(), "red");
saveLog("unassignedCase", "error", "Error in unassigned case: " . $e->getMessage());
}
}
/**
* @deprecated This function is only used in this file and must be deleted.
* @global string $sObject

View File

@@ -18,6 +18,7 @@ use Illuminate\Support\Facades\Log;
use ldapadvancedClassCron;
use NotificationQueue;
use ProcessMaker\BusinessModel\ActionsByEmail\ResponseReader;
use ProcessMaker\BusinessModel\Cases as BmCases;
use ProcessMaker\BusinessModel\Light\PushMessageAndroid;
use ProcessMaker\BusinessModel\Light\PushMessageIOS;
use ProcessMaker\Core\JobsManager;
@@ -233,6 +234,34 @@ class Task
$this->runTask($job);
}
/**
* Check if some task unassigned has enable the setting timeout and execute the trigger related
*
* @link https://wiki.processmaker.com/3.2/Tasks#Self-Service
*/
function executeCaseSelfService()
{
$job = function() {
try {
$this->setExecutionMessage("Unassigned case");
$this->saveLog("unassignedCase", "action", "Unassigned case", "c");
$casesExecuted = BmCases::executeSelfServiceTimeout();
foreach ($casesExecuted as $caseNumber) {
$this->saveLog("unassignedCase", "action", "OK Executed trigger to the case $caseNumber");
}
$this->setExecutionResultMessage(count($casesExecuted) . " Cases");
} catch (Exception $e) {
$this->setExecutionResultMessage("WITH ERRORS", "error");
$this->saveLog("unassignedCase", "action", "Unassigned case", "c");
if ($this->asynchronous === false) {
eprintln(" '-" . $e->getMessage(), "red");
}
$this->saveLog("unassignedCase", "error", "Error in unassigned case: " . $e->getMessage());
}
};
$this->runTask($job);
}
/**
* This calculate duration.
*/