mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
many renames to camelcase
This commit is contained in:
@@ -53,7 +53,7 @@ class module_console_schedulerStart extends Command
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(InputInterface $zinput, OutputInterface $output)
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
if ( ! setup::is_installed()) {
|
if ( ! setup::is_installed()) {
|
||||||
$output->writeln('Phraseanet is not set up');
|
$output->writeln('Phraseanet is not set up');
|
||||||
@@ -65,8 +65,9 @@ class module_console_schedulerStart extends Command
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$scheduler = new task_Scheduler();
|
$scheduler = new task_Scheduler();
|
||||||
$scheduler->run($zinput, $output);
|
$scheduler->run($input, $output);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
return $e->getCode();
|
return $e->getCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,10 +47,11 @@ class module_console_schedulerStop extends Command
|
|||||||
try {
|
try {
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$task_manager->set_sched_status(task_manager::STATUS_SCHED_TOSTOP);
|
$task_manager->setSchedulerState(task_manager::STATUS_SCHED_TOSTOP);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,14 +48,14 @@ class module_console_tasklist extends Command
|
|||||||
try {
|
try {
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$tasks = $task_manager->get_tasks();
|
$tasks = $task_manager->getTasks();
|
||||||
|
|
||||||
if (count($tasks) === 0) {
|
if (count($tasks) === 0) {
|
||||||
$output->writeln('No tasks on your install !');
|
$output->writeln('No tasks on your install !');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tasks as $task) {
|
foreach ($tasks as $task) {
|
||||||
$this->print_task($task, $output);
|
$this->printTask($task, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -64,9 +64,9 @@ class module_console_tasklist extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function print_task(task_abstract $task, OutputInterface &$output)
|
protected function printTask(task_abstract $task, OutputInterface &$output)
|
||||||
{
|
{
|
||||||
$message = $task->get_task_id() . "\t" . ($task->get_status() ) . "\t" . $task->get_title();
|
$message = $task->getID() . "\t" . ($task->getState() ) . "\t" . $task->getTitle();
|
||||||
$output->writeln($message);
|
$output->writeln($message);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -61,7 +61,7 @@ class module_console_taskrun extends Command
|
|||||||
if ($this->task) {
|
if ($this->task) {
|
||||||
$this->task->log(sprintf("signal %s received", $signo));
|
$this->task->log(sprintf("signal %s received", $signo));
|
||||||
if ($signo == SIGTERM)
|
if ($signo == SIGTERM)
|
||||||
$this->task->set_running(false);
|
$this->task->setRunning(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,11 +78,10 @@ class module_console_taskrun extends Command
|
|||||||
|
|
||||||
$appbox = \appbox::get_instance(\bootstrap::getCore());
|
$appbox = \appbox::get_instance(\bootstrap::getCore());
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$this->task = $task_manager->get_task($task_id);
|
$this->task = $task_manager->getTask($task_id);
|
||||||
|
|
||||||
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL) {
|
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL) {
|
||||||
$schedStatus = $task_manager->get_scheduler_state();
|
$schedStatus = $task_manager->getSchedulerState();
|
||||||
// printf("%s (%d) schedStatus=%s \n", __FILE__, __LINE__, var_export($schedStatus, true));
|
|
||||||
|
|
||||||
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
|
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
|
||||||
$this->shedulerPID = $schedStatus['pid'];
|
$this->shedulerPID = $schedStatus['pid'];
|
||||||
@@ -90,7 +89,7 @@ class module_console_taskrun extends Command
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$runner = task_abstract::RUNNER_SCHEDULER;
|
$runner = task_abstract::RUNNER_SCHEDULER;
|
||||||
$schedStatus = $task_manager->get_scheduler_state();
|
$schedStatus = $task_manager->getSchedulerState();
|
||||||
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
|
if ($schedStatus && $schedStatus['status'] == 'running' && $schedStatus['pid'])
|
||||||
$this->shedulerPID = $schedStatus['pid'];
|
$this->shedulerPID = $schedStatus['pid'];
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,6 @@ class module_console_taskrun extends Command
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->task->run($runner, $input, $output);
|
$this->task->run($runner, $input, $output);
|
||||||
// $this->task->log(sprintf("%s [%d] taskrun : returned from 'run()', get_status()=%s \n", __FILE__, __LINE__, $this->task->get_status()));
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->task->log(sprintf("taskrun : exception from 'run()', %s \n", $e->getMessage()));
|
$this->task->log(sprintf("taskrun : exception from 'run()', %s \n", $e->getMessage()));
|
||||||
return($e->getCode());
|
return($e->getCode());
|
||||||
@@ -122,13 +120,12 @@ class module_console_taskrun extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (time() - $start > 0) {
|
if (time() - $start > 0) {
|
||||||
// printf("%s (%d) : tick\n", __FILE__, __LINE__);
|
|
||||||
if ($this->shedulerPID) {
|
if ($this->shedulerPID) {
|
||||||
if ( ! posix_kill($this->shedulerPID, 0)) {
|
if ( ! posix_kill($this->shedulerPID, 0)) {
|
||||||
if (method_exists($this->task, 'signal'))
|
if (method_exists($this->task, 'signal'))
|
||||||
$this->task->signal('SIGNAL_SCHEDULER_DIED');
|
$this->task->signal('SIGNAL_SCHEDULER_DIED');
|
||||||
else
|
else
|
||||||
$this->task->set_status(task_abstract::STATUS_TOSTOP);
|
$this->task->setState(task_abstract::STATUS_TOSTOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -127,14 +127,14 @@ class task_Scheduler
|
|||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
|
|
||||||
// set every 'auto-start' task to start
|
// set every 'auto-start' task to start
|
||||||
foreach ($task_manager->get_tasks() as $task) {
|
foreach ($task_manager->getTasks() as $task) {
|
||||||
if ($task->is_active()) {
|
if ($task->isActive()) {
|
||||||
$tid = $task->get_task_id();
|
$tid = $task->getID();
|
||||||
|
|
||||||
if ( ! $task->get_pid()) {
|
if ( ! $task->getPID()) {
|
||||||
/* @var $task task_abstract */
|
/* @var $task task_abstract */
|
||||||
$task->reset_crash_counter();
|
$task->resetCrashCounter();
|
||||||
$task->set_status(task_abstract::STATUS_TOSTART);
|
$task->setState(task_abstract::STATUS_TOSTART);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,13 +224,13 @@ class task_Scheduler
|
|||||||
foreach ($taskPoll as $tkey => $task)
|
foreach ($taskPoll as $tkey => $task)
|
||||||
$taskPoll[$tkey]["todel"] = true;
|
$taskPoll[$tkey]["todel"] = true;
|
||||||
|
|
||||||
foreach ($task_manager->get_tasks(true) as $task) {
|
foreach ($task_manager->getTasks(true) as $task) {
|
||||||
$tkey = "t_" . $task->get_task_id();
|
$tkey = "t_" . $task->getID();
|
||||||
$status = $task->get_status();
|
$status = $task->getState();
|
||||||
|
|
||||||
logs::rotate($logdir . "task_t_" . $task->get_task_id() . ".log");
|
logs::rotate($logdir . "task_t_" . $task->getID() . ".log");
|
||||||
logs::rotate($logdir . "task_o_" . $task->get_task_id() . ".log");
|
logs::rotate($logdir . "task_o_" . $task->getID() . ".log");
|
||||||
logs::rotate($logdir . "task_e_" . $task->get_task_id() . ".log");
|
logs::rotate($logdir . "task_e_" . $task->getID() . ".log");
|
||||||
|
|
||||||
if ( ! isset($taskPoll[$tkey])) {
|
if ( ! isset($taskPoll[$tkey])) {
|
||||||
// the task is not in the poll, add it
|
// the task is not in the poll, add it
|
||||||
@@ -238,7 +238,7 @@ class task_Scheduler
|
|||||||
switch ($system) {
|
switch ($system) {
|
||||||
case "WINDOWS":
|
case "WINDOWS":
|
||||||
$cmd = $phpcli;
|
$cmd = $phpcli;
|
||||||
$args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->get_task_id(), '--runner=scheduler');
|
$args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->getID(), '--runner=scheduler');
|
||||||
if ($this->input && ($this->input->getOption('notasklog')))
|
if ($this->input && ($this->input->getOption('notasklog')))
|
||||||
$args[] = 'notasklog';
|
$args[] = 'notasklog';
|
||||||
break;
|
break;
|
||||||
@@ -246,7 +246,7 @@ class task_Scheduler
|
|||||||
case "DARWIN":
|
case "DARWIN":
|
||||||
case "LINUX":
|
case "LINUX":
|
||||||
$cmd = $phpcli;
|
$cmd = $phpcli;
|
||||||
$args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->get_task_id(), '--runner=scheduler');
|
$args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->getID(), '--runner=scheduler');
|
||||||
if ($this->input && ($this->input->getOption('notasklog')))
|
if ($this->input && ($this->input->getOption('notasklog')))
|
||||||
$args[] = 'notasklog';
|
$args[] = 'notasklog';
|
||||||
break;
|
break;
|
||||||
@@ -268,7 +268,7 @@ class task_Scheduler
|
|||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"new Task %s, status=%s"
|
"new Task %s, status=%s"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
, $status
|
, $status
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -278,7 +278,7 @@ class task_Scheduler
|
|||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"Task %s, oldstatus=%s, newstatus=%s"
|
"Task %s, oldstatus=%s, newstatus=%s"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
, $taskPoll[$tkey]["current_status"]
|
, $taskPoll[$tkey]["current_status"]
|
||||||
, $status
|
, $status
|
||||||
)
|
)
|
||||||
@@ -298,7 +298,7 @@ class task_Scheduler
|
|||||||
// remove not-existing task from poll
|
// remove not-existing task from poll
|
||||||
foreach ($taskPoll as $tkey => $task) {
|
foreach ($taskPoll as $tkey => $task) {
|
||||||
if ($task["todel"]) {
|
if ($task["todel"]) {
|
||||||
$this->log(sprintf("Task %s deleted", $taskPoll[$tkey]["task"]->get_task_id()));
|
$this->log(sprintf("Task %s deleted", $taskPoll[$tkey]["task"]->getID()));
|
||||||
unset($taskPoll[$tkey]);
|
unset($taskPoll[$tkey]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,14 +307,14 @@ class task_Scheduler
|
|||||||
$runningtask = 0;
|
$runningtask = 0;
|
||||||
|
|
||||||
foreach ($taskPoll as $tkey => $tv) {
|
foreach ($taskPoll as $tkey => $tv) {
|
||||||
$status = $tv['task']->get_status();
|
$status = $tv['task']->getState();
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
default:
|
default:
|
||||||
$this->log(sprintf('Unknow status `%s`', $status));
|
$this->log(sprintf('Unknow status `%s`', $status));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case task_abstract::STATUS_TORESTART:
|
case task_abstract::STATUS_TORESTART:
|
||||||
if ( ! $taskPoll[$tkey]['task']->get_pid()) {
|
if ( ! $taskPoll[$tkey]['task']->getPID()) {
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
@fclose($taskPoll[$tkey]["pipes"][1]);
|
@fclose($taskPoll[$tkey]["pipes"][1]);
|
||||||
@fclose($taskPoll[$tkey]["pipes"][2]);
|
@fclose($taskPoll[$tkey]["pipes"][2]);
|
||||||
@@ -323,7 +323,7 @@ class task_Scheduler
|
|||||||
$taskPoll[$tkey]["process"] = null;
|
$taskPoll[$tkey]["process"] = null;
|
||||||
}
|
}
|
||||||
if ($schedstatus == 'started') {
|
if ($schedstatus == 'started') {
|
||||||
$taskPoll[$tkey]["task"]->set_status(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
||||||
}
|
}
|
||||||
// trick to start the task immediatly : DON'T break if ending with 'tostart'
|
// trick to start the task immediatly : DON'T break if ending with 'tostart'
|
||||||
// so it will continue with 'tostart' case !
|
// so it will continue with 'tostart' case !
|
||||||
@@ -340,8 +340,8 @@ class task_Scheduler
|
|||||||
|
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
if ( ! $taskPoll[$tkey]["process"]) {
|
if ( ! $taskPoll[$tkey]["process"]) {
|
||||||
$descriptors[1] = array('file', $logdir . "task_o_" . $taskPoll[$tkey]['task']->get_task_id() . ".log", 'a+');
|
$descriptors[1] = array('file', $logdir . "task_o_" . $taskPoll[$tkey]['task']->getID() . ".log", 'a+');
|
||||||
$descriptors[2] = array('file', $logdir . "task_e_" . $taskPoll[$tkey]['task']->get_task_id() . ".log", 'a+');
|
$descriptors[2] = array('file', $logdir . "task_e_" . $taskPoll[$tkey]['task']->getID() . ".log", 'a+');
|
||||||
|
|
||||||
$taskPoll[$tkey]["process"] = proc_open(
|
$taskPoll[$tkey]["process"] = proc_open(
|
||||||
$taskPoll[$tkey]["cmd"] . ' ' . implode(' ', $taskPoll[$tkey]["args"])
|
$taskPoll[$tkey]["cmd"] . ' ' . implode(' ', $taskPoll[$tkey]["args"])
|
||||||
@@ -356,18 +356,18 @@ class task_Scheduler
|
|||||||
sleep(2); // let the process lock and write it's pid
|
sleep(2); // let the process lock and write it's pid
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_resource($taskPoll[$tkey]["process"]) && $taskPoll[$tkey]['task']->get_pid() !== null) {
|
if (is_resource($taskPoll[$tkey]["process"]) && $taskPoll[$tkey]['task']->getPID() !== null) {
|
||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"Task %s '%s' started (pid=%s)"
|
"Task %s '%s' started (pid=%s)"
|
||||||
, $taskPoll[$tkey]['task']->get_task_id()
|
, $taskPoll[$tkey]['task']->getID()
|
||||||
, $taskPoll[$tkey]["cmd"] . ' ' . implode(' ', $taskPoll[$tkey]["args"])
|
, $taskPoll[$tkey]["cmd"] . ' ' . implode(' ', $taskPoll[$tkey]["args"])
|
||||||
, $taskPoll[$tkey]['task']->get_pid()
|
, $taskPoll[$tkey]['task']->getPID()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$runningtask ++;
|
$runningtask ++;
|
||||||
} else {
|
} else {
|
||||||
$taskPoll[$tkey]["task"]->increment_crash_counter();
|
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
||||||
|
|
||||||
@fclose($taskPoll[$tkey]["pipes"][1]);
|
@fclose($taskPoll[$tkey]["pipes"][1]);
|
||||||
@fclose($taskPoll[$tkey]["pipes"][2]);
|
@fclose($taskPoll[$tkey]["pipes"][2]);
|
||||||
@@ -377,16 +377,16 @@ class task_Scheduler
|
|||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"Task %s '%s' failed to start %d times"
|
"Task %s '%s' failed to start %d times"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
, $taskPoll[$tkey]["cmd"]
|
, $taskPoll[$tkey]["cmd"]
|
||||||
, $taskPoll[$tkey]["task"]->get_crash_counter()
|
, $taskPoll[$tkey]["task"]->getCrashCounter()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["task"]->get_crash_counter() > 5)
|
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
||||||
$taskPoll[$tkey]["task"]->set_status(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
||||||
else
|
else
|
||||||
$taskPoll[$tkey]["task"]->set_status(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,8 +407,8 @@ class task_Scheduler
|
|||||||
fclose(STDOUT);
|
fclose(STDOUT);
|
||||||
fclose(STDERR);
|
fclose(STDERR);
|
||||||
$fdIN = fopen($nullfile, 'r');
|
$fdIN = fopen($nullfile, 'r');
|
||||||
$fdOUT = fopen($logdir . "task_o_" . $taskPoll[$tkey]["task"]->get_task_id() . ".log", 'a+');
|
$fdOUT = fopen($logdir . "task_o_" . $taskPoll[$tkey]["task"]->getID() . ".log", 'a+');
|
||||||
$fdERR = fopen($logdir . "task_e_" . $taskPoll[$tkey]["task"]->get_task_id() . ".log", 'a+');
|
$fdERR = fopen($logdir . "task_e_" . $taskPoll[$tkey]["task"]->getID() . ".log", 'a+');
|
||||||
|
|
||||||
$this->log(sprintf("exec('%s %s')", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"])));
|
$this->log(sprintf("exec('%s %s')", $taskPoll[$tkey]["cmd"], implode(' ', $taskPoll[$tkey]["args"])));
|
||||||
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
|
pcntl_exec($taskPoll[$tkey]["cmd"], $taskPoll[$tkey]["args"]);
|
||||||
@@ -445,7 +445,7 @@ class task_Scheduler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $crashed && ! $taskPoll[$tkey]['task']->get_pid()) {
|
if ( ! $crashed && ! $taskPoll[$tkey]['task']->getPID()) {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
// printf("=== %d ===\n", __LINE__);
|
||||||
$crashed = true;
|
$crashed = true;
|
||||||
}
|
}
|
||||||
@@ -456,7 +456,7 @@ class task_Scheduler
|
|||||||
} else {
|
} else {
|
||||||
// printf("=== %d ===\n", __LINE__);
|
// printf("=== %d ===\n", __LINE__);
|
||||||
// crashed !
|
// crashed !
|
||||||
$taskPoll[$tkey]["task"]->increment_crash_counter();
|
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
||||||
|
|
||||||
if ($this->method == self::METHOD_PROC_OPEN) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
@fclose($taskPoll[$tkey]["pipes"][1]);
|
@fclose($taskPoll[$tkey]["pipes"][1]);
|
||||||
@@ -467,15 +467,15 @@ class task_Scheduler
|
|||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"Task %s crashed %d times"
|
"Task %s crashed %d times"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
, $taskPoll[$tkey]["task"]->get_crash_counter()
|
, $taskPoll[$tkey]["task"]->getCrashCounter()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($taskPoll[$tkey]["task"]->get_crash_counter() > 5)
|
if ($taskPoll[$tkey]["task"]->getCrashCounter() > 5)
|
||||||
$taskPoll[$tkey]["task"]->set_status(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
||||||
else
|
else
|
||||||
$taskPoll[$tkey]["task"]->set_status(task_abstract::STATUS_TOSTART);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_TOSTART);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -484,7 +484,7 @@ class task_Scheduler
|
|||||||
if ($taskPoll[$tkey]["killat"] === NULL)
|
if ($taskPoll[$tkey]["killat"] === NULL)
|
||||||
$taskPoll[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
|
$taskPoll[$tkey]["killat"] = time() + self::TASKDELAYTOQUIT;
|
||||||
|
|
||||||
$pid = $taskPoll[$tkey]['task']->get_pid();
|
$pid = $taskPoll[$tkey]['task']->getPID();
|
||||||
if ($pid) {
|
if ($pid) {
|
||||||
// send ctrl-c to tell the task to CLEAN quit
|
// send ctrl-c to tell the task to CLEAN quit
|
||||||
// (just in case the task doesn't pool his status 'tostop' fast enough)
|
// (just in case the task doesn't pool his status 'tostop' fast enough)
|
||||||
@@ -494,7 +494,7 @@ class task_Scheduler
|
|||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"SIGTERM sent to task %s (pid=%s)"
|
"SIGTERM sent to task %s (pid=%s)"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
, $pid
|
, $pid
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -511,7 +511,7 @@ class task_Scheduler
|
|||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"proc_terminate(...) done on task %s (pid=%s)"
|
"proc_terminate(...) done on task %s (pid=%s)"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
, $pid
|
, $pid
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -520,23 +520,23 @@ class task_Scheduler
|
|||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"SIGKILL sent to task %s (pid=%s)"
|
"SIGKILL sent to task %s (pid=%s)"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
, $pid
|
, $pid
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
unlink($lockdir . 'task_' . $taskPoll[$tkey]['task']->get_task_id() . '.lock');
|
unlink($lockdir . 'task_' . $taskPoll[$tkey]['task']->getID() . '.lock');
|
||||||
|
|
||||||
$taskPoll[$tkey]["task"]->increment_crash_counter();
|
$taskPoll[$tkey]["task"]->incrementCrashCounter();
|
||||||
// $taskPoll[$tkey]["task"]->set_pid(null);
|
// $taskPoll[$tkey]["task"]->set_pid(null);
|
||||||
$taskPoll[$tkey]["task"]->set_status(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"waiting task %s to quit (kill in %d seconds)"
|
"waiting task %s to quit (kill in %d seconds)"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
, $dt
|
, $dt
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -546,10 +546,10 @@ class task_Scheduler
|
|||||||
$this->log(
|
$this->log(
|
||||||
sprintf(
|
sprintf(
|
||||||
"task %s has quit"
|
"task %s has quit"
|
||||||
, $taskPoll[$tkey]["task"]->get_task_id()
|
, $taskPoll[$tkey]["task"]->getID()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$taskPoll[$tkey]["task"]->set_status(task_abstract::STATUS_STOPPED);
|
$taskPoll[$tkey]["task"]->setState(task_abstract::STATUS_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@@ -101,8 +101,17 @@ abstract class task_abstract
|
|||||||
|
|
||||||
protected $completed_percentage;
|
protected $completed_percentage;
|
||||||
|
|
||||||
|
protected $period = 60;
|
||||||
|
|
||||||
public function get_status()
|
protected $taskid = NULL;
|
||||||
|
|
||||||
|
protected $system = ''; // "DARWIN", "WINDOWS" , "LINUX"...
|
||||||
|
|
||||||
|
protected $argt = array(
|
||||||
|
"--help" => array("set" => false, "values" => array(), "usage" => " (no help available)")
|
||||||
|
);
|
||||||
|
|
||||||
|
public function getState()
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
$sql = 'SELECT status FROM task2 WHERE task_id = :taskid LIMIT 1';
|
$sql = 'SELECT status FROM task2 WHERE task_id = :taskid LIMIT 1';
|
||||||
@@ -130,7 +139,7 @@ abstract class task_abstract
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_status($status)
|
public function setState($status)
|
||||||
{
|
{
|
||||||
$av_status = array(
|
$av_status = array(
|
||||||
self::STATUS_STARTED
|
self::STATUS_STARTED
|
||||||
@@ -149,19 +158,19 @@ abstract class task_abstract
|
|||||||
|
|
||||||
$sql = 'UPDATE task2 SET status = :status WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET status = :status WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':status' => $status, ':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':status' => $status, ':taskid' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$this->log(sprintf("task %d <- %s", $this->get_task_id(), $status));
|
$this->log(sprintf("task %d <- %s", $this->getID(), $status));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'active' means 'auto-start when scheduler starts'
|
// 'active' means 'auto-start when scheduler starts'
|
||||||
public function set_active($boolean)
|
public function setActive($boolean)
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
|
|
||||||
$sql = 'UPDATE task2 SET active = :active WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET active = :active WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':active' => ($boolean ? '1' : '0'), ':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':active' => ($boolean ? '1' : '0'), ':taskid' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$this->active = ! ! $boolean;
|
$this->active = ! ! $boolean;
|
||||||
@@ -169,14 +178,14 @@ abstract class task_abstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_title($title)
|
public function setTitle($title)
|
||||||
{
|
{
|
||||||
$title = strip_tags($title);
|
$title = strip_tags($title);
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
|
|
||||||
$sql = 'UPDATE task2 SET name = :title WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET name = :title WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':title' => $title, ':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':title' => $title, ':taskid' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
@@ -184,29 +193,27 @@ abstract class task_abstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_settings($settings)
|
public function setSettings($settings)
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
|
|
||||||
$sql = 'UPDATE task2 SET settings = :settings WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET settings = :settings WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':settings' => $settings, ':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':settings' => $settings, ':taskid' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
|
|
||||||
$this->load_settings(simplexml_load_string($settings));
|
$this->loadSettings(simplexml_load_string($settings));
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reset_crash_counter()
|
public function resetCrashCounter()
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
|
|
||||||
$sql = 'UPDATE task2 SET crashed = 0 WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET crashed = 0 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$this->crash_counter = 0;
|
$this->crash_counter = 0;
|
||||||
@@ -214,47 +221,38 @@ abstract class task_abstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_crash_counter()
|
public function getCrashCounter()
|
||||||
{
|
{
|
||||||
return $this->crash_counter;
|
return $this->crash_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function increment_crash_counter()
|
public function incrementCrashCounter()
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
|
|
||||||
$sql = 'UPDATE task2 SET crashed = crashed + 1 WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET crashed = crashed + 1 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
return $this->crash_counter ++;
|
return $this->crash_counter ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_settings()
|
public function getSettings()
|
||||||
{
|
{
|
||||||
return $this->settings;
|
return $this->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'active' means 'auto-start when scheduler starts'
|
// 'active' means 'auto-start when scheduler starts'
|
||||||
public function is_active()
|
public function isActive()
|
||||||
{
|
{
|
||||||
return $this->active;
|
return $this->active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_completed_percentage()
|
public function getCompletedPercentage()
|
||||||
{
|
{
|
||||||
return $this->completed_percentage;
|
return $this->completed_percentage;
|
||||||
}
|
}
|
||||||
protected $period = 60;
|
|
||||||
|
|
||||||
protected $taskid = NULL;
|
|
||||||
|
|
||||||
protected $system = ''; // "DARWIN", "WINDOWS" , "LINUX"...
|
|
||||||
|
|
||||||
protected $argt = array(
|
|
||||||
"--help" => array("set" => false, "values" => array(), "usage" => " (no help available)")
|
|
||||||
);
|
|
||||||
|
|
||||||
abstract public function getName();
|
abstract public function getName();
|
||||||
|
|
||||||
@@ -297,7 +295,7 @@ abstract class task_abstract
|
|||||||
$sql = 'SELECT crashed, pid, status, active, settings, name, completed, runner
|
$sql = 'SELECT crashed, pid, status, active, settings, name, completed, runner
|
||||||
FROM task2 WHERE task_id = :taskid LIMIT 1';
|
FROM task2 WHERE task_id = :taskid LIMIT 1';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
if ( ! $row)
|
if ( ! $row)
|
||||||
@@ -308,17 +306,15 @@ abstract class task_abstract
|
|||||||
$this->settings = $row['settings'];
|
$this->settings = $row['settings'];
|
||||||
$this->runner = $row['runner'];
|
$this->runner = $row['runner'];
|
||||||
$this->completed_percentage = (int) $row['completed'];
|
$this->completed_percentage = (int) $row['completed'];
|
||||||
$this->load_settings(simplexml_load_string($row['settings']));
|
$this->loadSettings(simplexml_load_string($row['settings']));
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_runner()
|
public function getRunner()
|
||||||
{
|
{
|
||||||
return $this->runner;
|
return $this->runner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_runner($runner)
|
public function setRunner($runner)
|
||||||
{
|
{
|
||||||
$this->runner = $runner;
|
$this->runner = $runner;
|
||||||
|
|
||||||
@@ -326,55 +322,42 @@ abstract class task_abstract
|
|||||||
$sql = 'UPDATE task2 SET runner = :runner WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET runner = :runner WHERE task_id = :taskid';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':taskid' => $this->get_task_id()
|
':taskid' => $this->getID()
|
||||||
, ':runner' => $this->runner
|
, ':runner' => $this->runner
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_title()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return $this->title;
|
return $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
if ( ! $this->get_pid()) { // do not delete a running task
|
if ( ! $this->getPID()) { // do not delete a running task
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$sql = "DELETE FROM task2 WHERE task_id = :task_id";
|
$sql = "DELETE FROM task2 WHERE task_id = :task_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':task_id' => $this->get_task_id()));
|
$stmt->execute(array(':task_id' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$lock_file = $registry->get('GV_RootPath') . 'tmp/locks/task_' . $this->get_task_id() . '.lock';
|
$lock_file = $registry->get('GV_RootPath') . 'tmp/locks/task_' . $this->getID() . '.lock';
|
||||||
@unlink($lock_file);
|
@unlink($lock_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function check_records_done()
|
public function setLastExecTime()
|
||||||
{
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
|
||||||
$this->current_state = self::STATE_MAXRECSDONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function set_last_exec_time()
|
|
||||||
{
|
{
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
$sql = 'UPDATE task2 SET last_exec_time=NOW() WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET last_exec_time=NOW() WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,10 +376,10 @@ abstract class task_abstract
|
|||||||
return isset($row['last_exec_time']) ? $row['last_exec_time'] : '';
|
return isset($row['last_exec_time']) ? $row['last_exec_time'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_pid()
|
public function getPID()
|
||||||
{
|
{
|
||||||
$pid = NULL;
|
$pid = NULL;
|
||||||
$taskid = $this->get_task_id();
|
$taskid = $this->getID();
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
system_file::mkdir($lockdir = $registry->get('GV_RootPath') . 'tmp/locks/');
|
system_file::mkdir($lockdir = $registry->get('GV_RootPath') . 'tmp/locks/');
|
||||||
@@ -414,7 +397,7 @@ abstract class task_abstract
|
|||||||
return $pid;
|
return $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_running($stat)
|
public function setRunning($stat)
|
||||||
{
|
{
|
||||||
$this->running = $stat;
|
$this->running = $stat;
|
||||||
}
|
}
|
||||||
@@ -429,9 +412,9 @@ abstract class task_abstract
|
|||||||
// $conn->close();
|
// $conn->close();
|
||||||
// unset($conn);
|
// unset($conn);
|
||||||
for ($t = $this->period - $when_started; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
for ($t = $this->period - $when_started; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
||||||
$s = $this->get_status();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATUS_TOSTOP) {
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
} else {
|
} else {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@@ -446,7 +429,7 @@ abstract class task_abstract
|
|||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
|
|
||||||
$taskid = $this->get_task_id();
|
$taskid = $this->getID();
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
@@ -472,8 +455,8 @@ abstract class task_abstract
|
|||||||
flock($tasklock, LOCK_UN);
|
flock($tasklock, LOCK_UN);
|
||||||
flock($tasklock, LOCK_SH);
|
flock($tasklock, LOCK_SH);
|
||||||
|
|
||||||
$this->set_runner($runner);
|
$this->setRunner($runner);
|
||||||
$this->set_status(self::STATUS_STARTED);
|
$this->setState(self::STATUS_STARTED);
|
||||||
|
|
||||||
// run the real code of the task -into the task's class- (may throw an exception)
|
// run the real code of the task -into the task's class- (may throw an exception)
|
||||||
$exception = NULL;
|
$exception = NULL;
|
||||||
@@ -489,12 +472,12 @@ abstract class task_abstract
|
|||||||
fclose($tasklock);
|
fclose($tasklock);
|
||||||
@unlink($lockfile);
|
@unlink($lockfile);
|
||||||
|
|
||||||
switch ($this->get_status()) {
|
switch ($this->getState()) {
|
||||||
case self::STATUS_TODELETE:
|
case self::STATUS_TODELETE:
|
||||||
$this->delete();
|
$this->delete();
|
||||||
break;
|
break;
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATUS_TOSTOP:
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,7 +488,7 @@ abstract class task_abstract
|
|||||||
|
|
||||||
abstract protected function run2();
|
abstract protected function run2();
|
||||||
|
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->period = (int) $sx_task_settings->period;
|
$this->period = (int) $sx_task_settings->period;
|
||||||
if ($this->period <= 0 || $this->period >= 60 * 60)
|
if ($this->period <= 0 || $this->period >= 60 * 60)
|
||||||
@@ -520,21 +503,17 @@ abstract class task_abstract
|
|||||||
$this->record_buffer_size = (int) $sx_task_settings->flush;
|
$this->record_buffer_size = (int) $sx_task_settings->flush;
|
||||||
if ($sx_task_settings->flush < 1 || $sx_task_settings->flush > 100)
|
if ($sx_task_settings->flush < 1 || $sx_task_settings->flush > 100)
|
||||||
$this->record_buffer_size = 10;
|
$this->record_buffer_size = 10;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function increment_loops()
|
protected function incrementLoops()
|
||||||
{
|
{
|
||||||
if ($this->get_runner() == self::RUNNER_SCHEDULER && ++ $this->loop >= $this->maxloops) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER && ++ $this->loop >= $this->maxloops) {
|
||||||
$this->log(sprintf(('%d loops done, restarting'), $this->loop));
|
$this->log(sprintf(('%d loops done, restarting'), $this->loop));
|
||||||
$this->set_status(self::STATUS_TORESTART);
|
$this->setState(self::STATUS_TORESTART);
|
||||||
// $this->return_xxxvalue = self::RETURNSTATUS_TORESTART;
|
// $this->return_xxxvalue = self::RETURNSTATUS_TORESTART;
|
||||||
|
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function traceRam($msg='')
|
function traceRam($msg='')
|
||||||
@@ -630,12 +609,8 @@ abstract class task_abstract
|
|||||||
return($t);
|
return($t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_argt()
|
|
||||||
{
|
|
||||||
return $this->argt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_task_id()
|
public function getID()
|
||||||
{
|
{
|
||||||
return $this->taskid;
|
return $this->taskid;
|
||||||
}
|
}
|
||||||
@@ -648,7 +623,7 @@ abstract class task_abstract
|
|||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
$sql = 'UPDATE task2 SET completed = :p WHERE task_id = :taskid';
|
$sql = 'UPDATE task2 SET completed = :p WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':p' => $p, ':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':p' => $p, ':taskid' => $this->getID()));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$this->completed_percentage = $p;
|
$this->completed_percentage = $p;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@@ -17,23 +17,21 @@
|
|||||||
abstract class task_appboxAbstract extends task_abstract
|
abstract class task_appboxAbstract extends task_abstract
|
||||||
{
|
{
|
||||||
|
|
||||||
abstract protected function retrieve_content(appbox $appbox);
|
abstract protected function retrieveContent(appbox $appbox);
|
||||||
|
|
||||||
abstract protected function process_one_content(appbox $appbox, Array $row);
|
abstract protected function processOneContent(appbox $appbox, Array $row);
|
||||||
|
|
||||||
abstract protected function post_process_one_content(appbox $appbox, Array $row);
|
abstract protected function postProcessOneContent(appbox $appbox, Array $row);
|
||||||
|
|
||||||
protected function run2()
|
protected function run2()
|
||||||
{
|
{
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
|
||||||
$this->running = TRUE;
|
$this->running = TRUE;
|
||||||
while ($this->running) {
|
while ($this->running) {
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
|
||||||
try {
|
try {
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
if ($this->get_runner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
@@ -45,60 +43,57 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
$this->set_last_exec_time();
|
$this->setLastExecTime();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$sql = 'SELECT task2.* FROM task2 WHERE task_id = :taskid LIMIT 1';
|
$sql = 'SELECT task2.* FROM task2 WHERE task_id = :taskid LIMIT 1';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
$this->records_done = 0;
|
$this->records_done = 0;
|
||||||
$duration = time();
|
$duration = time();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
|
||||||
// failed sql, simply return
|
// failed sql, simply return
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
|
||||||
if ($row) {
|
if ($row) {
|
||||||
if ( ! $this->running)
|
if ( ! $this->running)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
try {
|
try {
|
||||||
$this->load_settings(simplexml_load_string($row['settings']));
|
$this->loadSettings(simplexml_load_string($row['settings']));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
|
||||||
$process_ret = $this->process($appbox);
|
$process_ret = $this->process($appbox);
|
||||||
|
|
||||||
// printf("%s (%d) process_ret=%s \n", __FILE__, __LINE__, var_export($process_ret, true));
|
|
||||||
// $this->check_current_xxxstate();
|
|
||||||
switch ($process_ret) {
|
switch ($process_ret) {
|
||||||
case self::STATE_MAXMEGSREACHED:
|
case self::STATE_MAXMEGSREACHED:
|
||||||
case self::STATE_MAXRECSDONE:
|
case self::STATE_MAXRECSDONE:
|
||||||
if ($this->get_runner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->set_status(self::STATUS_TORESTART);
|
$this->setState(self::STATUS_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATUS_TOSTOP:
|
||||||
$this->set_status(self::STATUS_TOSTOP);
|
$this->setState(self::STATUS_TOSTOP);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TODELETE: // formal 'suicidable'
|
case self::STATUS_TODELETE: // formal 'suicidable'
|
||||||
$this->set_status(self::STATUS_TODELETE);
|
$this->setState(self::STATUS_TODELETE);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -107,7 +102,7 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
}
|
}
|
||||||
} // if(row)
|
} // if(row)
|
||||||
|
|
||||||
$this->increment_loops();
|
$this->incrementLoops();
|
||||||
$this->pause($duration);
|
$this->pause($duration);
|
||||||
} // while running
|
} // while running
|
||||||
|
|
||||||
@@ -120,20 +115,17 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
*/
|
*/
|
||||||
protected function process(appbox $appbox)
|
protected function process(appbox $appbox)
|
||||||
{
|
{
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
|
||||||
$ret = self::STATE_OK;
|
$ret = self::STATE_OK;
|
||||||
|
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
$tsub = array();
|
$tsub = array();
|
||||||
try {
|
try {
|
||||||
// get the records to process
|
// get the records to process
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
$rs = $this->retrieveContent($appbox);
|
||||||
$rs = $this->retrieve_content($appbox);
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log('Error : ' . $e->getMessage());
|
$this->log('Error : ' . $e->getMessage());
|
||||||
$rs = array();
|
$rs = array();
|
||||||
}
|
}
|
||||||
// printf("%s(%d)\n", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
$rowstodo = count($rs);
|
$rowstodo = count($rs);
|
||||||
$rowsdone = 0;
|
$rowsdone = 0;
|
||||||
@@ -144,7 +136,7 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
try {
|
try {
|
||||||
// process one record
|
// process one record
|
||||||
$this->process_one_content($appbox, $row);
|
$this->processOneContent($appbox, $row);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log("Exception : " . $e->getMessage() . " " . basename($e->getFile()) . " " . $e->getLine());
|
$this->log("Exception : " . $e->getMessage() . " " . basename($e->getFile()) . " " . $e->getLine());
|
||||||
}
|
}
|
||||||
@@ -153,7 +145,7 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$this->setProgress($rowsdone, $rowstodo);
|
$this->setProgress($rowsdone, $rowstodo);
|
||||||
|
|
||||||
// post-process
|
// post-process
|
||||||
$this->post_process_one_content($appbox, $row);
|
$this->post_processOneContent($appbox, $row);
|
||||||
|
|
||||||
// $this->check_memory_usage();
|
// $this->check_memory_usage();
|
||||||
$current_memory = memory_get_usage();
|
$current_memory = memory_get_usage();
|
||||||
@@ -163,7 +155,6 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXMEGSREACHED;
|
$ret = self::STATE_MAXMEGSREACHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_records_done();
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
if ($this->records_done >= (int) ($this->maxrecs)) {
|
||||||
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
@@ -172,8 +163,7 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
|
|
||||||
// $this->check_task_status();
|
// $this->check_task_status();
|
||||||
try {
|
try {
|
||||||
$status = $this->get_status();
|
$status = $this->getState();
|
||||||
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
if ($status == self::STATUS_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATUS_TOSTOP;
|
||||||
@@ -196,7 +186,6 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXMEGSREACHED;
|
$ret = self::STATE_MAXMEGSREACHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_records_done();
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
if ($this->records_done >= (int) ($this->maxrecs)) {
|
||||||
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
@@ -205,8 +194,7 @@ abstract class task_appboxAbstract extends task_abstract
|
|||||||
|
|
||||||
// $this->check_task_status();
|
// $this->check_task_status();
|
||||||
try {
|
try {
|
||||||
$status = $this->get_status();
|
$status = $this->getState();
|
||||||
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
if ($status == self::STATUS_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
$ret = self::STATUS_TOSTOP;
|
$ret = self::STATUS_TOSTOP;
|
||||||
|
@@ -22,13 +22,13 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
|
|
||||||
protected $mono_sbas_id;
|
protected $mono_sbas_id;
|
||||||
|
|
||||||
abstract protected function retrieve_sbas_content(databox $databox);
|
abstract protected function retrieveSbasContent(databox $databox);
|
||||||
|
|
||||||
abstract protected function process_one_content(databox $databox, Array $row);
|
abstract protected function processOneContent(databox $databox, Array $row);
|
||||||
|
|
||||||
abstract protected function flush_records_sbas();
|
abstract protected function flushRecordsSbas();
|
||||||
|
|
||||||
abstract protected function post_process_one_content(databox $databox, Array $row);
|
abstract protected function postProcessOneContent(databox $databox, Array $row);
|
||||||
|
|
||||||
protected function run2()
|
protected function run2()
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
if ($this->get_runner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
@@ -54,16 +54,16 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_last_exec_time();
|
$this->setLastExecTime();
|
||||||
try {
|
try {
|
||||||
if ($this->mono_sbas_id) {
|
if ($this->mono_sbas_id) {
|
||||||
$sql = 'SELECT sbas_id, task2.* FROM sbas, task2 WHERE task_id=:taskid AND sbas_id=:sbas_id';
|
$sql = 'SELECT sbas_id, task2.* FROM sbas, task2 WHERE task_id=:taskid AND sbas_id=:sbas_id';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->get_task_id(), ':sbas_id' => $this->mono_sbas_id));
|
$stmt->execute(array(':taskid' => $this->getID(), ':sbas_id' => $this->mono_sbas_id));
|
||||||
} else {
|
} else {
|
||||||
$sql = 'SELECT sbas_id, task2.* FROM sbas, task2 WHERE task_id = :taskid';
|
$sql = 'SELECT sbas_id, task2.* FROM sbas, task2 WHERE task_id = :taskid';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':taskid' => $this->get_task_id()));
|
$stmt->execute(array(':taskid' => $this->getID()));
|
||||||
}
|
}
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -83,33 +83,33 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id));
|
$this->log('This task works now on ' . phrasea::sbas_names($this->sbas_id));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->load_settings(simplexml_load_string($row['settings']));
|
$this->loadSettings(simplexml_load_string($row['settings']));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$process_ret = $this->process_sbas();
|
$process_ret = $this->processSbas();
|
||||||
|
|
||||||
// printf("%s (%d) process_ret=%s \n", __FILE__, __LINE__, var_export($process_ret, true));
|
// printf("%s (%d) process_ret=%s \n", __FILE__, __LINE__, var_export($process_ret, true));
|
||||||
// $this->check_current_xxxstate();
|
// $this->check_current_xxxstate();
|
||||||
switch ($process_ret) {
|
switch ($process_ret) {
|
||||||
case self::STATE_MAXMEGSREACHED:
|
case self::STATE_MAXMEGSREACHED:
|
||||||
case self::STATE_MAXRECSDONE:
|
case self::STATE_MAXRECSDONE:
|
||||||
if ($this->get_runner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->set_status(self::STATUS_TORESTART);
|
$this->setState(self::STATUS_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TOSTOP:
|
case self::STATUS_TOSTOP:
|
||||||
$this->set_status(self::STATUS_TOSTOP);
|
$this->setState(self::STATUS_TOSTOP);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case self::STATUS_TODELETE: // formal 'suicidable'
|
case self::STATUS_TODELETE: // formal 'suicidable'
|
||||||
// DO NOT SUICIDE IN THE LOOP, may have to work on other sbas !!!
|
// DO NOT SUICIDE IN THE LOOP, may have to work on other sbas !!!
|
||||||
// $this->set_status(self::STATUS_TODELETE);
|
// $this->setState(self::STATUS_TODELETE);
|
||||||
// $this->log('task will self delete');
|
// $this->log('task will self delete');
|
||||||
// $this->running = FALSE;
|
// $this->running = FALSE;
|
||||||
$task_must_delete = TRUE;
|
$task_must_delete = TRUE;
|
||||||
@@ -119,15 +119,15 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->flush_records_sbas();
|
$this->flushRecordsSbas();
|
||||||
} // foreach sbas
|
} // foreach sbas
|
||||||
|
|
||||||
$this->increment_loops();
|
$this->incrementLoops();
|
||||||
$this->pause($duration);
|
$this->pause($duration);
|
||||||
} // while($this->running)
|
} // while($this->running)
|
||||||
|
|
||||||
if ($task_must_delete) {
|
if ($task_must_delete) {
|
||||||
$this->set_status(self::STATUS_TODELETE);
|
$this->setState(self::STATUS_TODELETE);
|
||||||
$this->log('task will self delete');
|
$this->log('task will self delete');
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -137,7 +137,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
*
|
*
|
||||||
* @return <type>
|
* @return <type>
|
||||||
*/
|
*/
|
||||||
protected function process_sbas()
|
protected function processSbas()
|
||||||
{
|
{
|
||||||
$ret = self::STATE_OK;
|
$ret = self::STATE_OK;
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
// get the records to process
|
// get the records to process
|
||||||
$databox = databox::get_instance($this->sbas_id);
|
$databox = databox::get_instance($this->sbas_id);
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
$rs = $this->retrieve_sbas_content($databox);
|
$rs = $this->retrieveSbasContent($databox);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log('Error : ' . $e->getMessage());
|
$this->log('Error : ' . $e->getMessage());
|
||||||
$rs = array();
|
$rs = array();
|
||||||
@@ -163,7 +163,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
try {
|
try {
|
||||||
// process one record
|
// process one record
|
||||||
$this->process_one_content($databox, $row);
|
$this->processOneContent($databox, $row);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log("Exception : " . $e->getMessage() . " " . basename($e->getFile()) . " " . $e->getLine());
|
$this->log("Exception : " . $e->getMessage() . " " . basename($e->getFile()) . " " . $e->getLine());
|
||||||
}
|
}
|
||||||
@@ -172,7 +172,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$this->setProgress($rowsdone, $rowstodo);
|
$this->setProgress($rowsdone, $rowstodo);
|
||||||
|
|
||||||
// post-process
|
// post-process
|
||||||
$this->post_process_one_content($databox, $row);
|
$this->postProcessOneContent($databox, $row);
|
||||||
|
|
||||||
// $this->check_memory_usage();
|
// $this->check_memory_usage();
|
||||||
$current_memory = memory_get_usage();
|
$current_memory = memory_get_usage();
|
||||||
@@ -182,7 +182,6 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXMEGSREACHED;
|
$ret = self::STATE_MAXMEGSREACHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_records_done();
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
if ($this->records_done >= (int) ($this->maxrecs)) {
|
||||||
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
@@ -191,7 +190,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
|
|
||||||
// $this->check_task_status();
|
// $this->check_task_status();
|
||||||
try {
|
try {
|
||||||
$status = $this->get_status();
|
$status = $this->getState();
|
||||||
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
if ($status == self::STATUS_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
@@ -219,7 +218,6 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
$ret = self::STATE_MAXMEGSREACHED;
|
$ret = self::STATE_MAXMEGSREACHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->check_records_done();
|
|
||||||
if ($this->records_done >= (int) ($this->maxrecs)) {
|
if ($this->records_done >= (int) ($this->maxrecs)) {
|
||||||
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
$this->log(sprintf("Max records done (%s) reached (actual is %s)", $this->maxrecs, $this->records_done));
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
@@ -228,7 +226,7 @@ abstract class task_databoxAbstract extends task_abstract
|
|||||||
|
|
||||||
// $this->check_task_status();
|
// $this->check_task_status();
|
||||||
try {
|
try {
|
||||||
$status = $this->get_status();
|
$status = $this->getState();
|
||||||
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
// printf("%s (%d) status=%s \n", __FILE__, __LINE__, var_export($status, true));
|
||||||
if ($status == self::STATUS_TOSTOP) {
|
if ($status == self::STATUS_TOSTOP) {
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
|
@@ -22,6 +22,7 @@ class task_manager
|
|||||||
const STATUS_SCHED_TOSTOP = 'tostop';
|
const STATUS_SCHED_TOSTOP = 'tostop';
|
||||||
|
|
||||||
protected $appbox;
|
protected $appbox;
|
||||||
|
|
||||||
protected $tasks;
|
protected $tasks;
|
||||||
|
|
||||||
public function __construct(appbox &$appbox)
|
public function __construct(appbox &$appbox)
|
||||||
@@ -31,35 +32,7 @@ class task_manager
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function old_get_tasks($refresh = false)
|
public function getTasks($refresh = false)
|
||||||
{
|
|
||||||
if ($this->tasks && ! $refresh)
|
|
||||||
return $this->tasks;
|
|
||||||
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
|
|
||||||
$stmt = $this->appbox->get_connection()->prepare($sql);
|
|
||||||
$stmt->execute();
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$tasks = array();
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
$classname = $row['class'];
|
|
||||||
if ( ! class_exists($classname))
|
|
||||||
continue;
|
|
||||||
try {
|
|
||||||
$tasks[$row['task_id']] = new $classname($row['task_id']);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->tasks = $tasks;
|
|
||||||
|
|
||||||
return $this->tasks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_tasks($refresh = false)
|
|
||||||
{
|
{
|
||||||
if ($this->tasks && ! $refresh)
|
if ($this->tasks && ! $refresh)
|
||||||
return $this->tasks;
|
return $this->tasks;
|
||||||
@@ -109,12 +82,12 @@ class task_manager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param <type> $task_id
|
* @param int $task_id
|
||||||
* @return task_abstract
|
* @return task_abstract
|
||||||
*/
|
*/
|
||||||
public function get_task($task_id)
|
public function getTask($task_id)
|
||||||
{
|
{
|
||||||
$tasks = $this->get_tasks();
|
$tasks = $this->getTasks();
|
||||||
|
|
||||||
if ( ! isset($tasks[$task_id])) {
|
if ( ! isset($tasks[$task_id])) {
|
||||||
throw new Exception_NotFound('Unknown task_id');
|
throw new Exception_NotFound('Unknown task_id');
|
||||||
@@ -123,7 +96,7 @@ class task_manager
|
|||||||
return $tasks[$task_id];
|
return $tasks[$task_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_sched_status($status)
|
public function setSchedulerState($status)
|
||||||
{
|
{
|
||||||
$av_status = array(
|
$av_status = array(
|
||||||
self::STATUS_SCHED_STARTED
|
self::STATUS_SCHED_STARTED
|
||||||
@@ -143,7 +116,7 @@ class task_manager
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_scheduler_state()
|
public function getSchedulerState()
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ class task_period_apibridge extends task_appboxAbstract
|
|||||||
* @param appbox $appbox
|
* @param appbox $appbox
|
||||||
* @return Array
|
* @return Array
|
||||||
*/
|
*/
|
||||||
protected function retrieve_content(appbox $appbox)
|
protected function retrieveContent(appbox $appbox)
|
||||||
{
|
{
|
||||||
$status = array(Bridge_Element::STATUS_PENDING, Bridge_Element::STATUS_PROCESSING, Bridge_Element::STATUS_PROCESSING_SERVER);
|
$status = array(Bridge_Element::STATUS_PENDING, Bridge_Element::STATUS_PROCESSING, Bridge_Element::STATUS_PROCESSING_SERVER);
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ class task_period_apibridge extends task_appboxAbstract
|
|||||||
$n ++;
|
$n ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT id, account_id FROM bridge_elements
|
$sql = 'SELECT id, account_id FROM bridge_elements'
|
||||||
WHERE (status = ' . implode(' OR status = ', array_keys($params)) . ')';
|
. ' WHERE (status = ' . implode(' OR status = ', array_keys($params)) . ')';
|
||||||
|
|
||||||
$stmt = $appbox->get_connection()->prepare($sql);
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
@@ -69,7 +69,7 @@ class task_period_apibridge extends task_appboxAbstract
|
|||||||
* @param array $row
|
* @param array $row
|
||||||
* @return task_period_apibridge
|
* @return task_period_apibridge
|
||||||
*/
|
*/
|
||||||
protected function process_one_content(appbox $appbox, Array $row)
|
protected function processOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$account = Bridge_Account::load_account($appbox, $row['account_id']);
|
$account = Bridge_Account::load_account($appbox, $row['account_id']);
|
||||||
@@ -103,7 +103,7 @@ class task_period_apibridge extends task_appboxAbstract
|
|||||||
* @param array $row
|
* @param array $row
|
||||||
* @return task_period_apibridge
|
* @return task_period_apibridge
|
||||||
*/
|
*/
|
||||||
protected function post_process_one_content(appbox $appbox, Array $row)
|
protected function postProcessOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -363,7 +363,7 @@ class task_period_archive extends task_abstract
|
|||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
if ($this->get_runner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
@@ -381,28 +381,28 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
$path_in = (string) ($this->sxTaskSettings->hotfolder);
|
$path_in = (string) ($this->sxTaskSettings->hotfolder);
|
||||||
if ( ! @is_dir($path_in)) {
|
if ( ! @is_dir($path_in)) {
|
||||||
if ($this->get_runner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(sprintf(('Warning : missing hotfolder \'%s\', restarting in 10 min.'), $path_in));
|
$this->log(sprintf(('Warning : missing hotfolder \'%s\', restarting in 10 min.'), $path_in));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->set_status(self::STATUS_TORESTART);
|
$this->setState(self::STATUS_TORESTART);
|
||||||
} else {
|
} else {
|
||||||
$this->log(sprintf(('Error : missing hotfolder \'%s\', stopping.'), $path_in));
|
$this->log(sprintf(('Error : missing hotfolder \'%s\', stopping.'), $path_in));
|
||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_last_exec_time();
|
$this->setLastExecTime();
|
||||||
|
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
try {
|
try {
|
||||||
$sql = "SELECT * FROM task2 WHERE task_id = :task_id";
|
$sql = "SELECT * FROM task2 WHERE task_id = :task_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':task_id' => $this->get_task_id()));
|
$stmt->execute(array(':task_id' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
if ($row && $this->sxTaskSettings = @simplexml_load_string($row['settings'])) {
|
if ($row && $this->sxTaskSettings = @simplexml_load_string($row['settings'])) {
|
||||||
@@ -418,19 +418,19 @@ class task_period_archive extends task_abstract
|
|||||||
$cold = 60;
|
$cold = 60;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->get_task_id()));
|
throw new Exception(sprintf('Error fetching or reading settings of the task \'%d\'', $this->getID()));
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if ($this->get_runner() == self::RUNNER_SCHEDULER) {
|
if ($this->getRunner() == self::RUNNER_SCHEDULER) {
|
||||||
$this->log(sprintf(('Warning : error fetching or reading settings of the task \'%d\', restarting in 10 min.'), $this->get_task_id()));
|
$this->log(sprintf(('Warning : error fetching or reading settings of the task \'%d\', restarting in 10 min.'), $this->getID()));
|
||||||
|
|
||||||
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
for ($t = 60 * 10; $this->running && $t; $t -- ) // DON'T do sleep(600) because it prevents ticks !
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->set_status(self::STATUS_TORESTART);
|
$this->setState(self::STATUS_TORESTART);
|
||||||
} else {
|
} else {
|
||||||
$this->log(sprintf(('Error : error fetching task \'%d\', stopping.'), $this->get_task_id()));
|
$this->log(sprintf(('Error : error fetching task \'%d\', stopping.'), $this->getID()));
|
||||||
// runner = manual : can't restart so simply quit
|
// runner = manual : can't restart so simply quit
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
}
|
}
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return;
|
return;
|
||||||
@@ -449,15 +449,15 @@ class task_period_archive extends task_abstract
|
|||||||
|
|
||||||
switch ($r) {
|
switch ($r) {
|
||||||
case 'TOSTOP':
|
case 'TOSTOP':
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'WAIT':
|
case 'WAIT':
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'BAD':
|
case 'BAD':
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
break;
|
break;
|
||||||
case 'NORECSTODO':
|
case 'NORECSTODO':
|
||||||
@@ -472,9 +472,9 @@ class task_period_archive extends task_abstract
|
|||||||
sleep(5);
|
sleep(5);
|
||||||
*/
|
*/
|
||||||
for ($i = 0; $i < (($period + $cold) - $duration) && $this->running; $i ++ ) {
|
for ($i = 0; $i < (($period + $cold) - $duration) && $this->running; $i ++ ) {
|
||||||
$s = $this->get_status();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATUS_TOSTOP) {
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -489,14 +489,14 @@ class task_period_archive extends task_abstract
|
|||||||
case 'MAXRECSDONE':
|
case 'MAXRECSDONE':
|
||||||
case 'MAXMEMORY':
|
case 'MAXMEMORY':
|
||||||
case 'MAXLOOP':
|
case 'MAXLOOP':
|
||||||
if ($row['status'] == self::STATUS_STARTED && $this->get_runner() !== self::RUNNER_MANUAL) {
|
if ($row['status'] == self::STATUS_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
||||||
$this->set_status(self::STATUS_TORESTART);
|
$this->setState(self::STATUS_TORESTART);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ($row['status'] == self::STATUS_STARTED) {
|
if ($row['status'] == self::STATUS_STARTED) {
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -569,7 +569,7 @@ class task_period_archive extends task_abstract
|
|||||||
$cold = 60;
|
$cold = 60;
|
||||||
|
|
||||||
while ($cold > 0) {
|
while ($cold > 0) {
|
||||||
$s = $this->get_status();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP)
|
if ($s == self::STATUS_TOSTOP)
|
||||||
return('TOSTOP');
|
return('TOSTOP');
|
||||||
sleep(2);
|
sleep(2);
|
||||||
@@ -723,7 +723,7 @@ class task_period_archive extends task_abstract
|
|||||||
$time0 = time();
|
$time0 = time();
|
||||||
while (($file = $listFolder->read()) !== NULL) {
|
while (($file = $listFolder->read()) !== NULL) {
|
||||||
if (time() - $time0 >= 2) { // each 2 secs, check the status of the task
|
if (time() - $time0 >= 2) { // each 2 secs, check the status of the task
|
||||||
$s = $this->get_status();
|
$s = $this->getState();
|
||||||
if ($s == self::STATUS_TOSTOP) {
|
if ($s == self::STATUS_TOSTOP) {
|
||||||
$nnew = 'TOSTOP'; // since we will return a string...
|
$nnew = 'TOSTOP'; // since we will return a string...
|
||||||
break; // ...we can check it against numerical result
|
break; // ...we can check it against numerical result
|
||||||
|
@@ -28,21 +28,21 @@ class task_period_batchupload extends task_appboxAbstract
|
|||||||
return(("Hello I'm the batch upload process."));
|
return(("Hello I'm the batch upload process."));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function retrieve_content(appbox $appbox)
|
protected function retrieveContent(appbox $appbox)
|
||||||
{
|
{
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
|
|
||||||
$sql = 'UPDATE uplfile AS f INNER JOIN uplbatch AS u USING(uplbatch_id)
|
$sql = 'UPDATE uplfile AS f INNER JOIN uplbatch AS u USING(uplbatch_id)'
|
||||||
SET f.error="1", u.error="1"
|
. ' SET f.error="1", u.error="1"'
|
||||||
WHERE u.error=0 AND u.base_id NOT IN(SELECT base_id FROM bas)';
|
. ' WHERE u.error=0 AND u.base_id NOT IN(SELECT base_id FROM bas)';
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$sql = 'SELECT uplbatch_id, sbas_id, server_coll_id, usr_id
|
$sql = 'SELECT uplbatch_id, sbas_id, server_coll_id, usr_id'
|
||||||
FROM (uplbatch u INNER JOIN bas b USING(base_id))
|
. ' FROM (uplbatch u INNER JOIN bas b USING(base_id))'
|
||||||
WHERE complete="1" AND error="0" ORDER BY uplbatch_id';
|
. ' WHERE complete="1" AND error="0" ORDER BY uplbatch_id';
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@@ -52,7 +52,7 @@ class task_period_batchupload extends task_appboxAbstract
|
|||||||
return $rs;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function process_one_content(appbox $appbox, Array $row)
|
protected function processOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$registry = $appbox->get_registry();
|
$registry = $appbox->get_registry();
|
||||||
@@ -114,9 +114,9 @@ class task_period_batchupload extends task_appboxAbstract
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log($e->getMessage());
|
$this->log($e->getMessage());
|
||||||
|
|
||||||
$sql = 'UPDATE uplfile AS f INNER JOIN uplbatch AS u USING(uplbatch_id)
|
$sql = 'UPDATE uplfile AS f INNER JOIN uplbatch AS u USING(uplbatch_id)'
|
||||||
SET f.error="1", u.error="1"
|
. ' SET f.error="1", u.error="1"'
|
||||||
WHERE u.uplbatch_id = :batch_id';
|
. ' WHERE u.uplbatch_id = :batch_id';
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':batch_id' => $batch_id));
|
$stmt->execute(array(':batch_id' => $batch_id));
|
||||||
@@ -124,8 +124,8 @@ class task_period_batchupload extends task_appboxAbstract
|
|||||||
$errors = '1';
|
$errors = '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE uplbatch SET complete="2", error = :error
|
$sql = 'UPDATE uplbatch SET complete="2", error = :error'
|
||||||
WHERE uplbatch_id = :batch_id';
|
. ' WHERE uplbatch_id = :batch_id';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':error' => $errors, ':batch_id' => $batch_id));
|
$stmt->execute(array(':error' => $errors, ':batch_id' => $batch_id));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -135,7 +135,7 @@ class task_period_batchupload extends task_appboxAbstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function post_process_one_content(appbox $appbox, Array $row)
|
protected function postProcessOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -338,7 +338,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
* @param SimpleXMLElement $sx_task_settings
|
* @param SimpleXMLElement $sx_task_settings
|
||||||
* @return task_cindexer
|
* @return task_cindexer
|
||||||
*/
|
*/
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->host = trim($sx_task_settings->host);
|
$this->host = trim($sx_task_settings->host);
|
||||||
$this->port = trim($sx_task_settings->port);
|
$this->port = trim($sx_task_settings->port);
|
||||||
@@ -353,9 +353,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
$this->winsvc_run = p4field::isyes(trim($sx_task_settings->winsvc_run));
|
$this->winsvc_run = p4field::isyes(trim($sx_task_settings->winsvc_run));
|
||||||
$this->binpath = p4string::addEndSlash(trim($sx_task_settings->binpath));
|
$this->binpath = p4string::addEndSlash(trim($sx_task_settings->binpath));
|
||||||
|
|
||||||
parent::load_settings($sx_task_settings);
|
parent::loadSettings($sx_task_settings);
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -383,7 +381,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
|
if ( ! file_exists($cmd) || ! is_executable($cmd)) {
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->setState(self::STATUS_STOPPED);
|
||||||
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
|
$this->log(sprintf(_('task::cindexer:file \'%s\' does not exists'), $cmd));
|
||||||
throw new Exception('cindexer executable not found', self::ERR_EXECUTABLE_NOT_FOUND);
|
throw new Exception('cindexer executable not found', self::ERR_EXECUTABLE_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
@@ -433,7 +431,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->new_status !== NULL)
|
if ($this->new_status !== NULL)
|
||||||
$this->set_status($this->new_status);
|
$this->setState($this->new_status);
|
||||||
|
|
||||||
if ($this->exception)
|
if ($this->exception)
|
||||||
throw $this->exception;
|
throw $this->exception;
|
||||||
@@ -444,8 +442,8 @@ class task_period_cindexer extends task_abstract
|
|||||||
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
|
$nullfile = $this->system == 'WINDOWS' ? 'NUL' : '/dev/null';
|
||||||
|
|
||||||
$descriptors = array();
|
$descriptors = array();
|
||||||
// $descriptors[1] = array("file", $logdir . "/phraseanet_indexer_" . $this->get_task_id() . ".log", "a+");
|
// $descriptors[1] = array("file", $logdir . "/phraseanet_indexer_" . $this->getID() . ".log", "a+");
|
||||||
// $descriptors[2] = array("file", $logdir . "/phraseanet_indexer_" . $this->get_task_id() . ".error.log", "a+");
|
// $descriptors[2] = array("file", $logdir . "/phraseanet_indexer_" . $this->getID() . ".error.log", "a+");
|
||||||
$descriptors[1] = array("file", $nullfile, "a+");
|
$descriptors[1] = array("file", $nullfile, "a+");
|
||||||
$descriptors[2] = array("file", $nullfile, "a+");
|
$descriptors[2] = array("file", $nullfile, "a+");
|
||||||
|
|
||||||
@@ -467,7 +465,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
$this->running = true;
|
$this->running = true;
|
||||||
|
|
||||||
while ($this->running) {
|
while ($this->running) {
|
||||||
if ($this->get_status() == self::STATUS_TOSTOP && $this->socket > 0) {
|
if ($this->getState() == self::STATUS_TOSTOP && $this->socket > 0) {
|
||||||
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
|
// must quit task, so send 'Q' to port 127.0.0.1:XXXX to cindexer
|
||||||
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
|
if ( ! $qsent && (($sock = socket_create(AF_INET, SOCK_STREAM, 0)) !== false)) {
|
||||||
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
if (socket_connect($sock, '127.0.0.1', $this->socket) === true) {
|
||||||
@@ -564,7 +562,7 @@ class task_period_cindexer extends task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->get_status() == self::STATUS_TOSTOP) {
|
if ($this->getState() == self::STATUS_TOSTOP) {
|
||||||
posix_kill($pid, ($sigsent = SIGINT));
|
posix_kill($pid, ($sigsent = SIGINT));
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
|
@@ -18,8 +18,11 @@
|
|||||||
class task_period_emptyColl extends task_appboxAbstract
|
class task_period_emptyColl extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
protected $base_id;
|
protected $base_id;
|
||||||
|
|
||||||
protected $suicidable = true;
|
protected $suicidable = true;
|
||||||
|
|
||||||
|
protected $total_records = 0;
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return(_("Vidage de collection"));
|
return(_("Vidage de collection"));
|
||||||
@@ -35,16 +38,13 @@ class task_period_emptyColl extends task_appboxAbstract
|
|||||||
return("Vide une collection");
|
return("Vide une collection");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->base_id = (int) $sx_task_settings->base_id;
|
$this->base_id = (int) $sx_task_settings->base_id;
|
||||||
parent::load_settings($sx_task_settings);
|
parent::loadSettings($sx_task_settings);
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
protected $total_records = 0;
|
|
||||||
|
|
||||||
protected function retrieve_content(appbox $appbox)
|
protected function retrieveContent(appbox $appbox)
|
||||||
{
|
{
|
||||||
if ( ! $this->base_id) {
|
if ( ! $this->base_id) {
|
||||||
$this->current_state = self::STATE_FINISHED;
|
$this->current_state = self::STATE_FINISHED;
|
||||||
@@ -54,7 +54,7 @@ class task_period_emptyColl extends task_appboxAbstract
|
|||||||
$collection = collection::get_from_base_id($this->base_id);
|
$collection = collection::get_from_base_id($this->base_id);
|
||||||
$this->total_records = $collection->get_record_amount();
|
$this->total_records = $collection->get_record_amount();
|
||||||
$collection->empty_collection(200);
|
$collection->empty_collection(200);
|
||||||
$this->records_done +=$this->total_records;
|
$this->records_done += $this->total_records;
|
||||||
$this->setProgress($this->records_done, $this->total_records);
|
$this->setProgress($this->records_done, $this->total_records);
|
||||||
|
|
||||||
if ($this->total_records == 0) {
|
if ($this->total_records == 0) {
|
||||||
@@ -65,12 +65,12 @@ class task_period_emptyColl extends task_appboxAbstract
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function process_one_content(appbox $appbox, Array $row)
|
protected function processOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function post_process_one_content(appbox $appbox, Array $row)
|
protected function postProcessOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@@ -16,6 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
class task_period_ftp extends task_appboxAbstract
|
class task_period_ftp extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
|
protected $proxy;
|
||||||
|
|
||||||
|
protected $proxyport;
|
||||||
|
|
||||||
|
protected $debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -49,13 +54,13 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
, "proxyport"
|
, "proxyport"
|
||||||
, "period"
|
, "period"
|
||||||
);
|
);
|
||||||
if ($dom = @DOMDocument::loadXML($oldxml)) {
|
if (($dom = @DOMDocument::loadXML($oldxml))) {
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("str:proxy", "str:proxyport", "str:period") as $pname) {
|
foreach (array("str:proxy", "str:proxyport", "str:period") as $pname) {
|
||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
@@ -98,7 +103,6 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return("");
|
return("");
|
||||||
} else { // ... so we NEVER come here
|
} else { // ... so we NEVER come here
|
||||||
// bad xml
|
// bad xml
|
||||||
@@ -118,17 +122,18 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
{
|
{
|
||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
function chgxmlck(checkinput, fieldname)
|
function chgxmlck(checkinput, fieldname)
|
||||||
{
|
{
|
||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
function chgxmlpopup(popupinput, fieldname)
|
function chgxmlpopup(popupinput, fieldname)
|
||||||
{
|
{
|
||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,11 +181,11 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
|
|
||||||
if ($parm["xml"] === null) {
|
if ($parm["xml"] === null) {
|
||||||
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
||||||
if ($domTaskSettings = @DOMDocument::loadXML($taskrow["settings"])) {
|
if (($domTaskSettings = @DOMDocument::loadXML($taskrow["settings"]))) {
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("proxy", "proxyport", "period") as $f) {
|
foreach (array("proxy", "proxyport", "period") as $f) {
|
||||||
if ($parm[$f] !== NULL) {
|
if ($parm[$f] !== NULL) {
|
||||||
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) {
|
if (($ns = $domTaskSettings->getElementsByTagName($f)->item(0))) {
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
@@ -235,21 +240,16 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected $proxy;
|
|
||||||
protected $proxyport;
|
|
||||||
protected $debug;
|
|
||||||
|
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->proxy = (string) $sx_task_settings->proxy;
|
$this->proxy = (string) $sx_task_settings->proxy;
|
||||||
$this->proxyport = (string) $sx_task_settings->proxyport;
|
$this->proxyport = (string) $sx_task_settings->proxyport;
|
||||||
|
|
||||||
parent::load_settings($sx_task_settings);
|
parent::loadSettings($sx_task_settings);
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function retrieve_content(appbox $appbox)
|
protected function retrieveContent(appbox $appbox)
|
||||||
{
|
{
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
return $ftp_exports;
|
return $ftp_exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function process_one_content(appbox $appbox, Array $ftp_export)
|
protected function processOneContent(appbox $appbox, Array $ftp_export)
|
||||||
{
|
{
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
$registry = $appbox->get_registry();
|
$registry = $appbox->get_registry();
|
||||||
@@ -471,8 +471,8 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
unlink($localfile);
|
unlink($localfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE ftp_export_elements
|
$sql = "UPDATE ftp_export_elements"
|
||||||
SET done='1', error='0' WHERE id = :file_id";
|
. " SET done='1', error='0' WHERE id = :file_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':file_id' => $file['id']));
|
$stmt->execute(array(':file_id' => $file['id']));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -488,8 +488,8 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
|
|
||||||
$done = $file['error'];
|
$done = $file['error'];
|
||||||
|
|
||||||
$sql = "UPDATE ftp_export_elements
|
$sql = "UPDATE ftp_export_elements"
|
||||||
SET done = :done, error='1' WHERE id = :file_id";
|
. " SET done = :done, error='1' WHERE id = :file_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':done' => $done, ':file_id' => $file['id']));
|
$stmt->execute(array(':done' => $done, ':file_id' => $file['id']));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -503,10 +503,10 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
$date = new DateTime();
|
$date = new DateTime();
|
||||||
$remote_file = $date->format('U');
|
$remote_file = $date->format('U');
|
||||||
|
|
||||||
$sql = 'SELECT filename, folder
|
$sql = 'SELECT filename, folder'
|
||||||
FROM ftp_export_elements
|
. ' FROM ftp_export_elements'
|
||||||
WHERE ftp_export_id = :ftp_export_id
|
. ' WHERE ftp_export_id = :ftp_export_id'
|
||||||
AND error = "0" AND done="1"';
|
. ' AND error = "0" AND done="1"';
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':ftp_export_id' => $id));
|
$stmt->execute(array(':ftp_export_id' => $id));
|
||||||
@@ -545,8 +545,8 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo $line;
|
echo $line;
|
||||||
|
|
||||||
$sql = "UPDATE ftp_export SET crash=crash+1,date=now()
|
$sql = "UPDATE ftp_export SET crash=crash+1,date=now()"
|
||||||
WHERE id = :export_id";
|
. " WHERE id = :export_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $ftp_export['id']));
|
$stmt->execute(array(':export_id' => $ftp_export['id']));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
@@ -557,7 +557,7 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
phrasea_close_session($ses_id);
|
phrasea_close_session($ses_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function post_process_one_content(appbox $appbox, Array $row)
|
protected function postProcessOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -566,8 +566,8 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
{
|
{
|
||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
|
|
||||||
$sql = 'SELECT crash, nbretry FROM ftp_export
|
$sql = 'SELECT crash, nbretry FROM ftp_export'
|
||||||
WHERE id = :export_id';
|
. ' WHERE id = :export_id';
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
@@ -580,8 +580,8 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT count(id) as total, sum(error) as errors, sum(done) as done
|
$sql = 'SELECT count(id) as total, sum(error) as errors, sum(done) as done'
|
||||||
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
. ' FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
@@ -619,8 +619,8 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
$conn = $appbox->get_connection();
|
$conn = $appbox->get_connection();
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
|
|
||||||
$sql = 'SELECT filename, base_id, record_id, subdef, error, done
|
$sql = 'SELECT filename, base_id, record_id, subdef, error, done'
|
||||||
FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
. ' FROM ftp_export_elements WHERE ftp_export_id = :export_id';
|
||||||
|
|
||||||
$transferts = array();
|
$transferts = array();
|
||||||
|
|
||||||
@@ -648,8 +648,8 @@ class task_period_ftp extends task_appboxAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT addr, crash, nbretry, sendermail, mail, text_mail_sender, text_mail_receiver
|
$sql = 'SELECT addr, crash, nbretry, sendermail, mail, text_mail_sender, text_mail_receiver'
|
||||||
FROM ftp_export WHERE id = :export_id';
|
. ' FROM ftp_export WHERE id = :export_id';
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':export_id' => $id));
|
$stmt->execute(array(':export_id' => $id));
|
||||||
|
@@ -16,17 +16,26 @@
|
|||||||
*/
|
*/
|
||||||
class task_period_ftpPull extends task_appboxAbstract
|
class task_period_ftpPull extends task_appboxAbstract
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $debug = false;
|
protected $debug = false;
|
||||||
|
|
||||||
protected $proxy;
|
protected $proxy;
|
||||||
|
|
||||||
protected $proxyport;
|
protected $proxyport;
|
||||||
|
|
||||||
protected $host;
|
protected $host;
|
||||||
|
|
||||||
protected $port;
|
protected $port;
|
||||||
|
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
protected $password;
|
protected $password;
|
||||||
|
|
||||||
protected $ssl;
|
protected $ssl;
|
||||||
|
|
||||||
protected $passive;
|
protected $passive;
|
||||||
|
|
||||||
protected $ftppath;
|
protected $ftppath;
|
||||||
|
|
||||||
protected $localpath;
|
protected $localpath;
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
@@ -48,30 +57,24 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
, "password", "ssl", "ftppath", "localpath"
|
, "password", "ssl", "ftppath", "localpath"
|
||||||
, "passive", "period"
|
, "passive", "period"
|
||||||
);
|
);
|
||||||
if ($dom = @DOMDocument::loadXML($oldxml))
|
if ($dom = @DOMDocument::loadXML($oldxml)) {
|
||||||
{
|
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("str:proxy", "str:proxyport", "str:period", "boo:passive", "boo:ssl", "str:password", "str:user", "str:ftppath", "str:localpath", "str:port", "str:host") as $pname)
|
foreach (array("str:proxy", "str:proxyport", "str:period", "boo:passive", "boo:ssl", "str:password", "str:user", "str:ftppath", "str:localpath", "str:port", "str:host") as $pname) {
|
||||||
{
|
|
||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0))
|
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
|
||||||
{
|
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
||||||
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\n"));
|
$dom->documentElement->appendChild($dom->createTextNode("\n"));
|
||||||
}
|
}
|
||||||
// on fixe sa valeur
|
// on fixe sa valeur
|
||||||
switch ($ptype)
|
switch ($ptype) {
|
||||||
{
|
|
||||||
case "str":
|
case "str":
|
||||||
$ns->appendChild($dom->createTextNode($pvalue));
|
$ns->appendChild($dom->createTextNode($pvalue));
|
||||||
break;
|
break;
|
||||||
@@ -88,30 +91,26 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
||||||
{
|
|
||||||
// ... but we could check for safe values (ex. 0 < period < 3600)
|
// ... but we could check for safe values (ex. 0 < period < 3600)
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<?php echo $form ?>.proxy.value = "<?php echo p4string::MakeString($sxml->proxy, "js", '"') ?>";
|
<?php echo $form ?>.proxy.value = "<?php echo p4string::MakeString($sxml->proxy, "js", '"') ?>";
|
||||||
<?php echo $form ?>.proxyport.value = "<?php echo p4string::MakeString($sxml->proxyport, "js", '"') ?>";
|
<?php echo $form ?>.proxyport.value = "<?php echo p4string::MakeString($sxml->proxyport, "js", '"') ?>";
|
||||||
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
||||||
|
|
||||||
<?php echo $form ?>.localpath.value = "<?php echo p4string::MakeString($sxml->localpath, "js", '"') ?>";
|
<?php echo $form ?>.localpath.value = "<?php echo p4string::MakeString($sxml->localpath, "js", '"') ?>";
|
||||||
<?php echo $form ?>.ftppath.value = "<?php echo p4string::MakeString($sxml->ftppath, "js", '"') ?>";
|
<?php echo $form ?>.ftppath.value = "<?php echo p4string::MakeString($sxml->ftppath, "js", '"') ?>";
|
||||||
<?php echo $form ?>.host.value = "<?php echo p4string::MakeString($sxml->host, "js", '"') ?>";
|
<?php echo $form ?>.host.value = "<?php echo p4string::MakeString($sxml->host, "js", '"') ?>";
|
||||||
<?php echo $form ?>.port.value = "<?php echo p4string::MakeString($sxml->port, "js", '"') ?>";
|
<?php echo $form ?>.port.value = "<?php echo p4string::MakeString($sxml->port, "js", '"') ?>";
|
||||||
<?php echo $form ?>.user.value = "<?php echo p4string::MakeString($sxml->user, "js", '"') ?>";
|
<?php echo $form ?>.user.value = "<?php echo p4string::MakeString($sxml->user, "js", '"') ?>";
|
||||||
<?php echo $form ?>.password.value = "<?php echo p4string::MakeString($sxml->password, "js", '"') ?>";
|
<?php echo $form ?>.password.value = "<?php echo p4string::MakeString($sxml->password, "js", '"') ?>";
|
||||||
<?php echo $form ?>.ssl.checked = <?php echo p4field::isyes($sxml->ssl) ? "true" : 'false' ?>;
|
<?php echo $form ?>.ssl.checked = <?php echo p4field::isyes($sxml->ssl) ? "true" : 'false' ?>;
|
||||||
<?php echo $form ?>.passive.checked = <?php echo p4field::isyes($sxml->passive) ? "true" : 'false' ?>;
|
<?php echo $form ?>.passive.checked = <?php echo p4field::isyes($sxml->passive) ? "true" : 'false' ?>;
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return("");
|
return("");
|
||||||
}
|
} else { // ... so we NEVER come here
|
||||||
else // ... so we NEVER come here
|
|
||||||
{
|
|
||||||
// bad xml
|
// bad xml
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
@@ -120,7 +119,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
public function printInterfaceJS()
|
public function printInterfaceJS()
|
||||||
{
|
{
|
||||||
global $parm;
|
global $parm;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function chgxmltxt(textinput, fieldname)
|
function chgxmltxt(textinput, fieldname)
|
||||||
{
|
{
|
||||||
@@ -135,7 +134,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
setDirty();
|
setDirty();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGraphicForm()
|
function getGraphicForm()
|
||||||
@@ -147,46 +146,46 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
{
|
{
|
||||||
global $parm;
|
global $parm;
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:proxy') ?>
|
<?php echo('task::ftp:proxy') ?>
|
||||||
<input type="text" name="proxy" style="width:400px;" onchange="chgxmltxt(this, 'proxy');"><br/>
|
<input type="text" name="proxy" style="width:400px;" onchange="chgxmltxt(this, 'proxy');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:proxy port') ?>
|
<?php echo('task::ftp:proxy port') ?>
|
||||||
<input type="text" name="proxyport" style="width:400px;" onchange="chgxmltxt(this, 'proxyport');"><br/>
|
<input type="text" name="proxyport" style="width:400px;" onchange="chgxmltxt(this, 'proxyport');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<?php echo('task::ftp:host') ?>
|
<?php echo('task::ftp:host') ?>
|
||||||
<input type="text" name="host" style="width:400px;" onchange="chgxmltxt(this, 'host');"><br/>
|
<input type="text" name="host" style="width:400px;" onchange="chgxmltxt(this, 'host');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:port') ?>
|
<?php echo('task::ftp:port') ?>
|
||||||
<input type="text" name="port" style="width:400px;" onchange="chgxmltxt(this, 'port');"><br/>
|
<input type="text" name="port" style="width:400px;" onchange="chgxmltxt(this, 'port');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:user') ?>
|
<?php echo('task::ftp:user') ?>
|
||||||
<input type="text" name="user" style="width:400px;" onchange="chgxmltxt(this, 'user');"><br/>
|
<input type="text" name="user" style="width:400px;" onchange="chgxmltxt(this, 'user');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:password') ?>
|
<?php echo('task::ftp:password') ?>
|
||||||
<input type="password" name="password" style="width:400px;" onchange="chgxmltxt(this, 'password');"><br/>
|
<input type="password" name="password" style="width:400px;" onchange="chgxmltxt(this, 'password');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:chemin distant') ?>
|
<?php echo('task::ftp:chemin distant') ?>
|
||||||
<input type="text" name="ftppath" style="width:400px;" onchange="chgxmltxt(this, 'ftppath');"><br/>
|
<input type="text" name="ftppath" style="width:400px;" onchange="chgxmltxt(this, 'ftppath');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::ftp:localpath') ?>
|
<?php echo('task::ftp:localpath') ?>
|
||||||
<input type="text" name="localpath" style="width:400px;" onchange="chgxmltxt(this, 'localpath');"><br/>
|
<input type="text" name="localpath" style="width:400px;" onchange="chgxmltxt(this, 'localpath');"><br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<input type="checkbox" name="passive" onchange="chgxmlck(this)">
|
<input type="checkbox" name="passive" onchange="chgxmlck(this)">
|
||||||
<?php echo _('task::ftp:mode passif') ?>
|
<?php echo _('task::ftp:mode passif') ?>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="checkbox" name="ssl" onchange="chgxmlck(this)">
|
<input type="checkbox" name="ssl" onchange="chgxmlck(this)">
|
||||||
<?php echo _('task::ftp:utiliser SSL') ?>
|
<?php echo _('task::ftp:utiliser SSL') ?>
|
||||||
<br/>
|
<br/>
|
||||||
<?php echo('task::_common_:periodicite de la tache') ?>
|
<?php echo('task::_common_:periodicite de la tache') ?>
|
||||||
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');">
|
<input type="text" name="period" style="width:40px;" onchange="chgxmltxt(this, 'period');">
|
||||||
<?php echo('task::_common_:minutes (unite temporelle)') ?><br/>
|
<?php echo('task::_common_:minutes (unite temporelle)') ?><br/>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
@@ -202,24 +201,17 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
, "password", "passive", "ssl", "debug"
|
, "password", "passive", "ssl", "debug"
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($parm["xml"] === null)
|
if ($parm["xml"] === null) {
|
||||||
{
|
|
||||||
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
// pas de xml 'raw' : on accepte les champs 'graphic view'
|
||||||
if ($domTaskSettings = DOMDocument::loadXML($taskrow["settings"]))
|
if ($domTaskSettings = DOMDocument::loadXML($taskrow["settings"])) {
|
||||||
{
|
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f)
|
foreach (array("proxy", "proxyport", "period", "host", "port", "user", "password", "ssl", "passive", "localpath", "ftppath") as $f) {
|
||||||
{
|
if ($parm[$f] !== NULL) {
|
||||||
if ($parm[$f] !== NULL)
|
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0)) {
|
||||||
{
|
|
||||||
if ($ns = $domTaskSettings->getElementsByTagName($f)->item(0))
|
|
||||||
{
|
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
|
$domTaskSettings->documentElement->appendChild($domTaskSettings->createTextNode("\t"));
|
||||||
$ns = $domTaskSettings->documentElement->appendChild($domTaskSettings->createElement($f));
|
$ns = $domTaskSettings->documentElement->appendChild($domTaskSettings->createElement($f));
|
||||||
@@ -236,51 +228,41 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
// si on doit changer le xml, on verifie qu'il est valide
|
// si on doit changer le xml, on verifie qu'il est valide
|
||||||
if ($parm["xml"] && !DOMDocument::loadXML($parm["xml"]))
|
if ($parm["xml"] && ! DOMDocument::loadXML($parm["xml"]))
|
||||||
|
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
$sql = "";
|
$sql = "";
|
||||||
$params = array(':task_id' => $taskid);
|
$params = array(':task_id' => $taskid);
|
||||||
if ($parm["xml"] !== NULL)
|
if ($parm["xml"] !== NULL) {
|
||||||
{
|
|
||||||
$sql .= ( $sql ? " ," : "") . "settings = :settings";
|
$sql .= ( $sql ? " ," : "") . "settings = :settings";
|
||||||
$params[':settings'] = $parm['xml'];
|
$params[':settings'] = $parm['xml'];
|
||||||
}
|
}
|
||||||
if ($parm["name"] !== NULL)
|
if ($parm["name"] !== NULL) {
|
||||||
{
|
|
||||||
$sql .= ( $sql ? " ," : "") . "name = :name";
|
$sql .= ( $sql ? " ," : "") . "name = :name";
|
||||||
$params[':name'] = $parm['name'];
|
$params[':name'] = $parm['name'];
|
||||||
}
|
}
|
||||||
if ($parm["active"] !== NULL)
|
if ($parm["active"] !== NULL) {
|
||||||
{
|
|
||||||
$sql .= ( $sql ? " ," : "") . "active = :active";
|
$sql .= ( $sql ? " ," : "") . "active = :active";
|
||||||
$params[':active'] = $parm['active'];
|
$params[':active'] = $parm['active'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sql)
|
if ($sql) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
$sql = "UPDATE task2 SET $sql WHERE task_id = :task_id";
|
$sql = "UPDATE task2 SET $sql WHERE task_id = :task_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->proxy = (string) $sx_task_settings->proxy;
|
$this->proxy = (string) $sx_task_settings->proxy;
|
||||||
$this->proxyport = (string) $sx_task_settings->proxyport;
|
$this->proxyport = (string) $sx_task_settings->proxyport;
|
||||||
@@ -288,44 +270,36 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
$this->port = (string) ($sx_task_settings->port);
|
$this->port = (string) ($sx_task_settings->port);
|
||||||
$this->user = (string) ($sx_task_settings->user);
|
$this->user = (string) ($sx_task_settings->user);
|
||||||
$this->password = (string) ($sx_task_settings->password);
|
$this->password = (string) ($sx_task_settings->password);
|
||||||
$this->ssl = !!((string) ($sx_task_settings->ssl));
|
$this->ssl = ! ! ((string) ($sx_task_settings->ssl));
|
||||||
$this->passive = !!((string) ($sx_task_settings->passive));
|
$this->passive = ! ! ((string) ($sx_task_settings->passive));
|
||||||
$this->ftppath = (string) ($sx_task_settings->ftppath);
|
$this->ftppath = (string) ($sx_task_settings->ftppath);
|
||||||
$this->localpath = (string) ($sx_task_settings->localpath);
|
$this->localpath = (string) ($sx_task_settings->localpath);
|
||||||
|
|
||||||
parent::load_settings($sx_task_settings);
|
parent::loadSettings($sx_task_settings);
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function retrieve_content(appbox $appbox)
|
protected function retrieveContent(appbox $appbox)
|
||||||
{
|
{
|
||||||
foreach(array('localpath', 'host', 'port', 'user', 'password', 'ftppath') as $f)
|
foreach (array('localpath', 'host', 'port', 'user', 'password', 'ftppath') as $f) {
|
||||||
{
|
if (trim((string) ($this->{$f})) === '') {
|
||||||
if(trim((string)($this->{$f})) === '')
|
$this->log('setting \'' . $f . '\' must be set');
|
||||||
{
|
|
||||||
$this->log('setting \''.$f.'\' must be set');
|
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is_dir($this->localpath) || !system_file::mkdir($this->localpath))
|
if ( ! is_dir($this->localpath) || ! system_file::mkdir($this->localpath)) {
|
||||||
{
|
$this->log('\'' . $this->localpath . '\' does not exists');
|
||||||
$this->log('\''.$this->localpath.'\' does not exists');
|
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
if (!is_writeable($this->localpath))
|
if ( ! is_writeable($this->localpath)) {
|
||||||
{
|
$this->log('\'' . $this->localpath . '\' is not writeable');
|
||||||
$this->log('\''.$this->localpath.'\' is not writeable');
|
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
}
|
}
|
||||||
if(!$this->running )
|
if ( ! $this->running) {
|
||||||
{
|
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->set_status(self::STATUS_STOPPED);
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$ftp = new ftpclient($this->host, $port, 90, $this->ssl, $this->proxy, $this->proxyport);
|
$ftp = new ftpclient($this->host, $port, 90, $this->ssl, $this->proxy, $this->proxyport);
|
||||||
$ftp->login($this->user, $this->password);
|
$ftp->login($this->user, $this->password);
|
||||||
$ftp->chdir($this->ftppath);
|
$ftp->chdir($this->ftppath);
|
||||||
@@ -336,38 +310,32 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo "attente de 25sec pour avoir les fichiers froids...\n";
|
echo "attente de 25sec pour avoir les fichiers froids...\n";
|
||||||
for($t = 25; $this->running && $t > 0; $t--) // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
for ($t = 25; $this->running && $t > 0; $t -- ) { // DON'T do sleep($this->period - $when_started) because it prevents ticks !
|
||||||
{
|
$s = $this->getState();
|
||||||
$s = $this->get_status();
|
if ($s == self::STATUS_TOSTOP) {
|
||||||
if($s == self::STATUS_TOSTOP)
|
|
||||||
{
|
|
||||||
if (isset($ftp) && $ftp instanceof ftpclient)
|
if (isset($ftp) && $ftp instanceof ftpclient)
|
||||||
$ftp->close();
|
$ftp->close();
|
||||||
$this->set_status(self::STATUS_STOPPED);
|
$this->set_status(self::STATUS_STOPPED);
|
||||||
$this->running = FALSE;
|
$this->running = FALSE;
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$list_2 = $ftp->list_directory(true);
|
$list_2 = $ftp->list_directory(true);
|
||||||
|
|
||||||
foreach ($list_1 as $filepath => $timestamp)
|
foreach ($list_1 as $filepath => $timestamp) {
|
||||||
{
|
$done ++;
|
||||||
$done++;
|
|
||||||
$this->setProgress($done, $todo);
|
$this->setProgress($done, $todo);
|
||||||
|
|
||||||
if (!isset($list_2[$filepath]))
|
if ( ! isset($list_2[$filepath])) {
|
||||||
{
|
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo "le fichier $filepath a disparu...\n";
|
echo "le fichier $filepath a disparu...\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($list_2[$filepath] !== $timestamp)
|
if ($list_2[$filepath] !== $timestamp) {
|
||||||
{
|
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo "le fichier $filepath a ete modifie depuis le dernier passage...\n";
|
echo "le fichier $filepath a ete modifie depuis le dernier passage...\n";
|
||||||
continue;
|
continue;
|
||||||
@@ -376,8 +344,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
$finalpath = p4string::addEndSlash($this->localpath) . ($filepath[0] == '/' ? mb_substr($filepath, 1) : $filepath);
|
$finalpath = p4string::addEndSlash($this->localpath) . ($filepath[0] == '/' ? mb_substr($filepath, 1) : $filepath);
|
||||||
echo "Ok pour rappatriement de $filepath vers $finalpath\n";
|
echo "Ok pour rappatriement de $filepath vers $finalpath\n";
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
if (file_exists($finalpath))
|
if (file_exists($finalpath))
|
||||||
throw new Exception("Un fichier du meme nom ($finalpath) existe deja...");
|
throw new Exception("Un fichier du meme nom ($finalpath) existe deja...");
|
||||||
|
|
||||||
@@ -385,9 +352,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
|
|
||||||
$ftp->get($finalpath, $filepath);
|
$ftp->get($finalpath, $filepath);
|
||||||
$ftp->delete($filepath);
|
$ftp->delete($filepath);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
if ($this->debug)
|
if ($this->debug)
|
||||||
echo "Erreur lors du rappatriement de $filepath : " . $e->getMessage() . "\n";
|
echo "Erreur lors du rappatriement de $filepath : " . $e->getMessage() . "\n";
|
||||||
}
|
}
|
||||||
@@ -396,9 +361,7 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
$ftp->close();
|
$ftp->close();
|
||||||
|
|
||||||
$this->setProgress(0, 0);
|
$this->setProgress(0, 0);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
if (isset($ftp) && $ftp instanceof ftpclient)
|
if (isset($ftp) && $ftp instanceof ftpclient)
|
||||||
$ftp->close();
|
$ftp->close();
|
||||||
echo $e->getMessage() . "\n";
|
echo $e->getMessage() . "\n";
|
||||||
@@ -406,14 +369,13 @@ class task_period_ftpPull extends task_appboxAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function process_one_content(appbox $appbox, Array $row)
|
protected function processOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function post_process_one_content(appbox $appbox, Array $row)
|
protected function postProcessOneContent(appbox $appbox, Array $row)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -53,11 +53,10 @@ class task_period_outofdate extends task_abstract
|
|||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
$dom->preserveWhiteSpace = false;
|
$dom->preserveWhiteSpace = false;
|
||||||
$dom->formatOutput = true;
|
$dom->formatOutput = true;
|
||||||
if($dom->loadXML($oldxml))
|
if ($dom->loadXML($oldxml)) {
|
||||||
{
|
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
// foreach($parm2 as $pname=>$pvalue)
|
// foreach($parm2 as $pname=>$pvalue)
|
||||||
foreach(array(
|
foreach (array(
|
||||||
"str:sbas_id",
|
"str:sbas_id",
|
||||||
"str:period",
|
"str:period",
|
||||||
'str:field1',
|
'str:field1',
|
||||||
@@ -72,27 +71,22 @@ class task_period_outofdate extends task_abstract
|
|||||||
'str:coll1',
|
'str:coll1',
|
||||||
'str:status2',
|
'str:status2',
|
||||||
'str:coll2'
|
'str:coll2'
|
||||||
) as $pname)
|
) as $pname) {
|
||||||
{
|
|
||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if(($ns = $dom->getElementsByTagName($pname)->item(0)))
|
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
||||||
{
|
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while(($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
||||||
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\n"));
|
$dom->documentElement->appendChild($dom->createTextNode("\n"));
|
||||||
}
|
}
|
||||||
// on fixe sa valeur
|
// on fixe sa valeur
|
||||||
switch($ptype)
|
switch ($ptype) {
|
||||||
{
|
|
||||||
case "str":
|
case "str":
|
||||||
$ns->appendChild($dom->createTextNode($pvalue));
|
$ns->appendChild($dom->createTextNode($pvalue));
|
||||||
break;
|
break;
|
||||||
@@ -112,15 +106,14 @@ class task_period_outofdate extends task_abstract
|
|||||||
// ====================================================================
|
// ====================================================================
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if(($sxml = simplexml_load_string($xml))) // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
||||||
{
|
|
||||||
// ... but we could check for safe values
|
// ... but we could check for safe values
|
||||||
if((int) ($sxml->period) < 10)
|
if ((int) ($sxml->period) < 10)
|
||||||
$sxml->period = 10;
|
$sxml->period = 10;
|
||||||
elseif((int) ($sxml->period) > 1440) // 1 jour
|
elseif ((int) ($sxml->period) > 1440) // 1 jour
|
||||||
$sxml->period = 1440;
|
$sxml->period = 1440;
|
||||||
|
|
||||||
if((string) ($sxml->delay) == '')
|
if ((string) ($sxml->delay) == '')
|
||||||
$sxml->delay = 0;
|
$sxml->delay = 0;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -162,11 +155,9 @@ class task_period_outofdate extends task_abstract
|
|||||||
parent.calcSQL();
|
parent.calcSQL();
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
else // ... so we NEVER come here
|
else { // ... so we NEVER come here
|
||||||
{
|
|
||||||
// bad xml
|
// bad xml
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
@@ -240,11 +231,13 @@ class task_period_outofdate extends task_abstract
|
|||||||
setDirty();
|
setDirty();
|
||||||
calcSQL();
|
calcSQL();
|
||||||
}
|
}
|
||||||
|
|
||||||
function chgxmlck(checkinput, fieldname)
|
function chgxmlck(checkinput, fieldname)
|
||||||
{
|
{
|
||||||
setDirty();
|
setDirty();
|
||||||
calcSQL();
|
calcSQL();
|
||||||
}
|
}
|
||||||
|
|
||||||
function chgxmlpopup(popupinput, fieldname)
|
function chgxmlpopup(popupinput, fieldname)
|
||||||
{
|
{
|
||||||
setDirty();
|
setDirty();
|
||||||
@@ -254,7 +247,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
function calcSQL()
|
function calcSQL()
|
||||||
{
|
{
|
||||||
var data = $("form[name='graphicForm']").serializeJSON();
|
var data = $("form[name='graphicForm']").serializeJSON();
|
||||||
data["taskid"] = <?php echo $this->get_task_id(); ?>;
|
data["taskid"] = <?php echo $this->getID(); ?>;
|
||||||
data["ACT"] = "CALCSQL";
|
data["ACT"] = "CALCSQL";
|
||||||
data["cls"]="outofdate";
|
data["cls"]="outofdate";
|
||||||
$.ajax({ url: "/admin/taskfacility.php"
|
$.ajax({ url: "/admin/taskfacility.php"
|
||||||
@@ -281,7 +274,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
function chgsbas(sbaspopup)
|
function chgsbas(sbaspopup)
|
||||||
{
|
{
|
||||||
var data = {taskid:<?php echo $this->get_task_id(); ?>, bid: sbaspopup.value};
|
var data = {taskid:<?php echo $this->getID(); ?>, bid: sbaspopup.value};
|
||||||
data["ACT"] = "GETBASE";
|
data["ACT"] = "GETBASE";
|
||||||
data["cls"]="outofdate";
|
data["cls"]="outofdate";
|
||||||
$.ajax({ url: "/admin/taskfacility.php"
|
$.ajax({ url: "/admin/taskfacility.php"
|
||||||
@@ -314,72 +307,6 @@ class task_period_outofdate extends task_abstract
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
function chgxmltxt(textinput, fieldname)
|
|
||||||
{
|
|
||||||
var limits = { 'period':{min:1, 'max':1440} , 'delay':{min:0} } ;
|
|
||||||
if(typeof(limits[fieldname])!='undefined')
|
|
||||||
{
|
|
||||||
var v = 0|textinput.value;
|
|
||||||
if(limits[fieldname].min && v < limits[fieldname].min)
|
|
||||||
v = limits[fieldname].min;
|
|
||||||
else if(limits[fieldname].max && v > limits[fieldname].max)
|
|
||||||
v = limits[fieldname].max;
|
|
||||||
textinput.value = v;
|
|
||||||
}
|
|
||||||
setDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
function chgxmlck(checkinput, fieldname)
|
|
||||||
{
|
|
||||||
setDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
function chgxmlpopup(popupinput, fieldname)
|
|
||||||
{
|
|
||||||
setDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
function chgsbas(sbaspopup)
|
|
||||||
{
|
|
||||||
loadsbas(sbaspopup.value);
|
|
||||||
setDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadsbas(sbas)
|
|
||||||
{
|
|
||||||
$.ajax({ url:"/admin/taskfacility.php"
|
|
||||||
, data: {taskid:<?php echo $this->get_task_id() ?>, bid:sbas, type:"json", cls:"outofdate"}
|
|
||||||
, dataType:'json'
|
|
||||||
, type:"POST"
|
|
||||||
, async:false
|
|
||||||
, success:function(data)
|
|
||||||
{
|
|
||||||
$(".popfield").empty().append('<option class="jsFilled" value="">...</option>');
|
|
||||||
for(i in data.date_fields)
|
|
||||||
$(".popfield").append('<option class="jsFilled" value="'+data.date_fields[i]+'">'+data.date_fields[i]+'</option>');
|
|
||||||
|
|
||||||
$(".popcoll").empty().append('<option class="jsFilled" value="">...</option>');
|
|
||||||
for(i in data.collections)
|
|
||||||
$(".popcoll").append('<option class="jsFilled" value="'+data.collections[i].id+'">'+data.collections[i].name+'</option>');
|
|
||||||
|
|
||||||
$(".popstatus").empty().append('<option class="jsFilled" value="">...</option>');
|
|
||||||
for(i in data.status_bits)
|
|
||||||
{
|
|
||||||
$(".popstatus").append('<option class="jsFilled" value="'+data.status_bits[i].n+'_0">'+data.status_bits[i].labelOff+'</option>');
|
|
||||||
$(".popstatus").append('<option class="jsFilled" value="'+data.status_bits[i].n+'_1">'+data.status_bits[i].labelOn+'</option>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
?>
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -413,8 +340,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
|
<select onchange="chgsbas(this);setDirty();" name="sbas_id">
|
||||||
<option value="">...</option>
|
<option value="">...</option>
|
||||||
<?php
|
<?php
|
||||||
foreach($sbas_list as $databox)
|
foreach ($sbas_list as $databox) {
|
||||||
{
|
|
||||||
$selected = '';
|
$selected = '';
|
||||||
print("\t\t\t\t<option value=\"" . $databox->get_sbas_id() . "\" $selected>" . p4string::MakeString($databox->get_viewname(), "form") . "</option>\n");
|
print("\t\t\t\t<option value=\"" . $databox->get_sbas_id() . "\" $selected>" . p4string::MakeString($databox->get_viewname(), "form") . "</option>\n");
|
||||||
}
|
}
|
||||||
@@ -503,7 +429,6 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================================================================
|
// ====================================================================
|
||||||
// $argt : command line args specifics to this task (optional)
|
// $argt : command line args specifics to this task (optional)
|
||||||
// ====================================================================
|
// ====================================================================
|
||||||
@@ -518,14 +443,16 @@ class task_period_outofdate extends task_abstract
|
|||||||
{
|
{
|
||||||
return(_("task::outofdate:deplacement de docs suivant valeurs de champs 'date'"));
|
return(_("task::outofdate:deplacement de docs suivant valeurs de champs 'date'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================================================
|
// ======================================================================================================
|
||||||
// ===== run() : le code d'execution de la tache proprement dite
|
// ===== run() : le code d'execution de la tache proprement dite
|
||||||
// ======================================================================================================
|
// ======================================================================================================
|
||||||
|
|
||||||
protected $sxTaskSettings = null; // les settings de la tache en simplexml
|
protected $sxTaskSettings = null; // les settings de la tache en simplexml
|
||||||
|
|
||||||
private $connbas = null; // cnx a la base
|
private $connbas = null; // cnx a la base
|
||||||
|
|
||||||
private $msg = "";
|
private $msg = "";
|
||||||
|
|
||||||
private $sbas_id;
|
private $sbas_id;
|
||||||
|
|
||||||
protected function run2()
|
protected function run2()
|
||||||
@@ -548,62 +475,50 @@ class task_period_outofdate extends task_abstract
|
|||||||
// ici la tache tourne tant qu'elle est active
|
// ici la tache tourne tant qu'elle est active
|
||||||
$last_exec = 0;
|
$last_exec = 0;
|
||||||
$loop = 0;
|
$loop = 0;
|
||||||
while($this->running)
|
while ($this->running) {
|
||||||
{
|
if ( ! $conn->ping()) {
|
||||||
if(!$conn->ping())
|
|
||||||
{
|
|
||||||
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
$this->log(("Warning : abox connection lost, restarting in 10 min."));
|
||||||
for($i=0; $i<60 * 10; $i++)
|
for ($i = 0; $i < 60 * 10; $i ++ )
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
|
|
||||||
return(self::STATUS_TORESTART);
|
return(self::STATUS_TORESTART);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$connbas = connection::getPDOConnection($this->sbas_id);
|
$connbas = connection::getPDOConnection($this->sbas_id);
|
||||||
if(!$connbas->ping())
|
if ( ! $connbas->ping())
|
||||||
throw new Exception('Mysql has gone away');
|
throw new Exception('Mysql has gone away');
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch(Exception $e)
|
|
||||||
{
|
|
||||||
$this->log(("dbox connection lost, restarting in 10 min."));
|
$this->log(("dbox connection lost, restarting in 10 min."));
|
||||||
for($i=0; $i<60 * 10; $i++)
|
for ($i = 0; $i < 60 * 10; $i ++ )
|
||||||
sleep(1);
|
sleep(1);
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
|
|
||||||
return(self::STATUS_TORESTART);
|
return(self::STATUS_TORESTART);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_last_exec_time();
|
$this->setLastExecTime();
|
||||||
|
|
||||||
$databox = databox::get_instance($this->sbas_id);
|
$databox = databox::get_instance($this->sbas_id);
|
||||||
|
|
||||||
$sql = "SELECT * FROM task2 WHERE task_id = :task_id";
|
$sql = "SELECT * FROM task2 WHERE task_id = :task_id";
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
$stmt->execute(array(':task_id' => $this->get_task_id()));
|
$stmt->execute(array(':task_id' => $this->getID()));
|
||||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
if($row)
|
if ($row) {
|
||||||
{
|
if ($row['status'] == 'tostop') {
|
||||||
if($row['status'] == 'tostop')
|
|
||||||
{
|
|
||||||
$ret = self::STATUS_STOPPED;
|
$ret = self::STATUS_STOPPED;
|
||||||
;
|
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
} else {
|
||||||
else
|
if (($this->sxTaskSettings = simplexml_load_string($row['settings']))) {
|
||||||
{
|
|
||||||
if(($this->sxTaskSettings = simplexml_load_string($row['settings'])))
|
|
||||||
{
|
|
||||||
$period = (int) ($this->sxTaskSettings->period);
|
$period = (int) ($this->sxTaskSettings->period);
|
||||||
if($period <= 0 || $period >= 24 * 60)
|
if ($period <= 0 || $period >= 24 * 60)
|
||||||
$period = 60;
|
$period = 60;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$period = 60;
|
$period = 60;
|
||||||
}
|
}
|
||||||
$this->connbas = connection::getPDOConnection($this->sbas_id);
|
$this->connbas = connection::getPDOConnection($this->sbas_id);
|
||||||
@@ -612,8 +527,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
$r = $this->doRecords();
|
$r = $this->doRecords();
|
||||||
|
|
||||||
switch($r)
|
switch ($r) {
|
||||||
{
|
|
||||||
case 'WAIT':
|
case 'WAIT':
|
||||||
$ret = self::STATUS_STOPPED;
|
$ret = self::STATUS_STOPPED;
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
@@ -624,8 +538,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
break;
|
break;
|
||||||
case 'NORECSTODO':
|
case 'NORECSTODO':
|
||||||
$duration = time() - $duration;
|
$duration = time() - $duration;
|
||||||
if($duration < $period)
|
if ($duration < $period) {
|
||||||
{
|
|
||||||
sleep($period - $duration);
|
sleep($period - $duration);
|
||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
}
|
}
|
||||||
@@ -633,28 +546,24 @@ class task_period_outofdate extends task_abstract
|
|||||||
case 'MAXRECSDONE':
|
case 'MAXRECSDONE':
|
||||||
case 'MAXMEMORY':
|
case 'MAXMEMORY':
|
||||||
case 'MAXLOOP':
|
case 'MAXLOOP':
|
||||||
if($row['status'] == self::STATUS_STARTED && $this->get_runner() !== self::RUNNER_MANUAL)
|
if ($row['status'] == self::STATUS_STARTED && $this->getRunner() !== self::RUNNER_MANUAL) {
|
||||||
{
|
|
||||||
$ret = self::STATUS_TORESTART;
|
$ret = self::STATUS_TORESTART;
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if($row['status'] == self::STATUS_STARTED)
|
if ($row['status'] == self::STATUS_STARTED) {
|
||||||
{
|
|
||||||
$ret = self::STATUS_STOPPED;
|
$ret = self::STATUS_STOPPED;
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$ret = self::STATUS_STOPPED;
|
$ret = self::STATUS_STOPPED;
|
||||||
$this->running = false;
|
$this->running = false;
|
||||||
}
|
}
|
||||||
$loop++;
|
$loop ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,27 +575,21 @@ class task_period_outofdate extends task_abstract
|
|||||||
$tsql = $this->calcSQL($this->sxTaskSettings);
|
$tsql = $this->calcSQL($this->sxTaskSettings);
|
||||||
|
|
||||||
$nchanged = 0;
|
$nchanged = 0;
|
||||||
foreach($tsql as $xsql)
|
foreach ($tsql as $xsql) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
$stmt = $this->connbas->prepare($xsql['sql']);
|
$stmt = $this->connbas->prepare($xsql['sql']);
|
||||||
if($stmt->execute($xsql['params']))
|
if ($stmt->execute($xsql['params'])) {
|
||||||
{
|
|
||||||
$n = $stmt->rowCount();
|
$n = $stmt->rowCount();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$nchanged += $n;
|
$nchanged += $n;
|
||||||
if($n > 0)
|
if ($n > 0)
|
||||||
$this->log(sprintf("SQL='%s' ; parms=%s - %s changes", $xsql['sql'], var_export($xsql['params']), $n));
|
$this->log(sprintf("SQL='%s' ; parms=%s - %s changes", $xsql['sql'], var_export($xsql['params']), $n));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$this->log(sprintf("ERROR SQL='%s' ; parms=%s", $xsql['sql'], var_export($xsql['params'], true)));
|
$this->log(sprintf("ERROR SQL='%s' ; parms=%s", $xsql['sql'], var_export($xsql['params'], true)));
|
||||||
}
|
}
|
||||||
}
|
} catch (ErrorException $e) {
|
||||||
catch (ErrorException $e)
|
|
||||||
{
|
|
||||||
$this->log(sprintf("ERROR SQL='%s' ; parms=%s", $xsql['sql'], var_export($xsql['params'], true)));
|
$this->log(sprintf("ERROR SQL='%s' ; parms=%s", $xsql['sql'], var_export($xsql['params'], true)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -696,7 +599,6 @@ class task_period_outofdate extends task_abstract
|
|||||||
return($ret);
|
return($ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function calcSQL($sxTaskSettings)
|
private function calcSQL($sxTaskSettings)
|
||||||
{
|
{
|
||||||
$ret = array();
|
$ret = array();
|
||||||
@@ -707,12 +609,10 @@ class task_period_outofdate extends task_abstract
|
|||||||
$field1 = $field2 = '';
|
$field1 = $field2 = '';
|
||||||
|
|
||||||
// test : DATE 1
|
// test : DATE 1
|
||||||
if(($field1 = trim($this->sxTaskSettings->field1)) != '')
|
if (($field1 = trim($this->sxTaskSettings->field1)) != '') {
|
||||||
{
|
|
||||||
$date1 = time();
|
$date1 = time();
|
||||||
if(($delta = (int) ($this->sxTaskSettings->fieldDv1)) > 0)
|
if (($delta = (int) ($this->sxTaskSettings->fieldDv1)) > 0) {
|
||||||
{
|
if ($this->sxTaskSettings->fieldDs1 == '-')
|
||||||
if($this->sxTaskSettings->fieldDs1 == '-')
|
|
||||||
$date1 += 86400 * $delta;
|
$date1 += 86400 * $delta;
|
||||||
else
|
else
|
||||||
$date1 -= 86400 * $delta;
|
$date1 -= 86400 * $delta;
|
||||||
@@ -720,12 +620,10 @@ class task_period_outofdate extends task_abstract
|
|||||||
$date1 = date("YmdHis", $date1);
|
$date1 = date("YmdHis", $date1);
|
||||||
}
|
}
|
||||||
// test : DATE 2
|
// test : DATE 2
|
||||||
if(($field2 = trim($this->sxTaskSettings->field2)) != '')
|
if (($field2 = trim($this->sxTaskSettings->field2)) != '') {
|
||||||
{
|
|
||||||
$date2 = time();
|
$date2 = time();
|
||||||
if(($delta = (int) ($this->sxTaskSettings->fieldDv2)) > 0)
|
if (($delta = (int) ($this->sxTaskSettings->fieldDv2)) > 0) {
|
||||||
{
|
if ($this->sxTaskSettings->fieldDs2 == '-')
|
||||||
if($this->sxTaskSettings->fieldDs2 == '-')
|
|
||||||
$date2 += 86400 * $delta;
|
$date2 += 86400 * $delta;
|
||||||
else
|
else
|
||||||
$date2 -= 86400 * $delta;
|
$date2 -= 86400 * $delta;
|
||||||
@@ -735,28 +633,22 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
|
|
||||||
$sqlset = $params = $tmp_params = array();
|
$sqlset = $params = $tmp_params = array();
|
||||||
for($i = 0; $i <= 2; $i++)
|
for ($i = 0; $i <= 2; $i ++ ) {
|
||||||
{
|
|
||||||
$sqlwhere[$i] = '';
|
$sqlwhere[$i] = '';
|
||||||
$sqlset[$i] = '';
|
$sqlset[$i] = '';
|
||||||
$x = 'status' . $i;
|
$x = 'status' . $i;
|
||||||
@list($tostat, $statval) = explode('_', (string) ($this->sxTaskSettings->{$x}));
|
@list($tostat, $statval) = explode('_', (string) ($this->sxTaskSettings->{$x}));
|
||||||
if($tostat >= 4 && $tostat <= 63)
|
if ($tostat >= 4 && $tostat <= 63) {
|
||||||
{
|
if ($statval == '0') {
|
||||||
if($statval == '0')
|
|
||||||
{
|
|
||||||
$sqlset[$i] = 'status=status & ~(1<<' . $tostat . ')';
|
$sqlset[$i] = 'status=status & ~(1<<' . $tostat . ')';
|
||||||
$sqlwhere[$i] .= '(status & (1<<' . $tostat . ') = 0)';
|
$sqlwhere[$i] .= '(status & (1<<' . $tostat . ') = 0)';
|
||||||
}
|
} elseif ($statval == '1') {
|
||||||
elseif($statval == '1')
|
|
||||||
{
|
|
||||||
$sqlset[$i] = 'status=status|(1<<' . $tostat . ')';
|
$sqlset[$i] = 'status=status|(1<<' . $tostat . ')';
|
||||||
$sqlwhere[$i] .= '(status & (1<<' . $tostat . ') != 0)';
|
$sqlwhere[$i] .= '(status & (1<<' . $tostat . ') != 0)';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$x = 'coll' . $i;
|
$x = 'coll' . $i;
|
||||||
if(($tocoll = (string) ($this->sxTaskSettings->{$x})) != '')
|
if (($tocoll = (string) ($this->sxTaskSettings->{$x})) != '') {
|
||||||
{
|
|
||||||
$sqlset[$i] .= ( $sqlset[$i] ? ', ' : '') . ('coll_id = :coll_id_set' . $i);
|
$sqlset[$i] .= ( $sqlset[$i] ? ', ' : '') . ('coll_id = :coll_id_set' . $i);
|
||||||
$sqlwhere[$i] .= ( $sqlwhere[$i] ? ' AND ' : '') . '(coll_id = :coll_id_where' . $i . ')';
|
$sqlwhere[$i] .= ( $sqlwhere[$i] ? ' AND ' : '') . '(coll_id = :coll_id_where' . $i . ')';
|
||||||
$tmp_params[':coll_id_set' . $i] = $tocoll;
|
$tmp_params[':coll_id_set' . $i] = $tocoll;
|
||||||
@@ -764,44 +656,36 @@ class task_period_outofdate extends task_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($date1 && $sqlset[0])
|
if ($date1 && $sqlset[0]) {
|
||||||
{
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params[':name1'] = $field1;
|
$params[':name1'] = $field1;
|
||||||
$params[':date1'] = $date1;
|
$params[':date1'] = $date1;
|
||||||
$params[':coll_id_set0'] = $tmp_params[':coll_id_set0'];
|
$params[':coll_id_set0'] = $tmp_params[':coll_id_set0'];
|
||||||
|
|
||||||
$w = 'p1.name = :name1 AND :date1 <= p1.value';
|
$w = 'p1.name = :name1 AND :date1 <= p1.value';
|
||||||
if($sqlwhere[1] && $sqlwhere[2])
|
if ($sqlwhere[1] && $sqlwhere[2]) {
|
||||||
{
|
|
||||||
$w .= ' AND ((' . $sqlwhere[1] . ') OR (' . $sqlwhere[2] . '))';
|
$w .= ' AND ((' . $sqlwhere[1] . ') OR (' . $sqlwhere[2] . '))';
|
||||||
$params[':coll_id_where1'] = $tmp_params[':coll_id_where1'];
|
$params[':coll_id_where1'] = $tmp_params[':coll_id_where1'];
|
||||||
$params[':coll_id_where2'] = $tmp_params[':coll_id_where2'];
|
$params[':coll_id_where2'] = $tmp_params[':coll_id_where2'];
|
||||||
}
|
} else {
|
||||||
else
|
if ($sqlwhere[1]) {
|
||||||
{
|
|
||||||
if($sqlwhere[1])
|
|
||||||
{
|
|
||||||
$w .= ' AND ' . $sqlwhere[1];
|
$w .= ' AND ' . $sqlwhere[1];
|
||||||
$params[':coll_id_where1'] = $tmp_params[':coll_id_where1'];
|
$params[':coll_id_where1'] = $tmp_params[':coll_id_where1'];
|
||||||
}
|
} elseif ($sqlwhere[2]) {
|
||||||
elseif($sqlwhere[2])
|
|
||||||
{
|
|
||||||
$w .= ' AND ' . $sqlwhere[2];
|
$w .= ' AND ' . $sqlwhere[2];
|
||||||
$params[':coll_id_where2'] = $tmp_params[':coll_id_where2'];
|
$params[':coll_id_where2'] = $tmp_params[':coll_id_where2'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE prop AS p1 INNER JOIN record USING(record_id)
|
$sql = "UPDATE prop AS p1 INNER JOIN record USING(record_id)"
|
||||||
SET " . $sqlset[0] .
|
. " SET " . $sqlset[0]
|
||||||
" WHERE " . $w;
|
. " WHERE " . $w;
|
||||||
|
|
||||||
$ret[] = array('sql'=>$sql, 'params'=>$params);
|
$ret[] = array('sql' => $sql, 'params' => $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($date1 && $date2)
|
if ($date1 && $date2) {
|
||||||
{
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params[':name1'] = $field1;
|
$params[':name1'] = $field1;
|
||||||
$params[':name2'] = $field2;
|
$params[':name2'] = $field2;
|
||||||
@@ -810,75 +694,60 @@ class task_period_outofdate extends task_abstract
|
|||||||
$params[':coll_id_set1'] = $tmp_params[':coll_id_set1'];
|
$params[':coll_id_set1'] = $tmp_params[':coll_id_set1'];
|
||||||
|
|
||||||
$w = 'p1.name = :name1 AND p2.name = :name2 AND :date1 > p1.value AND :date2 <= p2.value';
|
$w = 'p1.name = :name1 AND p2.name = :name2 AND :date1 > p1.value AND :date2 <= p2.value';
|
||||||
if($sqlwhere[0] && $sqlwhere[2])
|
if ($sqlwhere[0] && $sqlwhere[2]) {
|
||||||
{
|
|
||||||
$w .= ' AND ((' . $sqlwhere[0] . ') OR (' . $sqlwhere[2] . '))';
|
$w .= ' AND ((' . $sqlwhere[0] . ') OR (' . $sqlwhere[2] . '))';
|
||||||
$params[':coll_id_where0'] = $tmp_params[':coll_id_where0'];
|
$params[':coll_id_where0'] = $tmp_params[':coll_id_where0'];
|
||||||
$params[':coll_id_where2'] = $tmp_params[':coll_id_where2'];
|
$params[':coll_id_where2'] = $tmp_params[':coll_id_where2'];
|
||||||
}
|
} else {
|
||||||
else
|
if ($sqlwhere[0]) {
|
||||||
{
|
|
||||||
if($sqlwhere[0])
|
|
||||||
{
|
|
||||||
$w .= ' AND ' . $sqlwhere[0];
|
$w .= ' AND ' . $sqlwhere[0];
|
||||||
$params[':coll_id_where0'] = $tmp_params[':coll_id_where0'];
|
$params[':coll_id_where0'] = $tmp_params[':coll_id_where0'];
|
||||||
}
|
} elseif ($sqlwhere[2]) {
|
||||||
elseif($sqlwhere[2])
|
|
||||||
{
|
|
||||||
$w .= ' AND ' . $sqlwhere[2];
|
$w .= ' AND ' . $sqlwhere[2];
|
||||||
$params[':coll_id_where2'] = $tmp_params[':coll_id_where2'];
|
$params[':coll_id_where2'] = $tmp_params[':coll_id_where2'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE (prop AS p1 INNER JOIN prop AS p2 USING(record_id))
|
$sql = "UPDATE (prop AS p1 INNER JOIN prop AS p2 USING(record_id))"
|
||||||
INNER JOIN record USING(record_id)
|
. " INNER JOIN record USING(record_id)"
|
||||||
SET " . $sqlset[1] .
|
. " SET " . $sqlset[1]
|
||||||
" WHERE " . $w;
|
. " WHERE " . $w;
|
||||||
|
|
||||||
$ret[] = array('sql'=>$sql, 'params'=>$params);
|
$ret[] = array('sql' => $sql, 'params' => $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($date2 && $sqlset[2])
|
if ($date2 && $sqlset[2]) {
|
||||||
{
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params[':name2'] = $field2;
|
$params[':name2'] = $field2;
|
||||||
$params[':date2'] = $date2;
|
$params[':date2'] = $date2;
|
||||||
$params[':coll_id_set2'] = $tmp_params[':coll_id_set2'];
|
$params[':coll_id_set2'] = $tmp_params[':coll_id_set2'];
|
||||||
|
|
||||||
$w = 'p2.name = :name2 AND :date2 > p2.value';
|
$w = 'p2.name = :name2 AND :date2 > p2.value';
|
||||||
if($sqlwhere[0] && $sqlwhere[1])
|
if ($sqlwhere[0] && $sqlwhere[1]) {
|
||||||
{
|
|
||||||
$w .= ' AND ((' . $sqlwhere[0] . ') OR (' . $sqlwhere[1] . '))';
|
$w .= ' AND ((' . $sqlwhere[0] . ') OR (' . $sqlwhere[1] . '))';
|
||||||
$params[':coll_id_where0'] = $tmp_params[':coll_id_where0'];
|
$params[':coll_id_where0'] = $tmp_params[':coll_id_where0'];
|
||||||
$params[':coll_id_where1'] = $tmp_params[':coll_id_where1'];
|
$params[':coll_id_where1'] = $tmp_params[':coll_id_where1'];
|
||||||
}
|
} else {
|
||||||
else
|
if ($sqlwhere[0]) {
|
||||||
{
|
|
||||||
if($sqlwhere[0])
|
|
||||||
{
|
|
||||||
$w .= ' AND ' . $sqlwhere[0];
|
$w .= ' AND ' . $sqlwhere[0];
|
||||||
$params[':coll_id_where0'] = $tmp_params[':coll_id_where0'];
|
$params[':coll_id_where0'] = $tmp_params[':coll_id_where0'];
|
||||||
}
|
} elseif ($sqlwhere[1]) {
|
||||||
elseif($sqlwhere[1])
|
|
||||||
{
|
|
||||||
$w .= ' AND ' . $sqlwhere[1];
|
$w .= ' AND ' . $sqlwhere[1];
|
||||||
$params[':coll_id_where1'] = $tmp_params[':coll_id_where1'];
|
$params[':coll_id_where1'] = $tmp_params[':coll_id_where1'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "UPDATE prop AS p2 INNER JOIN record USING(record_id)
|
$sql = "UPDATE prop AS p2 INNER JOIN record USING(record_id)"
|
||||||
SET " . $sqlset[2] .
|
. " SET " . $sqlset[2]
|
||||||
" WHERE " . $w;
|
. " WHERE " . $w;
|
||||||
|
|
||||||
$ret[] = array('sql'=>$sql, 'params'=>$params);
|
$ret[] = array('sql' => $sql, 'params' => $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
return($ret);
|
return($ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function facility()
|
public function facility()
|
||||||
{
|
{
|
||||||
$ret = NULL;
|
$ret = NULL;
|
||||||
@@ -890,8 +759,7 @@ class task_period_outofdate extends task_abstract
|
|||||||
|
|
||||||
phrasea::headers(200, true, 'application/json', 'UTF-8', false);
|
phrasea::headers(200, true, 'application/json', 'UTF-8', false);
|
||||||
$ret = NULL;
|
$ret = NULL;
|
||||||
switch($parm2['ACT'])
|
switch ($parm2['ACT']) {
|
||||||
{
|
|
||||||
case 'CALCSQL':
|
case 'CALCSQL':
|
||||||
$xml = $this->graphic2xml('<?xml version="1.0" encoding="UTF-8"?><tasksettings/>');
|
$xml = $this->graphic2xml('<?xml version="1.0" encoding="UTF-8"?><tasksettings/>');
|
||||||
$sxml = simplexml_load_string($xml);
|
$sxml = simplexml_load_string($xml);
|
||||||
@@ -900,34 +768,28 @@ class task_period_outofdate extends task_abstract
|
|||||||
case 'GETBASE':
|
case 'GETBASE':
|
||||||
$ret = array('date_fields' => array(), 'status_bits' => array(), 'collections' => array());
|
$ret = array('date_fields' => array(), 'status_bits' => array(), 'collections' => array());
|
||||||
|
|
||||||
if($parm2['bid'] != '')
|
if ($parm2['bid'] != '') {
|
||||||
{
|
|
||||||
$sbas_id = (int) $parm2['bid'];
|
$sbas_id = (int) $parm2['bid'];
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
$databox = databox::get_instance($sbas_id);
|
||||||
$meta_struct = $databox->get_meta_structure();
|
$meta_struct = $databox->get_meta_structure();
|
||||||
|
|
||||||
foreach($meta_struct as $meta)
|
foreach ($meta_struct as $meta) {
|
||||||
{
|
if (mb_strtolower($meta->get_type()) == 'date')
|
||||||
if(mb_strtolower($meta->get_type()) == 'date')
|
|
||||||
$ret['date_fields'][] = $meta->get_name();
|
$ret['date_fields'][] = $meta->get_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = $databox->get_statusbits();
|
$status = $databox->get_statusbits();
|
||||||
foreach($status as $n => $stat)
|
foreach ($status as $n => $stat) {
|
||||||
{
|
|
||||||
$labelon = $stat['labelon'] ? $stat['labelon'] : ($n . '-ON');
|
$labelon = $stat['labelon'] ? $stat['labelon'] : ($n . '-ON');
|
||||||
$labeloff = $stat['labeloff'] ? $stat['labeloff'] : ($n . '-OFF');
|
$labeloff = $stat['labeloff'] ? $stat['labeloff'] : ($n . '-OFF');
|
||||||
$ret['status_bits'][] = array('n' => $n, 'value' => 0, 'label' => $labeloff);
|
$ret['status_bits'][] = array('n' => $n, 'value' => 0, 'label' => $labeloff);
|
||||||
$ret['status_bits'][] = array('n' => $n, 'value' => 1, 'label' => $labelon);
|
$ret['status_bits'][] = array('n' => $n, 'value' => 1, 'label' => $labelon);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($databox->get_collections() as $collection)
|
foreach ($databox->get_collections() as $collection)
|
||||||
$ret['collections'][] = array('id' => $collection->get_coll_id(), 'name' => $collection->get_name());
|
$ret['collections'][] = array('id' => $collection->get_coll_id(), 'name' => $collection->get_name());
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch(Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -936,5 +798,4 @@ class task_period_outofdate extends task_abstract
|
|||||||
print(json_encode($ret));
|
print(json_encode($ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -78,7 +78,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0)) {
|
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
} else {
|
} else {
|
||||||
@@ -235,7 +235,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function retrieve_sbas_content(databox $databox)
|
public function retrieveSbasContent(databox $databox)
|
||||||
{
|
{
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
return $rs;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function process_one_content(databox $databox, Array $row)
|
public function processOneContent(databox $databox, Array $row)
|
||||||
{
|
{
|
||||||
$record_id = $row['record_id'];
|
$record_id = $row['record_id'];
|
||||||
$this->log(sprintf(
|
$this->log(sprintf(
|
||||||
@@ -266,14 +266,14 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
$this->recs_to_write[] = $record->get_record_id();
|
$this->recs_to_write[] = $record->get_record_id();
|
||||||
|
|
||||||
if (count($this->recs_to_write) >= $this->record_buffer_size) {
|
if (count($this->recs_to_write) >= $this->record_buffer_size) {
|
||||||
$this->flush_records_sbas();
|
$this->flushRecordsSbas();
|
||||||
}
|
}
|
||||||
unset($record);
|
unset($record);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function post_process_one_content(databox $databox, Array $row)
|
protected function postProcessOneContent(databox $databox, Array $row)
|
||||||
{
|
{
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
$sql = 'UPDATE record
|
$sql = 'UPDATE record
|
||||||
@@ -287,7 +287,7 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function flush_records_sbas()
|
protected function flushRecordsSbas()
|
||||||
{
|
{
|
||||||
$sql = implode(', ', $this->recs_to_write);
|
$sql = implode(', ', $this->recs_to_write);
|
||||||
|
|
||||||
@@ -314,6 +314,5 @@ class task_period_subdef extends task_databoxAbstract
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@@ -37,8 +37,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
$dom = new DOMDocument();
|
$dom = new DOMDocument();
|
||||||
$dom->preserveWhiteSpace = false;
|
$dom->preserveWhiteSpace = false;
|
||||||
$dom->formatOutput = true;
|
$dom->formatOutput = true;
|
||||||
if ($dom->loadXML($oldxml))
|
if ($dom->loadXML($oldxml)) {
|
||||||
{
|
|
||||||
$xmlchanged = false;
|
$xmlchanged = false;
|
||||||
// foreach($parm2 as $pname=>$pvalue)
|
// foreach($parm2 as $pname=>$pvalue)
|
||||||
foreach (array(
|
foreach (array(
|
||||||
@@ -48,27 +47,22 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
'str:coll0',
|
'str:coll0',
|
||||||
'str:status1',
|
'str:status1',
|
||||||
'str:coll1',
|
'str:coll1',
|
||||||
) as $pname)
|
) as $pname) {
|
||||||
{
|
|
||||||
$ptype = substr($pname, 0, 3);
|
$ptype = substr($pname, 0, 3);
|
||||||
$pname = substr($pname, 4);
|
$pname = substr($pname, 4);
|
||||||
$pvalue = $parm2[$pname];
|
$pvalue = $parm2[$pname];
|
||||||
if ($ns = $dom->getElementsByTagName($pname)->item(0))
|
if (($ns = $dom->getElementsByTagName($pname)->item(0))) {
|
||||||
{
|
|
||||||
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
// le champ existait dans le xml, on supprime son ancienne valeur (tout le contenu)
|
||||||
while (($n = $ns->firstChild))
|
while (($n = $ns->firstChild))
|
||||||
$ns->removeChild($n);
|
$ns->removeChild($n);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// le champ n'existait pas dans le xml, on le cree
|
// le champ n'existait pas dans le xml, on le cree
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
$dom->documentElement->appendChild($dom->createTextNode("\t"));
|
||||||
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
$ns = $dom->documentElement->appendChild($dom->createElement($pname));
|
||||||
$dom->documentElement->appendChild($dom->createTextNode("\n"));
|
$dom->documentElement->appendChild($dom->createTextNode("\n"));
|
||||||
}
|
}
|
||||||
// on fixe sa valeur
|
// on fixe sa valeur
|
||||||
switch ($ptype)
|
switch ($ptype) {
|
||||||
{
|
|
||||||
case "str":
|
case "str":
|
||||||
$ns->appendChild($dom->createTextNode($pvalue));
|
$ns->appendChild($dom->createTextNode($pvalue));
|
||||||
break;
|
break;
|
||||||
@@ -85,8 +79,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
|
|
||||||
public function xml2graphic($xml, $form)
|
public function xml2graphic($xml, $form)
|
||||||
{
|
{
|
||||||
if (($sxml = simplexml_load_string($xml))) // in fact XML IS always valid here...
|
if (($sxml = simplexml_load_string($xml))) { // in fact XML IS always valid here...
|
||||||
{
|
|
||||||
// ... but we could check for safe values
|
// ... but we could check for safe values
|
||||||
if ((int) ($sxml->period) < 1)
|
if ((int) ($sxml->period) < 1)
|
||||||
$sxml->period = 1;
|
$sxml->period = 1;
|
||||||
@@ -95,7 +88,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
|
|
||||||
if ((string) ($sxml->delay) == '')
|
if ((string) ($sxml->delay) == '')
|
||||||
$sxml->delay = 0;
|
$sxml->delay = 0;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var i;
|
var i;
|
||||||
var opts;
|
var opts;
|
||||||
@@ -121,23 +114,22 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
if(j==0)
|
if(j==0)
|
||||||
parent.chgsbas(<?php echo $form ?>[pops[j].name]);
|
parent.chgsbas(<?php echo $form ?>[pops[j].name]);
|
||||||
}
|
}
|
||||||
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
<?php echo $form ?>.period.value = "<?php echo p4string::MakeString($sxml->period, "js", '"') ?>";
|
||||||
parent.calccmd();
|
parent.calccmd();
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
else // ... so we NEVER come here
|
else { // ... so we NEVER come here
|
||||||
{
|
|
||||||
// bad xml
|
// bad xml
|
||||||
|
|
||||||
return("BAD XML");
|
return("BAD XML");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function printInterfaceHEAD()
|
public function printInterfaceHEAD()
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
<style>
|
<style>
|
||||||
OPTION.jsFilled
|
OPTION.jsFilled
|
||||||
{
|
{
|
||||||
@@ -149,12 +141,12 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
text-align:center;
|
text-align:center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
public function printInterfaceJS()
|
public function printInterfaceJS()
|
||||||
{
|
{
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function calccmd()
|
function calccmd()
|
||||||
{
|
{
|
||||||
@@ -209,16 +201,19 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
setDirty();
|
setDirty();
|
||||||
calccmd();
|
calccmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
function chgxmlck(checkinput, fieldname)
|
function chgxmlck(checkinput, fieldname)
|
||||||
{
|
{
|
||||||
setDirty();
|
setDirty();
|
||||||
calccmd();
|
calccmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
function chgxmlpopup(popupinput, fieldname)
|
function chgxmlpopup(popupinput, fieldname)
|
||||||
{
|
{
|
||||||
setDirty();
|
setDirty();
|
||||||
calccmd();
|
calccmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
function chgsbas(sbaspopup)
|
function chgsbas(sbaspopup)
|
||||||
{
|
{
|
||||||
for(fld=0; fld<=1; fld++)
|
for(fld=0; fld<=1; fld++)
|
||||||
@@ -242,7 +237,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url:"/admin/taskfacility.php"
|
url:"/admin/taskfacility.php"
|
||||||
, async:false
|
, async:false
|
||||||
, data:{'cls':'workflow01', 'taskid':<?php echo $this->get_task_id() ?>, 'bid':sbaspopup.value}
|
, data:{'cls':'workflow01', 'taskid':<?php echo $this->getID() ?>, 'bid':sbaspopup.value}
|
||||||
, success:function(data){
|
, success:function(data){
|
||||||
for(fld=0; fld<=1; fld++)
|
for(fld=0; fld<=1; fld++)
|
||||||
{
|
{
|
||||||
@@ -272,7 +267,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
calccmd();
|
calccmd();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGraphicForm()
|
function getGraphicForm()
|
||||||
@@ -286,7 +281,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
<form name="graphicForm" onsubmit="return(false);" method="post">
|
<form name="graphicForm" onsubmit="return(false);" method="post">
|
||||||
<?php echo _('task::outofdate:Base') ?> :
|
<?php echo _('task::outofdate:Base') ?> :
|
||||||
|
|
||||||
@@ -294,8 +289,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
<option value="">...</option>
|
<option value="">...</option>
|
||||||
<?php
|
<?php
|
||||||
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
|
$sbas_ids = $user->ACL()->get_granted_sbas(array('bas_manage'));
|
||||||
foreach ($sbas_ids as $databox)
|
foreach ($sbas_ids as $databox) {
|
||||||
{
|
|
||||||
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
|
print('<option value="' . $databox->get_sbas_id() . '">' . p4string::MakeString($databox->get_viewname(), "form") . '</option>');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -343,7 +337,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
<center>
|
<center>
|
||||||
<div style="margin:10px; padding:5px; border:1px #000000 solid; font-family:monospace; font-size:16px; text-align:left; color:#00e000; background-color:#404040" id="cmd">cmd</div>
|
<div style="margin:10px; padding:5px; border:1px #000000 solid; font-family:monospace; font-size:16px; text-align:left; color:#00e000; background-color:#404040" id="cmd">cmd</div>
|
||||||
</center>
|
</center>
|
||||||
<?php
|
<?php
|
||||||
$out = ob_get_clean();
|
$out = ob_get_clean();
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
@@ -353,13 +347,15 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
{
|
{
|
||||||
return(_("task::outofdate:deplacement de docs suivant valeurs de champs 'date'"));
|
return(_("task::outofdate:deplacement de docs suivant valeurs de champs 'date'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $status_origine;
|
protected $status_origine;
|
||||||
|
|
||||||
protected $coll_origine;
|
protected $coll_origine;
|
||||||
|
|
||||||
protected $status_destination;
|
protected $status_destination;
|
||||||
|
|
||||||
protected $coll_destination;
|
protected $coll_destination;
|
||||||
|
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->status_origine = (string) $sx_task_settings->status0;
|
$this->status_origine = (string) $sx_task_settings->status0;
|
||||||
$this->status_destination = (string) $sx_task_settings->status1;
|
$this->status_destination = (string) $sx_task_settings->status1;
|
||||||
@@ -367,7 +363,7 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
$this->coll_origine = (int) $sx_task_settings->coll0;
|
$this->coll_origine = (int) $sx_task_settings->coll0;
|
||||||
$this->coll_destination = (int) $sx_task_settings->coll1;
|
$this->coll_destination = (int) $sx_task_settings->coll1;
|
||||||
|
|
||||||
parent::load_settings($sx_task_settings);
|
parent::loadSettings($sx_task_settings);
|
||||||
|
|
||||||
$this->mono_sbas_id = (int) $sx_task_settings->sbas_id;
|
$this->mono_sbas_id = (int) $sx_task_settings->sbas_id;
|
||||||
// in minutes
|
// in minutes
|
||||||
@@ -375,11 +371,9 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
|
|
||||||
if ($this->period <= 0 || $this->period >= 24 * 60)
|
if ($this->period <= 0 || $this->period >= 24 * 60)
|
||||||
$this->period = 60;
|
$this->period = 60;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function retrieve_sbas_content(databox $databox)
|
protected function retrieveSbasContent(databox $databox)
|
||||||
{
|
{
|
||||||
static $firstCall = true;
|
static $firstCall = true;
|
||||||
|
|
||||||
@@ -387,52 +381,45 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
|
|
||||||
$sql_s = $sql_w = '';
|
$sql_s = $sql_w = '';
|
||||||
$sql_parms = array();
|
$sql_parms = array();
|
||||||
if($this->coll_origine != '')
|
if ($this->coll_origine != '') {
|
||||||
{
|
$sql_w .= ($sql_w ? ' AND ' : '')
|
||||||
$sql_w .= ($sql_w?' AND ':'')
|
. '(coll_id=:coll_org)';
|
||||||
.'(coll_id=:coll_org)';
|
|
||||||
$sql_parms[':coll_org'] = $this->coll_origine;
|
$sql_parms[':coll_org'] = $this->coll_origine;
|
||||||
}
|
}
|
||||||
if($this->status_origine != '')
|
if ($this->status_origine != '') {
|
||||||
{
|
|
||||||
$x = explode('_', $this->status_origine);
|
$x = explode('_', $this->status_origine);
|
||||||
if (count($x) !== 2)
|
if (count($x) !== 2)
|
||||||
throw new Exception('Error in settings for status origine');
|
throw new Exception('Error in settings for status origine');
|
||||||
$sql_w .= ($sql_w?' AND ':'')
|
$sql_w .= ($sql_w ? ' AND ' : '')
|
||||||
.'((status >> :stat_org_n & 1) = :stat_org_v)';
|
. '((status >> :stat_org_n & 1) = :stat_org_v)';
|
||||||
$sql_parms[':stat_org_n'] = $x[0];
|
$sql_parms[':stat_org_n'] = $x[0];
|
||||||
$sql_parms[':stat_org_v'] = $x[1];
|
$sql_parms[':stat_org_v'] = $x[1];
|
||||||
}
|
}
|
||||||
if($this->coll_destination != '')
|
if ($this->coll_destination != '') {
|
||||||
{
|
$sql_s .= ($sql_s ? ', ' : '')
|
||||||
$sql_s .= ($sql_s?', ':'')
|
. 'coll_id=:coll_dst';
|
||||||
.'coll_id=:coll_dst';
|
|
||||||
$sql_parms[':coll_dst'] = $this->coll_destination;
|
$sql_parms[':coll_dst'] = $this->coll_destination;
|
||||||
}
|
}
|
||||||
if($this->status_destination != '')
|
if ($this->status_destination != '') {
|
||||||
{
|
|
||||||
$x = explode('_', $this->status_destination);
|
$x = explode('_', $this->status_destination);
|
||||||
if (count($x) !== 2)
|
if (count($x) !== 2)
|
||||||
throw new Exception('Error in settings for status destination');
|
throw new Exception('Error in settings for status destination');
|
||||||
$sql_s .= ($sql_s?', ':'');
|
$sql_s .= ($sql_s ? ', ' : '');
|
||||||
if((int)$x[1] === 0)
|
if ((int) $x[1] === 0)
|
||||||
$sql_s .= 'status = status &~(1 << :stat_dst)';
|
$sql_s .= 'status = status &~(1 << :stat_dst)';
|
||||||
else
|
else
|
||||||
$sql_s .= 'status = status |(1 << :stat_dst)';
|
$sql_s .= 'status = status |(1 << :stat_dst)';
|
||||||
$sql_parms[':stat_dst'] = (int)$x[0];
|
$sql_parms[':stat_dst'] = (int) $x[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sql_w && $sql_s)
|
if ($sql_w && $sql_s) {
|
||||||
{
|
|
||||||
$sql = 'UPDATE record SET ' . $sql_s . ' WHERE ' . $sql_w;
|
$sql = 'UPDATE record SET ' . $sql_s . ' WHERE ' . $sql_w;
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute($sql_parms);
|
$stmt->execute($sql_parms);
|
||||||
|
|
||||||
if($firstCall || $stmt->rowCount() != 0)
|
if ($firstCall || $stmt->rowCount() != 0) {
|
||||||
{
|
$this->log(sprintf(("SQL=%s\n (parms=%s)\n - %s changes"), str_replace(array("\r\n", "\n", "\r", "\t"), " ", $sql)
|
||||||
$this->log(sprintf(("SQL=%s\n (parms=%s)\n - %s changes"),
|
, str_replace(array("\r\n", "\n", "\r", "\t"), " ", var_export($sql_parms, true))
|
||||||
str_replace(array("\r\n","\n","\r", "\t"), " ", $sql)
|
|
||||||
, str_replace(array("\r\n","\n","\r","\t"), " ", var_export($sql_parms, true))
|
|
||||||
, $stmt->rowCount()));
|
, $stmt->rowCount()));
|
||||||
$firstCall = false;
|
$firstCall = false;
|
||||||
}
|
}
|
||||||
@@ -442,17 +429,17 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function process_one_content(databox $databox, Array $row)
|
protected function processOneContent(databox $databox, Array $row)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function flush_records_sbas()
|
protected function flushRecordsSbas()
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function post_process_one_content(databox $databox, Array $row)
|
protected function postProcessOneContent(databox $databox, Array $row)
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -469,75 +456,39 @@ class task_period_workflow01 extends task_databoxAbstract
|
|||||||
|
|
||||||
phrasea::headers(200, true, 'text/json', 'UTF-8', false);
|
phrasea::headers(200, true, 'text/json', 'UTF-8', false);
|
||||||
|
|
||||||
$ret = new DOMDocument("1.0", "UTF-8");
|
$retjs = array('result' => NULL,
|
||||||
$ret->standalone = true;
|
'date_fields' => array(),
|
||||||
$ret->preserveWhiteSpace = false;
|
'status_bits' => array(),
|
||||||
|
'collections' => array()
|
||||||
$retjs = array('result'=>NULL,
|
|
||||||
'date_fields'=>array(),
|
|
||||||
'status_bits'=>array(),
|
|
||||||
'collections'=>array()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$element = $ret->createElement('result');
|
$sbas_id = (int) $parm['bid'];
|
||||||
|
try {
|
||||||
$root = $ret->appendChild($element);
|
|
||||||
$root->appendChild($ret->createCDATASection(var_export($parm, true)));
|
|
||||||
$dfields = $root->appendChild($ret->createElement("date_fields"));
|
|
||||||
$statbits = $root->appendChild($ret->createElement("status_bits"));
|
|
||||||
$coll = $root->appendChild($ret->createElement("collections"));
|
|
||||||
|
|
||||||
$sbas_id = (int)$parm['bid'];
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
$databox = databox::get_instance($sbas_id);
|
||||||
foreach ($databox->get_meta_structure() as $meta)
|
foreach ($databox->get_meta_structure() as $meta) {
|
||||||
{
|
|
||||||
if ($meta->get_type() !== 'date')
|
if ($meta->get_type() !== 'date')
|
||||||
continue;
|
continue;
|
||||||
$dfields->appendChild($ret->createElement("field"))
|
|
||||||
->appendChild($ret->createTextNode($meta->get_name()));
|
|
||||||
$retjs['date_fields'][] = $meta->get_name();
|
$retjs['date_fields'][] = $meta->get_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = $databox->get_statusbits();
|
$status = $databox->get_statusbits();
|
||||||
|
|
||||||
foreach ($status as $n => $s)
|
foreach ($status as $n => $s) {
|
||||||
{
|
|
||||||
$node = $statbits->appendChild($ret->createElement("bit"));
|
|
||||||
$node->setAttribute('n', $n);
|
|
||||||
$node->setAttribute('value', '0');
|
|
||||||
$node->setAttribute('label', $s['labeloff']);
|
|
||||||
$node->appendChild($ret->createTextNode($s['labeloff']));
|
|
||||||
$node = $statbits->appendChild($ret->createElement("bit"));
|
|
||||||
$node->setAttribute('n', $n);
|
|
||||||
$node->setAttribute('value', '1');
|
|
||||||
$node->setAttribute('label', $s['labelon']);
|
|
||||||
$node->appendChild($ret->createTextNode($s['labelon']));
|
|
||||||
|
|
||||||
$retjs['status_bits'][] = array(
|
$retjs['status_bits'][] = array(
|
||||||
'n'=>$n,
|
'n' => $n,
|
||||||
'value'=>0,
|
'value' => 0,
|
||||||
'label'=>$s['labeloff'] ? $s['labeloff'] : 'non '.$s['name'] );
|
'label' => $s['labeloff'] ? $s['labeloff'] : 'non ' . $s['name']);
|
||||||
$retjs['status_bits'][] = array(
|
$retjs['status_bits'][] = array(
|
||||||
'n'=>$n,
|
'n' => $n,
|
||||||
'value'=>1,
|
'value' => 1,
|
||||||
'label'=>$s['labelon'] ? $s['labelon'] : $s['name'] );
|
'label' => $s['labelon'] ? $s['labelon'] : $s['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$base_ids = $user->ACL()->get_granted_base(array(), array($sbas_id));
|
$base_ids = $user->ACL()->get_granted_base(array(), array($sbas_id));
|
||||||
|
foreach ($base_ids as $base_id => $collection) {
|
||||||
foreach ($base_ids as $base_id=>$collection)
|
$retjs['collections'][] = array('id' => (string) ($collection->get_coll_id()), 'name' => $collection->get_name());
|
||||||
{
|
|
||||||
$node = $coll->appendChild($ret->createElement("collection"));
|
|
||||||
$node->setAttribute('id', $collection->get_coll_id());
|
|
||||||
$node->appendChild($ret->createTextNode($collection->get_name()));
|
|
||||||
|
|
||||||
$retjs['collections'][] = array('id'=>(string)($collection->get_coll_id()), 'name'=>$collection->get_name());
|
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return p4string::jsonencode($retjs);
|
return p4string::jsonencode($retjs);
|
||||||
|
@@ -23,6 +23,7 @@ use PHPExiftool\Writer;
|
|||||||
class task_period_writemeta extends task_databoxAbstract
|
class task_period_writemeta extends task_databoxAbstract
|
||||||
{
|
{
|
||||||
protected $clear_doc;
|
protected $clear_doc;
|
||||||
|
|
||||||
protected $metasubdefs = array();
|
protected $metasubdefs = array();
|
||||||
|
|
||||||
function help()
|
function help()
|
||||||
@@ -30,12 +31,10 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
return(_("task::writemeta:(re)ecriture des metadatas dans les documents (et subdefs concernees)"));
|
return(_("task::writemeta:(re)ecriture des metadatas dans les documents (et subdefs concernees)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function load_settings(SimpleXMLElement $sx_task_settings)
|
protected function loadSettings(SimpleXMLElement $sx_task_settings)
|
||||||
{
|
{
|
||||||
$this->clear_doc = p4field::isyes($sx_task_settings->cleardoc);
|
$this->clear_doc = p4field::isyes($sx_task_settings->cleardoc);
|
||||||
parent::load_settings($sx_task_settings);
|
parent::loadSettings($sx_task_settings);
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
@@ -118,7 +117,6 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
<?php echo $form ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>";
|
<?php echo $form ?>.maxmegs.value = "<?php echo p4string::MakeString($sxml->maxmegs, "js", '"') ?>";
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return("");
|
return("");
|
||||||
}
|
}
|
||||||
else { // ... so we NEVER come here
|
else { // ... so we NEVER come here
|
||||||
@@ -212,7 +210,7 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function retrieve_sbas_content(databox $databox)
|
protected function retrieveSbasContent(databox $databox)
|
||||||
{
|
{
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
$subdefgroups = $databox->get_subdef_structure();
|
$subdefgroups = $databox->get_subdef_structure();
|
||||||
@@ -239,7 +237,7 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
return $rs;
|
return $rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function process_one_content(databox $databox, Array $row)
|
protected function processOneContent(databox $databox, Array $row)
|
||||||
{
|
{
|
||||||
$record_id = $row['record_id'];
|
$record_id = $row['record_id'];
|
||||||
$jeton = $row['jeton'];
|
$jeton = $row['jeton'];
|
||||||
@@ -327,12 +325,12 @@ class task_period_writemeta extends task_databoxAbstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function flush_records_sbas()
|
protected function flushRecordsSbas()
|
||||||
{
|
{
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function post_process_one_content(databox $databox, Array $row)
|
protected function postProcessOneContent(databox $databox, Array $row)
|
||||||
{
|
{
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
|
|
||||||
|
@@ -166,7 +166,7 @@
|
|||||||
|
|
||||||
currentView : null,
|
currentView : null,
|
||||||
|
|
||||||
oldXML:"{{task.get_settings()|stripdoublequotes}}",
|
oldXML:"{{task.getSettings()|stripdoublequotes}}",
|
||||||
|
|
||||||
view:function(type)
|
view:function(type)
|
||||||
{
|
{
|
||||||
@@ -300,7 +300,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = "/admin/adminFeedback.php?action=RESETTASKCRASHCOUNTER&task_id={{task.get_task_id()}}";
|
var url = "/admin/adminFeedback.php?action=RESETTASKCRASHCOUNTER&task_id={{task.getID()}}";
|
||||||
this.resetCrashCounter.x.xmlhttp.onreadystatechange = this.resetCrashCounter.x.cb; // ping_stateChange;
|
this.resetCrashCounter.x.xmlhttp.onreadystatechange = this.resetCrashCounter.x.cb; // ping_stateChange;
|
||||||
this.resetCrashCounter.x.xmlhttp.open("POST", url, true);
|
this.resetCrashCounter.x.xmlhttp.open("POST", url, true);
|
||||||
this.resetCrashCounter.x.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
this.resetCrashCounter.x.xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
@@ -356,7 +356,7 @@
|
|||||||
o.setAttribute("id", "__gtid");
|
o.setAttribute("id", "__gtid");
|
||||||
o.setAttribute("name", "__tid");
|
o.setAttribute("name", "__tid");
|
||||||
o.setAttribute("type", "hidden");
|
o.setAttribute("type", "hidden");
|
||||||
o.setAttribute("value", "{{task.get_task_id()}}");
|
o.setAttribute("value", "{{task.getID()}}");
|
||||||
f.appendChild(o);
|
f.appendChild(o);
|
||||||
}
|
}
|
||||||
redrawme();
|
redrawme();
|
||||||
@@ -380,15 +380,15 @@
|
|||||||
|
|
||||||
<body id="idBody" onResize="redrawme();" onLoad="loaded();" style="background-color:#AAAAAA; overflow:hidden" scroll="no" >
|
<body id="idBody" onResize="redrawme();" onLoad="loaded();" style="background-color:#AAAAAA; overflow:hidden" scroll="no" >
|
||||||
<div style="position:absolute; top:0px; left:5px; right:5px; height:45px; " nowrap>
|
<div style="position:absolute; top:0px; left:5px; right:5px; height:45px; " nowrap>
|
||||||
<h4 style="padding:2px; text-align:center">{{task.getName()}} <span id="taskid">id : {{task.get_task_id()}}</span></h4>
|
<h4 style="padding:2px; text-align:center">{{task.getName()}} <span id="taskid">id : {{task.getID()}}</span></h4>
|
||||||
<form name="__ftask" onsubmit="return(false);" method="post" method="post">
|
<form name="__ftask" onsubmit="return(false);" method="post" method="post">
|
||||||
<label>{% trans 'admin::tasks: nom de la tache' %}</label>
|
<label>{% trans 'admin::tasks: nom de la tache' %}</label>
|
||||||
<input type="text" name="__tname" style="width:200px" value="{{task.get_title()}}" onchange="setDirty();" />
|
<input type="text" name="__tname" style="width:200px" value="{{task.getTitle()}}" onchange="setDirty();" />
|
||||||
<input type="checkbox" name="__tactive" {% if task.is_active() %}checked="checked"{% endif %} onchange="setDirty();" />
|
<input type="checkbox" name="__tactive" {% if task.isActive() %}checked="checked"{% endif %} onchange="setDirty();" />
|
||||||
<label>{% trans 'admin::tasks: lancer au demarrage du scheduler' %}</label>
|
<label>{% trans 'admin::tasks: lancer au demarrage du scheduler' %}</label>
|
||||||
</form>
|
</form>
|
||||||
<div id="idCrashLine" style="visibility:{% if task.get_crash_counter() == 0 %}hidden{% endif %}">
|
<div id="idCrashLine" style="visibility:{% if task.getCrashCounter() == 0 %}hidden{% endif %}">
|
||||||
{% trans 'admin::tasks: Nombre de crashes : ' %} {{task.get_crash_counter()}}
|
{% trans 'admin::tasks: Nombre de crashes : ' %} {{task.getCrashCounter()}}
|
||||||
|
|
||||||
<a href="javascript:void();" onclick="jsTaskObj.resetCrashCounter();return(false);">
|
<a href="javascript:void();" onclick="jsTaskObj.resetCrashCounter();return(false);">
|
||||||
{% trans 'admin::tasks: reinitialiser el compteur de crashes' %}</a>
|
{% trans 'admin::tasks: reinitialiser el compteur de crashes' %}</a>
|
||||||
@@ -422,10 +422,10 @@
|
|||||||
<form style="position:absolute; top:0px; left:0px; right:4px; bottom:20px;" action="./task2utils.php" onsubmit="return(false);" name="fxml" method="post">
|
<form style="position:absolute; top:0px; left:0px; right:4px; bottom:20px;" action="./task2utils.php" onsubmit="return(false);" name="fxml" method="post">
|
||||||
<input type="hidden" name="__act" value="???" />
|
<input type="hidden" name="__act" value="???" />
|
||||||
<input type="hidden" name="__class" value="{{ task|get_class }}" />
|
<input type="hidden" name="__class" value="{{ task|get_class }}" />
|
||||||
<input type="hidden" name="__tid" value="{{task.get_task_id()}}" />
|
<input type="hidden" name="__tid" value="{{task.getID()}}" />
|
||||||
<input type="hidden" name="__tname" value="" />
|
<input type="hidden" name="__tname" value="" />
|
||||||
<input type="hidden" name="__tactive" value="" />
|
<input type="hidden" name="__tactive" value="" />
|
||||||
<textarea nowrap id="txtareaxml" style="position:absolute; top:0px; left:0px; width:100%; height:100%; white-space:pre;" onchange="setDirty();" name="txtareaxml" >{{task.get_settings()}}</textarea>
|
<textarea nowrap id="txtareaxml" style="position:absolute; top:0px; left:0px; width:100%; height:100%; white-space:pre;" onchange="setDirty();" name="txtareaxml" >{{task.getSettings()}}</textarea>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<!-- _____________ xml interface _____________ -->
|
<!-- _____________ xml interface _____________ -->
|
||||||
|
@@ -19,7 +19,7 @@ class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
|
|||||||
$commandTester->execute(array('command' => $command->getName()));
|
$commandTester->execute(array('command' => $command->getName()));
|
||||||
|
|
||||||
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
||||||
$state = $task_manager->get_scheduler_state();
|
$state = $task_manager->getSchedulerState();
|
||||||
|
|
||||||
$sentence = sprintf('Scheduler is %s', $state['status']);
|
$sentence = sprintf('Scheduler is %s', $state['status']);
|
||||||
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
68
tests/module/console/module_console_taskStateTest.php
Normal file
68
tests/module/console/module_console_taskStateTest.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../PhraseanetWebTestCaseAuthenticatedAbstract.class.inc';
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
|
use \Symfony\Component\Console\Application;
|
||||||
|
|
||||||
|
class module_console_taskStateTest extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers {className}::{origMethodName}
|
||||||
|
* @todo Implement testExecute().
|
||||||
|
*/
|
||||||
|
public function testExecute()
|
||||||
|
{
|
||||||
|
// mock the Kernel or create one depending on your needs
|
||||||
|
$application = new Application();
|
||||||
|
$application->add(new module_console_taskState('system:taskState'));
|
||||||
|
|
||||||
|
$command = $application->find('system:taskState');
|
||||||
|
$commandTester = new CommandTester($command);
|
||||||
|
|
||||||
|
// test a bad argument
|
||||||
|
$commandTester->execute(array('command' => $command->getName(), 'task_id' => 'not_a_number'));
|
||||||
|
$sentence = 'Argument must be an ID';
|
||||||
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
|
||||||
|
$commandTester->execute(array('command' => $command->getName(), 'task_id' => 'not_a_number', '--short' => true));
|
||||||
|
$sentence = 'bad_id';
|
||||||
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
|
||||||
|
// test good tasks ids
|
||||||
|
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
||||||
|
$tasks = $task_manager->getTasks();
|
||||||
|
$tids = array(); // list known ids of tasks so we can generate a 'unknown id' later
|
||||||
|
foreach ($tasks as $task) {
|
||||||
|
$tids[] = $task->getID();
|
||||||
|
$task = $task_manager->getTask($task->getID());
|
||||||
|
$state = $task->getState();
|
||||||
|
$pid = $task->getPID();
|
||||||
|
|
||||||
|
$commandTester->execute(array('command' => $command->getName(), 'task_id' => $task->getID()));
|
||||||
|
$sentence = sprintf('Task %d is %s', $task->getID(), $state);
|
||||||
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
|
||||||
|
$commandTester->execute(array('command' => $command->getName(), 'task_id' => $task->getID(), '--short' => true));
|
||||||
|
$sentence = sprintf('%s(%s)', $state, ($pid !== NULL ? $pid : ''));
|
||||||
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// test an unknown id
|
||||||
|
for ($badid = 999; in_array($badid, $tids); $badid += 10) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
/* we may not test the 'long' error message since it comes from the upper level exception and might be translated
|
||||||
|
$commandTester->execute(array('command' => $command->getName(), 'task_id' => $badid));
|
||||||
|
$sentence = sprintf('Unknown task_id %d', $task->getID());
|
||||||
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
*/
|
||||||
|
$commandTester->execute(array('command' => $command->getName(), 'task_id' => $badid, '--short' => true));
|
||||||
|
$sentence = 'unknown_id';
|
||||||
|
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@@ -24,13 +24,13 @@ class module_console_tasklistTest extends PHPUnit_Framework_TestCase
|
|||||||
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
|
||||||
$lines = explode("\n", trim($commandTester->getDisplay()));
|
$lines = explode("\n", trim($commandTester->getDisplay()));
|
||||||
|
|
||||||
if (count($task_manager->get_tasks()) > 0) {
|
if (count($task_manager->getTasks()) > 0) {
|
||||||
$this->assertEquals(count($task_manager->get_tasks()), count($lines));
|
$this->assertEquals(count($task_manager->getTasks()), count($lines));
|
||||||
foreach ($task_manager->get_tasks() as $task) {
|
foreach ($task_manager->getTasks() as $task) {
|
||||||
$this->assertTrue(strpos($commandTester->getDisplay(), $task->get_title()) !== false);
|
$this->assertTrue(strpos($commandTester->getDisplay(), $task->get_title()) !== false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals(1, $n_lines);
|
$this->assertEquals(1, count($lines));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -130,9 +130,9 @@ switch ($parm['action'])
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$task = $task_manager->get_task($parm['task_id']);
|
$task = $task_manager->getTask($parm['task_id']);
|
||||||
$pid = (int)($task->get_pid());
|
$pid = (int)($task->getPID());
|
||||||
$task->set_status($parm["status"]);
|
$task->setState($parm["status"]);
|
||||||
$signal = (int)($parm['signal']);
|
$signal = (int)($parm['signal']);
|
||||||
if( $signal > 0 && $pid )
|
if( $signal > 0 && $pid )
|
||||||
posix_kill($pid, $signal);
|
posix_kill($pid, $signal);
|
||||||
@@ -150,7 +150,7 @@ switch ($parm['action'])
|
|||||||
{
|
{
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
|
|
||||||
$task_manager->set_sched_status($parm['status']);
|
$task_manager->setSchedulerState($parm['status']);
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
@@ -163,8 +163,8 @@ switch ($parm['action'])
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$task = $task_manager->get_task($parm['task_id']);
|
$task = $task_manager->getTask($parm['task_id']);
|
||||||
$task->reset_crash_counter();
|
$task->resetCrashCounter();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
@@ -191,11 +191,11 @@ switch ($parm['action'])
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$task = $task_manager->get_task($parm["task_id"]);
|
$task = $task_manager->getTask($parm["task_id"]);
|
||||||
/**
|
/**
|
||||||
* @todo checker, cette methode n'est pas implementee partout
|
* @todo checker, cette methode n'est pas implementee partout
|
||||||
*/
|
*/
|
||||||
$root->setAttribute("crashed", $task->get_crash_counter());
|
$root->setAttribute("crashed", $task->getCrashCounter());
|
||||||
if ($task->saveChanges($conn, $parm["task_id"], $row))
|
if ($task->saveChanges($conn, $parm["task_id"], $row))
|
||||||
$root->setAttribute("saved", "1");
|
$root->setAttribute("saved", "1");
|
||||||
}
|
}
|
||||||
@@ -210,24 +210,24 @@ switch ($parm['action'])
|
|||||||
$ret = array('time'=> date("H:i:s") );
|
$ret = array('time'=> date("H:i:s") );
|
||||||
|
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$ret['scheduler'] = $task_manager->get_scheduler_state();
|
$ret['scheduler'] = $task_manager->getSchedulerState();
|
||||||
|
|
||||||
$ret['tasks'] = array();
|
$ret['tasks'] = array();
|
||||||
|
|
||||||
foreach ($task_manager->get_tasks(true) as $task)
|
foreach ($task_manager->getTasks(true) as $task)
|
||||||
{
|
{
|
||||||
if($task->get_status()==task_abstract::STATUS_TOSTOP && $task->get_pid()===NULL)
|
if($task->getState()==task_abstract::STATUS_TOSTOP && $task->getPID()===NULL)
|
||||||
{
|
{
|
||||||
// fix
|
// fix
|
||||||
$task->set_status(task_abstract::STATUS_STOPPED);
|
$task->setState(task_abstract::STATUS_STOPPED);
|
||||||
}
|
}
|
||||||
$id = $task->get_task_id();
|
$id = $task->getID();
|
||||||
$ret['tasks'][$id] = array(
|
$ret['tasks'][$id] = array(
|
||||||
'id'=>$id
|
'id'=>$id
|
||||||
, 'pid' =>$task->get_pid()
|
, 'pid' =>$task->getPID()
|
||||||
, 'crashed'=>$task->get_crash_counter()
|
, 'crashed'=>$task->getCrashCounter()
|
||||||
, 'completed'=>$task->get_completed_percentage()
|
, 'completed'=>$task->getCompletedPercentage()
|
||||||
, 'status'=>$task->get_status()
|
, 'status'=>$task->getState()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ try {
|
|||||||
$task = task_abstract::create($appbox, $parm['tcl']);
|
$task = task_abstract::create($appbox, $parm['tcl']);
|
||||||
break;
|
break;
|
||||||
case 'EDITTASK': // existing task
|
case 'EDITTASK': // existing task
|
||||||
$task = $task_manager->get_task($parm['tid']);
|
$task = $task_manager->getTask($parm['tid']);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception('Unknown action');
|
throw new Exception('Unknown action');
|
||||||
|
@@ -36,7 +36,7 @@ phrasea::headers();
|
|||||||
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,skins/admin/admincolor.css" />
|
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,skins/admin/admincolor.css" />
|
||||||
<?php
|
<?php
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$ztask = $task_manager->get_task($parm['__tid']);
|
$ztask = $task_manager->getTask($parm['__tid']);
|
||||||
switch ($parm['__act']) {
|
switch ($parm['__act']) {
|
||||||
case 'FORM2XML':
|
case 'FORM2XML':
|
||||||
if (method_exists($ztask, 'printInterfaceHTML')) {
|
if (method_exists($ztask, 'printInterfaceHTML')) {
|
||||||
@@ -117,11 +117,11 @@ phrasea::headers();
|
|||||||
}
|
}
|
||||||
$task_manager = new task_manager($appbox);
|
$task_manager = new task_manager($appbox);
|
||||||
$tid = $parm['__tid'];
|
$tid = $parm['__tid'];
|
||||||
$task = $task_manager->get_task($tid);
|
$task = $task_manager->getTask($tid);
|
||||||
|
|
||||||
$task->set_active($parm['__tactive']);
|
$task->setActive($parm['__tactive']);
|
||||||
$task->set_title($parm['__tname']);
|
$task->setTitle($parm['__tname']);
|
||||||
$task->set_settings($parm['txtareaxml']);
|
$task->setSettings($parm['txtareaxml']);
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
parent.document.getElementById("taskid").innerHTML = "id : <?php echo $tid ?>";
|
parent.document.getElementById("taskid").innerHTML = "id : <?php echo $tid ?>";
|
||||||
|
@@ -36,7 +36,7 @@ $task_manager = new task_manager($appbox);
|
|||||||
$refresh_tasklist = false;
|
$refresh_tasklist = false;
|
||||||
if ($parm["act"] == "DELETETASK") {
|
if ($parm["act"] == "DELETETASK") {
|
||||||
try {
|
try {
|
||||||
$task = $task_manager->get_task($parm['tid']);
|
$task = $task_manager->getTask($parm['tid']);
|
||||||
$task->delete();
|
$task->delete();
|
||||||
$refresh_tasklist = true;
|
$refresh_tasklist = true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -348,12 +348,12 @@ foreach ($tasks as $t) {
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
<?php ?>
|
<?php ?>
|
||||||
<iframe id="zsched" src="about:blank" style="position:absolute; top:0px; left:0px; width:50px; height:50px; visibility:hidden"></iframe>
|
<iframe id="zsched" src="about:blank" style="position:absolute; top:0px; left:0px; width:50px; height:50px; visibility:hidden"></iframe>
|
||||||
|
|
||||||
<h1><?php echo _('admin::tasks: planificateur de taches') ?>
|
<h1><?php echo _('admin::tasks: planificateur de taches') ?>
|
||||||
<span style="font-size:12px;">
|
<span style="font-size:12px;">
|
||||||
<?php echo sprintf(_('Last update at %s.'), '<span id="pingTime"></span>'); ?>
|
<?php echo sprintf(_('Last update at %s.'), '<span id="pingTime"></span>'); ?>
|
||||||
</span>
|
</span>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
@@ -381,11 +381,11 @@ foreach ($tasks as $t) {
|
|||||||
<td> </td>
|
<td> </td>
|
||||||
<td style="font-weight:900" class="taskname">TaskManager</td>
|
<td style="font-weight:900" class="taskname">TaskManager</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
$n = 0;
|
$n = 0;
|
||||||
foreach ($task_manager->get_tasks($refresh_tasklist) as $task) {
|
foreach ($task_manager->getTasks($refresh_tasklist) as $task) {
|
||||||
$n ++;
|
$n ++;
|
||||||
$tid = $task->get_task_id()
|
$tid = $task->getID()
|
||||||
?>
|
?>
|
||||||
<tr id="TR_<?php echo $tid ?>" class="task <?php echo $n % 2 == 0 ? 'even' : 'odd' ?>">
|
<tr id="TR_<?php echo $tid ?>" class="task <?php echo $n % 2 == 0 ? 'even' : 'odd' ?>">
|
||||||
<td class="dropdown task">
|
<td class="dropdown task">
|
||||||
@@ -403,11 +403,11 @@ foreach ($task_manager->get_tasks($refresh_tasklist) as $task) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="taskname"><?php echo p4string::MakeString($task->get_title()) ?> [<?php echo p4string::MakeString($task::getName()) ?>]</td>
|
<td class="taskname"><?php echo p4string::MakeString($task->getTitle()) ?> [<?php echo p4string::MakeString($task::getName()) ?>]</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -415,7 +415,7 @@ foreach ($task_manager->get_tasks($refresh_tasklist) as $task) {
|
|||||||
<img id="newTaskButton" src="/skins/admin/dropdown.png"/>
|
<img id="newTaskButton" src="/skins/admin/dropdown.png"/>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="6">
|
<td colspan="6">
|
||||||
<?php echo _('admin::tasks: Nouvelle tache') ?>
|
<?php echo _('admin::tasks: Nouvelle tache') ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
@@ -487,148 +487,6 @@ foreach ($task_manager->get_tasks($refresh_tasklist) as $task) {
|
|||||||
document.forms["taskManager"].submit();
|
document.forms["taskManager"].submit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
function old_pingScheduler()
|
|
||||||
{
|
|
||||||
$.ajax({
|
|
||||||
url: '/admin/adminFeedback.php?action=PINGSCHEDULER',
|
|
||||||
dataType:'xml',
|
|
||||||
success: function(ret)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
var ping= '', pingTime='', newStr='', statusping='', running='', qdelay;
|
|
||||||
|
|
||||||
status = ret.documentElement.getAttribute("status"); // +'_'+ret.documentElement.getAttribute("ping");
|
|
||||||
pingTime = ret.documentElement.getAttribute("time");
|
|
||||||
locked = ret.documentElement.getAttribute("locked");
|
|
||||||
qdelay = ret.documentElement.getAttribute("qdelay");
|
|
||||||
schedpid = ret.documentElement.getAttribute("pid");
|
|
||||||
|
|
||||||
T_task['SCHED'] = status+'_'+locked;
|
|
||||||
|
|
||||||
$("#PID_SCHED").empty().append(schedpid);
|
|
||||||
switch(status+'_'+locked)
|
|
||||||
{
|
|
||||||
case "stopped_0": // normal
|
|
||||||
|
|
||||||
$("#STATUSIMG_SCHED").attr("src", "/skins/icons/stop-alt.png").show();
|
|
||||||
break;
|
|
||||||
case "stopping_0": // not normal (scheduler killed ?)
|
|
||||||
case "started_0":
|
|
||||||
case "tostop_0":
|
|
||||||
$("#STATUSIMG_SCHED"+id).attr("src", "/skins/icons/alert.png").show();
|
|
||||||
break;
|
|
||||||
case "stopped_1": // not normal (no database ?)
|
|
||||||
|
|
||||||
$("#STATUSIMG_SCHED"+id).attr("src", "/skins/icons/alert.png").show();
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "stopping_1": // normal, wait
|
|
||||||
case "tostop_1":
|
|
||||||
|
|
||||||
$("#STATUSIMG_SCHED").attr("src", "/skins/icons/indicator.gif").show();
|
|
||||||
|
|
||||||
break
|
|
||||||
case "started_1":
|
|
||||||
|
|
||||||
$("#STATUSIMG_SCHED").attr("src", "/skins/icons/up.png").show();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$("#pingTime").empty().append(pingTime);
|
|
||||||
|
|
||||||
|
|
||||||
var t = ret.getElementsByTagName('task');
|
|
||||||
for(var i=0; i<t.length; i++)
|
|
||||||
{
|
|
||||||
var id = t.item(i).getAttribute('id');
|
|
||||||
var status = t.item(i).getAttribute('status') + "_" + t.item(i).getAttribute('running');
|
|
||||||
var active = t.item(i).getAttribute('active');
|
|
||||||
var pid = t.item(i).getAttribute('pid');
|
|
||||||
var completed = 0 | (t.item(i).getAttribute('completed'));
|
|
||||||
var crashed = 0 | (t.item(i).getAttribute('crashed'));
|
|
||||||
var runner = t.item(i).getAttribute('runner');
|
|
||||||
|
|
||||||
if(runner === 'manual')
|
|
||||||
status = 'manual'+ "_" + t.item(i).getAttribute('running');;
|
|
||||||
|
|
||||||
T_task[id] = status;
|
|
||||||
switch(status)
|
|
||||||
{
|
|
||||||
case "stopped_0": // normal
|
|
||||||
$("#STATUSIMG_"+id).attr("src", "/skins/icons/stop-alt.png").show();
|
|
||||||
break;
|
|
||||||
case "started_0":
|
|
||||||
case "stopping_0":
|
|
||||||
case "manual_0":
|
|
||||||
case "tostop_0":
|
|
||||||
case "stopped_1":
|
|
||||||
case "starting_1":
|
|
||||||
case "tostart_1":
|
|
||||||
$("#STATUSIMG_"+id).attr("src", "/skins/icons/alert.png").show();
|
|
||||||
break;
|
|
||||||
case "tostart_0":
|
|
||||||
case "starting_0":
|
|
||||||
case "stopping_1":
|
|
||||||
case "tostop_1":
|
|
||||||
case "torestart_0":
|
|
||||||
case "torestart_1":
|
|
||||||
$("#STATUSIMG_"+id).attr("src", "/skins/icons/indicator.gif").show();
|
|
||||||
break;
|
|
||||||
case "manual_1":
|
|
||||||
$("#STATUSIMG_"+id).attr("src", "/skins/icons/public.png").show();
|
|
||||||
break;
|
|
||||||
case "started_1":
|
|
||||||
$("#STATUSIMG_"+id).attr("src", "/skins/icons/up.png").show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(o = document.getElementById("COMP_"+id))
|
|
||||||
{
|
|
||||||
//if(completed >=0)
|
|
||||||
// o.innerHTML = completed + "%";
|
|
||||||
//else
|
|
||||||
// o.innerHTML = ' ';
|
|
||||||
if(completed >=0)
|
|
||||||
{
|
|
||||||
document.getElementById("COMP_"+id).style.width = completed + "%";
|
|
||||||
document.getElementById("COMPBOX_"+id).style.visibility = "visible";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
document.getElementById("COMPBOX_"+id).style.visibility = "hidden";
|
|
||||||
document.getElementById("COMP_"+id).style.width = '0px';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(o = document.getElementById("PID_"+id))
|
|
||||||
{
|
|
||||||
if(pid != "")
|
|
||||||
o.innerHTML = pid;
|
|
||||||
else
|
|
||||||
o.innerHTML = ' ';
|
|
||||||
}
|
|
||||||
if(o = document.getElementById("WARNING_"+id))
|
|
||||||
{
|
|
||||||
if(crashed > 0)
|
|
||||||
{
|
|
||||||
var str = "<?php echo p4string::MakeString(_('admin::tasks: Nombre de crashes : '), 'js', '"'); ?>"+crashed;
|
|
||||||
o.setAttribute('alt', str);
|
|
||||||
}
|
|
||||||
o.style.display = crashed > 0 ? '':'none';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.setTimeout("pingScheduler();", 3000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
function pingScheduler(repeat)
|
function pingScheduler(repeat)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user