protected function _updateStatus($status) { $request = $this->getRequest(); $id = $this->_helper->IdConvert->hexToStr($request->getParam('id')); $model = new WsPackage(); try { $packageRow = $model->findOne($id)->updatePackageStatus($status); if ($status == WsPackageStatus::STATUS_CANCELLED) { $dataModel = new WsPackageData(); $dataModel->changeStatusByPackage($id, WsPackageStatus::STATUS_CANCELLED); } } catch (Exception $exc) { $this->_helper->messenger()->error(); } $this->_helper->messenger()->success(); return $this->_helper->redirector('index'); }
/** * Wysłanie żądania wykonania wysyłki do GearmanWorker * @param integer $packageId Identyfikator pakietu * @param boolean $singleSend Czy wysyłka ma być realizowana z pominieciem funkcji masowej wysyłki. */ public function send($packageId, $singleSend = false) { $packageModel = new WsPackageData(); $select = $packageModel->select()->from('ws.package_data', array('id'))->where('ws_package_id=?', $packageId)->where('id_status=?', WsPackageStatus::STATUS_READY)->order('id ASC'); $packageDataRowset = $packageModel->fetchAll($select); switch ($this->getMode()) { case Logic_Package::SMS_MODE: $gearmanClient = new Logic_Gearman_Client(); // $gearmanClient = new Logic_Gearman_Worker_Send(); foreach ($packageDataRowset as $packageDataRow) { $jobHandler = $gearmanClient->sendpackage(Logic_Package::SMS_MODE, $packageDataRow->id, $packageId); if (null == $jobHandler || '' == $jobHandler) { $msg = "Cannot fetch job handler from Gerrit Worker!"; $this->updatePackageDataStatus($packageDataRow->id, array('id_status' => WsPackageStatus::STATUS_ERROR)); $this->packageError($packageId, array($msg)); throw new Exception($msg); } $this->updatePackageDataStatus($packageDataRow->id, array('id_job_handle' => $jobHandler)); } break; case Logic_Package::MAIL_MODE: break; default: $this->_logger->err("Niepoprawny typ pakietów. Oczekiwane to sms lub mail, podano: {$mode}"); } }