当前位置: 首页>>代码示例>>PHP>>正文


PHP Dao::rollbackTransaction方法代码示例

本文整理汇总了PHP中Dao::rollbackTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP Dao::rollbackTransaction方法的具体用法?PHP Dao::rollbackTransaction怎么用?PHP Dao::rollbackTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dao的用法示例。


在下文中一共展示了Dao::rollbackTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveItem

 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->id)) {
             throw new Exception('Invalid supplier ID passed in!');
         }
         $supplier = ($id = trim($param->CallbackParameter->id)) === '' ? new Supplier() : Supplier::get($id);
         if (!$supplier instanceof Supplier) {
             throw new Exception('Invalid supplier passed in!');
         }
         $contactName = trim($param->CallbackParameter->address->contactName);
         $contactNo = trim($param->CallbackParameter->address->contactNo);
         $street = trim($param->CallbackParameter->address->street);
         $city = trim($param->CallbackParameter->address->city);
         $region = trim($param->CallbackParameter->address->region);
         $postCode = trim($param->CallbackParameter->address->postCode);
         $country = trim($param->CallbackParameter->address->country);
         $address = $supplier->getAddress();
         $supplier->setName(trim($param->CallbackParameter->name))->setDescription(trim($param->CallbackParameter->description))->setContactNo(trim($param->CallbackParameter->contactNo))->setEmail(trim($param->CallbackParameter->email))->setAddress(Address::create($street, $city, $region, $country, $postCode, $contactName, $contactNo, $address))->save();
         $results['url'] = '/supplier/' . $supplier->getId() . '.html' . (isset($_REQUEST['blanklayout']) ? '?blanklayout=' . $_REQUEST['blanklayout'] : '');
         $results['item'] = $supplier->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage() . $ex->getTraceAsString();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:34,代码来源:DetailsController.php

示例2: run

 public static function run()
 {
     try {
         Dao::beginTransaction();
         $start = self::_logMsg("== START: processing Product Ageing ==", __CLASS__, __FUNCTION__);
         self::_emptyProductAgeingLog();
         $productCount = 0;
         $products = self::_getProducts();
         if (self::DEBUG === true) {
             self::_logMsg('ProductCount: ' . count($products), __CLASS__, __FUNCTION__);
         }
         foreach ($products as $product) {
             $productCount++;
             if (self::DEBUG === true) {
                 self::_logMsg('ProductId: ' . $product->getId(), __CLASS__, __FUNCTION__);
             }
             $lastPurchase = self::_getLastPurchase($product);
             if ($lastPurchase instanceof ProductQtyLog) {
                 self::_recordProductAgeingLog($lastPurchase);
             }
         }
         $end = new UDate();
         self::_logMsg("== FINISHED: process product ageing, (productCount: " . $productCount . ", ProductAgeingLogCount: " . ProductAgeingLog::countByCriteria('active = 1') . ")", __CLASS__, __FUNCTION__);
         Dao::commitTransaction();
     } catch (Exception $e) {
         Dao::rollbackTransaction();
         echo "\n" . $e->getMessage() . "\n" . $e->getTraceAsString();
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:29,代码来源:ProductAgeingReport.php

示例3: addComments

 /**
  *
  * @param unknown $sender
  * @param unknown $params
  */
 public function addComments($sender, $params)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($params->CallbackParameter->entityName) || ($entityName = trim($params->CallbackParameter->entityName)) === '') {
             throw new Exception('System Error: EntityName is not provided!');
         }
         if (!isset($params->CallbackParameter->entityId) || ($entityId = trim($params->CallbackParameter->entityId)) === '') {
             throw new Exception('System Error: entityId is not provided!');
         }
         if (!($entity = $entityName::get($entityId)) instanceof $entityName) {
             throw new Exception('System Error: no such a entity exisits!');
         }
         if (!isset($params->CallbackParameter->comments) || ($comments = trim($params->CallbackParameter->comments)) === '') {
             throw new Exception('System Error: invalid comments passed in!');
         }
         $comment = Comments::addComments($entity, $comments, Comments::TYPE_NORMAL);
         $results['item'] = $comment->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $params->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:31,代码来源:CommentsDiv.php

示例4: sendEmail

 /**
  * Sending the email out
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  */
 public function sendEmail($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->orderId) || !($order = Order::get($param->CallbackParameter->orderId)) instanceof Order) {
             throw new Exception('System Error: invalid order provided!');
         }
         if (!isset($param->CallbackParameter->emailAddress) || ($emailAddress = trim($param->CallbackParameter->emailAddress)) === '') {
             throw new Exception('System Error: invalid emaill address provided!');
         }
         $emailBody = '';
         if (isset($param->CallbackParameter->emailBody) && ($emailBody = trim($param->CallbackParameter->emailBody)) !== '') {
             $emailBody = str_replace("\n", "<br />", $emailBody);
         }
         $pdfFile = EntityToPDF::getPDF($order);
         $asset = Asset::registerAsset($order->getOrderNo() . '.pdf', file_get_contents($pdfFile), Asset::TYPE_TMP);
         $type = $order->getType();
         EmailSender::addEmail('sales@budgetpc.com.au', $emailAddress, 'BudgetPC ' . $type . ':' . $order->getOrderNo(), (trim($emailBody) === '' ? '' : $emailBody . "<br /><br />") . 'Please find attached ' . $type . ' (' . $order->getOrderNo() . '.pdf) from Budget PC Pty Ltd.', array($asset));
         $order->addComment('An email sent to "' . $emailAddress . '" with the attachment: ' . $asset->getAssetId(), Comments::TYPE_SYSTEM);
         $results['item'] = $order->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:36,代码来源:OrderBtns.php

示例5: run

 /**
  * runner
  * @param string $debug
  */
 public static function run($debug = false)
 {
     try {
         self::$_debug = $debug;
         Dao::beginTransaction();
         Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
         $start = self::_debug("Start to run " . __CLASS__ . ' =================== ');
         $assetIds = self::_findAllOverdueAssets();
         $assetIds = array_merge($assetIds, self::_findAllZombieAssets());
         self::_deleteAssets($assetIds);
         self::_debug("Finished to run " . __CLASS__ . ' =================== ', self::NEW_LINE, "", $start);
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         self::_debug("***** ERROR: " . $ex->getMessage());
         self::_debug($ex->getTraceAsString());
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:22,代码来源:AssetCleaner.php

示例6: createProduct

 /**
  * create product
  *
  * @param string $sku			The sku of product
  * @param string $name			The name of product
  * @param array $categoryPaths	The category paths of product (e.g. $categories = array(array('cate2', 'cate3'), array('cate4', 'cate5', 'cate6'));
  * @param string $mageProductId //TODO
  * @param string $isFromB2B
  * @param string $shortDescr
  * @param string $fullDescr
  * @param string $brandName
  *
  * @throws Exception
  * @return string
  * @soapmethod
  */
 public function createProduct($sku, $name, $categoryPaths = array(), $mageProductId = '', $isFromB2B = false, $shortDescr = '', $fullDescr = '', $brandName = '')
 {
     $response = $this->_getResponse(UDate::now());
     try {
         Dao::beginTransaction();
         Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
         //TODO
         if (Product::getBySku(trim($sku)) instanceof Product) {
             throw new Exception('sku "' . $sku . '" already exists');
         }
         $categories = array();
         if (is_array($categoryPaths)) {
             foreach ($categoryPaths as $categoryPath) {
                 $parentCategory = null;
                 foreach ($categoryPath as $categoryName) {
                     if (count($i = ProductCategory::getAllByCriteria('name = ?', array(trim($categoryName)), true, 1, 1)) > 0) {
                         $categories[$i[0]->getId()] = $category = $i[0];
                     } else {
                         $category = ProductCategory::create(trim($categoryName), trim($categoryName), $parentCategory);
                         $categories[$category->getId()] = $category;
                     }
                     $parentCategory = $category;
                 }
             }
         }
         // create product
         $product = Product::create(trim($sku), trim($name));
         // TODO
         foreach ($categories as $category) {
             $product->addCategory($category);
         }
         $response['status'] = self::RESULT_CODE_SUCC;
         $this->addCData('product', json_encode($product->getJson()), $response);
         Dao::commitTransaction();
     } catch (Exception $e) {
         Dao::rollbackTransaction();
         $response['status'] = self::RESULT_CODE_FAIL;
         $this->addCData('error', $e->getMessage(), $response);
     }
     return trim($response->asXML());
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:57,代码来源:APIProduct.php

示例7: addMemo

 /**
  * Creating a new Memo
  *
  * @param unknown $sender
  * @param unknown $params
  *
  * @throws Exception
  */
 public function addMemo($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->entity) || !isset($param->CallbackParameter->entityId) || ($entityName = trim($param->CallbackParameter->entity)) === '' || !($entity = $entityName::get(trim($param->CallbackParameter->entityId))) instanceof $entityName) {
             throw new Exception('System Error: no entity provided for the Memo');
         }
         if (!isset($param->CallbackParameter->data) || !isset($param->CallbackParameter->data->comments) || ($comments = trim($param->CallbackParameter->data->comments)) === '') {
             throw new Exception('You can NOT create a Memo with a blank message.');
         }
         $newComments = null;
         $entity->addComment($comments, Comments::TYPE_MEMO, '', $newComments);
         $results['item'] = $newComments->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:29,代码来源:LastMemoPanel.php

示例8: run

 public static function run()
 {
     $start = self::_logMsg("== START: processing Messages ==", __CLASS__, __FUNCTION__);
     $messages = self::_getAndMarkMessages();
     self::_logMsg("GOT " . count($messages) . ' Message(s): ', __CLASS__, __FUNCTION__);
     foreach ($messages as $message) {
         self::_logMsg("    Looping message(ID=" . $message->getId() . ': ', __CLASS__, __FUNCTION__);
         try {
             Dao::beginTransaction();
             EmailSender::sendEmail($message->getFrom(), $message->getTo(), $message->getSubject(), $message->getBody(), $message->getAttachmentAssetIdArray());
             $message->setStatus(Message::STATUS_SENT)->save();
             Dao::commitTransaction();
             self::_logMsg("    SUCCESS sending message(ID=" . $message->getId() . ').', __CLASS__, __FUNCTION__);
         } catch (Exception $ex) {
             Dao::rollbackTransaction();
             $message->setStatus(Message::STATUS_FAILED)->save();
             self::_logMsg("    ERROR sending message(ID=" . $message->getId() . ': ' . $ex->getMessage(), __CLASS__, __FUNCTION__);
             self::_logMsg("    ERROR sending message(ID=" . $message->getId() . ': ' . $ex->getTraceAsString(), __CLASS__, __FUNCTION__);
         }
     }
     $end = new UDate();
     self::_logMsg("== FINISHED: " . count($messages) . " Message(s) == ", __CLASS__, __FUNCTION__);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:23,代码来源:MessageSender.php

示例9: saveUser

 public function saveUser($sender, $params)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($params->CallbackParameter->firstName) || ($firstName = trim($params->CallbackParameter->firstName)) === '') {
             throw new Exception('System Error: firstName is mandatory!');
         }
         if (!isset($params->CallbackParameter->lastName) || ($lastName = trim($params->CallbackParameter->lastName)) === '') {
             throw new Exception('System Error: lastName is mandatory!');
         }
         if (!isset($params->CallbackParameter->userName) || ($userName = trim($params->CallbackParameter->userName)) === '') {
             throw new Exception('System Error: userName is mandatory!');
         }
         if (!isset($params->CallbackParameter->roleid) || !($role = Role::get($params->CallbackParameter->roleid)) instanceof Role) {
             throw new Exception('System Error: role is mandatory!');
         }
         $newpassword = trim($params->CallbackParameter->newpassword);
         if (!isset($params->CallbackParameter->userid) || !($userAccount = UserAccount::get($params->CallbackParameter->userid)) instanceof UserAccount) {
             $userAccount = new UserAccount();
             $person = new Person();
             if ($newpassword === '') {
                 throw new Exception('System Error: new password is mandatory!');
             }
             $newpassword = sha1($newpassword);
         } else {
             $person = $userAccount->getPerson();
             if ($newpassword === '') {
                 $newpassword = $userAccount->getPassword();
             } else {
                 $newpassword = sha1($newpassword);
             }
         }
         //double check whether the username has been used
         $users = UserAccount::getAllByCriteria('username=? and id!=?', array($userName, $userAccount->getId()), false, 1, 1);
         if (count($users) > 0) {
             throw new Exception('Username(=' . $userName . ') has been used by another user, please choose another one!');
         }
         $person->setFirstName($firstName)->setLastName($lastName)->save();
         $userAccount->setUserName($userName)->setPassword($newpassword)->setPerson($person)->save();
         $results = $userAccount->clearRoles()->addRole($role)->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $params->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:48,代码来源:UsersController.php

示例10: importProductAttributeSets

 /**
  * Importing the attribute sets from magento
  *
  * @return void|CatelogConnector
  */
 public function importProductAttributeSets()
 {
     $attributeSets = $this->getProductAttributeSetList();
     Log::logging(0, get_class($this), 'getting AttributeSets from magento', self::LOG_TYPE, '', __FUNCTION__);
     echo 'getting AttributeSets from magento' . "\n";
     if (count($attributeSets) === 0) {
         return;
     }
     try {
         $transStarted = false;
         try {
             Dao::beginTransaction();
         } catch (Exception $e) {
             $transStarted = true;
         }
         foreach ($attributeSets as $attributeSet) {
             $mageId = trim($attributeSet->set_id);
             $name = trim($attributeSet->name);
             $description = isset($category->description) ? trim($category->description) : $name;
             Log::logging(0, get_class($this), 'getting AttributeSet(mageId="' . $mageId . '")', self::LOG_TYPE, '', __FUNCTION__);
             $productAttributeSet = ProductAttributeSet::getByMageId($mageId);
             if (!$productAttributeSet instanceof ProductAttributeSet) {
                 Log::logging(0, get_class($this), 'found new AttributeSet from magento(mageId=' . $mageId . ', name="' . $name . '"' . ')', self::LOG_TYPE, '', __FUNCTION__);
                 echo 'found new AttributeSet from magento(mageId=' . $mageId . ', name="' . $name . '"' . ')' . "\n";
                 $productAttributeSet = ProductAttributeSet::create($name, $description, true, $mageId);
             } else {
                 Log::logging(0, get_class($this), 'found existing AttributeSet from magento(mageId=' . $mageId . ', name="' . $name . '", ID=' . $productAttributeSet->getId() . ')', self::LOG_TYPE, '', __FUNCTION__);
                 echo 'found existing AttributeSet from magento(mageId=' . $mageId . ', name="' . $name . '", ID=' . $productAttributeSet->getId() . ')' . "\n";
                 $productAttributeSet->setName($name)->setDescription($description);
             }
             $productAttributeSet->setActive(true)->save();
         }
         if ($transStarted === false) {
             Dao::commitTransaction();
         }
     } catch (Exception $e) {
         Dao::rollbackTransaction();
         throw $e;
     }
     return $this;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:46,代码来源:CatelogConnector.php

示例11: cancelOrder

 /**
  * cancelOrder
  *
  * @param unknown $sender
  * @param unknown $param
  *
  * @throws Exception
  *
  */
 public function cancelOrder($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->orderId) || !($order = Order::get($param->CallbackParameter->orderId)) instanceof Order) {
             throw new Exception('Invalid Order to CANCEL!');
         }
         if (!isset($param->CallbackParameter->reason) || !($reason = trim($param->CallbackParameter->reason)) === '') {
             throw new Exception('An reason for CANCELLING this ' . $order->getType() . ' is needed!');
         }
         $order->setStatus(OrderStatus::get(OrderStatus::ID_CANCELLED))->save()->addComment($msg = $order->getType() . ' is cancelled: ' . $reason, Comments::TYPE_SALES)->addLog($msg, Log::TYPE_SYSTEM, 'AUTO_GEN', __CLASS__ . '::' . __FUNCTION__);
         $results['item'] = $order->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:29,代码来源:OrderController.php

示例12: saveItem

 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $perchaseorder = !isset($param->CallbackParameter->id) ? new PurchaseOrder() : PurchaseOrder::get(trim($param->CallbackParameter->id));
         if (!$perchaseorder instanceof PurchaseOrder) {
             throw new Exception('Invalid Purchase Order passed in!');
         }
         $purchaseOrderNo = trim($param->CallbackParameter->purchaseOrderNo);
         $supplierId = trim($param->CallbackParameter->supplierId);
         $supplier = Supplier::get($supplierId);
         $orderDate = trim($param->CallbackParameter->orderDate);
         $totalAmount = trim($param->CallbackParameter->totalAmount);
         $totalPaid = trim($param->CallbackParameter->totalPaid);
         if (isset($param->CallbackParameter->id)) {
             $perchaseorder->setPurchaseOrderNo($purchaseOrderNo)->setSupplier($supplier)->setSupplierRefNo($supplierId)->setOrderDate($orderDate)->setTotalAmount($totalAmount)->setTotalPaid($totalPaid)->save();
         } else {
             // 				PurchaseOrder::
         }
         $results['url'] = '/purchase/' . $perchaseorder->getId() . '.html';
         $results['item'] = $perchaseorder->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage() . $ex->getTraceAsString();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:33,代码来源:DetailsController.php

示例13: saveItem

 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $kit = !isset($param->CallbackParameter->id) ? new Kit() : Kit::get(trim($param->CallbackParameter->id));
         if (!$kit instanceof Kit) {
             throw new Exception('Invalid Kit passed in!');
         }
         if (!isset($param->CallbackParameter->productId) || !($product = Product::get(trim($param->CallbackParameter->productId))) instanceof Product) {
             throw new Exception('Invalid Kit Product passed in!');
         }
         if (!isset($param->CallbackParameter->items) || count($items = $param->CallbackParameter->items) === 0) {
             throw new Exception('No Kit Components passed in!');
         }
         $task = null;
         if (isset($param->CallbackParameter->taskId) && !($task = Task::get(trim($param->CallbackParameter->taskId))) instanceof Task) {
             throw new Exception('Invalid Task passed in!');
         }
         $underCostReason = '';
         if (isset($param->CallbackParameter->underCostReason) && ($underCostReason = trim($param->CallbackParameter->underCostReason)) === '') {
             throw new Exception('UnderCostReason is Required!');
         }
         $isNewKit = false;
         if (trim($kit->getId()) === '') {
             $kit = Kit::create($product, $task);
             $isNewKit = true;
         } else {
             $kit->setTask($task)->save();
         }
         //add all the components
         foreach ($items as $item) {
             if (!($componentProduct = Product::get(trim($item->productId))) instanceof Product) {
                 continue;
             }
             if (($componentId = trim($item->id)) === '' && intval($item->active) === 1) {
                 $kit->addComponent($componentProduct, intval($item->qty));
             } else {
                 if (($kitComponent = KitComponent::get($componentId)) instanceof KitComponent) {
                     if ($kitComponent->getKit()->getId() !== $kit->getId()) {
                         continue;
                     }
                     if (intval($item->active) === 0) {
                         //deactivation
                         $kitComponent->setActive(false)->save();
                     } else {
                         $kitComponent->setQty(intval($item->qty))->save();
                     }
                 }
             }
         }
         if (trim($underCostReason) !== '') {
             $kit->addComment('The reason for continuing bulding this kit, when its cost is greater than its unit price: ' . $underCostReason, Comments::TYPE_WORKSHOP);
         }
         if ($isNewKit === true) {
             $kit->finishedAddingComponents();
         }
         $results['url'] = '/kit/' . $kit->getId() . '.html' . (trim($_SERVER['QUERY_STRING']) === '' ? '' : '?' . $_SERVER['QUERY_STRING']);
         if ($isNewKit === true) {
             $results['printUrl'] = '/print/kit/' . $kit->getId() . '.html?printlater=1';
         }
         $results['createdFromNew'] = $isNewKit;
         $results['item'] = $kit->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage() . '<pre>' . $ex->getTraceAsString() . '</pre>';
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:74,代码来源:Controller.php

示例14: actionTask

 /**
  * Getting the items
  *
  * @param unknown $sender
  * @param unknown $param
  * @throws Exception
  *
  */
 public function actionTask($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->taskId) || !($task = Task::get(trim($param->CallbackParameter->taskId))) instanceof Task) {
             throw new Exception('Invalid Task provided!');
         }
         if (!isset($param->CallbackParameter->method) || ($method = trim(trim($param->CallbackParameter->method))) === '' || !method_exists($task, $method)) {
             throw new Exception('Invalid Action Method!');
         }
         $comments = isset($param->CallbackParameter->comments) ? trim($param->CallbackParameter->comments) : '';
         $results['item'] = $task->{$method}(Core::getUser(), $comments)->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:28,代码来源:Controller.php

示例15: deleteItem

 /**
  * deleteItem
  *
  * @param unknown $sender
  * @param unknown $param
  * @throws Exception
  *
  */
 public function deleteItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->id) || !($recievingItem = ReceivingItem::get(trim($param->CallbackParameter->id))) instanceof ReceivingItem) {
             throw new Exception('System Error: invalid item provided');
         }
         $recievingItem->setActive(false)->save();
         $results['item'] = $recievingItem->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:25,代码来源:Controller.php


注:本文中的Dao::rollbackTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。