Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • ImportCatalog1C_ProcessTask
 1 <?php
 2 /**
 3  * Задача обработки заданий очереди импорта
 4  *
 5  * @package 1c_exchange_catalog 
 6  * @author menedem
 7  *
 8  */
 9 
10 class ImportCatalog1C_ProcessTask extends ScheduledTask {
11     function process() {
12         $pidFile = TEMP_FOLDER . '/import.pid';
13         if (is_file($pidFile)) {
14             $pid = (int) file_get_contents($pidFile);
15             if (posix_getsid($pid) !== false) {
16                 // импорт уже работает
17                 return;
18             }
19             else {
20                 // предыдущий импорт сдох?
21                 unlink($pidFile);
22             }
23         }
24         file_put_contents($pidFile, getmypid());
25         
26         $importerClass = ImportCatalogSiteConfig::$importer_class;
27         $importer = new $importerClass();
28         $importer::$startTime = date('Y-m-d H:i:s');
29 
30         // FIXME получать по одно пока не кончатся - так как сейчас не увидит тех, кто добавлен во время работы
31         if ($taskQueue = DataObject::get('Import1CLog_Task', "Status = 'new'", "ID")) {
32             foreach ($taskQueue as $entry) {
33                 if ($entry->Status != 'new') continue;
34                 
35                 $filepath = Base1CExchanger::absolute_import_path($entry->Filename);
36                 if (is_file($filepath)) {
37                     $entry->Status = 'process';
38                     $entry->write();
39                     
40                     if ($entry->Operation == 'catalog') {
41                         $importer->importCatalog($filepath, $entry->Log());
42                         $entry->Status = 'finish';
43                         $entry->write();
44                         // delete file after done ???
45                     }
46                     
47                     if ($entry->Operation == 'offers') {
48                         $entry->Log()->addStage('offers');
49                         if ($importer->ImportOffers($filepath, $entry->Log())) {
50                             $entry->Status = 'finish';
51                             $entry->write();
52                             // delete file after done ???
53                         }
54                         else {
55                             $entry->Status = 'error';
56                             $entry->write();
57                         }
58                     }
59                 }
60                 else {
61                     $entry->Log()->addStatus('error',  "File {$entry->Filename} not found");
62                     break;
63                 }
64                 if (is_file(Base1CExchanger::absolute_import_path('stop_import'))) {
65                     unlink(Base1CExchanger::absolute_import_path('stop_import'));
66                     $entry->Status = 'finish';
67                     $entry->write();
68                     
69                     $entry->Log()->addStatus('ok', _t('ProductCatalogImport.ImportInterrupted', 'Импорт прерван'));
70                     return;
71                 }
72             }
73         }
74         unlink($pidFile);
75     }
76 }
77 
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0