コード例 #1
0
 public AzureQueueAdapter(IConfigurationFactory configFactory, string configurationName, IBusLogger logger, string topicName, ILogController logController, IOptions <ConnectionStrings> connectionStrings, IOptions <AzureServiceBusConfiguration> serviceBusConfiguration)
 {
     this._configuration         = configFactory.GetConfiguration <AzureQueueConfiguration>("AzureQueueConfiguration/Queue");
     _azureQueueHelper           = new AzureQueueHelper(logController, connectionStrings, serviceBusConfiguration);
     _azureQueueHelper.TopicName = topicName;
     this._logger = logger;
 }
コード例 #2
0
 public AzureQueueAdapter(AzureQueueConfiguration configuration, IBusLogger logger, ILogController logController, IOptions <ConnectionStrings> connectionStrings, IOptions <AzureServiceBusConfiguration> serviceBusConfiguration)
 {
     this._configuration         = configuration;
     _azureQueueHelper           = new AzureQueueHelper(logController, connectionStrings, serviceBusConfiguration);
     _azureQueueHelper.TopicName = _configuration.name;
     this._logger = logger;
 }
コード例 #3
0
        private void AddToAzureStorageQueue(long propertyId, string userId, string userName)
        {
            var message       = new PropertyChangeNotificationMessage(propertyId, userId, userName);
            var messageString = JsonConvert.SerializeObject(message);

            AzureQueueHelper.AddAzureQueueMessage(messageString);
        }
コード例 #4
0
 public AzureMsgQProvider(string _pQName, string _pConnstionstring)
 {
     _objQHelper = new AzureQueueHelper(_pQName, _pConnstionstring);
 }
コード例 #5
0
        public async Task <ActionResult> Complete(OrderModel order)
        {
            try
            {
                // TODO: Complete the payment processing via the gateway and update the order...
                NVPAPICaller gatewayCaller = new NVPAPICaller();

                string   token = "";
                string   finalPaymentAmount = "";
                NVPCodec decoder            = new NVPCodec();

                token = Session["token"].ToString();
                //PayerID = Session["payerId"].ToString();
                //finalPaymentAmount = Session["payment_amt"].ToString();
                finalPaymentAmount = order.Total.ToString("C2");

                bool ret = gatewayCaller.DoCheckoutPayment(finalPaymentAmount, token, ref decoder);
                if (ret)
                {
                    // Retrieve PayPal confirmation value.
                    string PaymentConfirmation = decoder[NVPProperties.Properties.TRANSACTIONID].ToString();
                    order.PaymentTransactionId = PaymentConfirmation;

                    using (var _db = new ProductContext())
                    {
                        // Get the current order id.
                        int currentOrderId = -1;
                        if (Session["currentOrderId"] != null && Session["currentOrderId"].ToString() != string.Empty)
                        {
                            currentOrderId = Convert.ToInt32(Session["currentOrderID"]);
                        }
                        Order myCurrentOrder;
                        if (currentOrderId >= 0)
                        {
                            // Get the order based on order id.
                            myCurrentOrder = _db.Orders.Single(o => o.OrderId == currentOrderId);
                            // Update the order to reflect payment has been completed.
                            myCurrentOrder.PaymentTransactionId = PaymentConfirmation;
                            // Save to DB.
                            _db.SaveChanges();

                            // Queue up a receipt generation request, asynchronously.
                            await AzureQueueHelper.QueueReceiptRequest(myCurrentOrder);

                            if (myCurrentOrder.SMSOptIn)
                            {
                                await AzureQueueHelper.QueueSmsMessageRequest(myCurrentOrder);
                            }

                            // Report successful event to Application Insights.
                            var eventProperties = new Dictionary <string, string>
                            {
                                { "CustomerEmail", order.Email },
                                { "OrderTotal", finalPaymentAmount },
                                { "PaymentTransactionId", PaymentConfirmation }
                            };
                            TelemetryHelper.TrackEvent("OrderCompleted", eventProperties);
                        }

                        // Clear shopping cart.
                        using (ShoppingCartActions usersShoppingCart =
                                   new ShoppingCartActions(cartId))
                        {
                            usersShoppingCart.EmptyCart();
                        }

                        // Clear order id.
                        Session["currentOrderId"] = string.Empty;
                    }
                }
                else
                {
                    var error = gatewayCaller.PopulateGatewayErrorModel(decoder);

                    // Report failed event to Application Insights.
                    Exception ex = new Exception(error.ToString())
                    {
                        Source = "Contoso.Apps.SportsLeague.Web.CheckoutController.cs"
                    };
                    TelemetryHelper.TrackException(ex);

                    // Redirect to the checkout error view:
                    return(RedirectToAction("Error", error));
                }
            }
            catch (WebException wex)
            {
                ExceptionUtility.LogException(wex, "CheckoutController.cs Complete Action");

                var error = new CheckoutErrorModel
                {
                    ErrorCode = wex.Message
                };

                if (wex.Response != null && wex.Response.GetType() == typeof(HttpWebResponse))
                {
                    // Extract the response body from the WebException's HttpWebResponse:
                    error.LongMessage = ((HttpWebResponse)wex.Response).StatusDescription;
                }

                // Redirect to the checkout error view:
                return(RedirectToAction("Error", error));
            }
            catch (Exception ex)
            {
                ExceptionUtility.LogException(ex, "CheckoutController.cs Complete Action");

                var error = new CheckoutErrorModel
                {
                    ErrorCode = ex.Message
                };

                // Redirect to the checkout error view:
                return(RedirectToAction("Error", error));
            }

            return(View(order));
        }