summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2020-05-08 15:49:32 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-05-19 18:29:46 +0200
commit3085f3ca2c18387c867cac571aea463ca4dd27bd (patch)
tree0825f288dba099d8b1f5a5c193e28cab1a2eb809
parentb0ef87a38399820b38aaac62723cd70160c555e2 (diff)
#942 schedule commands (web)
-rw-r--r--admin/WebConsole/comandos/gestores/gestor_Comandos.php9
-rw-r--r--admin/WebConsole/gestores/gestor_programaciones.php7
-rw-r--r--admin/WebConsole/includes/restfunctions.php26
3 files changed, 34 insertions, 8 deletions
diff --git a/admin/WebConsole/comandos/gestores/gestor_Comandos.php b/admin/WebConsole/comandos/gestores/gestor_Comandos.php
index 4d52ba1f..757b9cea 100644
--- a/admin/WebConsole/comandos/gestores/gestor_Comandos.php
+++ b/admin/WebConsole/comandos/gestores/gestor_Comandos.php
@@ -197,7 +197,7 @@ if($sw_ejya=='on' || $sw_ejprg=="on" ){
$parametros=$funcion.$atributos;
$aplicacion=chr(13)."ido=".$cadenaid.chr(13)."mac=".$cadenamac.chr(13)."iph=".$cadenaip.chr(13);
if($sw_seguimiento==1 || $sw_ejprg=="on"){ // Switch de ejecución con seguimiento o comando programado
- $sesion=time();
+ $sesion = 0;
$cmd->ParamSetValor("@tipoaccion",$EJECUCION_COMANDO);
$cmd->ParamSetValor("@idtipoaccion",$idcomando);
$cmd->ParamSetValor("@descriaccion",$descricomando);
@@ -223,7 +223,14 @@ if($sw_ejya=='on' || $sw_ejprg=="on" ){
VALUES (@idordenador,@tipoaccion,@idtipoaccion,@descriaccion,@ip,
@sesion,@idcomando,@parametros,@fechahorareg,@estado,@resultado,@ambito,@idambito,@restrambito,@idcentro)";
$resul=$cmd->Ejecutar();
+ if ($i == 0) {
+ $sesion = $cmd->Autonumerico();
+ $cmd->ParamSetValor("@sesion",$sesion);
+ }
}
+ $cmd->texto = "UPDATE acciones SET sesion=@sesion ".
+ "WHERE idaccion = @sesion";
+ $resul=$cmd->Ejecutar();
$acciones=chr(13)."ids=".$sesion.chr(13); // Para seguimiento
}
if (!$resul){
diff --git a/admin/WebConsole/gestores/gestor_programaciones.php b/admin/WebConsole/gestores/gestor_programaciones.php
index 8aa0078b..0a76a8d9 100644
--- a/admin/WebConsole/gestores/gestor_programaciones.php
+++ b/admin/WebConsole/gestores/gestor_programaciones.php
@@ -13,6 +13,7 @@ include_once("../includes/CreaComando.php");
include_once("../clases/AdoPhp.php");
include_once("../includes/comunes.php");
include_once("../includes/restfunctions.php");
+include_once("../includes/constantes.php");
//________________________________________________________________________________________________________
$op_alta=1;
$op_modificacion=2;
@@ -71,18 +72,20 @@ if(empty($pminutos)) $pminutos=0;
if(empty($psegundos)) $psegundos=0;
if(empty($pminutosini)) $pminutosini=0;
if(empty($pminutosfin)) $pminutosfin=0;
-
if($wsw_sus=='true')
$psw_sus=1;
else
$psw_sus=0 ;
+if ($ptipoaccion == $EJECUCION_COMANDO)
+ $pidentificador = $psesion;
+
if($pswop!=$op_suspension){
$result;
$idr=$pidprogramacion;
switch($pswop){
case $op_alta:
- $result = create_schedule($pidentificador,
+ $result = create_schedule($pidentificador, $ptipoaccion,
$pnombrebloque, $pannos, $pmeses, $psemanas,
$pdias, $pdiario, $phoras, $pampm, $pminutos);
$swop=$op_alta;
diff --git a/admin/WebConsole/includes/restfunctions.php b/admin/WebConsole/includes/restfunctions.php
index 66af9d9f..6abe56e0 100644
--- a/admin/WebConsole/includes/restfunctions.php
+++ b/admin/WebConsole/includes/restfunctions.php
@@ -65,7 +65,7 @@ define('OG_REST_PARAM_DIFF_NAME', 'diff_name');
define('OG_REST_PARAM_METHOD', 'method');
define('OG_REST_PARAM_ECHO', 'echo');
define('OG_REST_PARAM_TASK', 'task');
-define('OG_REST_PARAM_TIME_PARAMS', 'time_params');
+define('OG_REST_PARAM_WHEN', 'when');
define('OG_REST_PARAM_YEARS', 'years');
define('OG_REST_PARAM_MONTHS', 'months');
define('OG_REST_PARAM_WEEKS', 'weeks');
@@ -75,6 +75,11 @@ define('OG_REST_PARAM_HOURS', 'hours');
define('OG_REST_PARAM_AM_PM', 'am_pm');
define('OG_REST_PARAM_MINUTES', 'minutes');
+define('TYPE_COMMAND', 1);
+define('TYPE_TASK', 3);
+define('OG_SCHEDULE_COMMAND', 'command');
+define('OG_SCHEDULE_TASK', 'task');
+
$conf_file = parse_ini_file(__DIR__ . '/../../etc/ogAdmServer.cfg');
define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['APITOKEN']);
@@ -573,13 +578,24 @@ function run_task($task_id) {
return common_request(OG_REST_CMD_RUN_TASK, POST, $data);
}
-function create_schedule($task_id, $name, $years, $months, $weeks, $week_days,
- $days, $hours, $am_pm, $minutes) {
+function create_schedule($task_id, $type, $name, $years, $months, $weeks,
+ $week_days, $days, $hours, $am_pm, $minutes) {
+ $type_string;
+
+ switch ($type) {
+ case TYPE_COMMAND:
+ $type_string = OG_SCHEDULE_COMMAND;
+ break;
+ case TYPE_TASK:
+ default:
+ $type_string = OG_SCHEDULE_TASK;
+ }
$data = array (
OG_REST_PARAM_TASK => $task_id,
+ OG_REST_PARAM_TYPE => $type_string,
OG_REST_PARAM_NAME => $name,
- OG_REST_PARAM_TIME_PARAMS => array (
+ OG_REST_PARAM_WHEN => array (
OG_REST_PARAM_YEARS => intval($years),
OG_REST_PARAM_MONTHS => intval($months),
OG_REST_PARAM_WEEKS => intval($weeks),
@@ -610,7 +626,7 @@ function update_schedule($schedule_id, $task_id, $name, $years, $months, $days,
OG_REST_PARAM_ID => $schedule_id,
OG_REST_PARAM_TASK => $task_id,
OG_REST_PARAM_NAME => $name,
- OG_REST_PARAM_TIME_PARAMS => array (
+ OG_REST_PARAM_WHEN => array (
OG_REST_PARAM_YEARS => intval($years),
OG_REST_PARAM_MONTHS => intval($months),
OG_REST_PARAM_DAYS => intval($days),