private ProcessOrderResponse TryEnsureCartNotProcessing(ProcessLockInformation lockInfo, ProcessOrderResponse response) { try { EnsureCartNotProcessing(lockInfo, response); } catch (Exception ex) { _logger.Error(ex.Message, ex); } return(response); }
private void EnsureCartNotProcessing(ProcessLockInformation lockInfo, ProcessOrderResponse response) { if (response.PurchaseOrder != null) { return; } ICart cart; if (lockInfo.OrderGroupId.HasValue) { cart = _orderRepository.Load <ICart>(lockInfo.OrderGroupId.Value); } else { cart = _vippsService.GetCartByContactId(lockInfo.ContactId.Value, lockInfo.MarketId, lockInfo.CartName); } SetCartNotProcessing(lockInfo.OrderId, cart); }
private ProcessOrderResponse ProcessLocked(ProcessLockInformation lockInfo, Func <ProcessOrderResponse> method) { ProcessOrderResponse response; var readLock = _synchronizer.Get(lockInfo.OrderId); try { readLock.Wait(); response = method(); } catch (Exception ex) { _logger.Error(ex.Message, ex); response = GetErrorResponse(ex); } finally { _synchronizer.TryRelease(lockInfo.OrderId); } return(TryEnsureCartNotProcessing(lockInfo, response)); }