Пример #1
0
        public async Task <IActionResult> GetUserOrders([FromQuery] OrderHistoryRequest query)
        {
            Guid userId = new Guid(User.FindFirst("Id")?.Value);
            var  orders = await _service.GetUserOrder(userId, query);

            return(Ok(orders));
        }
Пример #2
0
        public void ProcessRequests()
        {
            string rawRequest = KeithLink.Svc.Impl.Helpers.Retry.Do <string>
                                    (() => _queue.ConsumeFromQueue(Configuration.RabbitMQConfirmationServer, Configuration.RabbitMQUserNameConsumer,
                                                                   Configuration.RabbitMQUserPasswordConsumer, Configuration.RabbitMQVHostConfirmation, Configuration.RabbitMQQueueOrderUpdateRequest),
                                    TimeSpan.FromSeconds(1), Constants.QUEUE_REPO_RETRY_COUNT);

            while (!string.IsNullOrEmpty(rawRequest))
            {
                OrderHistoryRequest request = JsonConvert.DeserializeObject <OrderHistoryRequest>(rawRequest);

                _log.WriteInformationLog(string.Format("Consuming order history request from queue for message ({0}).", request.MessageId));

                if (request.InvoiceNumber == null)
                {
                    request.InvoiceNumber = string.Empty;
                }

                StringBuilder transactionData = new StringBuilder();
                transactionData.Append(request.BranchId);
                transactionData.Append(request.CustomerNumber);
                transactionData.Append(request.InvoiceNumber.PadLeft(8));

                _log.WriteInformationLog(string.Format("Requesting history from mainframe - Branch: {0}, CustomerNumber: {1}, InvoiceNumber: {2}", request.BranchId, request.CustomerNumber, request.InvoiceNumber));

                _socket.Connect();
                _socket.StartTransaction(Configuration.MainframeHistoryTransactionId, transactionData.ToString());
                _socket.Close();

                _log.WriteInformationLog(string.Format("Request sent to mainframe - Branch: {0}, CustomerNumber: {1}, InvoiceNumber: {2}", request.BranchId, request.CustomerNumber, request.InvoiceNumber));

                rawRequest = _queue.ConsumeFromQueue(Configuration.RabbitMQConfirmationServer, Configuration.RabbitMQUserNameConsumer, Configuration.RabbitMQUserPasswordConsumer, Configuration.RabbitMQVHostConfirmation, Configuration.RabbitMQQueueOrderUpdateRequest);
            }
        }
        private async Task LoadMoreOrders()
        {
            if (HasMoreOrders)
            {
                await Task.Delay(200);

                PageIndex += 1;
                var orderHistoryRequest = new OrderHistoryRequest
                {
                    CustomerId = GlobalSettings.User.Id,
                    Page       = PageIndex,
                    PageSize   = GlobalSettings.AppConst.PageSize
                };

                await WebRequestExecuter.Execute(async() => await _wooCommerceService.GetOrders(orderHistoryRequest), myOrders =>
                {
                    if (myOrders != null && myOrders.Any())
                    {
                        foreach (var order in myOrders)
                        {
                            MyOrders.Add(order);
                        }

                        HasMoreOrders = myOrders.Count >= orderHistoryRequest.PageSize ? true : false;
                    }
                    else
                    {
                        PageIndex    -= 1;
                        HasMoreOrders = false;
                    }
                    return(Task.CompletedTask);
                });
            }
        }
Пример #4
0
        public async Task <List <OrderModel> > GetOrders(OrderHistoryRequest orderHistoryRequest)
        {
            var builder     = new UriBuilder(GlobalSettings.WooCommerceOrderEndpoint);
            var queryParams = orderHistoryRequest.GetQueryString();

            builder.Query = queryParams;
            var uri = builder.ToString();

            return(await _requestService.GetAsync <List <OrderModel> >(uri, forcedRefresh : true));
        }
Пример #5
0
        public async override Task <OrderHistoryReply> GetOrderHistory(OrderHistoryRequest request, Grpc.Core.ServerCallContext context)
        {
            var orders = await db.Orders
                         .Where(o => o.UserId == request.UserId)
                         .Include(o => o.DeliveryLocation)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping)
                         .ToListAsync();

            var reply = new OrderHistoryReply();

            reply.Orders.Add(orders.Select(o => o.ToGrpc()));
            return(reply);
        }
Пример #6
0
        public static async Task <Orders> GetOrdersAsync(string orderID, string transactionType, int count, int after, CurrencyType currency)
        {
            var request = new OrderHistoryRequest
            {
                apiKey    = _apiKey,
                secretKey = _apiSecretKey,
                order_id  = orderID,
                type      = transactionType,
                count     = count,
                after     = after,
                currency  = currency.ToString()
            };

            return(await RestClient.Instance.PostAsync <OrderHistoryRequest, Orders>(PrivateAPI.Orders, request));
        }
Пример #7
0
        public void RequestAllOrdersForCustomer(UserSelectedContext context)
        {
            OrderHistoryRequest request = new OrderHistoryRequest()
            {
                SenderApplicationName = Configuration.ApplicationName,
                SenderProcessName     = "Publish Order History Request for customer to queue",

                BranchId       = context.BranchId.ToUpper(),
                CustomerNumber = context.CustomerId
            };

            _queue.PublishToQueue(JsonConvert.SerializeObject(request), Configuration.RabbitMQConfirmationServer, Configuration.RabbitMQUserNamePublisher, Configuration.RabbitMQUserPasswordPublisher, Configuration.RabbitMQVHostConfirmation, Configuration.RabbitMQExchangeOrderUpdateRequests);

            _log.WriteInformationLog(string.Format("Publishing order history request to queue for message ({0}).", request.MessageId));
            _log.WriteInformationLog(string.Format("Request for all orders sent to queue - Branch: {0}, CustomerNumber: {1}", context.BranchId, context.CustomerId));
        }
Пример #8
0
        /**
         * getOrderHistoryExample
         * Get historical order information and return information only for the last two days
         */
        public static void getOrderHistoryExample()
        {
            /***Initialize the calling object*/
            IdaxApiRestClient idaxApiRestClient = IdaxConfig.init();

            /**Request parameter encapsulation**/
            string symbol = IdaxApiConstants.ETH_BTC;
            OrderHistoryRequest orderHistoryRequest = new OrderHistoryRequest();

            orderHistoryRequest.currentPage = 1;
            orderHistoryRequest.key         = IdaxConfig.API_KEY;
            orderHistoryRequest.orderState  = -1;
            orderHistoryRequest.pair        = symbol;
            orderHistoryRequest.timestamp   = DateTime.UtcNow.UnixTimeStamp();
            orderHistoryRequest.pageLength  = 10;

            /**Call remote interface**/
            OrderHistoryEntry orderHistoryEntry = idaxApiRestClient.getOrderHistory(orderHistoryRequest);
        }
        private async Task FetchOrdersAsync(int customerId)
        {
            var orderHistoryRequest = new OrderHistoryRequest();

            orderHistoryRequest.CustomerId = customerId;
            orderHistoryRequest.Page       = PageIndex;
            orderHistoryRequest.PageSize   = GlobalSettings.AppConst.PageSize;

            await WebRequestExecuter.Execute(async() => await _wooCommerceService.GetOrders(orderHistoryRequest), myOrders =>
            {
                if (myOrders != null && myOrders.Any())
                {
                    MyOrders = new ObservableCollection <OrderModel>(myOrders);

                    HasMoreOrders = myOrders.Count >= orderHistoryRequest.PageSize ? true : false;
                }
                else
                {
                    HasMoreOrders = false;
                }
                return(Task.CompletedTask);
            });
        }
Пример #10
0
        public async Task <PagedList <Order> > GetUserOrder(Guid userId, OrderHistoryRequest query)
        {
            var orders = _context.Orders.Include(o => o.Customer).Where(o => o.Customer.CustomerId.Equals(userId)).OrderByDescending(o => o.CreatedDate);

            return(await PagedList <Order> .CreateAsync(orders, query.pageIndex, query.pageSize));
        }
Пример #11
0
 public Task <BaseResponse <OrderHistoryResponse> > GetOpenOrders(OrderHistoryRequest request)
 {
     throw new NotImplementedException();
 }