Пример #1
0
 public function executeAdd()
 {
     $str = strtotime("2014-05-12 +3months");
     echo date("Y-m-d", $str);
     exit('');
     exit('no');
     $is = new ImportSession();
     $is->setLabel('Импорт сесия 21.04.2014');
     $is->setImportId(403);
     $is->setStartId(163);
     $is->setTmCount(79);
     $is->save();
     $is2 = new ImportSession();
     $is2->setLabel('Импорт сесия 01.05.2014');
     $is2->setImportId(404);
     $is2->setStartId(242);
     $is2->setTmCount(89);
     $is2->save();
     exit('done');
 }
Пример #2
0
function run_import_session($task, $args)
{
    ini_set("memory_limit", "6048M");
    define('SF_ROOT_DIR', sfConfig::get('sf_root_dir'));
    define('SF_APP', 'frontend');
    define('SF_ENVIRONMENT', 'prod');
    define('SF_DEBUG', true);
    require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
    $databaseManager = new sfDatabaseManager();
    $databaseManager->initialize();
    //$request = sfContext::getInstance()->getRequest();
    $ds = DIRECTORY_SEPARATOR;
    $root = sfConfig::get('sf_root_dir') . $ds . sfConfig::get('sf_web_dir_name') . $ds . "uploads" . $ds;
    _echo_cms_title('IMPORT-SESSION: Check for new imports');
    // faster save!!!
    //sfConfig::set('sf_cache_objects', false);
    //sfConfig::set('sf_cache_relations', false);
    //sfConfig::set('sf_use_relations_cache', false);
    // check Imports status='new'
    $c = new Criteria();
    //$c->add(ImportPeer::SYSTEM, 3);
    $c->add(ImportPeer::STATUS, 'new');
    $newImports = ImportPeer::doSelect($c);
    //$newImport1 = Document::getDocumentInstance(548884);
    //$newImports = array($newImport1);
    foreach ($newImports as $newImport) {
        $zipFile = $newImport->getLabel();
        _echo_cms("Importing file: {$zipFile}...");
        $system = $newImport->getSystem();
        if ($system == 2) {
            $start = $count = 0;
            $params = array($zipFile);
            try {
                $status = _import_oami($params, $start, $count);
                _echo_cms('Import #' . $newImport->getId() . ', status=' . $status);
            } catch (Exception $e) {
                $status = 'error';
            }
            if ($status) {
                $newImport->setStatus($status);
                $newImport->save();
                if ($status == 'imported') {
                    // save Import Session object
                    $is = new ImportSession();
                    $is->setLabel('Импорт сесия ' . date('d.m.Y'));
                    $is->setImportId($newImport->getId());
                    $is->setStartId($start);
                    $is->setTmCount($count);
                    $is->save();
                    //_index_session($is->getId());
                }
            }
        } else {
            if ($system == 3) {
                $start = $count = 0;
                $params = array($zipFile);
                try {
                    $status = _import_wipo($params, $start, $count);
                    _echo_cms('Import #' . $newImport->getId() . ', status=' . $status);
                } catch (Exception $e) {
                    $status = 'error';
                }
                if ($status) {
                    $newImport->setStatus($status);
                    $newImport->save();
                    if ($status == 'imported') {
                        // save Import Session object
                        $is = new ImportSession();
                        $is->setLabel('Импорт сесия ' . date('d.m.Y'));
                        $is->setImportId($newImport->getId());
                        $is->setStartId($start);
                        $is->setTmCount($count);
                        $is->save();
                        //_index_session($is->getId());
                    }
                }
            }
        }
    }
    _echo_cms('--------------------------------------------------------------------------------');
    _echo_cms("IMPORT-SESSION: Done!");
}