/// <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();
        }
        /// <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();
        }
示例#3
0
        /// <summary>
        /// Create Territory with Circular Shape
        /// </summary>
        public void CreateTerritory()
        {
            // 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.Circle.Description(),
                    Data = new string[] {
                        "37.569752822786455,-77.47833251953125",
                        "5000"
                    }
                }
            };

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

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

            PrintExampleTerritory(territory, errorString);

            RemoveTestTerritoryZones();
        }
        /// <summary>
        /// Add Avoidance Zone
        /// </summary>
        /// <returns> Id of added territory </returns>
        public string AddAvoidanceZone(bool removeAvoidanceZone = true)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

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

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

            PrintExampleAvoidanceZone(avoidanceZone, errorString);

            string avZoneId = avoidanceZone != null && avoidanceZone.GetType() == typeof(AvoidanceZone)
                ? avoidanceZone.TerritoryId
                : null;

            if (removeAvoidanceZone)
            {
                RemoveAvidanceZone(avZoneId);
            }

            return(removeAvoidanceZone ? null : avZoneId);
        }
        /// <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 = "";
            TerritoryZone 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);
            }
        }
        /// <summary>
        /// Update Avoidance Zone
        /// </summary>
        /// <param name="territoryId"> Avoidance Zone Id </param>
        public void UpdateAvoidanceZone(string territoryId)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AvoidanceZoneParameters avoidanceZoneParameters = new AvoidanceZoneParameters()
            {
                TerritoryId    = territoryId,
                TerritoryName  = "Test Territory Updated",
                TerritoryColor = "ff00ff",
                Territory      = new Territory()
                {
                    Type = TerritoryType.Circle.Description(),
                    Data = new string[] { "38.41322259056806,-78.501953234",
                                          "3000" }
                }
            };

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

            Console.WriteLine("");

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

                Console.WriteLine("Territory ID: {0}", avoidanceZone.TerritoryId);
            }
            else
            {
                Console.WriteLine("UpdateAvoidanceZone error: {0}", errorString);
            }
        }
        /// <summary>
        /// Add Polygon Avoidance Zone
        /// </summary>
        /// <returns> Id of added territory </returns>
        public string AddPolygonAvoidanceZone()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AvoidanceZoneParameters avoidanceZoneParameters = new AvoidanceZoneParameters
            {
                TerritoryName  = "Test Territory",
                TerritoryColor = "ff0000",
                Territory      = new Territory
                {
                    Type = TerritoryType.Poly.Description(),
                    Data = new string[] {
                        "37.569752822786455,-77.47833251953125",
                        "37.75886716305343,-77.68974800109863",
                        "37.74763966054455,-77.6917221069336",
                        "37.74655084306813,-77.68863220214844",
                        "37.7502255383101,-77.68125076293945",
                        "37.74797991274437,-77.67498512268066",
                        "37.73327960206065,-77.6411678314209",
                        "37.74430510679532,-77.63172645568848",
                        "37.76641925847049,-77.66846199035645"
                    }
                }
            };

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

            Console.WriteLine("");

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

                Console.WriteLine("Territory ID: {0}", avoidanceZone.TerritoryId);

                return(avoidanceZone.TerritoryId);
            }
            else
            {
                Console.WriteLine("AddPolygonAvoidanceZone error: {0}", errorString);

                return(null);
            }
        }
        /// <summary>
        /// Add Polygon Avoidance Zone
        /// </summary>
        /// <returns> Id of added territory </returns>
        public string AddPolygonAvoidanceZone(bool removeAvoidanceZone = true)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            var avoidanceZoneParameters = new AvoidanceZoneParameters
            {
                TerritoryName  = "Test Territory",
                TerritoryColor = "ff0000",
                Territory      = new Territory
                {
                    Type = TerritoryType.Poly.Description(),
                    Data = new string[] {
                        "37.569752822786455,-77.47833251953125",
                        "37.75886716305343,-77.68974800109863",
                        "37.74763966054455,-77.6917221069336",
                        "37.74655084306813,-77.68863220214844",
                        "37.7502255383101,-77.68125076293945",
                        "37.74797991274437,-77.67498512268066",
                        "37.73327960206065,-77.6411678314209",
                        "37.74430510679532,-77.63172645568848",
                        "37.76641925847049,-77.66846199035645"
                    }
                }
            };

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

            PrintExampleAvoidanceZone(avoidanceZone, errorString);

            string avZoneId = avoidanceZone != null && avoidanceZone.GetType() == typeof(AvoidanceZone)
                ? avoidanceZone.TerritoryId
                : null;

            if (removeAvoidanceZone)
            {
                RemoveAvidanceZone(avZoneId);
            }

            return(removeAvoidanceZone ? null : avZoneId);
        }
示例#9
0
        /// <summary>
        /// Add Rectangular Avoidance Zone
        /// </summary>
        /// <returns> Id of added territory </returns>
        public string AddRectAvoidanceZone()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AvoidanceZoneParameters avoidanceZoneParameters = 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 avoidanceZone = route4Me.AddAvoidanceZone(avoidanceZoneParameters, out errorString);

            Console.WriteLine("");

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

                Console.WriteLine("Territory ID: {0}", avoidanceZone.TerritoryId);

                return(avoidanceZone.TerritoryId);
            }
            else
            {
                Console.WriteLine("AddRectAvoidanceZone error: {0}", errorString);

                return(null);
            }
        }
        /// <summary>
        /// Create Territory with Polygon Shape
        /// </summary>
        public void CreatePolygonTerritory()
        {
            // 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.Poly.Description(),
                    Data = new string[] {
                        "37.569752822786455,-77.47833251953125",
                        "37.75886716305343,-77.68974800109863",
                        "37.74763966054455,-77.6917221069336",
                        "37.74655084306813,-77.68863220214844",
                        "37.7502255383101,-77.68125076293945",
                        "37.74797991274437,-77.67498512268066",
                        "37.73327960206065,-77.6411678314209",
                        "37.74430510679532,-77.63172645568848",
                        "37.76641925847049,-77.66846199035645"
                    }
                }
            };

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

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

            PrintExampleTerritory(territory, errorString);

            RemoveTestTerritoryZones();
        }
        /// <summary>
        /// Add Avoidance Zone
        /// </summary>
        /// <returns> Id of added territory </returns>
        public string AddAvoidanceZone()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            AvoidanceZoneParameters avoidanceZoneParameters = new AvoidanceZoneParameters()
            {
                TerritoryName  = "Test Territory",
                TerritoryColor = "ff0000",
                Territory      = new Territory()
                {
                    Type = TerritoryType.Circle.Description(),
                    Data = new string[] { "37.569752822786455,-77.47833251953125",
                                          "5000" }
                }
            };

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

            Console.WriteLine("");

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

                Console.WriteLine("Territory ID: {0}", avoidanceZone.TerritoryId);

                return(avoidanceZone.TerritoryId);
            }
            else
            {
                Console.WriteLine("AddAvoidanceZone error: {0}", errorString);

                return(null);
            }
        }
示例#12
0
        /// <summary>
        /// Update Territory
        /// </summary>
        public void UpdateTerritory()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            string territoryId = "1CEFEC7568D900FB781C21603780775E";

            AvoidanceZoneParameters 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
            string        errorString = "";
            AvoidanceZone territory   = route4Me.UpdateTerritory(territoryParameters, out errorString);

            Console.WriteLine("");

            if (territory != null)
            {
                Console.WriteLine("UpdateTerritory executed successfully");
                Console.WriteLine("Territory ID: {0}", territory.TerritoryId);
            }
            else
            {
                Console.WriteLine("UpdateTerritory error: {0}", errorString);
            }
        }
示例#13
0
        /// <summary>
        /// Update Avoidance Zone
        /// </summary>
        /// <param name="territoryId"> Avoidance Zone Id </param>
        public void UpdateAvoidanceZone(string territoryId = null)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

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

            if (isInnerExample)
            {
                CreateAvoidanceZone();
                territoryId = this.avoidanceZone.TerritoryId;
            }

            var avoidanceZoneParameters = new AvoidanceZoneParameters()
            {
                TerritoryId    = territoryId,
                TerritoryName  = "Test Territory Updated",
                TerritoryColor = "ff00ff",
                Territory      = new Territory()
                {
                    Type = TerritoryType.Circle.Description(),
                    Data = new string[] { "38.41322259056806,-78.501953234",
                                          "3000" }
                }
            };

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

            PrintExampleAvoidanceZone(avoidanceZone, errorString);

            if (isInnerExample)
            {
                RemoveAvidanceZone(territoryId);
            }
        }
        /// <summary>
        /// Add Rectangular Avoidance Zone
        /// </summary>
        /// <returns> Id of added territory </returns>
        public string AddRectAvoidanceZone(bool removeAvoidanceZone = true)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            var avoidanceZoneParameters = 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
            AvoidanceZone avoidanceZone = route4Me.AddAvoidanceZone(
                avoidanceZoneParameters,
                out string errorString);

            PrintExampleAvoidanceZone(avoidanceZone, errorString);

            string avZoneId = avoidanceZone != null && avoidanceZone.GetType() == typeof(AvoidanceZone)
                ? avoidanceZone.TerritoryId
                : null;

            if (removeAvoidanceZone)
            {
                RemoveAvidanceZone(avZoneId);
            }

            return(removeAvoidanceZone ? null : avZoneId);
        }