diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6015d7c --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +buildimage: + docker build -t vitexsoftware/discomp2abraflexi:latest . + +buildx: + docker buildx build . --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag vitexsoftware/discomp2abraflexi:latest + +drun: + docker run --env-file .env vitexsoftware/discomp2abraflexi:latest diff --git a/multiflexi/discomp2abraflexi.multiflexi.app.json b/multiflexi/discomp2abraflexi.multiflexi.app.json index 4fce117..cabbeaa 100644 --- a/multiflexi/discomp2abraflexi.multiflexi.app.json +++ b/multiflexi/discomp2abraflexi.multiflexi.app.json @@ -7,6 +7,7 @@ "cmdparams": "", "deploy": "apt install discomp2abraflexi", "homepage": "https:\/\/github.com\/Spoje-NET\/discomp2abraflexi", + "ociimage": "docker.io/vitexsoftware/discomp2abraflexi", "requirements": "AbraFlexi", "environment": { "ABRAFLEXI_COMPANY": { @@ -33,7 +34,6 @@ "defval": "https:\/\/demo.flexibee.eu:5434", "required": true }, - "ABRAFLEXI_STORAGE": { "type": "string", "description": "Intial storage Code", @@ -66,5 +66,4 @@ } }, "multiflexi": "1.7.2" - } diff --git a/src/Discomp/Importer.php b/src/Discomp/Importer.php index d13d901..54153a8 100644 --- a/src/Discomp/Importer.php +++ b/src/Discomp/Importer.php @@ -140,6 +140,19 @@ public function __construct() { $this->setObjectName(); $this->discomper = new ApiClient(); + $this->abraFlexiInit(); + if (\Ease\Shared::cfg('APP_DEBUG', false)) { + $this->logBanner(); + } + $this->addStatusMessage(_('Supplier Exists'), $this->ensureSupplierExists() ? 'success' : 'error'); + $this->addStatusMessage(_('Category Root Exists'), $this->ensureCategoryRootExists() ? 'success' : 'error'); + } + + /** + * Connect to AbraFlexi + */ + public function abraFlexiInit() + { $this->sokoban = new \AbraFlexi\Cenik(null, ['ignore404' => true]); $this->sokoban->setObjectName('Pricelist'); $this->suplier = \AbraFlexi\RO::code(\Ease\Shared::cfg('ABRAFLEXI_DISCOMP_CODE', 'DISCOMP')); @@ -148,11 +161,19 @@ public function __construct() $this->atribut = new RW(null, ['evidence' => 'atribut']); $this->atributType = new RW(null, ['evidence' => 'typ-atributu', 'ignore404' => true]); $this->atributType->setObjectName('AttributeType'); - if (\Ease\Shared::cfg('APP_DEBUG', false)) { - $this->logBanner(); - } - $this->addStatusMessage(_('Supplier Exists'), $this->ensureSupplierExists() ? 'success' : 'error'); - $this->addStatusMessage(_('Category Root Exists'), $this->ensureCategoryRootExists() ? 'success' : 'error'); + } + + /** + * Try to free resources + */ + public function abraFlexiDisconnect() + { + unset($this->sokoban); + unset($this->suplier); + unset($this->pricer); + unset($this->category); + unset($this->atribut); + unset($this->atributType); } /** @@ -203,9 +224,9 @@ public function freshItems() $errors = 0; $freshItems = $this->getFreshItems(); foreach ($freshItems as $pos => $activeItemData) { - $this->sokoban->connectionReset(); - $this->category->connectionReset(); - $this->sokoban->dataReset(); + $this->abraFlexiDisconnect(); + $this->abraFlexiInit(); + $discompItemCode = $activeItemData['CODE']; $this->sokoban->setObjectName('(' . $pos . '/' . count($freshItems) . ') StoreItem:' . $discompItemCode);