Esempio n. 1
0
 /**
  * Mark task as running
  * 
  * @return void
  */
 protected function markAsRunning()
 {
     \XLite\Core\Lock\FileLock::getInstance()->setRunning($this->getLockKey(), $this->getPeriod() / 4);
 }
Esempio n. 2
0
 /**
  * Returns shipping rates
  *
  * @param array|\XLite\Logic\Order\Modifier\Shipping $inputData   Shipping order modifier or array of data for request
  * @param boolean                                    $ignoreCache Flag: if true then do not get rates from cache OPTIONAL
  *
  * @return array
  */
 public function getRates($inputData, $ignoreCache = false)
 {
     $this->errorMsg = null;
     $rates = array();
     if ($this->isConfigured()) {
         if (\XLite::isAdminZone() && 'order' === \XLite::getController()->getTarget() && 'recalculate' === \XLite::getController()->getAction()) {
             // Realisation of createOrder and confirmOrder in AOM, but today...
             // So called 'The knight's move'
             $rates = array();
         } elseif ($this->isGuaranteedRatesNeeded($inputData)) {
             $key = \XLite\Core\Session::getInstance()->getID();
             while (\XLite\Core\Lock\FileLock::getInstance()->isRunning($key)) {
                 usleep(100);
             }
             \XLite\Core\Lock\FileLock::getInstance()->setRunning($key);
             $rates = $this->getGuaranteedRates($inputData, $ignoreCache);
             \XLite\Core\Lock\FileLock::getInstance()->release($key);
         } else {
             $rates = $this->getNonGuaranteedRates($inputData, $ignoreCache);
         }
     } elseif (\XLite\Module\XC\PitneyBowes\Main::isStrictMode()) {
         $this->errorMsg = 'PitneyBowes module is not configured';
     }
     return $rates;
 }
Esempio n. 3
0
 /**
  * mark as not running
  * 
  * @return void
  */
 protected function release()
 {
     \XLite\Core\Lock\FileLock::getInstance()->release($this->getLockKey());
 }
Esempio n. 4
0
 /**
  * Unlock export
  *
  * @return string
  */
 public static function unlockExport()
 {
     \XLite\Core\Lock\FileLock::getInstance()->release(static::getLockKey());
 }