mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Background processes - API ready for periodicity management
SVN:trunk[1137]
This commit is contained in:
@@ -26,6 +26,11 @@
|
||||
|
||||
class ExecAsyncTask implements iBackgroundProcess
|
||||
{
|
||||
public function GetPeriodicity()
|
||||
{
|
||||
return 2; // seconds
|
||||
}
|
||||
|
||||
public function Process($iTimeLimit)
|
||||
{
|
||||
$sOQL = "SELECT AsyncTask WHERE ISNULL(started)";
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
interface iBackgroundProcess
|
||||
{
|
||||
public function GetPeriodicity();
|
||||
public function Process($iUnixTimeLimit);
|
||||
}
|
||||
|
||||
|
||||
@@ -612,6 +612,11 @@ abstract class ResponseTicket extends Ticket
|
||||
|
||||
class ProcessSLAResponseTicket implements iBackgroundProcess
|
||||
{
|
||||
public function GetPeriodicity()
|
||||
{
|
||||
return 2; // seconds
|
||||
}
|
||||
|
||||
public function Process($iTimeLimit)
|
||||
{
|
||||
$oMyChange = new CMDBChange();
|
||||
@@ -622,7 +627,7 @@ class ProcessSLAResponseTicket implements iBackgroundProcess
|
||||
$aReport = array();
|
||||
|
||||
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'new\' AND tto_escalation_deadline <= NOW()'));
|
||||
while ($oToEscalate = $oSet->Fetch())
|
||||
while ((time() < $iTimeLimit) && $oToEscalate = $oSet->Fetch())
|
||||
{
|
||||
$oToEscalate->ApplyStimulus('ev_timeout');
|
||||
//$oToEscalate->Set('tto_escalation_deadline', null);
|
||||
@@ -631,7 +636,7 @@ class ProcessSLAResponseTicket implements iBackgroundProcess
|
||||
}
|
||||
|
||||
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'assigned\' AND ttr_escalation_deadline <= NOW()'));
|
||||
while ($oToEscalate = $oSet->Fetch())
|
||||
while ((time() < $iTimeLimit) && $oToEscalate = $oSet->Fetch())
|
||||
{
|
||||
$oToEscalate->ApplyStimulus('ev_timeout');
|
||||
//$oToEscalate->Set('ttr_escalation_deadline', null);
|
||||
@@ -640,7 +645,7 @@ class ProcessSLAResponseTicket implements iBackgroundProcess
|
||||
}
|
||||
|
||||
$oSet = new DBObjectSet(DBObjectSearch::FromOQL('SELECT ResponseTicket WHERE status = \'resolved\' AND closure_deadline <= NOW()'));
|
||||
while ($oToEscalate = $oSet->Fetch())
|
||||
while ((time() < $iTimeLimit) && $oToEscalate = $oSet->Fetch())
|
||||
{
|
||||
$oToEscalate->ApplyStimulus('ev_close');
|
||||
//$oToEscalate->Set('closure_deadline', null);
|
||||
|
||||
@@ -31,6 +31,10 @@ require_once(APPROOT.'/application/clipage.class.inc.php');
|
||||
require_once(APPROOT.'/application/startup.inc.php');
|
||||
|
||||
|
||||
|
||||
// Known limitation - the background process periodicity is NOT taken into account
|
||||
|
||||
|
||||
function CronExec($oP, $aBackgroundProcesses, $bVerbose)
|
||||
{
|
||||
$iStarted = time();
|
||||
@@ -117,7 +121,7 @@ foreach(get_declared_classes() as $sPHPClass)
|
||||
{
|
||||
$oExecInstance = new $sPHPClass;
|
||||
}
|
||||
$aBackgroundProcesses[] = $oExecInstance;
|
||||
$aBackgroundProcesses[$sPHPClass] = $oExecInstance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user