Changeset 666 for trunk/Modules/Export


Ignore:
Timestamp:
Dec 24, 2013, 3:04:01 PM (11 years ago)
Author:
maron
Message:
  • Fixed: dbc export task
  • Added: EXE file task
  • Moved: Instalace_CzechWoW.nsi
Location:
trunk/Modules/Export
Files:
1 added
1 deleted
2 edited

Legend:

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

    r663 r666  
    206206  if($ExportTask['TimeFinish'] > $ExportTask['TimeStart'])
    207207  {
    208     $Output .= '<strong>Souhrný balík: <a href="../tmp/Export/'.$ExportTask['Export'].'/CzWoW_DBC.zip">CzWoW_DBC.zip</a></strong><br/>';
    209208    $Export = new Export($System);
    210209    $Export->Id = $ExportId;
    211210    $Export->Init();
     211    $Output .= '<strong>Souhrný balík: <a href="'.$System->Link('/'.$Export->TempDirRelative.'CzWoW_DBC.zip').'">CzWoW_DBC.zip</a></strong><br/>';
    212212    $DbResult = $System->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$Export->Id.' AND `Group`.`DBCFileName` != ""');
    213213    while($Group = $DbResult->fetch_assoc())
    214214    {
    215215      if(file_exists($Export->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc'))
    216         $Output .= '<a href="'.$Export->TempDir.'dbc/'.$Group['DBCFileName'].'.dbc">'.$Group['DBCFileName'].'.dbc</a><br/>';
     216        $Output .= '<a href="'.$System->Link('/'.$Export->TempDirRelative.'dbc/'.$Group['DBCFileName'].'.dbc').'">'.$Group['DBCFileName'].'.dbc</a><br/>';
    217217    }
     218  } else $Output .= '<strong>Soubor čeká na zpracování ve frontě.</strong><br/>';
     219  return($Output);
     220}
     221function OutputEXEToFile($ExportId)
     222{
     223  global $System;
     224 
     225  $Output = '';
     226  if(array_key_exists('Regenerate', $_POST))
     227  {
     228    $System->Database->query('UPDATE ExportTask SET TimeStart = NOW(), TimeFinish = NULL WHERE Export = '.$ExportId);
     229    $Output .= ShowMessage('Soubor zařazen znovu ke zpracování do fronty.');
     230  }
     231
     232  $Output .= '<form action="?Action=View&amp;Tab=7&amp;ExportId='.$ExportId.'" method="post"><input type="submit" name="Regenerate" value="Přegenerovat"/></form><br />';
     233  $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 />';
     234   
     235  $DbResult = $System->Database->query('SELECT * FROM ExportTask WHERE Export = '.$ExportId);
     236  if($DbResult->num_rows == 0)
     237  {
     238    $System->Database->query('INSERT INTO ExportTask (`Export` ,`TimeStart` ) VALUES ('.$ExportId.', NOW())');
     239    $this->System->ModuleManager->Modules['Log']->WriteLog('Zadání úlohy pro vygenerování dbc souboru', LOG_TYPE_DOWNLOAD);
     240  } 
     241 
     242  $DbResult = $System->Database->query('SELECT * FROM `ExportTask` WHERE `Export` = '.$ExportId);
     243  $ExportTask = $DbResult->fetch_assoc();
     244  if($ExportTask['TimeFinish'] > $ExportTask['TimeStart'])
     245  {
     246    $Export = new Export($System);
     247    $Export->Id = $ExportId;
     248    $Export->Init();
     249    $Export->LoadFilters();
     250    $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/>';
     251
    218252  } else $Output .= '<strong>Soubor čeká na zpracování ve frontě.</strong><br/>';
    219253  return($Output);
     
    265299  else if($Type == 8) $Output = OutputLua($ExportId);
    266300  else if($Type == 9) $Output = OutputDBCToFile($ExportId);
     301  else if($Type == 10) $Output = OutputEXEToFile($ExportId);
    267302  else $Output = ShowMessage('Nebyl vybrán žádný formát výstupu.', MESSAGE_CRITICAL);
    268303  return($Output);
  • trunk/Modules/Export/ProcessTask.php

    r558 r666  
    33ini_set('memory_limit', '100M');
    44
    5 include_once('../includes/global.php');
    6 include_once('../includes/zip.lib.php');
     5include_once(dirname(__FILE__).'/../../includes/global.php');
     6include_once(dirname(__FILE__).'/../../includes/zip.lib.php');
     7
    78include_once('Export.php');   
    89include_once('ExportOutput.php');   
    910
    1011//LoadCommandLineParameters();
     12  $System = new System();
     13  $System->DoNotShowPage = true;
     14        $System->Run();
    1115
    1216while(1)
    1317{
    14   $DbResult = $System->Database->query('SELECT `ExportTask`.`Export`, `Export`.`Id` AS `ExportId` FROM `ExportTask` LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE `ExportTask`.`TimeFinish` IS NULL');
     18  //DBC files
     19  $DbResult = $System->Database->query('SELECT `ExportTask`.`Export`, `Export`.`Id` AS `ExportId` FROM `ExportTask` LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE `Export`.`OutputType` = 9 AND `ExportTask`.`TimeFinish` IS NULL');
    1520  while($DbRow = $DbResult->fetch_assoc())
    1621  {
     
    5560    }
    5661  }
     62
     63  //EXE files
     64  $DbResult = $System->Database->query('SELECT `ExportTask`.`Export`, `Export`.`Id` AS `ExportId` FROM `ExportTask` LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE `Export`.`OutputType` = 10 AND `ExportTask`.`TimeFinish` IS NULL');
     65  while($DbRow = $DbResult->fetch_assoc())
     66  {
     67    echo(StrFTime("%d/%m/%Y %H:%M:%S", time()).': Generování EXE souboru pro export '.$DbRow['ExportId'].'.. '."\n");
     68    if($DbRow['ExportId'] != '')
     69    {     
     70      echo shell_exec('"'.dirname(__FILE__).'./client_cz_export.sh" '.$DbRow['ExportId'].'');
     71      $System->Database->query('UPDATE `ExportTask` SET `TimeFinish`=NOW() WHERE `Export`='.$DbRow['Export']);
     72    } else
     73    {
     74      $System->Database->query('DELETE FROM `ExportTask` WHERE `Export`='.$DbRow['Export']);
     75      echo('Export '.$DbRow['Export'].' nenalezen. Jeho úloha smazána.'."\n");
     76    }
     77  }
    5778  sleep($Config['ExportTaskProcessPeriod']);
    5879}
Note: See TracChangeset for help on using the changeset viewer.