Example #1
0
        public void CanEditOrderTest(string date, string name, string state, string pType, decimal area, int orderNumber)
        {
            OrderManager      manager  = OrderManagerFactory.Create();
            OrderListResponse response = manager.GetOrdersByDate(date);
            OrderResponse     r        = manager.EditOrder(date, name, state, pType, area, orderNumber);

            manager.RemoveOrder(response.Orders, orderNumber, date);
            manager.SaveOrder(r.Order, date);
            response = manager.GetOrdersByDate(date);
            Order editedOrder = response.Orders[0];

            Assert.AreEqual(name, editedOrder.CustomerName);
            Assert.AreEqual(state, editedOrder.State);
            Assert.AreEqual(pType, editedOrder.ProductType);
            Assert.AreEqual(area, editedOrder.Area);
        }
        public OrderListResponse GetOrdersByDate(string date)
        {
            OrderListResponse response = new OrderListResponse();

            DateTime d          = DateTime.Parse(date);
            string   formatDate = d.ToString("MMddyyyy");

            response.Orders = _orderRepo.LoadOrders(formatDate);
            if (response.Orders == null)
            {
                response.Success = false;
                response.Message = "There are no orders for this date.";
                return(response);
            }

            response.Success = true;
            return(response);
        }
Example #3
0
        public void GetOrderListWithJsonServClt()
        {
            GetOrderListRequest request = new GetOrderListRequest();

            OrderListResponse response = null;

            using (JsonServiceClient client = new JsonServiceClient(listenOnUrl))
            {
                response = client.Get <OrderListResponse>(request);
            }

            if (response != null)
            {
                response.PrintDump();
            }
            Console.WriteLine("成功获取所有订单。");
            Console.ReadLine();
        }
Example #4
0
        public void Execute()
        {
            OrderManager manager       = DIContainer.Kernel.Get <OrderManager>();
            var          tempOrderInfo = DIContainer.Kernel.Get <OrderInfo>();

            Console.Clear();

            var orderDate = Input.GetOrderDate();

            tempOrderInfo = DIContainer.Kernel.Get <OrderInfo>();

            tempOrderInfo.OrderDate = orderDate;

            OrderListResponse response = manager.ListOrders(tempOrderInfo);

            var line = "{0, 6} {1,-35} {2} {3,-20} {4, 5} {5, 10:c}";



            if (response.Success)
            {
                Output.SendToConsole();
                Output.SendToConsole(String.Format(line, "Order", "Customer", "St", "Product", "Area", "Total"));
                Output.SendToConsole();
                foreach (var order in response.Orders)
                {
                    Output.SendToConsole(String.Format(line, order.OrderNumber, order.CustomerName, order.State, order.ProductType, order.Area, order.Total));
                }
            }
            else
            {
                Output.SendToConsole("\nNo orders found");
            }

            Output.SendToConsole("\nPress any key to continue...");
            Console.ReadKey();
            ;
        }
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();
            string       date    = ConsoleIO.GetValidDate("Enter the date of the order you are attempting to look up:");

            OrderListResponse response = manager.GetOrdersByDate(date);

            if (!response.Success)
            {
                Console.WriteLine(response.Message);
                Console.WriteLine("Press any key to return to Main Menu.");
                Console.ReadKey();
                return;
            }

            foreach (var order in response.Orders)
            {
                ConsoleIO.DisplayOrder(order, date);
            }

            Console.WriteLine("Press any key to continue.");
            Console.ReadKey();
        }
Example #6
0
        //获取订单列表:
        public OrderListResponse Get(GetOrderListRequest request)
        {
            OrderListResponse result = OrderLogic.Instance.GetOrderList();

            return(result);
        }
Example #7
0
        public void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            Console.Clear();
            string date = ConsoleIO.GetValidDate("Enter the date of the order you are trying to edit.");

            OrderListResponse response = manager.GetOrdersByDate(date);

            if (!response.Success)
            {
                Console.WriteLine(response.Message);
                Console.WriteLine("Press any key to return to Main Menu.");
                Console.ReadKey();
            }

            Console.Clear();
            foreach (var order in response.Orders)
            {
                ConsoleIO.DisplayOrder(order, date);
            }

            int orderNumber = ConsoleIO.GetOrderNumber("Enter the order number of the order you want to edit:");


            OrderResponse oResponse = manager.GetOrderByOrderNumber(response.Orders, orderNumber);

            if (!oResponse.Success)
            {
                Console.WriteLine(oResponse.Message);
                Console.WriteLine("Press any key to try again.");
                Console.ReadKey();
                return;
            }

            Console.Clear();
            Console.WriteLine($"Enter customer name ({oResponse.Order.CustomerName}):");
            string name = Console.ReadLine();

            if (name == "")
            {
                name = oResponse.Order.CustomerName;
            }

            Console.WriteLine($"Enter what state you or your company is located ({oResponse.Order.State}):");
            string state = Console.ReadLine();

            if (state == "")
            {
                state = oResponse.Order.State;
            }


            Console.WriteLine($"Enter the product type you would like to use ({oResponse.Order.ProductType}):");
            string pType = Console.ReadLine();

            if (pType == "")
            {
                pType = oResponse.Order.ProductType;
            }

            Console.WriteLine($"Enter in the total area of your flooring project (minimum 100 Sq Ft) ({oResponse.Order.Area}):");
            string  temp = Console.ReadLine();
            decimal area;

            if (temp == "")
            {
                area = oResponse.Order.Area;
            }
            else
            {
                area = decimal.Parse(temp);
            }
            OrderResponse r = manager.EditOrder(date, name, state, pType, area, orderNumber);

            if (!r.Success)
            {
                Console.WriteLine(r.Message);
                Console.WriteLine("Press any key to continue.");
                Console.ReadKey();
                return;
            }

            ConsoleIO.DisplayOrder(r.Order, date);
            Console.WriteLine("Are you sure you want to make these changes? Y / N");
            string input = Console.ReadLine().ToUpper();

            if (input != "Y")
            {
                Console.WriteLine("Your changes have been cancelled!");
                Console.WriteLine("Press any key to return to Main Menu.");
                Console.ReadKey();
                return;
            }
            Console.WriteLine("The edits you made have been processed");
            Console.WriteLine("Press any key to return to Main Menu.");
            Console.ReadKey();
            manager.RemoveOrder(response.Orders, orderNumber, date);
            manager.SaveOrder(r.Order, date);
        }
Example #8
0
        //获取订单列表:
        public OrderListResponse Get(GetOrderList request)
        {
            OrderListResponse result = OrderRepository.GetOrderList();

            return(result);
        }
Example #9
0
        /// <summary>
        /// Process the incoming messages
        /// </summary>
        /// <param name="message">Incoming message</param>
        private void processMessage(string message)
        {
            // Deserialize the incoming command to check wich message has just arrived
            // The action property brings the command name
            switch (Command.Deserialize(message).action)
            {
            case KeepAlive.CLASSNAME:
            {           // If it is a KeepAlive message, just answer Quantsis Conneciton Box another KeepAlive message
                        //CheckAsyncTaskInProgress
                this.send(new KeepAlive().Serialize());
                break;
            }

            case NewOrderResponse.CLASSNAME:
            {           // If it is an NewOrderResponse message and it contains error, show the error message
                var cmd = NewOrderResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case NewStopOrderResponse.CLASSNAME:
            {           // If it is an NewStopOrderResponse message and it contains error, show the error message
                var cmd = NewStopOrderResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case NewStopGainLossOrderResponse.CLASSNAME:
            {           // If it is an NewStopGainLossOrderResponse message and it contains error, show the error message
                var cmd = NewStopGainLossOrderResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case CancelOrderResponse.CLASSNAME:
            {           // If it is an CancelOrderResponse message and it contains error, show the error message
                var cmd = CancelOrderResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case ExecutionReport.CLASSNAME:
            {           // If it is an ExecutionReport message, check if it was successful and updates the order list or show error message
                var cmd = ExecutionReport.Deserialize(message);
                if (cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                else
                {
                    NotifyOMS(cmd.ToString());
                }

                break;
            }

            case OrderListResponse.CLASSNAME:
            {           // If it is an OrderListResponse, check if it was successful. In negative case show error message.
                var cmd = OrderListResponse.Deserialize(message);
                if (!cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case PositionResponse.CLASSNAME:
            {           // If it is a Position Response, check if it was successful and updates the position list. In case of failure, show error messasge
                var cmd = PositionResponse.Deserialize(message);
                if (cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                else
                {
                    NotifyOMS(cmd.ToString());
                }

                break;
            }

            case QuoteResponse.CLASSNAME:
            {           // If it is a Quote Response, check if it was successful and logs the message
                var cmd = QuoteResponse.Deserialize(message);
                if (cmd.success)
                {
                    OnQuoteResponse(cmd);
                }
                else
                {
                    NotifyQCB(cmd.ToString());
                }
                break;
            }

            case QuoteUpdate.CLASSNAME:
            {           // If it is a Quote Update, check if it was successful and logs the message
                var cmd = QuoteUpdate.Deserialize(message);
                if (cmd.success)
                {
                    OnQuoteUpdate(cmd);
                }
                else
                {
                    NotifyQCB(cmd.ToString());
                }
                break;
            }

            case QuoteUnsubscribeResponse.CLASSNAME:
            {           // If it is a Quote Unsubscribe Response, check if it was successful
                var cmd = QuoteUnsubscribeResponse.Deserialize(message);
                if (cmd.success)
                {
                    NotifyOMS(cmd.ToString());
                }
                else
                {
                    NotifyOMS(cmd.ToString());
                }
                break;
            }

            case CandleResponse.CLASSNAME:
            {           // If it is a Quote Update, check if it was successful and logs the message
                var cmd = CandleResponse.Deserialize(message);
                if (cmd.success)
                {
                    if (cmd.candles != null)
                    {
                        if (cmd.candles.Count <= 0)
                        {
                            NotifyOMS("Nenhum foi possivel retornar nenhum candle para " + cmd.security + " - Timeframe: " + cmd.timeframe);
                        }
                        else
                        {
                            NotifyOMS("Dados Historicos Intraday para: " + cmd.security + " - Qtd de Candles: " + cmd.candles.Count + " - Timeframe: " + cmd.timeframe);
                            //foreach (Candle candle in cmd.candles)
                            //    this.mainForm.log(candle.ToString());
                        }
                    }
                }
                else
                {
                    NotifyOMS(cmd.ToString());
                }

                break;
            }

            // Candle Update
            case CandleUpdate.CLASSNAME:
            {           // If it is a Candle Update, check if it was successful and logs the message
                var cmd = CandleUpdate.Deserialize(message);

                if (cmd.success)
                {
                    if (cmd.candle != null)
                    {
                        switch (cmd.timeframe)
                        {
                        case CandleUpdate.TIMEFRAME_INTRADAY_1_MIN:
                            NotifyOMS("Candle Intraday Update: " + cmd.security + " - Last: " + cmd.candle.close + " - Time: " + cmd.candle.date);
                            break;

                        case CandleUpdate.TIMEFRAME_DAILY:
                            NotifyOMS("Candle Daily Update: " + cmd.security + " - Last: " + cmd.candle.close + " - Time: " + cmd.candle.date);
                            break;
                        }
                    }
                }
                //this.mainForm.updatePositions(cmd);
                else
                {
                    NotifyOMS(cmd.ToString());
                }

                break;
            }

            // QCB has disconnected (shut down)
            case Disconnect.CLASSNAME:
                this.disconnect();
                break;
            }
        }