Ignore:
Timestamp:
Apr 14, 2015, 10:20:16 PM (10 years ago)
Author:
chronos
Message:
  • Removed: Spaces on end of line.
  • Modified: Tabs converted to spaces.
File:
1 edited

Legend:

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

    r735 r738  
    1313    $this->Dependencies = array();
    1414  }
    15  
     15
    1616  function DoStart()
    1717  {
     
    3434      'Table' => 'SchedulerAction',
    3535      'DefaultSortColumn' => 'Name',
    36         'ReadOnly' => true,
     36      'ReadOnly' => true,
    3737      'Items' => array(
    3838        'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => '', 'ReadOnly' => true),
     
    4141    ));
    4242    $this->System->FormManager->RegisterFormType('TSchedulerAction', array(
    43         'Type' => 'Reference',
    44         'Table' => 'SchedulerAction',
    45         'Id' => 'Id',
    46         'Name' => 'Name',
    47         'Filter' => '1',
     43      'Type' => 'Reference',
     44      'Table' => 'SchedulerAction',
     45      'Id' => 'Id',
     46      'Name' => 'Name',
     47      'Filter' => '1',
    4848    ));
    4949    $this->System->RegisterCommandLine('run-scheduler', array('ModuleScheduler', 'Run'));
    5050  }
    51  
     51
    5252  function DoInstall()
    5353  {
     
    5555
    5656  function DoUnInstall()
    57   { 
     57  {
    5858  }
    59  
     59
    6060  function Run()
    61   {     
    62         while(true)
    63         {
    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` < "'.TimeToMysqlDateTime(time()).'") AND '.
    67                 ' (`Scheduler`.`LastExecutedTime` < `Scheduler`.`ScheduledTime`)) OR '.
    68                 '(`Scheduler`.`ScheduledTime` IS NULL))');
    69           while($DbRow = $DbResult->fetch_assoc())
    70           {
    71                 echo('Executing '.$DbRow['Name']."\n");
    72                 $Output = '';
    73             if(class_exists($DbRow['Class']))
    74             {
    75                 $Class = new $DbRow['Class']($this->System);
    76               $Output = $Class->Execute();
    77             } else echo('Class '.$DbRow['Class'].' not found'."\n");
    78                           $this->Database->update('Scheduler', 'Id='.$DbRow['Id'],
    79                           array('Log' => $Output, 'LastExecutedTime' => 'NOW()'));
    80                           if($DbRow['ScheduledTime'] == '') $NewScheduledTime = time() + $DbRow['Period'];
    81                             else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period']; 
    82                         if($DbRow['Period'] != '') $this->Database->update('Scheduler', 'Id='.$DbRow['Id'],
    83                                 array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime)));                       
    84           }     
    85           echo('.');
    86           sleep(1);
    87         }
     61  {
     62    while(true)
     63    {
     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` < "'.TimeToMysqlDateTime(time()).'") AND '.
     67        ' (`Scheduler`.`LastExecutedTime` < `Scheduler`.`ScheduledTime`)) OR '.
     68        '(`Scheduler`.`ScheduledTime` IS NULL))');
     69      while($DbRow = $DbResult->fetch_assoc())
     70      {
     71        echo('Executing '.$DbRow['Name']."\n");
     72        $Output = '';
     73        if(class_exists($DbRow['Class']))
     74        {
     75          $Class = new $DbRow['Class']($this->System);
     76          $Output = $Class->Execute();
     77        } else echo('Class '.$DbRow['Class'].' not found'."\n");
     78        $this->Database->update('Scheduler', 'Id='.$DbRow['Id'],
     79          array('Log' => $Output, 'LastExecutedTime' => 'NOW()'));
     80        if($DbRow['ScheduledTime'] == '') $NewScheduledTime = time() + $DbRow['Period'];
     81          else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period'];
     82        if($DbRow['Period'] != '') $this->Database->update('Scheduler', 'Id='.$DbRow['Id'],
     83          array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime)));
     84      }
     85      echo('.');
     86      sleep(1);
     87    }
    8888  }
    8989}
     
    9191class SchedulerTask extends Model
    9292{
    93         function Execute()
    94         {
    95         }
     93  function Execute()
     94  {
     95  }
    9696}
Note: See TracChangeset for help on using the changeset viewer.