/// <summary> /// Example refers to the process of searching for the specified text /// throughout all routes names belonging to the user's account. /// </summary> /// <param name="query">Query text</param> public void SearchRoutesForText() { // Create the manager with the api key var route4Me = new Route4MeManager(ActualApiKey); RunOptimizationSingleDriverRoute10Stops("Nonstandard route name"); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; var routeParameters = new RouteParametersQuery() { Query = "Nonstandard" }; // Run the query DataObjectRoute[] dataObjects = route4Me.GetRoutes( routeParameters, out string errorString ); PrintExampleRouteResult(dataObjects, errorString); RemoveTestOptimizations(); }
public void GenericExampleShortcut() { Route4MeManager route4Me = new Route4MeManager(c_ApiKey); RouteParametersQuery routeQueryParameters = new RouteParametersQuery() { Limit = 10, Offset = 5 }; string errorMessage; DataObjectRoute[] dataObjects = route4Me.GetRoutes(routeQueryParameters, out errorMessage); if (dataObjects != null) { Console.WriteLine("GenericExampleShortcut executed successfully, {0} routes returned", dataObjects.Length); Console.WriteLine(""); dataObjects.ForEach(dataObject => { Console.WriteLine("Optimization Problem ID: {0}", dataObject.OptimizationProblemId); Console.WriteLine("RouteID: {0}", dataObject.RouteID); Console.WriteLine(""); }); } else { Console.WriteLine("GenericExampleShortcut error {0}", errorMessage); } }
public void GetRoutes() { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); RouteParametersQuery routeParameters = new RouteParametersQuery() { Limit = 10, Offset = 5 }; // Run the query string errorString; DataObjectRoute[] dataObjects = route4Me.GetRoutes(routeParameters, out errorString); Console.WriteLine(""); if (dataObjects != null) { Console.WriteLine("GetRoutes executed successfully, {0} routes returned", dataObjects.Length); Console.WriteLine(""); dataObjects.ForEach(dataObject => { Console.WriteLine("RouteID: {0}", dataObject.RouteID); Console.WriteLine(""); }); } else { Console.WriteLine("GetRoutes error {0}", errorString); } }
/// <summary> /// Get route directions /// </summary> public void GetRouteDirections() { var route4Me = new Route4MeManager(ActualApiKey); RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; var routeParameters = new RouteParametersQuery() { RouteId = SD10Stops_route_id, Directions = true }; // Run the query var dataObject = route4Me.GetRoute( routeParameters, out string errorString ); PrintExampleRouteResult(dataObject, errorString); RemoveTestOptimizations(); }
public void GetOptimizations() { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); RouteParametersQuery queryParameters = new RouteParametersQuery() { Limit = 10, Offset = 5 }; // Run the query string errorString; DataObject[] dataObjects = route4Me.GetOptimizations(queryParameters, out errorString); Console.WriteLine(""); if (dataObjects != null) { Console.WriteLine("GetOptimizations executed successfully, {0} optimizations returned", dataObjects.Length); Console.WriteLine(""); dataObjects.ForEach(optimization => { Console.WriteLine("Optimization Problem ID: {0}", optimization.OptimizationProblemId); Console.WriteLine(""); }); } else { Console.WriteLine("GetOptimizations error: {0}", errorString); } }
public void SearchRoutesForText(string query) { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); // Example refers to the process of searching for the specified text throughout all routes belonging to the user's account. RouteParametersQuery routeParameters = new RouteParametersQuery() { Query = query }; // Run the query string errorString; DataObjectRoute[] dataObjects = route4Me.GetRoutes(routeParameters, out errorString); Console.WriteLine(""); if (dataObjects != null) { Console.WriteLine("SearchRoutesForText executed successfully, {0} routes returned", dataObjects.Length); Console.WriteLine(""); dataObjects.ForEach(dataObject => { Console.WriteLine("RouteID: {0}", dataObject.RouteID); Console.WriteLine(""); }); } else { Console.WriteLine("SearchRoutesForText error {0}", errorString); } }
public void RouteSharing(string routeId, string Email) { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(ActualApiKey); // Example refers to the process of sharing a route by email // Run the query RouteParametersQuery parameters = new RouteParametersQuery() { RouteId = routeId, ResponseFormat = "json" }; string errorString; bool result = route4Me.RouteSharing(parameters, Email, out errorString); Console.WriteLine(""); if (result) { Console.WriteLine("RouteSharing executed successfully"); } else { Console.WriteLine("RouteSharing error {0}", errorString); } }
public void UpdateRouteCustomData(string routeId, int routeDestionationId, Dictionary <string, string> CustomData) { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); // The example refers to the process of updating a route by sending custom data of an address with HTTP PUT method. // Run the query RouteParametersQuery parameters = new RouteParametersQuery() { RouteId = routeId, RouteDestinationId = routeDestionationId }; string errorString; Address result = route4Me.UpdateRouteCustomData(parameters, CustomData, out errorString); Console.WriteLine(""); if (result != null) { Console.WriteLine("UpdateRouteCustomData executed successfully"); Console.WriteLine("Route ID: {0}", result.RouteId); Console.WriteLine("Route Destination ID: {0}", result.RouteDestinationId); } else { Console.WriteLine("UpdateRouteCustomData error {0}", errorString); } }
public void GetRoute(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; DataObjectRoute dataObject = route4Me.GetRoute(routeParameters, out errorString); Console.WriteLine(""); if (dataObject != null) { Console.WriteLine("GetRoute executed successfully"); Console.WriteLine("Route ID: {0}", dataObject.RouteID); Console.WriteLine("State: {0}", dataObject.State); /*foreach (Address a in dataObject.Addresses) * { * Console.WriteLine("addr: {0}, {1}, {2}, {3}, {4}", a.RouteDestinationId, a.Latitude, a.Longitude, a.Alias, a.AddressString); * }*/ } else { Console.WriteLine("GetRoute error: {0}", errorString); } }
/// <summary> /// Get the routes by list of the route IDs. /// </summary> public void GetRoutesByIDs() { var route4Me = new Route4MeManager(ActualApiKey); #region // Retrieve first 3 routes var routesParameters = new RouteParametersQuery() { Offset = 0, Limit = 3 }; DataObjectRoute[] threeRoutes = route4Me.GetRoutes( routesParameters, out string errorString ); #endregion #region // Retrieve 2 route by their IDs var routeParameters = new RouteParametersQuery() { RouteId = threeRoutes[0].RouteID + "," + threeRoutes[1].RouteID }; var twoRoutes = route4Me.GetRoutes(routeParameters, out errorString); #endregion PrintExampleRouteResult(twoRoutes, errorString); }
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 void ReoptimizeRoute(string routeId) { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); RouteParametersQuery routeParameters = new RouteParametersQuery() { RouteId = routeId, ReOptimize = true }; // Run the query string errorString; DataObjectRoute dataObject = route4Me.UpdateRoute(routeParameters, out errorString); Console.WriteLine(""); if (dataObject != null) { Console.WriteLine("ReoptimizeRoute executed successfully"); Console.WriteLine("Route ID: {0}", dataObject.RouteID); Console.WriteLine("State: {0}", dataObject.State); } else { Console.WriteLine("ReoptimizeRoute error: {0}", errorString); } }
/// <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(); } } }
public void GetRoute(string routeId, bool getRouteDirections, bool getRoutePathPoints) { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); RouteParametersQuery routeParameters = new RouteParametersQuery() { RouteId = routeId }; if (getRouteDirections) { routeParameters.Directions = true; } if (getRoutePathPoints) { routeParameters.RoutePathOutput = RoutePathOutput.Points.ToString(); } // Run the query string errorString; DataObjectRoute dataObject = route4Me.GetRoute(routeParameters, out errorString); Console.WriteLine(""); if (dataObject != null) { Console.WriteLine("GetRoute executed successfully"); Console.WriteLine("Route ID: {0}", dataObject.RouteID); Console.WriteLine("State: {0}", dataObject.State); /*foreach (Address a in dataObject.Addresses) * { * Console.WriteLine("addr: {0}, {1}, {2}, {3}, {4}", a.RouteDestinationId, a.Latitude, a.Longitude, a.Alias, a.AddressString); * }*/ if (dataObject.Directions != null) { Console.WriteLine("Directions: lenth = {0}", dataObject.Directions.Length); } if (dataObject.Path != null) { Console.WriteLine("Path: lenth = {0}", dataObject.Path.Length); } } else { Console.WriteLine("GetRoute error: {0}", errorString); } }
/// <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(); }
public void GetPaginatedRouteListWithoutElasticSearchTest() { var route4Me = new Route4MeManagerV5(c_ApiKey); var routeParameters = new RouteParametersQuery() { Page = 1, PerPage = 20 }; DataObjectRoute[] dataObjects = route4Me.GetPaginatedRouteListWithoutElasticSearch(routeParameters, out ResultResponse resultResponse); Assert.IsType <DataObjectRoute[]>(dataObjects); }
public void GetAllRoutesWithPaginationTest() { var route4Me = new Route4MeManagerV5(c_ApiKey); var routeParameters = new RouteParametersQuery() { Page = 1, PerPage = 20 }; DataObjectRoute[] dataObjects = route4Me.GetAllRoutesWithPagination(routeParameters, out ResultResponse resultResponse); Assert.IsType <DataObjectRoute[]>(dataObjects); }
public void GetRouteListWithoutElasticSearchTest() { var route4Me = new Route4MeManagerV5(c_ApiKey); var routeParameters = new RouteParametersQuery() { Offset = 0, Limit = 10 }; DataObjectRoute[] dataObjects = route4Me.GetRouteListWithoutElasticSearch(routeParameters, out ResultResponse resultResponse); Assert.IsType <DataObjectRoute[]>(dataObjects); }
public void GetAllRoutesTest() { var route4Me = new Route4MeManagerV5(c_ApiKey); var routeParameters = new RouteParametersQuery() { Limit = 1, Offset = 15 }; // Run the query DataObjectRoute[] dataObjects = route4Me.GetRoutes(routeParameters, out ResultResponse resultResponse); Assert.IsType <DataObjectRoute[]>(dataObjects); }
/// <summary> /// Assign a vehicle to a route. /// </summary> public void AssignVehicleToRoute() { var route4Me = new Route4MeManager(ActualApiKey); #region Get Random Vehicle var vehicleParameters = new VehicleParameters { WithPagination = true, Page = 1, PerPage = 10 }; // Run the query var vehicles = route4Me.GetVehicles( vehicleParameters, out string errorString ); int randomNumber = (new Random()).Next(0, vehicles.PerPage - 1); var vehicleId = vehicles.Data[randomNumber].VehicleId; #endregion RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; string routeId = SD10Stops_route_id; var routeParameters = new RouteParametersQuery() { RouteId = routeId, Parameters = new RouteParameters() { VehicleId = vehicleId } }; var route = route4Me.UpdateRoute(routeParameters, out errorString); PrintExampleRouteResult(route, errorString); RemoveTestOptimizations(); }
/// <summary> /// Get a route by route ID /// </summary> /// <param name="routeId">Route ID</param> /// <param name="getRouteDirections">If true, the directions included in the response</param> /// <param name="getRoutePathPoints">If true, the path points included in the response</param> public void GetRoute(string routeId = null, bool?getRouteDirections = null, bool?getRoutePathPoints = null) { // Create the manager with the api key var route4Me = new Route4MeManager(ActualApiKey); bool isInnerExample = routeId == null ? true : false; if (isInnerExample) { RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; routeId = SD10Stops_route_id; getRouteDirections = true; getRoutePathPoints = true; } var routeParameters = new RouteParametersQuery() { RouteId = routeId, Directions = getRouteDirections, RoutePathOutput = getRoutePathPoints == true ? RoutePathOutput.Points.ToString() : "" }; // Run the query DataObjectRoute dataObject = route4Me.GetRoute( routeParameters, out string errorString ); PrintExampleRouteResult(dataObject, errorString); if (isInnerExample) { RemoveTestOptimizations(); } }
/// <summary> /// Get limited number of the routes. /// </summary> public void GetRoutes() { // Create the manager with the api key var route4Me = new Route4MeManager(ActualApiKey); var routeParameters = new RouteParametersQuery() { Limit = 10, Offset = 5 }; // Run the query DataObjectRoute[] dataObjects = route4Me.GetRoutes( routeParameters, out string errorString ); PrintExampleRouteResult(dataObjects, errorString); }
/// <summary> /// Update route avoidance zones. /// </summary> public void UpdateRouteAvoidanceZones() { var route4Me = new Route4MeManager(ActualApiKey); RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; #region Get Avoidance Zones CreateAvoidanceZone(); AvoidanceZonesToRemove = new List <string>() { avoidanceZone.TerritoryId }; CreateAvoidanceZone(); AvoidanceZonesToRemove.Add(avoidanceZone.TerritoryId); #endregion var parameters = new RouteParametersQuery() { RouteId = SD10Stops_route_id, Parameters = new RouteParameters() { AvoidanceZones = new string[] { AvoidanceZonesToRemove[0], AvoidanceZonesToRemove[1] } } }; var result = route4Me.UpdateRoute(parameters, out string errorString); PrintExampleRouteResult(result, errorString); RemoveTestOptimizations(); RemoveAvoidanceZones(); }
/// <summary> /// The example refers to the process of updating a route /// by sending custom data of an address with HTTP PUT method. /// </summary> /// <param name="routeId">Route ID</param> /// <param name="routeDestionationId">Route destination ID</param> /// <param name="CustomData">Custom data</param> public void UpdateRouteCustomData(string routeId = null, int?routeDestionationId = null, Dictionary <string, string> CustomData = null) { // Create the manager with the api key var route4Me = new Route4MeManager(ActualApiKey); bool isInnerExample = routeId == null ? true : false; if (isInnerExample) { RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; routeId = SD10Stops_route_id; routeDestionationId = SD10Stops_route.Addresses[1].RouteDestinationId; } // Run the query var parameters = new RouteParametersQuery() { RouteId = routeId, RouteDestinationId = routeDestionationId }; Address result = route4Me.UpdateRouteCustomData( parameters, CustomData, out string errorString ); PrintExampleDestination(result, errorString); if (isInnerExample) { RemoveTestOptimizations(); } }
/// <summary> /// Gets the routes from specified date range. /// </summary> public void GetRoutesFromDateRange() { var route4Me = new Route4MeManager(ActualApiKey); TimeSpan t10days = new TimeSpan(10, 0, 0, 0); DateTime dtNow = DateTime.Now; var routeParameters = new RouteParametersQuery() { StartDate = (dtNow - t10days).ToString("yyyy-MM-dd"), EndDate = dtNow.ToString("yyyy-MM-dd") }; // Run the query DataObjectRoute[] dataObjects = route4Me.GetRoutes( routeParameters, out string errorString ); PrintExampleRouteResult(dataObjects, errorString); }
public void UpdateRoute(string routeId = null) { // Create the manager with the api key var route4Me = new Route4MeManager(ActualApiKey); bool isInnerExample = routeId == null ? true : false; if (isInnerExample) { RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; routeId = SD10Stops_route_id; } var parametersNew = new RouteParameters() { RouteName = "New name of the route" }; var routeParameters = new RouteParametersQuery() { RouteId = routeId, Parameters = parametersNew }; // Run the query DataObjectRoute dataObject = route4Me.UpdateRoute( routeParameters, out string errorString ); PrintExampleRouteResult(dataObject, errorString); RemoveTestOptimizations(); }
/// <summary> /// Assign a team member to a route. /// </summary> public void AssignMemberToRoute() { var route4Me = new Route4MeManager(ActualApiKey); var members = route4Me.GetUsers( new GenericParameters(), out string errorString ); int randomNumber = (new Random()).Next(0, members.results.Length - 1); var memberId = members.results[randomNumber].member_id != null ? Convert.ToInt32(members.results[randomNumber].member_id) : -1; RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; string routeId = SD10Stops_route_id; var routeParameters = new RouteParametersQuery() { RouteId = routeId, Parameters = new RouteParameters() { MemberId = memberId } }; var updatedRoute = route4Me.UpdateRoute(routeParameters, out errorString); PrintExampleRouteResult(updatedRoute, errorString); RemoveTestOptimizations(); }
public void ReoptimizeRoute(string routeId = null) { // Create the manager with the api key var route4Me = new Route4MeManager(ActualApiKey); bool isInnerExample = routeId == null ? true : false; if (isInnerExample) { RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new System.Collections.Generic.List <string>() { SD10Stops_optimization_problem_id }; routeId = SD10Stops_route_id; } var routeParameters = new RouteParametersQuery() { RouteId = routeId, ReOptimize = true }; // Run the query DataObjectRoute dataObject = route4Me.UpdateRoute( routeParameters, out string errorString ); PrintExampleRouteResult(dataObject, errorString); if (isInnerExample) { RemoveTestOptimizations(); } }
/// <summary> /// Resequence route destinations. /// </summary> public void ResequenceRouteDestinations() { var route4Me = new Route4MeManager(ActualApiKey); RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_optimization_problem_id }; var route = SD10Stops_route; var rParams = new RouteParametersQuery() { RouteId = route.RouteID }; var lsAddresses = new List <Address>(); var address1 = route.Addresses[2]; var address2 = route.Addresses[3]; address1.SequenceNo = 4; address2.SequenceNo = 3; lsAddresses.Add(address1); lsAddresses.Add(address2); var route1 = route4Me.ManuallyResequenceRoute( rParams, lsAddresses.ToArray(), out string errorString ); PrintExampleRouteResult(route1, errorString); RemoveTestOptimizations(); }
/// <summary> /// Share a route by email. /// </summary> public void ShareRoute() { var route4Me = new Route4MeManager(ActualApiKey); RunOptimizationSingleDriverRoute10Stops(); OptimizationsToRemove = new List <string>() { SD10Stops_route_id }; string routeId = SD10Stops_route_id; var routeParameters = new RouteParametersQuery() { RouteId = routeId, ResponseFormat = "json" }; string email = "*****@*****.**"; // Run the query var result = route4Me.RouteSharing( routeParameters, email, out string errorString ); Console.WriteLine( result ? String.Format("The route {0} shared successfully", routeId) : String.Format("Cannot share the route." + Environment.NewLine + errorString) ); RemoveTestOptimizations(); }