Ignore:
Timestamp:
Jan 13, 2015, 12:18:19 AM (10 years ago)
Author:
chronos
Message:
  • Added: Scheduler available action table. Modules can register actions as read only items in table.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Scheduler/Scheduler.php

    r729 r730  
    2424        'Enabled' => array('Type' => 'Boolean', 'Caption' => 'Povoleno', 'Default' => '0'),
    2525        'ScheduledTime' => array('Type' => 'DateTime', 'Caption' => 'Plánovaný čas', 'Default' => ''),
    26         'Class' => array('Type' => 'String', 'Caption' => 'Vykonat třídu', 'Default' => ''),
     26        'Action' => array('Type' => 'TSchedulerAction', 'Caption' => 'Akce', 'Default' => ''),
    2727        'Period' => array('Type' => 'Integer', 'Caption' => 'Opakovat po', 'Default' => '', 'Null' => true, 'Suffix' => 'sekund'),
    2828        'Log' => array('Type' => 'Text', 'Caption' => 'Poslední záznam', 'Default' => '', 'ReadOnly' => true),
    2929        'LastExecutedTime' => array('Type' => 'DateTime', 'Caption' => 'Čas posledního spuštění', 'Default' => '', 'ReadOnly' => true),
    3030      ),
     31    ));
     32    $this->System->FormManager->RegisterClass('SchedulerAction', array(
     33      'Title' => 'Akce plánovače',
     34      'Table' => 'SchedulerAction',
     35      'DefaultSortColumn' => 'Name',
     36        'ReadOnly' => true,
     37      'Items' => array(
     38        'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => '', 'ReadOnly' => true),
     39        'Class' => array('Type' => 'String', 'Caption' => 'Vykonat třídu', 'Default' => '', 'ReadOnly' => true),
     40      ),
     41    ));
     42    $this->System->FormManager->RegisterFormType('TSchedulerAction', array(
     43        'Type' => 'Reference',
     44        'Table' => 'SchedulerAction',
     45        'Id' => 'Id',
     46        'Name' => 'Name',
     47        'Filter' => '1',
    3148    ));
    3249    $this->System->RegisterCommandLine('run-scheduler', array('ModuleScheduler', 'Run'));
     
    4562        while(true)
    4663        {
    47           $DbResult = $this->Database->select('Scheduler', '*', '(Enabled=1) AND (ScheduledTime < NOW())');
     64          $DbResult = $this->Database->query('SELECT `Scheduler`.*, `SchedulerAction`.`Class` AS `Class` FROM `Scheduler` '.
     65                'LEFT JOIN `SchedulerAction` ON `SchedulerAction`.`Id` = `Scheduler`.`Action` '.
     66                'WHERE (`Scheduler`.`Enabled`=1) AND (`Scheduler`.`ScheduledTime` > `Scheduler`.`LastExecutedTime`)');
    4867          while($DbRow = $DbResult->fetch_assoc())
    4968          {
     
    6079                                array('ScheduledTime' => TimeToMysqlDateTime((MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period']))));                       
    6180          }     
     81          echo('.');
    6282          sleep(1);
    6383        }
Note: See TracChangeset for help on using the changeset viewer.