Changeset 759
- Timestamp:
- Oct 26, 2015, 11:50:43 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Version.php
r758 r759 1 1 <?php 2 2 3 $Revision = 75 8; // Subversion revision4 $DatabaseRevision = 75 5; // SQL structure revision3 $Revision = 759; // Subversion revision 4 $DatabaseRevision = 759; // SQL structure revision 5 5 $ReleaseTime = strtotime('2015-10-26'); -
trunk/Common/Setup/Updates.php
r757 r759 1577 1577 ADD CONSTRAINT `FinanceInvoiceStorno_ibfk_2` FOREIGN KEY (`StornoOf`) REFERENCES `FinanceInvoice` (`Id`); 1578 1578 "); 1579 } 1580 1581 function UpdateTo759($Manager) 1582 { 1583 $Manager->Execute('ALTER TABLE `Scheduler` ADD `Duration` INT NOT NULL AFTER `Period`;'); 1579 1584 } 1580 1585 … … 1653 1658 748 => array('Revision' => 752, 'Function' => 'UpdateTo752'), 1654 1659 752 => array('Revision' => 755, 'Function' => 'UpdateTo755'), 1660 755 => array('Revision' => 759, 'Function' => 'UpdateTo759'), 1655 1661 )); 1656 1662 } -
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.