diff options
author | ramon <ramongomez@us.es> | 2017-05-26 11:48:25 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2017-05-26 11:48:25 +0000 |
commit | 232d1dac93cc15a6999a4f108a6d0a8a1bd847af (patch) | |
tree | 764bc4c181a0f0084a1967faaad145462a64281d /admin/WebConsole/rest/remotepc.php | |
parent | 0a42c1c2f4abf0b935bdc7b068a9e031e83faa88 (diff) |
#708 #730: Activar calendario de eventos de MySQL; creación correcta de eventos MySQL para liberar reservas sin acción asociada.branches/version1.1/admin/Database
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5319 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/WebConsole/rest/remotepc.php')
-rw-r--r-- | admin/WebConsole/rest/remotepc.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/admin/WebConsole/rest/remotepc.php b/admin/WebConsole/rest/remotepc.php index 7f4fc53d..823608e7 100644 --- a/admin/WebConsole/rest/remotepc.php +++ b/admin/WebConsole/rest/remotepc.php @@ -27,7 +27,9 @@ $app->post('/ous/:ouid/images/:imageid/reserve(/)', 'validateApiKey', global $AMBITO_ORDENADORES; global $EJECUCION_COMANDO; global $ACCION_INICIADA; + global $ACCION_FINALIZADA; global $ACCION_SINRESULTADO; + global $ACCION_FALLIDA; global $userid; $response = Array(); $ogagent = Array(); @@ -149,29 +151,31 @@ INSERT INTO acciones idcentro=$ouid; EOD; $t2 = $cmd->Ejecutar(); - // Delete reservation on timeout (15 min.). + // Create event to remove reservation on timeout (15 min.). $timeout = "15 MINUTE"; -/* $cmd->texto = <<<EOD CREATE EVENT e_timeout_$clntid ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL $timeout DO BEGIN - SET @clntid = NULL; + SET @clntid = NULL; UPDATE acciones SET estado = $ACCION_FINALIZADA, resultado = $ACCION_FALLIDA, descrinotificacion = 'Timeout' - WHERE idordenador = (SELECT @clntid := '$clntid') - AND descriaccion = 'RemotePC Session' AND estado = $ACCION_INICIADA; + WHERE descriaccion = 'RemotePC Session' AND estado = $ACCION_INICIADA + AND idordenador = (SELECT @clntid := '$clntid'); IF @clntid IS NOT NULL THEN UPDATE remotepc SET reserved=NOW() - INTERVAL 1 SECOND, urllogin=NULL, urllogout=NULL WHERE id = @clntid; - END IF; + DELETE FROM acciones + WHERE idordenador = @clntid + AND descriaccion = 'RemotePC Session' + AND descrinotificacion = 'Timeout'; + END IF; END EOD; $t3 = $cmd->Ejecutar(); -*/ - if ($t1 and $t2) { + if ($t1 and $t2 and $t3) { // Commit transaction on success. $cmd->texto = "COMMIT;"; $cmd->Ejecutar(); @@ -190,7 +194,7 @@ EOD; $response['lab']['id'] = $labid; $response['ou']['id'] = $ouid; jsonResponse(200, $response); - } else{ + } else { // Roll-back transaction on DB error. $cmd->texto = "ROLLBACK;"; $cmd->Ejecutar(); |