Changeset 759 for trunk/Modules/Scheduler/Scheduler.php
- Timestamp:
- Oct 26, 2015, 11:50:43 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Scheduler/Scheduler.php
r754 r759 28 28 'Log' => array('Type' => 'Text', 'Caption' => 'Poslední záznam', 'Default' => '', 'ReadOnly' => true), 29 29 'LastExecutedTime' => array('Type' => 'DateTime', 'Caption' => 'Čas posledního spuštění', 'Default' => '', 'ReadOnly' => true), 30 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true), 30 31 ), 31 32 )); … … 64 65 $DbResult = $this->Database->query('SELECT `Scheduler`.*, `SchedulerAction`.`Class` AS `Class` FROM `Scheduler` '. 65 66 '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 '.67 'WHERE (`Scheduler`.`Enabled`=1) AND ( '. 68 '(`Scheduler`.`ScheduledTime` < "'.TimeToMysqlDateTime(time()).'") OR '. 68 69 '(`Scheduler`.`ScheduledTime` IS NULL))'); 69 70 while($DbRow = $DbResult->fetch_assoc()) … … 71 72 echo('Executing '.$DbRow['Name']."\n"); 72 73 $Output = ''; 74 $StartTime = time(); 73 75 if(class_exists($DbRow['Class'])) 74 76 { … … 77 79 echo($Output); 78 80 } else echo('Class '.$DbRow['Class'].' not found'."\n"); 81 $StopTime = time(); 82 $Duration = $StopTime - $StartTime; 79 83 $this->Database->update('Scheduler', 'Id='.$DbRow['Id'], 80 array('Log' => $Output, 'LastExecutedTime' => 'NOW()')); 81 if($DbRow['ScheduledTime'] == '') $NewScheduledTime = time() + $DbRow['Period']; 82 else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period']; 83 if($DbRow['Period'] != '') $this->Database->update('Scheduler', 'Id='.$DbRow['Id'], 84 array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime))); 84 array('Log' => $Output, 'LastExecutedTime' => TimeToMysqlDateTime($StartTime))); 85 if($DbRow['Period'] != '') { 86 if($DbRow['ScheduledTime'] == '') $NewScheduledTime = $StartTime + $DbRow['Period']; 87 else $NewScheduledTime = MysqlDateTimeToTime($DbRow['ScheduledTime']) + $DbRow['Period']; 88 if($NewScheduledTime < $StopTime) $NewScheduledTime = $StopTime + $DbRow['Period']; 89 $this->Database->update('Scheduler', 'Id='.$DbRow['Id'], 90 array('ScheduledTime' => TimeToMysqlDateTime($NewScheduledTime))); 91 } 85 92 } 86 93 echo('.'); … … 96 103 } 97 104 } 105 106 107 class ScheduleTaskTest extends SchedulerTask 108 { 109 function Execute() 110 { 111 $Output = '#'; 112 return($Output); 113 } 114 }
Note:
See TracChangeset
for help on using the changeset viewer.