private void ProcessCancelMessage(OrderCancelMessage cancelMsg)
        {
            var id = _orders.TryGetKey(cancelMsg.OrderTransactionId);

            if (id == 0)
            {
                throw new InvalidOperationException(LocalizedStrings.Str3551Params.Put(cancelMsg.OrderTransactionId));
            }

            BaseCommandMessage command;

            switch (_ordersTypes[cancelMsg.OrderTransactionId])
            {
            case OrderTypes.Limit:
            case OrderTypes.Market:
                command = new CancelOrderMessage {
                    TransactionId = id
                };
                break;

            case OrderTypes.Conditional:
                command = new CancelStopOrderMessage {
                    TransactionId = id
                };
                break;

            case OrderTypes.Repo:
            case OrderTypes.ExtRepo:
            case OrderTypes.Rps:
                command = new CancelNegDealMessage {
                    TransactionId = id
                };
                break;

            case OrderTypes.Execute:
                command = new CancelReportMessage {
                    TransactionId = id
                };
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            SendCommand(command);
        }
示例#2
0
 public void Handle(CancelOrderMessage message)
 {
     Console.WriteLine("======================================================================");
 }
        public Task <List <TransactionMetadata> > CancelOrderAsync(CancelOrder cancelOrder, Wallet wallet, TransactionOption options, bool sync = true)
        {
            TransactionMessage message = new CancelOrderMessage(cancelOrder, wallet, options);

            return(BroadcastAsync(message.BuildMessageBody()));
        }
示例#4
0
        static async Task Main(string[] args)
        {
            var configuration = BuildConfiguration();

            var bus = CreateBusControl(configuration);

            await Task.Factory.StartNew(async() => await bus.StartAsync());

            // 通过指定的 queue uri 创建 send endpoint
            var sendEndpoint = await bus.GetSendEndpoint(new Uri(configuration.QueueUrl));

            Console.WriteLine("Press a key:");
            Console.WriteLine(" 1 to send a CreateOrder message");
            Console.WriteLine(" 2 to send a CancelOrder message");
            Console.WriteLine(" q to stop the application");

            ConsoleKeyInfo key;

            int orderId = 0;

            do
            {
                key = Console.ReadKey();
                Console.WriteLine();

                if (key.Key == ConsoleKey.NumPad1)
                {
                    var message = new CreateOrderMessage()
                    {
                        OrderId = ++orderId, OrderDate = DateTime.Now
                    };

                    await sendEndpoint.Send(message);

                    Console.WriteLine($"Order with Id {message.OrderId} has been sent.");
                }
                else if (key.Key == ConsoleKey.NumPad2)
                {
                    Console.WriteLine("Enter the Id of the order that you want to cancel: ");

                    string cancelOrderId = Console.ReadLine();

                    var m2 = new CancelOrderMessage()
                    {
                        OrderId = Int32.Parse(cancelOrderId)
                    };

                    await sendEndpoint.Send(m2);
                }
                else if (key.Key == ConsoleKey.Q)
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Invalid input, press key either 1, 2, or q.");
                }
            } while (true);

            Console.WriteLine("Stopping...");

            await Task.Delay(2000);

            await bus.StopAsync();

            Console.WriteLine("MassTransit Queue demo stopped.");
        }
示例#5
0
 public void Handle(CancelOrderMessage message)
 {
 }