Changeset 864


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.
Location:
trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    r862 r864  
    332332    $this->PageHeaders[$Name] = $Callback;
    333333  }
     334
     335  function HumanDate($Time)
     336  {
     337    return(date('j.n.Y', $Time));
     338  }
    334339}
  • trunk/Application/Version.php

    r862 r864  
    66// and system will need database update.
    77
    8 $Version = '1.0-alfa';
    9 $Revision = 862; // Subversion revision
     8$Version = '1.0';
     9$Revision = 864; // Subversion revision
    1010$DatabaseRevision = 857; // Database structure revision
    11 $ReleaseTime = '2016-01-22';
     11$ReleaseDate = strtotime('2016-02-05');
  • trunk/Application/View.php

    r863 r864  
    109109  function ShowFooter()
    110110  {
    111     global $ScriptStartTime, $Revision, $ReleaseTime, $Version;
     111    global $ScriptStartTime, $Revision, $ReleaseDate, $Version;
    112112
    113113    $ScriptGenerateDuration = round(GetMicrotime() - $ScriptStartTime, 2);
     
    123123    $Output .= '</td>';
    124124    $Output .= '</tr><tr>'.
    125       '<td colspan="4" class="page-bottom">'.T('Version').': '.$Version.' '.T('Revision').': '.$Revision.' ('.HumanDate($ReleaseTime).')'.
     125      '<td colspan="4" class="page-bottom">'.T('Version').': '.$Version.' '.T('Revision').': '.$Revision.' ('.$this->System->HumanDate($ReleaseDate).')'.
    126126      ' &nbsp; <a href="http://svn.zdechov.net/trac/wowpreklad/browser/trunk">'.T('Source code').'</a> &nbsp; '.
    127127      '<a href="http://svn.zdechov.net/trac/wowpreklad/log/trunk?verbose=on">'.T('Changelog').'</a> &nbsp; '.
  • trunk/Modules/Export/Export.php

    r859 r864  
    715715  {
    716716    $this->System->RegisterPage('export', 'PageExport');
     717    $this->System->RegisterPage(array('export', 'progress'), 'PageExportProgress');
    717718    $this->System->RegisterMenuItem(array(
    718719      'Title' => 'Exporty',
     
    723724    ), 2);
    724725  }
     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&amp;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&amp;Tab=7&amp;ExportId='.$TaskId).'\'", 500)'.
     752        '</script>';
     753    }
     754    return($Output);
     755  }
    725756}
    726 
  • 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);
  • trunk/Modules/Export/Page.php

    r862 r864  
    828828  }
    829829}
     830
     831class 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}
  • trunk/Modules/Info/Info.php

    r844 r864  
    9393'Addon jako takový je běžný doplněk do hry a je možné jej bez problémů používat i na oficiálních serverech.<br/>'.
    9494'<iframe width="420" height="315" src="https://www.youtube.com/embed/6EhBFv59syk" frameborder="0" allowfullscreen></iframe><br/>'.
    95 '<img src="images/promotion.bmp" width="800" alt="addon-obr">';
     95'<img src="'.$this->System->Link('/images/promotion.bmp').'" width="800" alt="addon-obr">';
    9696    return($Output);
    9797  }
Note: See TracChangeset for help on using the changeset viewer.