コード例 #1
0
        /// <summary>
        /// Remove a Configuration Key
        /// </summary>
        public void RemoveConfigurationKey()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            MemberConfigurationParameters @params = new MemberConfigurationParameters { config_key = "My height" };

            // Run the query
            string errorString = "";
            MemberConfigurationResponse result = route4Me.RemoveConfigurationKey(@params, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("RemoveConfigurationKey executed successfully");
                Console.WriteLine("Result: " + result.result);
                Console.WriteLine("Affected: " + result.affected);
                Console.WriteLine("---------------------------");
            }
            else
            {
                Console.WriteLine("UserRegistration error: {0}", errorString);
            }
        }
コード例 #2
0
        /// <summary>
        /// The example refers to the process of query all the activities from the last specified days.
        /// </summary>
        public void GetLastActivities()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            var activitiesAfterTime = DateTime.Now - (new TimeSpan(7, 0, 0, 0));

            activitiesAfterTime = new DateTime(activitiesAfterTime.Year, activitiesAfterTime.Month, activitiesAfterTime.Day, 0, 0, 0);

            uint uiActivitiesAfterTime = (uint)Route4MeSDK.R4MeUtils.ConvertToUnixTimestamp(activitiesAfterTime);

            var activityParameters = new ActivityParameters()
            {
                Limit  = 10,
                Offset = 0,
                Start  = uiActivitiesAfterTime
            };

            // Run the query
            Activity[] activities = route4Me.GetActivities(activityParameters, out string errorString);

            Console.WriteLine("");

            foreach (Activity activity in activities)
            {
                uint activityTime = activity.ActivityTimestamp != null ? (uint)activity.ActivityTimestamp : 0;

                if (activityTime < uiActivitiesAfterTime)
                {
                    Console.WriteLine("GetLastActivities failed - the last time filter not works.");
                    break;
                }
            }

            PrintExampleActivities(activities, errorString);
        }
コード例 #3
0
        /// <summary>
        /// Search for Specified Text, Show Specified Fields
        /// </summary>
        public void GetSpecifiedFieldsSearchText()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            CreateTestContacts();

            var addressBookParameters = new AddressBookParameters
            {
                Query  = "Test FirstName",
                Fields = "address_id,first_name,address_email,address_group,first_name,cached_lat,schedule",
                Offset = 0,
                Limit  = 20
            };

            // Run the query
            var response = route4Me.SearchAddressBookLocation(
                addressBookParameters,
                out List <AddressBookContact> contactsFromObjects,
                out string errorString);

            PrintExampleContact(
                contactsFromObjects.ToArray(),
                (contactsFromObjects != null ? (uint)contactsFromObjects.Count : 0),
                errorString);

            RemoveTestContacts();
        }
コード例 #4
0
        /// <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);
        }
        /// <summary>
        /// Get Activities Destination Marked as Departed
        /// </summary>
        public void SearchDestinationMarkedAsDeparted()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            ActivityParameters activityParameters = new ActivityParameters
            {
                ActivityType = "mark-destination-departed",
                RouteId = "03CEF546324F727239ABA69EFF3766E1"
            };

            // Run the query
            string errorString = "";
            Activity[] activities = route4Me.GetActivityFeed(activityParameters, out errorString);

            Console.WriteLine("");

            if (activities != null)
            {
                Console.WriteLine("SearchDestinationMarkedAsDeparted executed successfully, {0} activities returned", activities.Length);
                Console.WriteLine("");

                foreach (Activity Activity in activities)
                {
                    Console.WriteLine("Activity ID: {0}", Activity.ActivityId);
                }

                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("SearchDestinationMarkedAsDeparted error: {0}", errorString);
            }
        }
コード例 #6
0
        /// <summary>
        /// Get Team Activities on a Route
        /// </summary>
        public void GetRouteTeamActivities()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            RunOptimizationSingleDriverRoute10Stops();

            string routeId = SD10Stops_route_id;

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

            var activityParameters = new ActivityParameters()
            {
                RouteId = routeId,
                Team    = "true",
                Limit   = 10,
                Offset  = 0
            };

            // Run the query
            Activity[] activities = route4Me.GetActivities(activityParameters, out string errorString);

            PrintExampleActivities(activities, errorString);

            RemoveTestOptimizations();
        }
コード例 #7
0
        /// <summary>
        /// Get Orders by Scheduled Date
        /// </summary>
        public void GetOrdersByScheduledDate(string ScheduleddDate = null)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            bool isInnerExample = ScheduleddDate == null ? true : false;

            if (isInnerExample)
            {
                CreateExampleOrder();
                ScheduleddDate = DateTime.Now.ToString("yyyy-MM-dd");
            }

            var oParams = new OrderParameters {
                ScheduledForYYMMDD = ScheduleddDate
            };

            var result = route4Me.SearchOrders(oParams, out string errorString);

            PrintExampleOrder(result, errorString);

            if (isInnerExample && result != null && result.GetType() == typeof(GetOrdersResponse))
            {
                OrdersToRemove = new List <string>();

                foreach (Order ord in ((GetOrdersResponse)result).Results)
                {
                    OrdersToRemove.Add(ord.order_id.ToString());
                }

                RemoveTestOrders();
            }
        }
コード例 #8
0
        /// <summary>
        /// Get User By ID
        /// </summary>
        public void GetUserById()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            MemberParametersV4 @params = new MemberParametersV4 { member_id = 45844 };

            // Run the query
            string errorString = "";
            MemberResponseV4 result = route4Me.GetUserById(@params, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("GetUserById executed successfully");
                Console.WriteLine("User: "******" " + result.member_last_name);
                Console.WriteLine("member_id: " + result.member_id);
                Console.WriteLine("---------------------------");
            }
            else
            {
                Console.WriteLine("GetUserById error: {0}", errorString);
            }
        }
コード例 #9
0
        /// <summary>
        /// Get Territory
        /// </summary>
        public void GetTerritory()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            string territoryId = "596A2A44FE9FB19EEB9C3C072BF2D0BE";

            TerritoryQuery territoryQuery1 = new TerritoryQuery
            {
                TerritoryId = territoryId,
                addresses = 1
            };

            // Run the query
            string errorString = "";
            TerritoryZone territory = route4Me.GetTerritory(territoryQuery1, out errorString);

            Console.WriteLine("");

            if (territory != null)
            {
                Console.WriteLine("GetTerritory executed successfully");

                Console.WriteLine("Territory ID: {0}", territory.TerritoryId);
            }
            else
            {
                Console.WriteLine("GetTerritory error: {0}", errorString);
            }
        }
コード例 #10
0
        /// <summary>
        /// Add Order
        /// </summary>
        /// <returns> Added Order </returns>
        public Order AddOrder()
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              Order order = new Order()
              {
            Address1 = "Test Address1 " + (new Random()).Next().ToString(),
            AddressAlias = "Test AddressAlias " + (new Random()).Next().ToString(),
            CachedLatitude = 37.773972,
            CachedLongitude = -122.431297
              };

              // Run the query
              string errorString;
              Order resultOrder = route4Me.AddOrder(order, out errorString);

              Console.WriteLine("");

              if (resultOrder != null)
              {
            Console.WriteLine("AddOrder executed successfully");

            Console.WriteLine("Order ID: {0}", resultOrder.OrderId);

            return resultOrder;
              }
              else
              {
            Console.WriteLine("AddOrder error: {0}", errorString);

            return null;
              }
        }
コード例 #11
0
        /// <summary>
        /// Create Territory with Rectangular Shape
        /// </summary>
        public void CreateRectTerritory()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AvoidanceZoneParameters territoryParameters = new AvoidanceZoneParameters
            {
                TerritoryName = "Test Territory",
                TerritoryColor = "ff0000",
                Territory = new Territory
                {
                    Type = TerritoryType.Rect.Description(),
                    Data = new string[] {
                        "43.51668853502909,-109.3798828125",
                        "46.98025235521883,-101.865234375"
                    }
                }
            };

            // Run the query
            string errorString = "";
            AvoidanceZone territory = route4Me.CreateTerritory(territoryParameters, out errorString);

            Console.WriteLine("");

            if (territory != null)
            {
                Console.WriteLine("CreateRectTerritory executed successfully");
                Console.WriteLine("Territory ID: {0}", territory.TerritoryId);
            }
            else
            {
                Console.WriteLine("CreateRectTerritory error: {0}", errorString);
            }
        }
コード例 #12
0
        /// <summary>
        /// GEt Vehicles List
        /// </summary>
        public void GetVehicles()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            VehicleParameters vehicleParameters = new VehicleParameters
            {
                Limit = 10,
                Offset = 0
            };

            // Run the query
            string errorString = "";
            VehicleResponse[] vehicles = route4Me.GetVehicles(vehicleParameters, out errorString);

            Console.WriteLine("");

            if (vehicles != null)
            {
                Console.WriteLine("GetVehicles executed successfully, {0} vehicles returned", vehicles.Length);
                Console.WriteLine("");

                foreach (VehicleResponse vehicle in vehicles)
                {
                    Console.WriteLine("Vehicle ID: {0}", vehicle.VehicleId);
                }

                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("GetVehicles error: {0}", errorString);
            }
        }
コード例 #13
0
        public AddressBookContact AddAddressBookContact()
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              AddressBookContact contact = new AddressBookContact()
              {
            FirstName = "Test FirstName " + (new Random()).Next().ToString(),
            Address1 = "Test Address1 " + (new Random()).Next().ToString(),
            CachedLat = 38.024654,
            CachedLng = -77.338814
              };

              // Run the query
              string errorString;
              AddressBookContact resultContact = route4Me.AddAddressBookContact(contact, out errorString);

              Console.WriteLine("");

              if (resultContact != null)
              {
            Console.WriteLine("AddAddressBookContact executed successfully");

            Console.WriteLine("AddressId: {0}", resultContact.AddressId);

            return resultContact;
              }
              else
              {
            Console.WriteLine("AddAddressBookContact error: {0}", errorString);

            return null;
              }
        }
コード例 #14
0
        /// <summary>
        /// Rapid Street Data Single
        /// </summary>
        public void RapidStreetDataSingle()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            GeocodingParameters geoParams = new GeocodingParameters()
            {
                Pk =4
            };
            // Run the query
            string errorString = "";
            ArrayList result = route4Me.RapidStreetData(geoParams, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("RapidStreetDataSingle executed successfully");
                foreach (Dictionary<string, string> res1 in result)
                {

                    Console.WriteLine("Zipcode: " + res1["zipcode"]);
                    Console.WriteLine("Street name: " + res1["street_name"]);
                    Console.WriteLine("---------------------------");
                }
            }
            else
            {
                Console.WriteLine("RapidStreetDataSingle error: {0}", errorString);
            }
        }
コード例 #15
0
        /// <summary>
        /// Create Territory with Rectangular Shape
        /// </summary>
        public void CreateRectTerritory()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            var territoryParameters = new AvoidanceZoneParameters
            {
                TerritoryName  = "Test Territory",
                TerritoryColor = "ff0000",
                Territory      = new Territory
                {
                    Type = TerritoryType.Rect.Description(),
                    Data = new string[] {
                        "43.51668853502909,-109.3798828125",
                        "46.98025235521883,-101.865234375"
                    }
                }
            };

            // Run the query
            TerritoryZone territory = route4Me.CreateTerritory(territoryParameters,
                                                               out string errorString);

            if ((territory?.TerritoryId ?? null) != null)
            {
                TerritoryZonesToRemove.Add(territory.TerritoryId);
            }

            PrintExampleTerritory(territory, errorString);

            RemoveTestTerritoryZones();
        }
コード例 #16
0
        public void SetGPSPosition(string routeId)
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              // Create the gps parametes
              GPSParameters gpsParameters = new GPSParameters()
              {
            Format = Format.Csv.Description(),
            RouteId = routeId,
            Latitude = 33.14384,
            Longitude = -83.22466,
            Course = 1,
            Speed = 120,
            DeviceType = DeviceType.IPhone.Description(),
            MemberId = 1,
            DeviceGuid = "TEST_GPS",
            DeviceTimestamp = "2014-06-14 17:43:35"
              };

              string errorString;
              string response = route4Me.SetGPS(gpsParameters, out errorString);

              Console.WriteLine("");

              if (string.IsNullOrEmpty(errorString))
              {
            Console.WriteLine("SetGps response: {0}", response);
              }
              else
              {
            Console.WriteLine("SetGps error: {0}", errorString);
              }
        }
コード例 #17
0
        /// <summary>
        /// Rapid Street Zipcode All
        /// </summary>
        public void RapidStreetZipcodeAll()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            GeocodingParameters geoParams = new GeocodingParameters()
            {
                Zipcode = "00601"
            };
            // Run the query
            string    errorString = "";
            ArrayList result      = route4Me.RapidStreetZipcode(geoParams, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("RapidStreetZipcodeAll executed successfully");
                foreach (Dictionary <string, string> res1 in result)
                {
                    Console.WriteLine("Zipcode: " + res1["zipcode"]);
                    Console.WriteLine("Street name: " + res1["street_name"]);
                    Console.WriteLine("---------------------------");
                }
            }
            else
            {
                Console.WriteLine("RapidStreetZipcodeAll error: {0}", errorString);
            }
        }
コード例 #18
0
        public void GetOptimization(string optimizationProblemID)
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              OptimizationParameters optimizationParameters = new OptimizationParameters()
              {
            OptimizationProblemID = optimizationProblemID
              };

              // Run the query
              string errorString;
              DataObject dataObject = route4Me.GetOptimization(optimizationParameters, out errorString);

              Console.WriteLine("");

              if (dataObject != null)
              {
            Console.WriteLine("GetOptimization executed successfully");

            Console.WriteLine("Optimization Problem ID: {0}", dataObject.OptimizationProblemId);
            Console.WriteLine("State: {0}", dataObject.State);
              }
              else
              {
            Console.WriteLine("GetOptimization error: {0}", errorString);
              }
        }
コード例 #19
0
        public void GetAddress(string routeId, int routeDestinationId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AddressParameters addressParameters = new AddressParameters()
            {
                RouteId            = routeId,
                RouteDestinationId = routeDestinationId,
                Notes = true
            };

            // Run the query
            string  errorString;
            Address dataObject = route4Me.GetAddress(addressParameters, out errorString);

            Console.WriteLine("");

            if (dataObject != null)
            {
                Console.WriteLine("GetAddress executed successfully");
                Console.WriteLine("RouteId: {0}; RouteDestinationId: {1}", dataObject.RouteId, dataObject.RouteDestinationId);
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("GetAddress error: {0}", errorString);
                Console.WriteLine("");
            }
        }
コード例 #20
0
        public void ResequenceReoptimizeRoute(string routeId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            Dictionary<string, string> roParameters = new Dictionary<string, string>()
            {
                {"route_id","CA902292134DBC134EAF8363426BD247"},
                {"disable_optimization","0"},
                {"optimize","Distance"},
            };

            // Run the query
            string errorString;
            bool result = route4Me.ResequenceReoptimizeRoute(roParameters, out errorString);

            Console.WriteLine("");

            if (result)
            {
                Console.WriteLine("ResequenceReoptimizeRoute executed successfully");
            }
            else
            {
                Console.WriteLine("ResequenceReoptimizeRoute error: {0}", errorString);
            }
        }
コード例 #21
0
        public void GetUsers()
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              GenericParameters parameters = new GenericParameters()
              {
              };

              // Run the query
              string errorString;
              User[] dataObjects = route4Me.GetUsers(parameters, out errorString);

              Console.WriteLine("");

              if (dataObjects != null)
              {
            Console.WriteLine("GetUsers executed successfully, {0} users returned", dataObjects.Length);
            Console.WriteLine("");

            //dataObjects.ForEach(user =>
            //{
            //  Console.WriteLine("User ID: {0}", user.MemberId);
            //});
              }
              else
              {
            Console.WriteLine("GetUsers error: {0}", errorString);
              }
        }
コード例 #22
0
        /// <summary>
        /// Get Orders be containing specified text in any text field
        /// </summary>
        public void GetOrdersBySpecifiedText(string query)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            OrderParameters oParams = new OrderParameters()
            {
                Query  = query,
                Offset = 0,
                Limit  = 20
            };

            string errorString = "";

            Order[] orders = route4Me.SearchOrders(oParams, out errorString);

            Console.WriteLine("");

            if (orders != null)
            {
                Console.WriteLine("GetOrdersByCustomFields executed successfully, orders searched total = {0}", orders.Length);
            }
            else
            {
                Console.WriteLine("GetOrdersByCustomFields error: {0}", errorString);
            }
        }
コード例 #23
0
        /// <summary>
        /// Get Specific Configuration Key Value (v4)
        /// </summary>
        public void GetSpecificConfigurationKeyData()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            MemberConfigurationParameters @params = new MemberConfigurationParameters { config_key = "destination_icon_uri" };

            // Run the query
            string errorString = "";
            MemberConfigurationDataRersponse result = route4Me.GetConfigurationData(@params, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("GetSpecificConfigurationKeyData executed successfully");
                Console.WriteLine("Result: " + result.result);
                foreach (MemberConfigurationData mc_data in result.data)
                {
                    Console.WriteLine("member_id= " + mc_data.member_id);
                    Console.WriteLine("config_key= " + mc_data.config_key);
                    Console.WriteLine("config_value= " + mc_data.config_value);
                    Console.WriteLine("---------------------------");
                }
            }
            else
            {
                Console.WriteLine("GetSpecificConfigurationKeyData error: {0}", errorString);
            }
        }
コード例 #24
0
        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);
            }
        }
コード例 #25
0
        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);
              }
        }
コード例 #26
0
        /// <summary>
        /// Rapid Street Service Limited
        /// </summary>
        public void RapidStreetServiceLimited()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            GeocodingParameters geoParams = new GeocodingParameters()
            {
                Zipcode = "00601",
                Housenumber = "17",
                Offset = 1,
                Limit = 10
            };
            // Run the query
            string errorString = "";
            ArrayList result = route4Me.RapidStreetService(geoParams, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("RapidStreetServiceLimited executed successfully");
                foreach (Dictionary<string, string> res1 in result)
                {

                    Console.WriteLine("Zipcode: " + res1["zipcode"]);
                    Console.WriteLine("Street name: " + res1["street_name"]);
                    Console.WriteLine("---------------------------");
                }
            }
            else
            {
                Console.WriteLine("RapidStreetServiceLimited error: {0}", errorString);
            }
        }
コード例 #27
0
        /// <summary>
        /// Get Order details by order_id
        /// </summary>
        public void GetOrderByID(string orderIds)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            OrderParameters orderParameters = new OrderParameters()
            {
                order_id = orderIds
            };

            string errorString;

            Order[] orders = route4Me.GetOrderByID(orderParameters, out errorString);

            Console.WriteLine("");

            if (orders != null)
            {
                Console.WriteLine("GetOrderByID executed successfully, orders total = {0}", orders.Length);
            }
            else
            {
                Console.WriteLine("GetOrderByID error: {0}", errorString);
            }
        }
コード例 #28
0
        /// <summary>
        /// Update a Configuration Key Value
        /// </summary>
        public void UpdateConfigurationKey()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            MemberConfigurationParameters @params = new MemberConfigurationParameters
            {
                config_key   = "destination_icon_uri",
                config_value = "444"
            };

            // Run the query
            string errorString = "";
            MemberConfigurationResponse result = route4Me.UpdateConfigurationKey(@params, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("UpdateConfigurationKey executed successfully");
                Console.WriteLine("Result: " + result.result);
                Console.WriteLine("Affected: " + result.affected);
                Console.WriteLine("---------------------------");
            }
            else
            {
                Console.WriteLine("UpdateConfigurationKey error: {0}", errorString);
            }
        }
コード例 #29
0
        /// <summary>
        /// Mark Address as Marked as Visited
        /// </summary>
        /// <returns> status </returns>
        public void MarkAddressAsMarkedAsVisited(AddressParameters aParams)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            // Run the query

            string errorString = "";
            Address resultAddress = route4Me.MarkAddressAsMarkedAsVisited(aParams, out errorString);

            Console.WriteLine("");

            if (resultAddress != null)
            {
                Console.WriteLine("MarkAddressAsMarkedAsVisited executed successfully");

                Console.WriteLine("Marked Address ID: {0}", resultAddress.RouteDestinationId);

            }
            else
            {
                Console.WriteLine("MarkAddressAsMarkedAsVisited error: {0}", errorString);

            }
        }
コード例 #30
0
        public void ReOptimization(string optimizationProblemID)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            OptimizationParameters optimizationParameters = new OptimizationParameters()
            {
                OptimizationProblemID = optimizationProblemID,
                ReOptimize            = true
            };

            // Run the query
            string     errorString;
            DataObject dataObject = route4Me.UpdateOptimization(optimizationParameters, out errorString);

            Console.WriteLine("");

            if (dataObject != null)
            {
                Console.WriteLine("ReOptimization executed successfully");

                Console.WriteLine("Optimization Problem ID: {0}", dataObject.OptimizationProblemId);
                Console.WriteLine("State: {0}", dataObject.State);
            }
            else
            {
                Console.WriteLine("ReOptimization error: {0}", errorString);
            }
        }
コード例 #31
0
        /// <summary>
        /// Get Avoidance Zone list
        /// </summary>
        public void GetAvoidanceZones()
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              AvoidanceZoneQuery avoidanceZoneQuery = new AvoidanceZoneQuery()
              {

              };

              // Run the query
              string errorString;
              AvoidanceZone[] avoidanceZones = route4Me.GetAvoidanceZones(avoidanceZoneQuery, out errorString);

              Console.WriteLine("");

              if (avoidanceZones != null)
              {
            Console.WriteLine("GetAvoidanceZones executed successfully, {0} zones returned", avoidanceZones.Length);
              }
              else
              {
            Console.WriteLine("GetAvoidanceZones error: {0}", errorString);
              }
        }
コード例 #32
0
        /// <summary>
        /// Get Avoidance Zone
        /// </summary>
        /// <param name="territoryId"> Avoidance Zone Id </param>
        public void GetAvoidanceZone(string territoryId)
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              AvoidanceZoneQuery avoidanceZoneQuery = new AvoidanceZoneQuery()
              {
            TerritoryId = territoryId
              };

              // Run the query
              string errorString;
              AvoidanceZone avoidanceZone = route4Me.GetAvoidanceZone(avoidanceZoneQuery, out errorString);

              Console.WriteLine("");

              if (avoidanceZone != null)
              {
            Console.WriteLine("GetAvoidanceZone executed successfully");

            Console.WriteLine("Territory ID: {0}", avoidanceZone.TerritoryId);
              }
              else
              {
            Console.WriteLine("GetAvoidanceZone error: {0}", errorString);
              }
        }
コード例 #33
0
        /// <summary>
        /// Get Activities Search Area Added
        /// </summary>
        public void SearchAreaAdded()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            ActivityParameters activityParameters = new ActivityParameters { ActivityType = "area-added" };

            // Run the query
            string errorString = "";
            Activity[] activities = route4Me.GetActivityFeed(activityParameters, out errorString);

            Console.WriteLine("");

            if (activities != null)
            {
                Console.WriteLine("SearchAreaAdded executed successfully, {0} activities returned", activities.Length);
                Console.WriteLine("");

                foreach (Activity Activity in activities)
                {
                    Console.WriteLine("Activity ID: {0}", Activity.ActivityId);
                }

                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("SearchAreaAdded error: {0}", errorString);
            }
        }
コード例 #34
0
        /// <summary>
        /// Add Order
        /// </summary>
        /// <returns> Added Order </returns>
        public Order AddOrder()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            Order order = new Order()
            {
                address_1     = "Test Address1 " + (new Random()).Next().ToString(),
                address_alias = "Test AddressAlias " + (new Random()).Next().ToString(),
                cached_lat    = 37.773972,
                cached_lng    = -122.431297
            };

            // Run the query
            string errorString;
            Order  resultOrder = route4Me.AddOrder(order, out errorString);

            Console.WriteLine("");

            if (resultOrder != null)
            {
                Console.WriteLine("AddOrder executed successfully");

                Console.WriteLine("Order ID: {0}", resultOrder.order_id);

                return(resultOrder);
            }
            else
            {
                Console.WriteLine("AddOrder error: {0}", errorString);

                return(null);
            }
        }
コード例 #35
0
        /// <summary>
        /// Get Activities Route Owner Changed
        /// </summary>
        public void SearchRouteOwnerChanged()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            ActivityParameters activityParameters = new ActivityParameters
            {
                ActivityType = "route-owner-changed",
                RouteId = "5C15E83A4BE005BCD1537955D28D51D7"
            };

            // Run the query
            string errorString = "";
            Activity[] activities = route4Me.GetActivityFeed(activityParameters, out errorString);

            Console.WriteLine("");

            if (activities != null)
            {
                Console.WriteLine("SearchRouteOwnerChanged executed successfully, {0} activities returned", activities.Length);
                Console.WriteLine("");

                foreach (Activity Activity in activities)
                {
                    Console.WriteLine("Activity ID: {0}", Activity.ActivityId);
                }
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("SearchRouteOwnerChanged error: {0}", errorString);
            }
        }
コード例 #36
0
        /// <summary>
        /// Add custom note to the specified route
        /// </summary>
        public void AddCustomNoteToRoute()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            RunSingleDriverRoundTrip();
            OptimizationsToRemove = new List <string>()
            {
                SDRT_optimization_problem_id
            };

            var noteParameters = new NoteParameters()
            {
                RouteId   = SDRT_route.RouteID,
                AddressId = SDRT_route.Addresses[1].RouteDestinationId != null
                    ? (int)SDRT_route.Addresses[1].RouteDestinationId
                    : 0,
                Format    = "json",
                Latitude  = SDRT_route.Addresses[1].Latitude,
                Longitude = SDRT_route.Addresses[1].Longitude
            };

            var customNotes = new Dictionary <string, string>()
            {
                { "custom_note_type[11]", "slippery" },
                { "custom_note_type[10]", "Backdoor" },
                { "strUpdateType", "dropoff" },
                { "strNoteContents", "test1111" }
            };

            var response = route4Me.addCustomNoteToRoute(noteParameters, customNotes, out string errorString);

            PrintExampleAddressNote(response, errorString);

            RemoveTestOptimizations();
        }
コード例 #37
0
        /// <summary>
        /// Get User By ID
        /// </summary>
        public void GetUserById()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            MemberParametersV4 @params = new MemberParametersV4 {
                member_id = 45844
            };

            // Run the query
            string           errorString = "";
            MemberResponseV4 result      = route4Me.GetUserById(@params, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("GetUserById executed successfully");
                Console.WriteLine("User: "******" " + result.member_last_name);
                Console.WriteLine("member_id: " + result.member_id);
                Console.WriteLine("---------------------------");
            }
            else
            {
                Console.WriteLine("GetUserById error: {0}", errorString);
            }
        }
コード例 #38
0
        /// <summary>
        /// Get the address book contacts by specified address book group.
        /// </summary>
        public void GetAddressBookContactsByGroup()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            CreateAddressBookGroup();

            string groupId = addressBookGroupsToRemove[addressBookGroupsToRemove.Count - 1];

            var addressBookGroupParameters = new AddressBookGroupParameters()
            {
                groupID = groupId,
                Fields  = new string[] { "address_id" }
            };

            // Run the query
            var response = route4Me
                           .GetAddressBookContactsByGroup(
                addressBookGroupParameters,
                out string errorString);

            Console.WriteLine((response?.results?.Length ?? 0) < 1
                ? "Cannot retrieve contacts by group " + groupId + Environment.NewLine + errorString
                : "Retrieved the contacts by group " + groupId + ": " + response.results.Length
                              );

            RemoveAddressBookGroups();
        }
コード例 #39
0
        /// <summary>
        /// Remove Orders
        /// </summary>
        /// <param name="orderIds"> Order Ids </param>
        public void RemoveOrders(string[] orderIds = null)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            bool isInnerExample = orderIds == null ? true : false;

            if (isInnerExample)
            {
                CreateExampleOrder();
            }

            orderIds = orderIds == null
                ? new string[] { lastCreatedOrder.order_id.ToString() }
                : orderIds;

            // Run the query
            bool removed = route4Me.RemoveOrders(orderIds, out string errorString);

            Console.WriteLine("");

            Console.WriteLine(
                removed
                ? String.Format("RemoveOrders executed successfully, {0} orders removed", orderIds.Length)
                : String.Format("RemoveOrders error: {0}", errorString)
                );
        }
コード例 #40
0
        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);
            }
        }
コード例 #41
0
        /// <summary>
        /// Get Address Book Location
        /// </summary>
        public void GetAddressbookLocation()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AddressBookParameters addressBookParameters = new AddressBookParameters
            {
                Query = "david",
                Offset = 0,
                Limit = 20
            };

            // Run the query
            uint total = 0;
            string errorString = "";
            AddressBookContact[] contacts = route4Me.GetAddressBookLocation(addressBookParameters, out total, out errorString);

            Console.WriteLine("");

            if (contacts != null)
            {
                Console.WriteLine("GetAddressbookLocation executed successfully, {0} contacts returned, total = {1}", contacts.Length, total);

                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("GetAddressbookLocation error: {0}", errorString);
            }
        }
コード例 #42
0
        /// <summary>
        /// Get Avoidance Zone list
        /// </summary>
        public void GetAvoidanceZones()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AvoidanceZoneQuery avoidanceZoneQuery = new AvoidanceZoneQuery()
            {
            };

            // Run the query
            string errorString;

            AvoidanceZone[] avoidanceZones = route4Me.GetAvoidanceZones(avoidanceZoneQuery, out errorString);

            Console.WriteLine("");

            if (avoidanceZones != null)
            {
                Console.WriteLine("GetAvoidanceZones executed successfully, {0} zones returned", avoidanceZones.Length);
            }
            else
            {
                Console.WriteLine("GetAvoidanceZones error: {0}", errorString);
            }
        }
コード例 #43
0
        /// <summary>
        /// Get Device History from Time Range
        /// </summary>
        public void GetDeviceHistoryTimeRange(string routeId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            int uStartTime = 0;
            int uEndTime = 0;
            uStartTime = (int)(new DateTime(2016, 10, 20, 0, 0, 0) - (new DateTime(1970, 1, 1, 0, 0, 0))).TotalSeconds;
            uEndTime = (int)(new DateTime(2016, 10, 26, 23, 59, 59) - (new DateTime(1970, 1, 1, 0, 0, 0))).TotalSeconds;

            GPSParameters gpsParameters = new GPSParameters
            {
                Format = "csv",
                RouteId = routeId,
                time_period = "custom",
                start_date = uStartTime,
                end_date = uEndTime
            };

            string errorString = "";
            string response = route4Me.SetGPS(gpsParameters, out errorString);

            if (!string.IsNullOrEmpty(errorString))
            {
                Console.WriteLine("SetGps error: {0}", errorString);
                return;
            }

            Console.WriteLine("SetGps response: {0}", response);

            GenericParameters genericParameters = new GenericParameters();
            genericParameters.ParametersCollection.Add("route_id", routeId);
            genericParameters.ParametersCollection.Add("device_tracking_history", "1");

            var dataObject = route4Me.GetLastLocation(genericParameters, out errorString);

            Console.WriteLine("");

            if (dataObject != null)
            {
                Console.WriteLine("GetDeviceHistoryTimeRange executed successfully");
                Console.WriteLine("");

                Console.WriteLine("Optimization Problem ID: {0}", dataObject.OptimizationProblemId);
                Console.WriteLine("State: {0}", dataObject.State);
                Console.WriteLine("");
                foreach (TrackingHistory th in dataObject.TrackingHistory)
                {
                    Console.WriteLine("Speed: {0}", th.Speed);
                    Console.WriteLine("Longitude: {0}", th.Longitude);
                    Console.WriteLine("Latitude: {0}", th.Latitude);
                    Console.WriteLine("Time Stamp: {0}", th.TimeStampFriendly);
                    Console.WriteLine("");
                }
            }
            else
            {
                Console.WriteLine("GetDeviceHistoryTimeRange error: {0}", errorString);
            }
        }
コード例 #44
0
        /// <summary>
        /// Update Territory
        /// </summary>
        public void UpdateTerritory()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            CreateTerritoryZone();

            string territoryId = TerritoryZonesToRemove[TerritoryZonesToRemove.Count - 1];

            var territoryParameters = new AvoidanceZoneParameters
            {
                TerritoryId    = territoryId,
                TerritoryName  = "Test Territory Updated",
                TerritoryColor = "ff0000",
                Territory      = new Territory
                {
                    Type = TerritoryType.Circle.Description(),
                    Data = new string[] {
                        "37.569752822786455,-77.47833251953125",
                        "6000"
                    }
                }
            };

            // Run the query
            AvoidanceZone territory = route4Me.UpdateTerritory(territoryParameters,
                                                               out string errorString);

            PrintExampleTerritory(territory, errorString);

            RemoveTestTerritoryZones();
        }
コード例 #45
0
        /// <summary>
        /// Mark Address as Visited
        /// </summary>
        /// <returns> status </returns>
        public void MarkAddressVisited(AddressParameters aParams)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            // Run the query

            {
                string errorString = "";
                int result = route4Me.MarkAddressVisited(aParams, out errorString);

                Console.WriteLine("");

                if (result != null)
                {
                    if (result==1)
                    {
                        Console.WriteLine("MarkAddressVisited executed successfully");
                    }
                    else
                    {
                        Console.WriteLine("MarkAddressVisited error: {0}", errorString);
                    }
                }
                else
                {
                    Console.WriteLine("MarkAddressVisited error: {0}", errorString);
                }
            }
        }
コード例 #46
0
        public AddressBookContact AddAddressBookContact()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AddressBookContact contact = new AddressBookContact()
            {
                first_name = "Test FirstName " + (new Random()).Next().ToString(),
                address_1  = "Test Address1 " + (new Random()).Next().ToString(),
                cached_lat = 38.024654,
                cached_lng = -77.338814
            };

            // Run the query
            string             errorString;
            AddressBookContact resultContact = route4Me.AddAddressBookContact(contact, out errorString);

            Console.WriteLine("");

            if (resultContact != null)
            {
                Console.WriteLine("AddAddressBookContact executed successfully");

                Console.WriteLine("AddressId: {0}", resultContact.address_id);

                return(resultContact);
            }
            else
            {
                Console.WriteLine("AddAddressBookContact error: {0}", errorString);

                return(null);
            }
        }
コード例 #47
0
        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);
              }
        }
コード例 #48
0
        /// <summary>
        /// Create New Configuration Key
        /// </summary>
        public void AddNewConfigurationKey()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            MemberConfigurationParameters @params = new MemberConfigurationParameters
            {
                config_key = "destination_icon_uri",
                config_value = "value"
            };

            // Run the query
            string errorString = "";
            MemberConfigurationResponse result = route4Me.CreateNewConfigurationKey(@params, out errorString);

            Console.WriteLine("");

            if (result != null)
            {
                Console.WriteLine("AddNewConfigurationKey executed successfully");
                Console.WriteLine("Result: " + result.result);
                Console.WriteLine("Affected: " + result.affected);
                Console.WriteLine("---------------------------");
            }
            else
            {
                Console.WriteLine("AddNewConfigurationKey error: {0}", errorString);
            }
        }
コード例 #49
0
        /// <summary>
        /// Create User Activity
        /// </summary>
        /// <param name="message"> Activity message </param>
        /// <param name="routeId"> Route identifier </param>
        /// <returns> True/False </returns>
        public bool LogCustomActivity(string message, string routeId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            Activity activity = new Activity()
            {
                ActivityType    = "user_message",
                ActivityMessage = message,
                RouteId         = routeId
            };

            // Run the query
            string errorString;
            bool   added = route4Me.LogCustomActivity(activity, out errorString);

            Console.WriteLine("");

            if (added)
            {
                Console.WriteLine("LogCustomActivity executed successfully");
                return(added);
            }
            else
            {
                Console.WriteLine("LogCustomActivity error: {0}", errorString);
                return(added);
            }
        }
コード例 #50
0
        /// <summary>
        /// Resequence the route destinations.
        /// </summary>
        /// <param name="route">A route object</param>
        public void ResequenceRouteDestinations(DataObjectRoute route = null)
        {
            bool isInnerExample = route == null ? true : false;

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

                route = SD10Stops_route;
            }

            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            // Switch 2 addresses after departure address:

            AddressesOrderInfo addressesOrderInfo = new AddressesOrderInfo();

            addressesOrderInfo.RouteId   = route.RouteID;
            addressesOrderInfo.Addresses = new AddressInfo[0];

            for (int i = 0; i < route.Addresses.Length; i++)
            {
                Address     address     = route.Addresses[i];
                AddressInfo addressInfo = new AddressInfo();

                addressInfo.DestinationId = address.RouteDestinationId.Value;

                addressInfo.SequenceNo = i;

                addressInfo.SequenceNo = i == 1 ? 2 : 1;

                addressInfo.IsDepot = (addressInfo.SequenceNo == 0);

                var addressesList = new List <AddressInfo>(addressesOrderInfo.Addresses);

                addressesList.Add(addressInfo);

                addressesOrderInfo.Addresses = addressesList.ToArray();
            }

            // Run the query
            DataObjectRoute route1 = route4Me
                                     .GetJsonObjectFromAPI <DataObjectRoute>(addressesOrderInfo,
                                                                             R4MEInfrastructureSettings.RouteHost,
                                                                             HttpMethodType.Put,
                                                                             out string errorString1);

            // Output the result
            PrintExampleRouteResult(route1, errorString1);

            if (isInnerExample)
            {
                RemoveTestOptimizations();
            }
        }
コード例 #51
0
        public void GetOptimizationsByText()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            RunOptimizationSingleDriverRoute10Stops();
            OptimizationsToRemove = new List <string>();
            OptimizationsToRemove.Add(SD10Stops_optimization_problem_id);

            string queryText = "SD Route 10 Stops Test";

            var queryParameters = new OptimizationParameters()
            {
                Limit  = 3,
                Offset = 0,
                Query  = queryText
            };

            // Run the query
            var dataObjects = route4Me.GetOptimizations(
                queryParameters,
                out string errorString);

            int foundOptimizations = dataObjects
                                     .Where(x => x.Parameters.RouteName.Contains(queryText))
                                     .Count();

            Console.WriteLine(
                foundOptimizations > 0
                    ? "Found the optimizations searched by text: " + foundOptimizations
                    : "Cannot found the optimizations searched by text"
                );

            RemoveTestOptimizations();
        }
コード例 #52
0
        public void GetActivities(string routeId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            ActivityParameters activityParameters = new ActivityParameters()
            {
                RouteId = routeId,
                Limit   = 10,
                Offset  = 0
            };

            // Run the query
            string errorString;

            Activity[] activities = route4Me.GetActivityFeed(activityParameters, out errorString);

            Console.WriteLine("");

            if (activities != null)
            {
                Console.WriteLine("GetActivities executed successfully, {0} activities returned", activities.Length);
                Console.WriteLine("");

                activities.ForEach(activity =>
                {
                    Console.WriteLine("Activity ID: {0}", activity.ActivityId);
                });
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("GetActivities error: {0}", errorString);
            }
        }
コード例 #53
0
        /// <summary>
        /// Update an User
        /// </summary>
        public void UpdateUser()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            CreateTestUser();

            int memberId = Convert.ToInt32(usersToRemove[usersToRemove.Count - 1]);

            var @params = new MemberParametersV4
            {
                member_id    = memberId,
                member_phone = "571-259-5939"
            };

            // Run the query
            MemberResponseV4 result = route4Me.UserUpdate(@params, out string errorString);

            PrintTestUsers(result, errorString);

            if (result != null && result.GetType() == typeof(MemberResponseV4))
            {
                Console.WriteLine(
                    result.member_phone != "571-259-5939"
                        ? "The user phone is not '571-259-5939'"
                        : "The user phone is '571-259-5939'"
                    );
            }

            RemoveTestUsers();
        }
コード例 #54
0
        /// <summary>
        /// Remove Territory
        /// </summary>
        public void RemoveTerritory()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            string territoryId = "12ABBFA3B5E4FB007BB0ED73291576C2";

            AvoidanceZoneQuery territoryQuery = new AvoidanceZoneQuery {
                TerritoryId = territoryId
            };

            // Run the query
            string errorString = "";

            route4Me.RemoveTerritory(territoryQuery, out errorString);

            Console.WriteLine("");

            if (string.IsNullOrEmpty(errorString))
            {
                Console.WriteLine("RemoveTerritory executed successfully");

                Console.WriteLine("Territory ID: {0}", territoryId);
            }
            else
            {
                Console.WriteLine("RemoveTerritory error: {0}", errorString);
            }
        }
コード例 #55
0
        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);
            }
        }
コード例 #56
0
        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);
            }
        }
コード例 #57
0
        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);
            }
        }
コード例 #58
0
        /// <summary>
        /// Get Orders
        /// </summary>
        public void GetOrders()
        {
            // Create the manager with the api key
              Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

              OrderParameters orderParameters = new OrderParameters()
              {
            Limit = 10
              };

              uint total;
              string errorString;
              Order[] orders = route4Me.GetOrders(orderParameters, out total, out errorString);

              Console.WriteLine("");

              if (orders != null)
              {
            Console.WriteLine("GetOrders executed successfully, {0} orders returned, total = {1}", orders.Length, total);
              }
              else
              {
            Console.WriteLine("GetOrders error: {0}", errorString);
              }
        }
コード例 #59
0
        /// <summary>
        /// Get Activities Destination Updated
        /// </summary>
        public void SearchDestinationUpdated()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            ActivityParameters activityParameters = new ActivityParameters {
                ActivityType = "update-destinations"
            };

            // Run the query
            string errorString = "";

            Activity[] activities = route4Me.GetActivityFeed(activityParameters, out errorString);

            Console.WriteLine("");

            if (activities != null)
            {
                Console.WriteLine("SearchDestinationUpdated executed successfully, {0} activities returned", activities.Length);
                Console.WriteLine("");

                foreach (Activity Activity in activities)
                {
                    Console.WriteLine("Activity ID: {0}", Activity.ActivityId);
                }

                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("SearchDestinationUpdated error: {0}", errorString);
            }
        }
コード例 #60
0
        /// <summary>
        /// Search for Specified Text, Show Specified Fields
        /// </summary>
        public void GetSpecifiedFieldsSearchText()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AddressBookParameters addressBookParameters = new AddressBookParameters
            {
                Query = "david",
                Fields = "first_name,address_email",
                Offset = 0,
                Limit = 20
            };

            // Run the query
            uint total = 0;
            string errorString = "";
            List<string[]> contacts = route4Me.SearchAddressBookLocation(addressBookParameters, out total, out errorString);

            Console.WriteLine("");

            if (contacts != null)
            {
                Console.WriteLine("GetSpecifiedFieldsSearchText executed successfully, {0} contacts returned, total = {1}", contacts.Count, total);

                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("GetSpecifiedFieldsSearchText error: {0}", errorString);
            }
        }