Changeset 864 for trunk/Modules/Export
- Timestamp:
- Feb 5, 2016, 11:47:36 PM (9 years ago)
- Location:
- trunk/Modules/Export
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Export/Export.php
r859 r864 715 715 { 716 716 $this->System->RegisterPage('export', 'PageExport'); 717 $this->System->RegisterPage(array('export', 'progress'), 'PageExportProgress'); 717 718 $this->System->RegisterMenuItem(array( 718 719 'Title' => 'Exporty', … … 723 724 ), 2); 724 725 } 726 727 function GetTaskProgress($TaskId) 728 { 729 $Output = ''; 730 $DbResult = $this->Database->query('SELECT * FROM `ExportTask` '. 731 'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '. 732 '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '. 733 '(`TimeFinish` IS NULL) OR (`Export` ='.$TaskId.') ORDER BY `Progress` DESC'); // `Export`='.$Export->Id 734 while($Task = $DbResult->fetch_assoc()) 735 { 736 $Export = '<a href="'.$this->System->Link('/export/?Action=View&ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>'; 737 if ($TaskId == $Task['Export']) 738 $Export = ''.$Export.' (tento)'; 739 740 // Show progress bar 741 $Output .= ' <strong>Export '.$Export.': <div id="progress'.$Task['Export'].'">'. 742 ProgressBar(300, $Task['Progress']).'</div></strong>'; 743 744 // Show estimated time to complete 745 $PrefixMultiplier = new PrefixMultiplier(); 746 $EstimatedTime = (time() - MysqlDateTimeToTime($Task['TimeStart'])) / $Task['Progress'] * (100 - $Task['Progress']); 747 $Output .= 'Zbývající odhadovaný čas: '.$PrefixMultiplier->Add($EstimatedTime, '', 4, 'Time').'<br/>'; 748 749 if($Task['Progress'] > 99) 750 $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'. 751 'setTimeout("parent.location.href=\''.$this->System->Link('/export/?Action=View&Tab=7&ExportId='.$TaskId).'\'", 500)'. 752 '</script>'; 753 } 754 return($Output); 755 } 725 756 } 726 -
trunk/Modules/Export/ExportOutput.php
r818 r864 235 235 '$(document).ready(function() {'. 236 236 'var refreshId = setInterval(function() {'. 237 '$("#progress").load("'.$System->Link('/ Modules/Export/Progress.php?RedirectId='.$_GET['ExportId']).'"); '.237 '$("#progress").load("'.$System->Link('/export/progress?i='.$_GET['ExportId']).'"); '. 238 238 '}, 1000);'. 239 239 '});'. 240 240 '</script>'; 241 241 242 $Output .= ' <strong><div id="progress"></div></strong><br />'; 243 242 $Output .= ' <div id="progress">'.$System->ModuleManager->Modules['Export']->GetTaskProgress($_GET['ExportId'] * 1). 243 '</div><br />'; 244 245 // Check if process task is running 244 246 $DbResult = $System->Database->query('SELECT * FROM `ExportTask` '. 245 247 'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` '. 246 'WHERE ((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND (`TimeFinish` IS NULL) AND (`TimeStart` < (NOW() - 10000))'); 248 'WHERE ((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '. 249 '(`TimeFinish` IS NULL) AND (`TimeStart` < (NOW() - 10000))'); 247 250 if($DbResult->num_rows > 0) 248 251 { … … 262 265 263 266 $Output = ''; 264 if(array_key_exists('Regenerate', $_POST)) 265 { 266 $System->Database->query('UPDATE ExportTask SET TimeStart = NOW(), `Progress`=0, TimeFinish = NULL WHERE Export = '.$ExportId); 267 $Output .= ShowMessage('Soubor zařazen znovu ke zpracování do fronty.'); 268 $System->ModuleManager->Modules['Log']->WriteLog('Zadání úlohy pro vygenerování exe souboru', LOG_TYPE_DOWNLOAD); 269 } 270 271 $Output .= '<form action="?Action=View&Tab=7&ExportId='.$ExportId.'" method="post"><input type="submit" name="Regenerate" value="Přegenerovat"/></form><br />'; 267 // Allow to regenerate output if it was previously finished 268 $DbResult = $System->Database->query('SELECT `Id` FROM `ExportTask` WHERE (`Export` = '.$ExportId. 269 ') AND ((`TimeFinish` < `TimeStart`) OR (`TimeFinish` IS NULL))'); 270 if($DbResult->num_rows == 0) 271 { 272 if(array_key_exists('Regenerate', $_POST)) 273 { 274 $System->Database->query('UPDATE `ExportTask` SET `TimeStart` = NOW(), `Progress`=0, `TimeFinish` = NULL WHERE `Export` = '.$ExportId); 275 $Output .= ShowMessage('Soubor zařazen znovu ke zpracování do fronty.'); 276 $System->ModuleManager->Modules['Log']->WriteLog('Zadání úlohy pro vygenerování exe souboru', LOG_TYPE_DOWNLOAD); 277 } else { 278 $Output .= '<form action="?Action=View&Tab=7&ExportId='.$ExportId.'" method="post">'. 279 '<input type="submit" name="Regenerate" value="Přegenerovat"/></form><br />'; 280 } 281 } 282 272 283 $Output .= 'U souhrné instalace češtiny funguje export textů jinak, protože generování je náročné, jsou požadavky zařazovány do fronty a postupně zpracovávány.<br /><br />'; 273 284 274 $DbResult = $System->Database->query('SELECT * FROM ExportTask WHERE Export = '.$ExportId); 285 // Start task for the first time if export task was not yet started 286 $DbResult = $System->Database->query('SELECT * FROM `ExportTask` WHERE `Export` = '.$ExportId); 275 287 if($DbResult->num_rows == 0) 276 288 { … … 283 295 if($ExportTask['TimeFinish'] > $ExportTask['TimeStart']) 284 296 { 285 $Output .= '<strong>Souhrný EXE balík: <a href="'.$System->Link('/'.$Export->TempDirRelative.'Instalace_CzechWoW_'.$Export->ClientVersion['Version'].'.exe').'">Instalace_CzechWoW_'.$Export->ClientVersion['Version'].'.exe</a></strong><br/>'; 297 $FileName = 'Instalace_CzechWoW_'.$Export->ClientVersion['Version'].'.exe'; 298 $Output .= '<strong>Souhrný EXE balík: <a href="'.$System->Link('/'.$Export->TempDirRelative.$FileName).'">'.$FileName.'</a></strong><br/>'; 286 299 } else { 287 300 $Output .= ShowProgress($Export); -
trunk/Modules/Export/Page.php
r862 r864 828 828 } 829 829 } 830 831 class PageExportProgress extends Page 832 { 833 function __construct($System) 834 { 835 parent::__construct($System); 836 $this->RawPage = true; 837 } 838 839 function Show() 840 { 841 if(array_key_exists('i', $_GET)) 842 $Output = $this->System->ModuleManager->Modules['Export']->GetTaskProgress($_GET['i'] * 1); 843 else $Output = 'Missing task id'; 844 return($Output); 845 } 846 }
Note:
See TracChangeset
for help on using the changeset viewer.