예제 #1
0
        public string DuplicateRoute(string routeId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            RouteParametersQuery routeParameters = new RouteParametersQuery()
            {
                RouteId = routeId
            };

            // Run the query
            string errorString;
            string duplicatedRouteId = route4Me.DuplicateRoute(routeParameters, out errorString);

            Console.WriteLine("");

            if (duplicatedRouteId != null)
            {
                Console.WriteLine("DuplicateRoute executed successfully, duplicated route ID: {0}", duplicatedRouteId);
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("DuplicateRoute error {0}", errorString);
            }

            return(duplicatedRouteId);
        }
        public string DuplicateRoute(string routeId)
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              RouteParametersQuery routeParameters = new RouteParametersQuery()
              {
            RouteId = routeId
              };

              // Run the query
              string errorString;
              string duplicatedRouteId = route4Me.DuplicateRoute(routeParameters, out errorString);

              Console.WriteLine("");

              if (duplicatedRouteId != null)
              {
            Console.WriteLine("DuplicateRoute executed successfully, duplicated route ID: {0}", duplicatedRouteId);
            Console.WriteLine("");
              }
              else
              {
            Console.WriteLine("DuplicateRoute error {0}", errorString);
              }

              return duplicatedRouteId;
        }
예제 #3
0
        /// <summary>
        /// Duplicate a route
        /// </summary>
        /// <param name="routeId">Route ID</param>
        public void DuplicateRoute(string routeId = null)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            bool isInnerEample = routeId == null ? true : false;

            if (isInnerEample)
            {
                RunOptimizationSingleDriverRoute10Stops();
                OptimizationsToRemove = new List <string>()
                {
                    SD10Stops_optimization_problem_id
                };

                routeId = SD10Stops_route_id;
            }

            var routeParameters = new RouteParametersQuery()
            {
                RouteId = routeId
            };

            // Run the query
            string duplicatedRouteId = route4Me.DuplicateRoute(
                routeParameters,
                out string errorString
                );

            if (duplicatedRouteId != null)
            {
                RoutesToRemove = new List <string>()
                {
                    duplicatedRouteId
                }
            }
            ;

            Console.WriteLine(
                duplicatedRouteId != null
                ? String.Format(
                    "DuplicateRoute executed successfully, duplicated route ID: {0}",
                    duplicatedRouteId
                    )
                : String.Format(
                    "DuplicateRoute error {0}",
                    errorString
                    )
                );

            if (isInnerEample)
            {
                RemoveTestRoutes();
                RemoveTestOptimizations();
            }
        }
    }
        /// <summary>
        /// Get origin route of the duplicated route.
        /// </summary>
        public void RouteOriginParameter()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            RunOptimizationSingleDriverRoute10Stops();
            OptimizationsToRemove = new System.Collections.Generic.List <string>()
            {
                SD10Stops_optimization_problem_id
            };

            #region Duplicate Route

            var duplParameters = new RouteParametersQuery()
            {
                RouteId = SD10Stops_route_id
            };

            // Run the query
            string duplicatedRouteId = route4Me.DuplicateRoute(
                duplParameters,
                out string errorString
                );

            if (duplicatedRouteId != null)
            {
                RoutesToRemove = new List <string>()
                {
                    duplicatedRouteId
                };
            }
            else
            {
                Console.WriteLine("Cannot duplicate the route");
                return;
            }

            #endregion

            var routeParameters = new RouteParametersQuery()
            {
                RouteId  = duplicatedRouteId,
                Original = true
            };

            var route = route4Me.GetRoute(routeParameters, out errorString);

            PrintExampleRouteResult((route?.OriginalRoute ?? null), errorString);

            RemoveTestRoutes();
            RemoveTestOptimizations();
        }
예제 #5
0
        /// <summary>
        /// Unlink a route from an optimization.
        /// </summary>
        public void UnlinkRouteFromOptimization()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            RunOptimizationSingleDriverRoute10Stops();
            OptimizationsToRemove = new List <string>()
            {
                SD10Stops_optimization_problem_id
            };

            #region Duplicate the route

            var routeDuplicateParameters = new RouteParametersQuery()
            {
                RouteId = SD10Stops_route_id
            };

            // Run the query
            var duplicatedRouteId = route4Me.DuplicateRoute(
                routeDuplicateParameters,
                out string errorString);

            if (duplicatedRouteId == null)
            {
                Console.WriteLine("Cannot duplicate the route");
                return;
            }

            var duplicatedRoute = route4Me.GetRoute(
                new RouteParametersQuery()
            {
                RouteId = duplicatedRouteId
            },
                out errorString);

            if (duplicatedRoute == null && duplicatedRoute.GetType() != typeof(DataObjectRoute))
            {
                Console.WriteLine("Cannot retrieve the duplicated route.");
                return;
            }

            RoutesToRemove = new List <string>()
            {
                duplicatedRouteId
            };

            #endregion

            var routeParameters = new RouteParametersQuery()
            {
                RouteId = duplicatedRouteId,
                UnlinkFromMasterOptimization = true
            };

            // Run the query
            var unlinkedRoute = route4Me.UpdateRoute(routeParameters, out errorString);

            PrintExampleRouteResult(unlinkedRoute, errorString);

            RemoveTestRoutes();
            RemoveTestOptimizations();
        }