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); } }
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 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 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); } }
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(c_ApiKey); // 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 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 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> /// Add Orders to a Route /// </summary> /// <returns> Route object </returns> public void AddOrdersToRoute() { // Create the manager with the api key Route4MeManager route4Me = new Route4MeManager(c_ApiKey); RouteParametersQuery rQueryParams = new RouteParametersQuery() { RouteId = "F0C842829D8799067F9BF7A495076335", Redirect = false }; Address[] addresses = new Address[] { new Address { AddressString = "273 Canal St, New York, NY 10013, USA", Latitude = 40.7191558, Longitude = -74.0011966, Alias = "", CurbsideLatitude = 40.7191558, CurbsideLongitude = -74.0011966 }, new Address { AddressString = "106 Liberty St, New York, NY 10006, USA", Alias = "BK Restaurant #: 2446", Latitude = 40.709637, Longitude = -74.011912, CurbsideLatitude = 40.709637, CurbsideLongitude = -74.011912, Email = "", Phone = "(917) 338-1887", FirstName = "", LastName = "", CustomFields = new Dictionary<string, string> { { "icon", null } }, Time = 0, OrderId = 7205705 }, new Address { AddressString = "106 Fulton St, Farmingdale, NY 11735, USA", Alias = "BK Restaurant #: 17871", Latitude = 40.73073, Longitude = -73.459283, CurbsideLatitude = 40.73073, CurbsideLongitude = -73.459283, Email = "", Phone = "(212) 566-5132", FirstName = "", LastName = "", CustomFields = new Dictionary<string, string> { { "icon", null } }, Time = 0, OrderId = 7205703 } }; RouteParameters rParams = new RouteParameters() { RouteName = "Wednesday 15th of June 2016 07:01 PM (+03:00)", RouteDate = 1465948800, RouteTime = 14400, Optimize = "Time", RouteType = "single", AlgorithmType = AlgorithmType.TSP, RT = false, LockLast = false, MemberId = "1", VehicleId = "", DisableOptimization = false }; string errorString; RouteResponse result = route4Me.AddOrdersToRoute(rQueryParams, addresses, rParams, out errorString); Console.WriteLine(""); if (result != null) { Console.WriteLine("AddOrdersToRoute executed successfully"); Console.WriteLine("Route ID: {0}", result.RouteID); } else { Console.WriteLine("AddOrdersToRoute error: {0}", errorString); } }