Ignore:
Timestamp:
Feb 5, 2016, 11:47:36 PM (9 years ago)
Author:
chronos
Message:
  • Fixed: Do not allow to regenerate multipletimes already running export task.
  • Modified: Progress reimplemented as Page class extension with virtual URL to avoid execution of any scripts with path to Modules subdirectory.
  • Added: Show estimated time to complete export task.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Export/ExportOutput.php

    r818 r864  
    235235    '$(document).ready(function() {'.
    236236    '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']).'"); '.
    238238    '}, 1000);'.
    239239    '});'.
    240240    '</script>';
    241241
    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
    244246  $DbResult = $System->Database->query('SELECT * FROM `ExportTask` '.
    245247    '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))');
    247250  if($DbResult->num_rows > 0)
    248251  {
     
    262265
    263266  $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&amp;Tab=7&amp;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&amp;Tab=7&amp;ExportId='.$ExportId.'" method="post">'.
     279        '<input type="submit" name="Regenerate" value="Přegenerovat"/></form><br />';
     280    }
     281  }
     282
    272283  $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 />';
    273284
    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);
    275287  if($DbResult->num_rows == 0)
    276288  {
     
    283295  if($ExportTask['TimeFinish'] > $ExportTask['TimeStart'])
    284296  {
    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/>';
    286299  } else {
    287300    $Output .= ShowProgress($Export);
Note: See TracChangeset for help on using the changeset viewer.