Beispiel #1
0
        public async Task Refuse_Invalid_Coordinates()
        {
            //Arrange
            var request = new RouteReqDto()
            {
                Stops = new List <StopReqDto>
                {
                    new StopReqDto
                    {
                        Latitude  = 100,
                        Longitude = 200
                    },
                    new StopReqDto
                    {
                        Latitude  = 200,
                        Longitude = 400
                    }
                }
            };

            //Act
            var content = new StringContent(request.ToString(), Encoding.UTF8, "application/json");

            _client.DefaultRequestHeaders.Add(Constants.ApiKey, "123123");
            var response = await _client.PostAsync("route", content);

            //Assert
            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
        public async Task <ActionResult <RouteRespDto> > CreateRoute([FromBody] RouteReqDto reqRoute)
        {
            var coordinates = reqRoute.Stops.Select(s => new Stop(s.Latitude, s.Longitude)).ToList();
            var tour        = await _routeConstructionService.CreateTour(coordinates);

            return(CreatedAtAction(nameof(GetRoute), new { routeId = tour.Id }, tour));
        }
Beispiel #3
0
        private void RouteQuery()
        {
            string url = "https://open-sbox.sf-express.com/rest/v1.0/route/query/access_token/" + accesstoken + "/sf_appid/00037521/sf_appkey/21662E074E84B37EB4DBA0F89F9803AA";
            MessageReq <RouteReqDto> req  = new MessageReq <RouteReqDto>();
            HeadMessageReq           req2 = new HeadMessageReq
            {
                transType      = 0x1f5,
                transMessageId = GettransMessageId()
            };

            req.head = req2;
            RouteReqDto dto = new RouteReqDto
            {
                methodType     = 2,
                trackingType   = 1,
                trackingNumber = textBox2.Text.ToString()
            };

            req.body = dto;
            MessageResp <List <RouteRespDto> > resp = RouteTools.routeQuery(url, req);
            string newLine = "订单追踪message:" + resp.head.message + "\n";

            //richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
            if (resp.head.code.Equals("EX_CODE_OPENAPI_0200"))
            {
                for (int i = 0; i < resp.body.Count; i++)
                {
                    newLine           = "{\n";
                    richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                    newLine           = "     快递接收地址:" + resp.body[i].acceptAddress + "\n";
                    richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                    newLine           = "     快递接收时间:" + resp.body[i].acceptTime + "\n";
                    richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                    newLine           = "     客户订单号:" + resp.body[i].orderId + "\n";
                    richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                    newLine           = "     快递运单号:" + resp.body[i].mailNo + "\n";
                    richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                    newLine           = "     操作码:" + resp.body[i].opcode + "\n";
                    richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                    newLine           = "     备注:" + resp.body[i].remark + "\n";
                    richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                    newLine           = "}\n";
                    richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
                }
            }
            else
            {
                newLine           = "订单追踪message:" + resp.head.message + "\n";
                richTextBox1.Text = richTextBox1.Text.Insert(0, newLine);
            }
        }