diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2020-05-13 16:33:38 +0200 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2020-06-02 12:32:36 +0200 |
commit | d1de0b2d59c5b20e5445816a5badbab4ee7e7adb (patch) | |
tree | 15a4386649c52d06d92e75104c0c4b3540de70ee | |
parent | 3b6c2d83ef751145d5c387c537797dd9e4adb8af (diff) |
#942 Fix immediate procedures (web)
-rw-r--r-- | admin/WebConsole/gestores/gestor_ejecutaracciones.php | 41 | ||||
-rw-r--r-- | admin/WebConsole/includes/restfunctions.php | 5 |
2 files changed, 40 insertions, 6 deletions
diff --git a/admin/WebConsole/gestores/gestor_ejecutaracciones.php b/admin/WebConsole/gestores/gestor_ejecutaracciones.php index 05a0ffa4..4f6f8138 100644 --- a/admin/WebConsole/gestores/gestor_ejecutaracciones.php +++ b/admin/WebConsole/gestores/gestor_ejecutaracciones.php @@ -19,6 +19,25 @@ include_once("../includes/RecopilaIpesMacs.php"); include_once("../includes/restfunctions.php"); //________________________________________________________________________________________________________ +function now_params() +{ + $year = intval(date('Y')) - 2010; + $month = intval(date('m')) - 1; + $day = intval(date('j')) - 1; + $hour = intval(date('g')); + $am_pm = date('a'); + $minute = intval(date('i')); + + $params['map_year'] = 1 << $year; + $params['map_month'] = 1 << $month; + $params['map_day'] = 1 << $day; + $params['map_hour'] = 1 << $hour; + $params['map_am_pm'] = strcmp($am_pm, 'am') ? 1 : 0; + $params['map_minute'] = $minute; + + return $params; +} + define('OG_CMD_ID_WAKEUP', 1); $opcion=0; // Inicializa parametros @@ -59,7 +78,7 @@ if ($cmd){ RecopilaIpesMacs($cmd,$ambito,$idambito); // Recopila Ipes del ámbito if(opcion!=$EJECUCION_AUTOEXEC){ //Creación parametros para inserción en tabla acciones - $sesion=time(); + $sesion=0; $cmd->CreaParametro("@tipoaccion",$opcion,1); $cmd->CreaParametro("@idtipoaccion",0,1); $cmd->CreaParametro("@descriaccion","",0); @@ -202,6 +221,7 @@ function recorreProcedimientos($idprocedimiento,$ambito,$idambito) //________________________________________________________________________________________________________ function insertaComando($idcomando,$parametros,$idprocedimiento,$ambito,$idambito) { + global $EJECUCION_PROCEDIMIENTO; global $cadenaid; global $cadenaip; global $cmd; @@ -233,13 +253,22 @@ function insertaComando($idcomando,$parametros,$idprocedimiento,$ambito,$idambit $resul=$cmd->Ejecutar(); //echo $cmd->texto; if(!$resul) return(false); - - // Let the clients know they can start executing pending commands. - if(empty($vez)){ - run_schedule($cadenaip); - $vez++; + if ($i == 0) { + $sesion = $cmd->Autonumerico(); + $cmd->ParamSetValor("@sesion",$sesion); } } + $cmd->texto = "UPDATE acciones SET sesion=@sesion ". + "WHERE idaccion = @sesion"; + $resul=$cmd->Ejecutar(); + if (resul) { + $when = now_params(); + $resul = create_schedule(strval($sesion), $EJECUCION_PROCEDIMIENTO, "", + $when['map_year'], $when['map_month'], + 0, 0, $when['map_day'], + $when['map_hour'], $when['map_am_pm'], + $when['map_minute']); + } return(true); } diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php index 6abe56e0..b1355e36 100644 --- a/admin/WebConsole/includes/restfunctions.php +++ b/admin/WebConsole/includes/restfunctions.php @@ -76,8 +76,10 @@ define('OG_REST_PARAM_AM_PM', 'am_pm'); define('OG_REST_PARAM_MINUTES', 'minutes'); define('TYPE_COMMAND', 1); +define('TYPE_PROCEDURE', 2); define('TYPE_TASK', 3); define('OG_SCHEDULE_COMMAND', 'command'); +define('OG_SCHEDULE_PROCEDURE', 'procedure'); define('OG_SCHEDULE_TASK', 'task'); $conf_file = parse_ini_file(__DIR__ . '/../../etc/ogAdmServer.cfg'); @@ -586,6 +588,9 @@ function create_schedule($task_id, $type, $name, $years, $months, $weeks, case TYPE_COMMAND: $type_string = OG_SCHEDULE_COMMAND; break; + case TYPE_PROCEDURE: + $type_string = OG_SCHEDULE_PROCEDURE; + break; case TYPE_TASK: default: $type_string = OG_SCHEDULE_TASK; |