/// <summary>
        /// Handles when a user clicks on the card button option.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The RoutedEventArgs of the event.</param>
        private void CreditDebitButton_Click(object sender, RoutedEventArgs e)
        {
            CardTransactionResult res = CardReader.RunCard((DataContext as Order).Total);

            switch (res)
            {
            case CardTransactionResult.Approved:
                ((Order)this.DataContext).PrintReciept(PaymentType.Card, 0.00);
                NewOrderEvent?.Invoke(this, new NewOrderEventArgs(new Order()));
                break;

            case CardTransactionResult.Declined:
                MessageBox.Show("Your card was declined, contact your bank.");
                break;

            case CardTransactionResult.ReadError:
                MessageBox.Show("Error reading your card, try again.");
                break;

            case CardTransactionResult.InsufficientFunds:
                MessageBox.Show("Your card was rejected due to a lack of funds.");
                break;

            case CardTransactionResult.IncorrectPin:
                MessageBox.Show("Your pin was incorrect, try re-enterring");
                break;
            }
        }
Beispiel #2
0
        private static async Task RunLoop(IEndpointInstance endpointInstance)
        {
            while (true)
            {
                Log.Info("Press 'T' to order the tour, or 'Q' to quit.");
                var key = Console.ReadKey();
                Console.WriteLine();

                switch (key.Key)
                {
                case ConsoleKey.T:
                    var orderEvent = new NewOrderEvent {
                        TripId = Guid.NewGuid().ToString()
                    };
                    await endpointInstance.Publish(orderEvent);

                    break;

                case ConsoleKey.Q:
                    return;

                default:
                    Log.Info("Please try again...");
                    break;
                }
            }
        }
        private void ProcessNewOrder(NewOrderEvent e)
        {
            var data = CtpConvert.GetCtpOrder(e.Order);

            data.InvestorID = _client.CtpLoginInfo.UserID;
            data.BrokerID   = _client.CtpLoginInfo.BrokerID;
            _client.Api.ReqOrderInsert(data, _client.GetNextRequestId());
            _orders.AddOrder(e.Order);
        }
 private void ProcessNewOrder(NewOrderEvent e)
 {
     _orders.AddOrder(e.Order);
     if (e.Order.Status == OrderStatus.NotSent)
     {
         var data = CtpConvert.GetInputOrder(e.Order);
         data.InvestorID = _client.CtpLoginInfo.UserID;
         data.BrokerID   = _client.CtpLoginInfo.BrokerID;
         _client.Api.ReqOrderInsert(data, _client.GetNextRequestId());
     }
 }
 /// <summary>
 /// Finalizes the sale and prints the reciept.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">The RoutedEventArgs of the event.</param>
 private void FinalizeSale_Click(object sender, RoutedEventArgs e)
 {
     if (((CashRegister)DataContext).Due <= 0)
     {
         _orderInstance.PrintReciept(PaymentType.Cash, ((CashRegister)DataContext).Owed);
         NewOrderEvent?.Invoke(this, new NewOrderEventArgs(new Order()));
     }
     else
     {
         MessageBox.Show("Cannot finalize sale until fully paid");
     }
 }
 private void ProcessNewOrder(NewOrderEvent e)
 {
     _orders.AddOrder(e.Order);
     if (e.Order.Status == OrderStatus.NotSent)
     {
         var data = CtpConvert.GetInputOrder(e.Order);
         data.InvestorID = _client.ctpLoginInfo.UserID;
         data.BrokerID   = _client.ctpLoginInfo.BrokerID;
         data.OrderRef   = e.Order.LocalID;
         var ret = _client.api.ReqOrderInsert(data, _client.GetNextRequestId());
         if (ret == 0)
         {
             return;
         }
         ProcessOrderReject(data, new CtpRspInfo {
             ErrorID = -1, ErrorMsg = "连接中断发送失败"
         });
     }
 }
Beispiel #7
0
 protected virtual void OnNewOrderEvent(NewOrderEventArgs e)
 {
     NewOrderEvent?.Invoke(this, e);
 }
 /// <summary>
 /// Handles when the user clicks on the cancel order button.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">The RoutedEventArgs of the event.</param>
 private void CancelOrder(object sender, RoutedEventArgs e)
 {
     NewOrderEvent?.Invoke(this, new NewOrderEventArgs(new Order()));
 }
Beispiel #9
0
 private OrderRoot(NewOrderEvent @event)
     : this()
     => ApplyChange <OrderRoot>(@event);
Beispiel #10
0
 public Task Handle(NewOrderEvent message, IMessageHandlerContext context)
 {
     Log.Info($"Tour booking started. Tour Id {message.TripId} ");
     return(Task.CompletedTask);
 }