/// <summary> /// RemoveItem /// </summary> /// <param name="theInfo"></param> /// <param name="targetTicket"></param> /// <param name="targetItem"></param> public void removeItem(IDisplayActions.displayActionInfo theInfo, Ticket targetTicket, MenuItem targetItem) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { return; } if (_configurationHelper != null && _configurationHelper.ENABLE_bLOYAL && targetItem != null && _configurationHelper.LOAD_GIFTCARD_ITEMS != null && _configurationHelper.LOAD_GIFTCARD_ITEMS.Any()) { RefreshTicket(targetTicket); UpdateTicketDictionary(_ticketId); var loadGiftCardItem = _configurationHelper.LOAD_GIFTCARD_ITEMS.Find(t => t.Equals(targetItem.ItemName, StringComparison.InvariantCultureIgnoreCase)); if (!string.IsNullOrWhiteSpace(loadGiftCardItem)) { var service = new LoyaltyEngineServices(); var calculatedCart = AsyncHelper.RunSync(() => service.GetCartBySourceExternalIdAsync(_targetTicket.ID)); if (calculatedCart != null && calculatedCart.Cart != null && calculatedCart.Cart.Lines != null && calculatedCart.Cart.Lines.Any()) { var lines = calculatedCart.Cart.Lines; var giftCartLine = calculatedCart.Cart.Lines.ToList().Find(t => t.ProductName.Equals(loadGiftCardItem, StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrWhiteSpace(t.GiftCardNumber) && t.ProductExternalId.Equals(targetItem.TIID)); if (giftCartLine != null && giftCartLine.GiftCardAmount.HasValue && giftCartLine.GiftCardAmount.Value > 0) { if (!_calculateTransaction.CreditLoadGiftCardItem(calculatedCart, targetItem.Price, giftCartLine.GiftCardNumber, targetTicket.ID, giftCartLine)) { frmServerOfflineWarning offLineMsg = new frmServerOfflineWarning(); offLineMsg.ShowDialog(); } else { lines.Remove(giftCartLine); } } calculatedCart.Cart.Lines = lines; var request = new CalculateCartCommand() { Cart = calculatedCart.Cart, Uid = calculatedCart.Cart.Uid }; service.CalculateCart(request); } } } } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "removeItem"); } }
/// <summary> /// Exit Payment Window and close ticket event /// </summary> /// <param name="theInfo"></param> public async void exitPaymentWindow(IDisplayActions.displayActionInfo theInfo) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { return; } if (_configurationHelper != null && _configurationHelper.ENABLE_bLOYAL) { if (_ticketId != 0) { if (_targetTicket != null && _targetTicket.AmountDue == 0) { var response = _calculateTransaction.ApplyLoadGiftCardBalance(_ticketId, theInfo.userID); if (response != null) { foreach (var loadItem in response) { frmApplyGiftCardSummary gcSummary = new frmApplyGiftCardSummary(loadItem.NetAmount, loadItem.GiftCardNumber, loadItem.IsProvision, loadItem.IsNewCard); gcSummary.ShowDialog(); } } if (_ticketId > 0 && TicketDictionary.Dictionary != null && TicketDictionary.Dictionary.ContainsKey(_ticketId) && TicketDictionary.Dictionary[_ticketId] == Constants.CALCULATEDCURRENT) { var approveCartCommand = new ApproveCartCommand { CartUid = TicketDictionary.CartDictionary[_ticketId], CartSourceExternalId = _ticketId.ToString(), ReferenceNumber = _ticketId.ToString() }; var service = new LoyaltyEngineServices(); var cartApproval = service.ApproveCartAsync(approveCartCommand); await _calculateTransaction.CommitCartAsync(_ticketId); } _ticketId = 0; // after process complete set ticket id to 0 } } } } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "exitPaymentWindow"); } }
public override void ButtonPressed(object parentForm, Dinerware.TicketCollection theTickets, Dinerware.Ticket currentTicket, Dinerware.User currentUser, Dinerware.Person currentCustomer) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { frmConfigurationSettingsWarning frmConfigurationSettingsWarning = new frmConfigurationSettingsWarning(); frmConfigurationSettingsWarning.ShowDialog(); return; } if (currentTicket != null) { currentOpenTicket = currentTicket; currentOpenTicketId = currentTicket.ID; currentUserId = currentUser.ID; } else { currentOpenTicket = null; currentOpenTicketId = string.Empty; currentUserId = string.Empty; } var configurationHelper = ConfigurationHelper.Instance; if (configurationHelper.ENABLE_bLOYAL) { if (!string.IsNullOrWhiteSpace(configurationHelper.GIFTCARD_TENDER_CODE)) { if (!ServiceURLHelper.IsbLoyalServiceUrlDown) { int ticketId = 0; int.TryParse(currentOpenTicketId, out ticketId); if (ticketId != 0) { if (!ServiceURLHelper.IsbLoyalServiceUrlDown) { // Load Gift Card Tender Window frmLoadGiftCardWarning loadGiftCardWarning = null; var loadGiftCardItems = configurationHelper.LOAD_GIFTCARD_ITEMS.Where(p => currentTicket.Items.Any(p2 => p2.ItemName.Equals(p, StringComparison.InvariantCultureIgnoreCase))); if (loadGiftCardItems != null && loadGiftCardItems.Any()) { foreach (var loadGiftItem in loadGiftCardItems) { var loadGiftCardMenuItems = currentTicket.Items.ToList().FindAll(t => t.ItemName.Equals(loadGiftItem, StringComparison.InvariantCultureIgnoreCase)); if (loadGiftCardMenuItems != null) { foreach (var loadItem in loadGiftCardMenuItems) { var service = new LoyaltyEngineServices(); var calculatedCart = AsyncHelper.RunSync(() => service.GetCartBySourceExternalIdAsync(currentTicket.ID)); bLoyal.Connectors.LoyaltyEngine.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, currentTicket, loadItem, calculatedCart, loadGiftItem); loadGiftCardBalance.ShowDialog(); } } } } } else { loadGiftCardWarning = new frmLoadGiftCardWarning(Messages.ADD_LOAD_GIFTCARD_WARNING); loadGiftCardWarning.ShowDialog(); } } else { if (ServiceURLHelper.IsbLoyalServiceUrlDown) { frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning(); frmServiceUrlDown.ShowDialog(); } } } else { frmShowWarningMessage frmshowWarning = new frmShowWarningMessage(); frmshowWarning.ShowDialog(); } } else { frmbLoyalServiceUrlDownWarning frmServiceUrlDown = new frmbLoyalServiceUrlDownWarning(); frmServiceUrlDown.ShowDialog(); } } else { frmCheckGiftCardWarning giftCardWarning = new frmCheckGiftCardWarning(); giftCardWarning.ShowDialog(); } } else { DisableEnablebLoyalFunctionality disableEnablebLoyal = new DisableEnablebLoyalFunctionality(); disableEnablebLoyal.ShowDialog(); } } catch (Exception ex) { LoggerHelper.Instance.WriteLogError(ex, "bLoyalLoadGiftCard OEButtonPressed"); } }
/// <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"); } }
/// <summary> /// Void Ticket /// </summary> /// <param name="theInfo"></param> /// <param name="targetTicket"></param> public void voidTicket(IDisplayActions.displayActionInfo theInfo, Ticket targetTicket) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { return; } if (_configurationHelper != null && _configurationHelper.ENABLE_bLOYAL && targetTicket != null && targetTicket.Items != null && targetTicket.Items.Any() && _configurationHelper.LOAD_GIFTCARD_ITEMS != null && _configurationHelper.LOAD_GIFTCARD_ITEMS.Any()) { RefreshTicket(targetTicket); var loadGiftCardItems = _configurationHelper.LOAD_GIFTCARD_ITEMS.Where(p => targetTicket.Items.Any(p2 => p2.ItemName.Equals(p, StringComparison.InvariantCultureIgnoreCase))); if (loadGiftCardItems != null && loadGiftCardItems.Any()) { var service = new LoyaltyEngineServices(); bool isCreditLoadGiftCard = false; var calculatedCart = AsyncHelper.RunSync(() => service.GetCartBySourceExternalIdAsync(_targetTicket.ID)); if (calculatedCart != null && calculatedCart.Cart != null && calculatedCart.Cart.Lines != null) { var lines = new List <CartLine>(calculatedCart.Cart.Lines.ToList()); foreach (var giftCartLine in calculatedCart.Cart.Lines) { if (giftCartLine.GiftCardAmount.HasValue && giftCartLine.GiftCardAmount.Value > 0) { if (!_calculateTransaction.CreditLoadGiftCardItem(calculatedCart, giftCartLine.GiftCardAmount.Value, giftCartLine.GiftCardNumber, targetTicket.ID, giftCartLine)) { frmServerOfflineWarning offLineMsg = new frmServerOfflineWarning(); offLineMsg.ShowDialog(); } else { isCreditLoadGiftCard = true; lines.Remove(giftCartLine); } } } if (isCreditLoadGiftCard) { calculatedCart.Cart.Lines = lines; var request = new CalculateCartCommand() { Cart = calculatedCart.Cart, Uid = calculatedCart.Cart.Uid }; service.CalculateCart(request); } } } } } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "voidTicket"); } }