public static void TestRun() { Route4MeExamples examples = new Route4MeExamples(); // Note run an example by uncommenting code lines between appropriate //=======.... lines // ======== Update Configuration Key =================================== // examples.UpdateConfigurationKey(); // ============================================================== // ======== Remove Configuration Key =================================== // examples.RemoveConfigurationKey(); // ============================================================== // ======== Get Specific Configuration Key Data ================= // examples.GetSpecificConfigurationKeyData(); // ============================================================== // ======== Get All Configuration Data ========================= // examples.GetAllConfigurationData(); // ============================================================== // ======== Create New Configuration Key ======================= // examples.AddNewConfigurationKey(); // ============================================================== // ======== Update Territory =================================== // examples.UpdateTerritory(); // ============================================================== // ======== Remove Territory =================================== // examples.RemoveTerritory(); // ============================================================= // ======== Get Territory =================================== // examples.GetTerritory(); // ====================================================================== // ======== Get Territories =================================== // examples.GetTerritories(); // ====================================================================== // ======== Create a Territory with Rectangular Shape =================== // examples.CreateRectTerritory(); // ====================================================================== // ======== Create a Territory with Polygon Shape =========================== // examples.CreatePolygonTerritory(); // ====================================================================== // ======== Create a Territory with Circular Shape =========================== // examples.CreateTerritory(); // ====================================================================== // ======== Add Rectangular Avoidance Zone =========================== // examples.AddRectAvoidanceZone(); // ====================================================================== // ======== Add Polygon Avoidance Zone =========================== // examples.AddPolygonAvoidanceZone(); // ====================================================================== // ======== Search Routed Locations =========================== // examples.SearchRoutedLocations(); // ====================================================================== // ======== Search Locations By IDs =========================== // examples.SearchLocationsByIDs(); // ====================================================================== // ======== Get Addressbook Specified Fields Filtered by Text in Any Field =========================== // examples.GetSpecifiedFieldsSearchText(); // ====================================================================== // ======== Get Addressbook Locations By Text In Any Field =========================== // examples.GetAddressbookLocation(); // ====================================================================== // ======== Get Team Activities on a Route =========================== // examples.GetRouteTeamActivities(); // ====================================================================== // ======== Search Area Added Activiities =========================== // examples.SearchAreaAdded(); // ====================================================================== // ======== Get Vehicles =========================== // examples.GetVehicles(); // ====================================================================== // ======== Validate Session =========================== // examples.ValidateSession(); // ====================================================================== // ======== User Registratin =========================== //examples.UserRegistration(); // ====================================================================== // ======== User Authentication =========================== //examples.UserAuthentication(); // ====================================================================== // ======== Update an User =========================== //examples.UpdateUser(); // ====================================================================== // ======== Get USer By ID =========================== //examples.GetUserById(); // ====================================================================== // ======== Delete an User =========================== //examples.DeleteUser(); // ====================================================================== // ======== Create an User =========================== //examples.CreateUser(); // ====================================================================== // ======== Get Device History from Time Range ============ //examples.GetDeviceHistoryTimeRange("814FB49CEA8188D134E9D4D4B8B0DAF7"); // ====================================================================== // ======== Find Asset (Asset Tracking) =========================== examples.FindAsset(); // ====================================================================== // ======== Rapid Stret Service Limited =========================== //examples.RapidStreetServiceLimited(); // ===================================================================== // ======== Rapid Stret Service All =========================== //examples.RapidStreetServiceAll(); // ====================================================================== // ======== Rapid Stret Zipcode Limited =========================== //examples.RapidStreetZipcodeLimited(); // ====================================================================== // ======== Rapid Stret Zipcode All =========================== //examples.RapidStreetZipcodeAll(); // ====================================================================== // ======== Rapid Stret Data Single =========================== //examples.RapidStreetDataSingle(); // ====================================================================== // ======== Rapid Stret Data Limited =========================== //examples.RapidStreetDataLimited(); // ====================================================================== // ======== Rapid Stret Data All =========================== //examples.RapidStreetDataAll(); //====================================================================== // ======== Reverse Geocoding =========================== //xexamples.ReverseGeocoding(); //======================================================= // ======== Forward Geocoding =========================== //GeocodingParameters geoParams = new GeocodingParameters //{ // Addresses = "Los20%Angeles20%International20%Airport,20%CA", // Format = "xml" //}; //examples.GeocodingForward(geoParams); //====================================================================== // ======== Mark Address As Marked As Departed =========================== //AddressParameters aParams = new AddressParameters //{ // RouteId = "241466F15515D67D3F951E2DA38DE76D", // RouteDestinationId = 167899269, // IsDeparted = true //}; //examples.MarkAddressAsMarkedAsDeparted(aParams); //====================================================================== // ======== Mark Address As Marked As Visited =========================== //AddressParameters aParams = new AddressParameters //{ // RouteId = "241466F15515D67D3F951E2DA38DE76D", // RouteDestinationId = 167899269, // IsVisited = true //}; //examples.MarkAddressAsMarkedAsVisited(aParams); //====================================================================== // ======== Mark Address As Departed =========================== //AddressParameters aParams = new AddressParameters //{ // RouteId = "DD376C7148E7FEE36CFABE2BD9978BDD", // AddressId = 183045808, // IsDeparted = true //}; //examples.MarkAddressDeparted(aParams); //====================================================================== // ======== Mark Address As Visited =========================== //AddressParameters aParams = new AddressParameters //{ // RouteId = "DD376C7148E7FEE36CFABE2BD9978BDD", // AddressId = 183045808, // IsVisited = true //}; //examples.MarkAddressVisited(aParams); //====================================================================== //======== Get the Orders by containing specified text in any field ======= //string query = "Luzerne"; //examples.GetOrdersBySpecifiedText(query); //====================================================================== //======== Show the Orders using values of the specified fields ======= //string CustomFields = "order_id,member_id"; //examples.GetOrdersByCustomFields(CustomFields); //====================================================================== //======== Get the Orders by Scheduled Date =========================== //string scheduledDate = "2016-12-20"; //examples.GetOrderByScheduledDate(scheduledDate); //====================================================================== //======== Get the Orders by Inserted Date =========================== //string InsertedDate = "2016-12-18"; //examples.GetOrderByInsertedDate(InsertedDate); //====================================================================== //======== Get an Order Details by order_id =========================== //string OrderIds = "437,438,439"; //examples.GetOrderByID(OrderIds); //====================================================================== //======== Add Orders To a Route =========================== //examples.AddOrdersToOptimization(); //====================================================================== //======== Add Orders To a Route =========================== //examples.AddOrdersToRoute(); //====================================================================== //======== Search Routes For Text ============ //examples.SearchRoutesForText("Tbilisi"); //=================================================================== //======== Update Route Custom Data ============ //string RouteId = "CA902292134DBC134EAF8363426BD247"; //int RouteDestinationId = 174405640; //Dictionary<string, string> CustomData = new Dictionary<string, string>(); //CustomData.Add("animal", "tiger"); //CustomData.Add("bird", "canary"); //examples.UpdateRouteCustomData(RouteId, RouteDestinationId, CustomData); //=================================================================== //======== Route Sharing ============ //examples.RouteSharing("56E8F6BF949670F0C0BBAC00590FD116", "*****@*****.**"); //=================================================================== //======== Routes Merging ============ //examples.MergeRoutes(new string[2] { "56E8F6BF949670F0C0BBAC00590FD116", "A6DAA07A7D4737723A9C85E7C3BA2351" }); //=================================================================== System.Console.WriteLine(""); System.Console.WriteLine("Press any key"); System.Console.ReadKey(); }
static void Main(string[] args) { Route4MeExamples examples = new Route4MeExamples(); DataObject dataObject = null; DataObject dataObject1 = examples.SingleDriverRoute10Stops(); dataObject = dataObject1; DataObjectRoute routeSingleDriverRoute10Stops = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0] : null; string routeId_SingleDriverRoute10Stops = (routeSingleDriverRoute10Stops != null) ? routeSingleDriverRoute10Stops.RouteID : null; if (routeSingleDriverRoute10Stops != null) examples.ResequenceRouteDestinations(routeSingleDriverRoute10Stops); else System.Console.WriteLine("ResequenceRouteDestinations not called. routeSingleDriverRoute10Stops == null."); if (routeSingleDriverRoute10Stops != null) examples.ResequenceReoptimizeRoute(routeId_SingleDriverRoute10Stops); else System.Console.WriteLine("ResequenceReoptimizeRoute not called. routeSingleDriverRoute10Stops == null."); int[] destinationIds = examples.AddRouteDestinations(routeId_SingleDriverRoute10Stops); if (destinationIds != null && destinationIds.Length > 0) { examples.RemoveRouteDestination(routeId_SingleDriverRoute10Stops, destinationIds[0]); } DataObject dataObject2 = examples.SingleDriverRoundTrip(); dataObject = dataObject2; string routeId_SingleDriverRoundTrip = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null; string routeIdToMoveTo = routeId_SingleDriverRoundTrip; int routeDestinationIdToMove = (dataObject1 != null && dataObject1.Routes != null && dataObject1.Routes.Length > 0 && dataObject1.Routes[0].Addresses.Length > 1 && dataObject1.Routes[0].Addresses[1].RouteDestinationId != null) ? dataObject1.Routes[0].Addresses[1].RouteDestinationId.Value : 0; int afterDestinationIdToMoveAfter = (dataObject2 != null && dataObject2.Routes != null && dataObject2.Routes.Length > 0 && dataObject2.Routes[0].Addresses.Length > 1 && dataObject2.Routes[0].Addresses[0].RouteDestinationId != null) ? dataObject2.Routes[0].Addresses[0].RouteDestinationId.Value : 0; if (routeIdToMoveTo != null && routeDestinationIdToMove != 0 && afterDestinationIdToMoveAfter != 0) { examples.MoveDestinationToRoute(routeIdToMoveTo, routeDestinationIdToMove, afterDestinationIdToMoveAfter); } else { System.Console.WriteLine("MoveDestinationToRoute not called. routeDestinationId = {0}, afterDestinationId = {1}.", routeDestinationIdToMove, afterDestinationIdToMoveAfter); } string optimizationProblemID = examples.SingleDriverRoundTripGeneric(); dataObject = examples.MultipleDepotMultipleDriver(); string routeId_MultipleDepotMultipleDriver = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null; dataObject = examples.MultipleDepotMultipleDriverTimeWindow(); string routeId_MultipleDepotMultipleDriverTimeWindow = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null; dataObject = examples.SingleDepotMultipleDriverNoTimeWindow(); string routeId_SingleDepotMultipleDriverNoTimeWindow = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null; dataObject = examples.MultipleDepotMultipleDriverWith24StopsTimeWindow(); string routeId_MultipleDepotMultipleDriverWith24StopsTimeWindow = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null; dataObject = examples.SingleDriverMultipleTimeWindows(); string routeId_SingleDriverMultipleTimeWindows = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null; if (optimizationProblemID != null) examples.GetOptimization(optimizationProblemID); else System.Console.WriteLine("GetOptimization not called. optimizationProblemID == null."); examples.GetOptimizations(); if (optimizationProblemID != null) { dataObject = examples.AddDestinationToOptimization(optimizationProblemID, true); } else { System.Console.WriteLine("AddDestinationToOptimization not called. optimizationProblemID == null."); dataObject = null; } if (optimizationProblemID != null) { Address destinationToRemove = (dataObject != null && dataObject.Addresses.Length > 0) ? dataObject.Addresses[dataObject.Addresses.Length - 1] : null; if (destinationToRemove != null) examples.RemoveDestinationFromOptimization(optimizationProblemID, destinationToRemove.RouteDestinationId.Value, false); else System.Console.WriteLine("RemoveDestinationFromOptimization not called. destinationToRemove == null."); } else System.Console.WriteLine("RemoveDestinationFromOptimization not called. optimizationProblemID == null."); if (optimizationProblemID != null) examples.ReOptimization(optimizationProblemID); else System.Console.WriteLine("ReOptimization not called. optimizationProblemID == null."); if (routeId_SingleDriverRoute10Stops != null) { examples.UpdateRoute(routeId_SingleDriverRoute10Stops); examples.ReoptimizeRoute(routeId_SingleDriverRoute10Stops); bool getRouteDirections = true; bool getRoutePathPoints = true; examples.GetRoute(routeId_SingleDriverRoute10Stops, getRouteDirections, getRoutePathPoints); } else { System.Console.WriteLine("UpdateRoute, ReoptimizeRoute, GetRoute not called. routeId_SingleDriverRoute10Stops == null."); } examples.GetRoutes(); examples.GetUsers(); if (routeId_SingleDriverRoute10Stops != null) examples.LogCustomActivity("Test User Activity " + DateTime.Now.ToString(), routeId_SingleDriverRoute10Stops); else System.Console.WriteLine("LogCustomActivity not called. routeId_SingleDriverRoute10Stops == null."); if (routeId_SingleDriverRoute10Stops != null) examples.GetActivities(routeId_SingleDriverRoute10Stops); else System.Console.WriteLine("GetActivities not called. routeId_SingleDriverRoute10Stops == null."); if (routeIdToMoveTo != null && routeDestinationIdToMove != 0) { examples.GetAddress(routeIdToMoveTo, routeDestinationIdToMove); examples.AddAddressNote(routeIdToMoveTo, routeDestinationIdToMove); examples.AddAddressNoteWithFile(routeIdToMoveTo, routeDestinationIdToMove); examples.GetAddressNotes(routeIdToMoveTo, routeDestinationIdToMove); } else { System.Console.WriteLine("AddAddressNote, GetAddress, GetAddressNotes not called. routeIdToMoveTo == null || routeDestinationIdToMove == 0."); } string routeId_DuplicateRoute = null; if (routeId_SingleDriverRoute10Stops != null) routeId_DuplicateRoute = examples.DuplicateRoute(routeId_SingleDriverRoute10Stops); else System.Console.WriteLine("DuplicateRoute not called. routeId_SingleDriverRoute10Stops == null."); //disabled by default, not necessary for optimization tests //not all accounts are capable of storing gps data /*if (routeId_SingleDriverRoute10Stops != null) { examples.SetGPSPosition(routeId_SingleDriverRoute10Stops); examples.TrackDeviceLastLocationHistory(routeId_SingleDriverRoute10Stops); } else { System.Console.WriteLine("SetGPSPosition, TrackDeviceLastLocationHistory not called. routeId_SingleDriverRoute10Stops == null."); }*/ List<string> routeIdsToDelete = new List<string>(); if (routeId_SingleDriverRoute10Stops != null) routeIdsToDelete.Add(routeId_SingleDriverRoute10Stops); if (routeId_SingleDriverRoundTrip != null) routeIdsToDelete.Add(routeId_SingleDriverRoundTrip); if (routeId_DuplicateRoute != null) routeIdsToDelete.Add(routeId_DuplicateRoute); if (routeId_MultipleDepotMultipleDriver != null) routeIdsToDelete.Add(routeId_MultipleDepotMultipleDriver); if (routeId_MultipleDepotMultipleDriverTimeWindow != null) routeIdsToDelete.Add(routeId_MultipleDepotMultipleDriverTimeWindow); if (routeId_SingleDepotMultipleDriverNoTimeWindow != null) routeIdsToDelete.Add(routeId_SingleDepotMultipleDriverNoTimeWindow); if (routeId_MultipleDepotMultipleDriverWith24StopsTimeWindow != null) routeIdsToDelete.Add(routeId_MultipleDepotMultipleDriverWith24StopsTimeWindow); if (routeId_SingleDriverMultipleTimeWindows != null) routeIdsToDelete.Add(routeId_SingleDriverMultipleTimeWindows); if (routeIdsToDelete.Count > 0) examples.DeleteRoutes(routeIdsToDelete.ToArray()); else System.Console.WriteLine("routeIdsToDelete.Count == 0. DeleteRoutes not called."); // Remove optimization if (optimizationProblemID != null) examples.RemoveOptimization(optimizationProblemID); else System.Console.WriteLine("RemoveOptimization not called. optimizationProblemID == null."); // Address Book AddressBookContact contact1 = examples.AddAddressBookContact(); AddressBookContact contact2 = examples.AddAddressBookContact(); examples.GetAddressBookContacts(); if (contact1 != null) { contact1.LastName = "Updated " + (new Random()).Next().ToString(); examples.UpdateAddressBookContact(contact1); } else { System.Console.WriteLine("contact1 == null. UpdateAddressBookContact not called."); } List<string> addressIdsToRemove = new List<string>(); if (contact1 != null) addressIdsToRemove.Add(contact1.AddressId); if (contact2 != null) addressIdsToRemove.Add(contact2.AddressId); examples.RemoveAddressBookContacts(addressIdsToRemove.ToArray()); // Avoidance Zones string territoryId = examples.AddAvoidanceZone(); examples.GetAvoidanceZones(); if (territoryId != null) examples.GetAvoidanceZone(territoryId); else System.Console.WriteLine("GetAvoidanceZone not called. territoryId == null."); if (territoryId != null) examples.UpdateAvoidanceZone(territoryId); else System.Console.WriteLine("UpdateAvoidanceZone not called. territoryId == null."); if (territoryId != null) examples.DeleteAvoidanceZone(territoryId); else System.Console.WriteLine("DeleteAvoidanceZone not called. territoryId == null."); // Orders Order order1 = examples.AddOrder(); Order order2 = examples.AddOrder(); examples.GetOrders(); if (order1 != null) { order1.LastName = "Updated " + (new Random()).Next().ToString(); examples.UpdateOrder(order1); } else { System.Console.WriteLine("order1 == null. UpdateOrder not called."); } List<string> orderIdsToRemove = new List<string>(); if (order1 != null) orderIdsToRemove.Add(order1.OrderId); if (order2 != null) orderIdsToRemove.Add(order2.OrderId); examples.RemoveOrders(orderIdsToRemove.ToArray()); examples.GenericExample(); examples.GenericExampleShortcut(); System.Console.WriteLine(""); System.Console.WriteLine("Press any key"); System.Console.ReadKey(); }