Beispiel #1
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());
            }
        }
        public RouteServiceResultDTO Process(RouteServiceParameterRequestDTO routeParameterRequest)
        {
            RouteServiceResultDTO routeServiceResult = new RouteServiceResultDTO();

            try
            {
                if (routeParameterRequest == null || routeParameterRequest.originalRoute == null || routeParameterRequest.destinationRoute == null)
                {
                    ThrowFaultException("Invalid Input Parameters !");
                }

                RouteType routeType = routeParameterRequest.routeType;

                //Set GeoLocation Information from Original Route
                SetGeolocationInfo(routeParameterRequest.originalRoute);

                //Get GeoLocation Information from Destination Route
                SetGeolocationInfo(routeParameterRequest.destinationRoute);

                //Mount RouteStop Objects
                RouteStop originalRouteDetails    = GetRouteStopInfo(routeParameterRequest.originalRoute);
                RouteStop destinationRouteDetails = GetRouteStopInfo(routeParameterRequest.destinationRoute);

                //Get Route Proximity Options
                var routeProximityOptions = GetRouteProximityOptions(routeType);
                var routes = new[] { originalRouteDetails, destinationRouteDetails };

                //Get Summary Totals
                routeServiceResult = GetRouteProximityTotals(routeProximityOptions, routes);
            }
            catch (Exception)
            {
                ThrowFaultException("Problem while executing Process Call !");
            }

            return(routeServiceResult);
        }