コード例 #1
0
 /// <summary>
 /// Show Alerts
 /// </summary>
 private void ShowAlerts()
 {
     try
     {
         if (_calculatedCartResponse != null && _calculatedCartResponse.LoyaltySummary != null && _calculatedCartResponse.LoyaltySummary.Alerts != null && _calculatedCartResponse.LoyaltySummary.Alerts.Any())
         {
             foreach (var alert in _calculatedCartResponse.LoyaltySummary.Alerts)
             {
                 if (alert.Uid != Guid.Empty && !string.IsNullOrWhiteSpace(alert.SnippetUrl))
                 {
                     frmAlerts frmAlert = new frmAlerts(_calculatedCartResponse.Cart.Uid.ToString(), alert.Uid.ToString(), alert.SnippetUrl);
                     frmAlert.ShowDialog();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _logger.WriteLogError(ex, "ShowAlerts");
     }
 }
コード例 #2
0
        /// <summary>
        /// EnterPaymentWindow for PaymentWindow - event
        /// </summary>
        /// <param name="theInfo"></param>
        /// <param name="theTicket"></param>
        public void enterPaymentWindow(IDisplayActions.displayActionInfo theInfo, Ticket theTicket)
        {
            try
            {
                if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection)
                {
                    return;
                }
                if (_configurationHelper != null && _configurationHelper.ENABLE_bLOYAL && theTicket != null && theTicket.Items != null && theTicket.Items.Any())
                {
                    RefreshTicket(theTicket);

                    if (theTicket != null)
                    {
                        var services = new LoyaltyEngineServices();

                        if (_configurationHelper.LOAD_GIFTCARD_ITEMS != null && _configurationHelper.LOAD_GIFTCARD_ITEMS.Any())
                        {
                            var loadGiftCardItems = _configurationHelper.LOAD_GIFTCARD_ITEMS.Where(p => theTicket.Items.Any(p2 => p2.ItemName.Equals(p, StringComparison.InvariantCultureIgnoreCase)));
                            if (loadGiftCardItems != null && loadGiftCardItems.Any())
                            {
                                foreach (var loadGiftItem in loadGiftCardItems)
                                {
                                    var loadGiftCardMenuItems = theTicket.Items.ToList().FindAll(t => t.ItemName.Equals(loadGiftItem, StringComparison.InvariantCultureIgnoreCase));
                                    if (loadGiftCardMenuItems != null)
                                    {
                                        foreach (var loadItem in loadGiftCardMenuItems)
                                        {
                                            var calculatedCart = AsyncHelper.RunSync(() => services.GetCartBySourceExternalIdAsync(theTicket.ID));

                                            CartLine giftCartLine = null;
                                            if (calculatedCart != null && calculatedCart.Cart != null && calculatedCart.Cart.Lines != null && calculatedCart.Cart.Lines.Any())
                                            {
                                                giftCartLine = calculatedCart.Cart.Lines.FirstOrDefault(t => t.ProductName.Equals(loadGiftItem, StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrWhiteSpace(t.GiftCardNumber) && !string.IsNullOrWhiteSpace(t.ProductExternalId) && t.ProductExternalId.Equals(loadItem.TIID));
                                            }

                                            if (giftCartLine == null || string.IsNullOrWhiteSpace(giftCartLine.GiftCardNumber))
                                            {
                                                frmLoadGiftCardBalance loadGiftCardBalance = new frmLoadGiftCardBalance(_ticketId, string.Empty, _targetTicket, loadItem, calculatedCart, loadGiftItem);
                                                loadGiftCardBalance.ShowDialog();
                                                loadGiftCardBalance.CheckCardNumber();
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (TicketDictionary.Dictionary != null && TicketDictionary.Dictionary.ContainsKey(_ticketId))
                        {
                            if (TicketDictionary.Dictionary[_ticketId] == Constants.CALCULATEDCURRENT &&
                                TicketDictionary.CartDictionary != null && TicketDictionary.CartDictionary.ContainsKey(_ticketId) &&
                                TicketDictionary.CartDictionary[_ticketId] != null)
                            {
                                var approveCartCommand = new ApproveCartCommand
                                {
                                    CartUid = TicketDictionary.CartDictionary[_ticketId],
                                    CartSourceExternalId = _ticketId.ToString(),
                                    ReferenceNumber      = _ticketId.ToString()
                                };

                                CartApproval cartApproval = AsyncHelper.RunSync(() => services.ApproveCartAsync(approveCartCommand));

                                if (cartApproval != null && cartApproval.Alerts != null && cartApproval.Alerts.Count > 0)
                                {
                                    foreach (var alert in cartApproval.Alerts)
                                    {
                                        if (alert.Uid != null && alert.Uid != Guid.Empty && !string.IsNullOrWhiteSpace(alert.SnippetUrl))
                                        {
                                            frmAlerts frmAlert = new frmAlerts(TicketDictionary.CartDictionary[_ticketId].ToString(), alert.Uid.ToString(), alert.SnippetUrl);
                                            frmAlert.ShowDialog();
                                        }
                                    }
                                }
                            }
                            else if (_configurationHelper.IS_CALCULATE_DISCOUNT_WARNING)
                            {
                                frmTicketMsgForm discountWarning = new frmTicketMsgForm(theInfo.userID, _ticketId);
                                discountWarning.ShowDialog();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _loggerHelper.WriteLogError(ex, "enterPaymentWindow");
            }
        }