Exemplo n.º 1
0
        /// <summary>
        /// Return info about route - stops, waypoints, park (depot)
        /// </summary>
        /// <param name="routeId"></param>
        /// <returns></returns>
        public GetRouteResponseResult GetRouteInfo(int routeId)
        {
            var request  = new GetRouteRequest(_requestId, _sessionId, routeId);
            var response = (GetRouteResponse)GetResponse(request, typeof(GetRouteResponse));

            return(response.Result);
        }
        private static GetRouteResponse GetRouteSample(string routeID)
        {
            GetRouteRequest gr = new GetRouteRequest()
            {
                RouteId = routeID
            };

            Console.WriteLine(gr.URL);
            GetRouteResponse grr = gr.Get();

            return(grr);
        }
 /// <summary>Snippet for Get</summary>
 public void GetRequestObject()
 {
     // Snippet: Get(GetRouteRequest, CallSettings)
     // Create client
     RoutesClient routesClient = RoutesClient.Create();
     // Initialize request argument(s)
     GetRouteRequest request = new GetRouteRequest
     {
         Route   = "",
         Project = "",
     };
     // Make the request
     Route response = routesClient.Get(request);
     // End snippet
 }
Exemplo n.º 4
0
        public ActionResult <RootViewModel> Get([FromQuery] GetRouteRequest request)
        {
            long userId;

            long.TryParse(User.Identity.Name, out userId);


            Root          result    = service.CountDistance(userId, request.PubName);
            RootViewModel viewModel = new RootViewModel()
            {
                distance = result.rows.First().elements.First().distance.text,
                duration = result.rows.First().elements.First().duration.text
            };

            return(Ok(viewModel));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the GetRoute request.
        /// </summary>
        public override async Task <RouteData> GetRoute(GetRouteRequest request, ServerCallContext context)
        {
            if (request.Route == Route.Unspecified)
            {
                throw new RpcException(new Status(StatusCode.NotFound, "Invalid route supplied."));
            }

            try
            {
                return((await GetAllRoutes()).Where(route => route.Route == request.Route).First());
            }
            catch (InvalidOperationException)
            {
                throw new RpcException(new Status(StatusCode.NotFound, "Requested route not found."));
            }
        }
Exemplo n.º 6
0
        private void btnTestService_Click(object sender, EventArgs e)
        {
            RouteService.IRouteService RouteService  = new RouteServiceClient();
            RouteServiceParameterDTO   originalroute = new RouteServiceParameterDTO();

            //originalroute.StreetAvenueName = "Rua XYZ de ABC";
            originalroute.StreetAvenueName = "Rua Jose Fabiano Rodrigues";
            originalroute.Number           = "10";
            originalroute.City             = "Osasco";
            originalroute.State            = "SP";

            RouteServiceParameterDTO destinationroute = new RouteServiceParameterDTO();

            destinationroute.StreetAvenueName = "Avenida Manoel Pedro Pimentel";
            destinationroute.Number           = "155";
            destinationroute.City             = "Osasco";
            destinationroute.State            = "SP";

            GetRouteRequest inValue = new GetRouteRequest();

            inValue.Body = new GetRouteRequestBody();
            RouteServiceParameterRequestDTO routeServiceParameterRequestDTO = new RouteServiceParameterRequestDTO();

            routeServiceParameterRequestDTO.originalRoute    = originalroute;
            routeServiceParameterRequestDTO.destinationRoute = destinationroute;
            routeServiceParameterRequestDTO.routeType        = RouteType.FastestRoute;
            inValue.Body.routeParameterRequest = routeServiceParameterRequestDTO;

            try
            {
                GetRouteResponse retVal = RouteService.GetRoute(inValue);
                string           result = "Distancia Total {0}. Custo Combustivel {1}. Tempo Total Rota {2}. Custo Considerando Pedagio {3}";
                if (retVal.Body.GetRouteResult != null)
                {
                    MessageBox.Show(string.Format(result, retVal.Body.GetRouteResult.TotalDistance.ToString(),
                                                  retVal.Body.GetRouteResult.TotalFuelCost.ToString(),
                                                  retVal.Body.GetRouteResult.TotalTime.ToString(),
                                                  retVal.Body.GetRouteResult.TotalTollFeeCost.ToString()));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetRouteRequest, CallSettings)
            // Additional: GetAsync(GetRouteRequest, CancellationToken)
            // Create client
            RoutesClient routesClient = await RoutesClient.CreateAsync();

            // Initialize request argument(s)
            GetRouteRequest request = new GetRouteRequest
            {
                Route   = "",
                Project = "",
            };
            // Make the request
            Route response = await routesClient.GetAsync(request);

            // End snippet
        }
Exemplo n.º 8
0
        public async stt::Task GetRequestObjectAsync()
        {
            moq::Mock <Routes.RoutesClient> mockGrpcClient = new moq::Mock <Routes.RoutesClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetRouteRequest request = new GetRouteRequest
            {
                Route   = "route8a40469c",
                Project = "projectaa6ff846",
            };
            Route expectedResponse = new Route
            {
                Id   = 11672635353343658936UL,
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                Tags = { "tags52c47ad5", },
                CreationTimestamp = "creation_timestamp235e59a1",
                NextHopIp         = "next_hop_ipa30be6cf",
                AsPaths           = { new RouteAsPath(), },
                NextHopIlb        = "next_hop_ilbbb4605ad",
                Network           = "networkd22ce091",
                NextHopNetwork    = "next_hop_networkec878a41",
                RouteType         = Route.Types.RouteType.Bgp,
                NextHopGateway    = "next_hop_gateway86a0bbe5",
                DestRange         = "dest_range56ada943",
                NextHopInstance   = "next_hop_instance57e80635",
                NextHopPeering    = "next_hop_peering2cca5109",
                Description       = "description2cf9da67",
                Priority          = 1546225849U,
                SelfLink          = "self_link7e87f12d",
                Warnings          = { new Warnings(), },
                NextHopVpnTunnel  = "next_hop_vpn_tunnela5f8e0c5",
            };

            mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Route>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            RoutesClient client = new RoutesClientImpl(mockGrpcClient.Object, null);
            Route        responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Route responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 9
0
        public void Get()
        {
            moq::Mock <Routes.RoutesClient> mockGrpcClient = new moq::Mock <Routes.RoutesClient>(moq::MockBehavior.Strict);
            GetRouteRequest request = new GetRouteRequest
            {
                Route   = "route8a40469c",
                Project = "projectaa6ff846",
            };
            Route expectedResponse = new Route
            {
                Id   = "id74b70bb8",
                Kind = "kindf7aa39d9",
                Name = "name1c9368b0",
                Tags = { "tags52c47ad5", },
                CreationTimestamp = "creation_timestamp235e59a1",
                NextHopGateway    = "next_hop_gateway86a0bbe5",
                NextHopIp         = "next_hop_ipa30be6cf",
                DestRange         = "dest_range56ada943",
                NextHopInstance   = "next_hop_instance57e80635",
                NextHopPeering    = "next_hop_peering2cca5109",
                Description       = "description2cf9da67",
                Priority          = 1546225849U,
                SelfLink          = "self_link7e87f12d",
                NextHopIlb        = "next_hop_ilbbb4605ad",
                Warnings          = { new Warnings(), },
                Network           = "networkd22ce091",
                NextHopVpnTunnel  = "next_hop_vpn_tunnela5f8e0c5",
                NextHopNetwork    = "next_hop_networkec878a41",
            };

            mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RoutesClient client   = new RoutesClientImpl(mockGrpcClient.Object, null);
            Route        response = client.Get(request.Project, request.Route);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>
 /// Returns the specified Route resource. Gets a list of available routes by making a list() request.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public override stt::Task <Route> GetAsync(GetRouteRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_GetRouteRequest(ref request, ref callSettings);
     return(_callGet.Async(request, callSettings));
 }
 /// <summary>
 /// Returns the specified Route resource. Gets a list of available routes by making a list() request.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public override Route Get(GetRouteRequest request, gaxgrpc::CallSettings callSettings = null)
 {
     Modify_GetRouteRequest(ref request, ref callSettings);
     return(_callGet.Sync(request, callSettings));
 }
 partial void Modify_GetRouteRequest(ref GetRouteRequest request, ref gaxgrpc::CallSettings settings);
 /// <summary>
 /// Returns the specified Route resource. Gets a list of available routes by making a list() request.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Route> GetAsync(GetRouteRequest request, st::CancellationToken cancellationToken) =>
 GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
 /// <summary>
 /// Returns the specified Route resource. Gets a list of available routes by making a list() request.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <Route> GetAsync(GetRouteRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();
 /// <summary>
 /// Returns the specified Route resource. Gets a list of available routes by making a list() request.
 /// </summary>
 /// <param name="request">The request object containing all of the parameters for the API call.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual Route Get(GetRouteRequest request, gaxgrpc::CallSettings callSettings = null) =>
 throw new sys::NotImplementedException();