Changeset 730


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.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/System.php

    r729 r730  
    210210              echo($Output);
    211211      } else echo('Command "'.$argv[1].'" not supported.'."\n");       
    212         }
    213         //print_r($argv);
     212        } else echo('No command was given as parameter'."\n");
    214213  }
    215214 
  • trunk/Application/Version.php

    r729 r730  
    11<?php
    22
    3 $Revision = 729; // Subversion revision
    4 $DatabaseRevision = 729; // SQL structure revision
    5 $ReleaseTime = strtotime('2015-01-11');
     3$Revision = 730; // Subversion revision
     4$DatabaseRevision = 730; // SQL structure revision
     5$ReleaseTime = strtotime('2015-01-12');
  • trunk/Common/Setup/Updates.php

    r729 r730  
    12071207 
    12081208  $Manager->Execute('INSERT INTO `Module` (`Id`, `Name`, `Title`) VALUES (NULL, "Plánovač", "Scheduler");');
     1209}
     1210
     1211function UpdateTo730($Manager)
     1212{
     1213        $Manager->Execute('CREATE TABLE IF NOT EXISTS `SchedulerAction` (
     1214  `Id` int(11) NOT NULL AUTO_INCREMENT,
     1215  `Name` varchar(255) NOT NULL,
     1216  `Class` varchar(255) NOT NULL
     1217) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');     
     1218        $Manager->Execute('ALTER TABLE `SchedulerAction` ADD PRIMARY KEY (`Id`);');
     1219       
     1220  $Manager->Execute('ALTER TABLE `Scheduler` CHANGE `Class` `Action` INT(11) NOT NULL;');
     1221  $Manager->Execute("ALTER TABLE `Scheduler` ADD INDEX ( `Action` ) ");
     1222  $Manager->Execute('ALTER TABLE `Scheduler` ADD CONSTRAINT `Schedule_ibfk_2` FOREIGN KEY (`Action`) REFERENCES `SchedulerAction` (`Id`);');
     1223  $Manager->Execute('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) VALUES (NULL, "Import bankovních účtů", "ScheduleBankImport");'); 
    12091224}
    12101225
     
    12711286        725 => array('Revision' => 726, 'Function' => 'UpdateTo726'),
    12721287        726 => array('Revision' => 729, 'Function' => 'UpdateTo729'),
     1288        729 => array('Revision' => 730, 'Function' => 'UpdateTo730'),
    12731289    ));
    12741290  }
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r729 r730  
    8888        {
    8989                $Output = '';
    90                 $DbResult = $this->Database->select('FinanceBankAccount', 'Id', '(AutoImport=1) AND ((TimeEnd IS NULL) OR (TimeEnd > NOW()))');
     90                $DbResult = $this->Database->select('FinanceBankAccount', 'Id', '(`AutoImport`=1) AND ((`TimeEnd` IS NULL) OR (`TimeEnd` > NOW()))');
    9191                while($DbRow = $DbResult->fetch_assoc())
    9292                {                       
     93                        echo($DbRow['Comment']."\n");
    9394                        $Page = new PageImportAPI($this->System);
    9495                        $Output .= $Page->Show();
  • 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.