Пример #1
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);
            }
        }
        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;
              }
        }
        /// <summary>
        /// Add address book contact
        /// </summary>
        public void AddAddressBookContact()
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            var 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,
                address_custom_data = new Dictionary <string, string>()
                {
                    { "Service type", "publishing" },
                    { "Facilities", "storage" },
                    { "Parking", "temporarry" }
                }
            };

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

            if (resultContact == null || resultContact.GetType() != typeof(AddressBookContact))
            {
                Console.WriteLine(
                    "Cannot create an address book contact." +
                    Environment.NewLine +
                    errorString);

                return;
            }

            ContactsToRemove = new List <string>();
            ContactsToRemove.Add(resultContact.address_id.ToString());

            PrintExampleContact(resultContact, 0, errorString);

            RemoveTestContacts();
        }
Пример #4
0
        /// <summary>
        /// Add a scheduled address book contact
        /// </summary>
        public void AddScheduledAddressBookContact()
        {
            var route4Me = new Route4MeManager(ActualApiKey);

            ContactsToRemove = new List <string>();

            #region // Add a location, scheduled daily.
            var sched1 = new Schedule("daily", false)
            {
                Enabled = true,
                From    = DateTime.Today.ToString("yyyy-MM-dd"),
                Mode    = "daily",
                Daily   = new ScheduleDaily(1)
            };

            scheduledContact1 = new AddressBookContact()
            {
                address_1            = "1604 PARKRIDGE PKWY, Louisville, KY, 40214",
                address_alias        = "1604 PARKRIDGE PKWY 40214",
                address_group        = "Scheduled daily",
                first_name           = "Peter",
                last_name            = "Newman",
                address_email        = "*****@*****.**",
                address_phone_number = "65432178",
                cached_lat           = 38.141598,
                cached_lng           = -85.793846,
                address_city         = "Louisville",
                address_custom_data  = new Dictionary <string, string>()
                {
                    { "scheduled", "yes" },
                    { "service type", "publishing" }
                },
                schedule = new List <Schedule>()
                {
                    sched1
                }
            };

            scheduledContact1Response = route4Me.AddAddressBookContact(scheduledContact1, out string errorString);

            PrintExampleScheduledContact(scheduledContact1Response, "daily", errorString);
            #endregion

            #region // Add a location, scheduled weekly.
            var sched2 = new Schedule("weekly", false)
            {
                Enabled = true,
                From    = DateTime.Today.ToString("yyyy-MM-dd"),
                Weekly  = new ScheduleWeekly(1, new int[] { 1, 2, 3, 4, 5 })
            };

            scheduledContact2 = new AddressBookContact()
            {
                address_1            = "1407 MCCOY, Louisville, KY, 40215",
                address_alias        = "1407 MCCOY 40215",
                address_group        = "Scheduled weekly",
                first_name           = "Bart",
                last_name            = "Douglas",
                address_email        = "*****@*****.**",
                address_phone_number = "95487454",
                cached_lat           = 38.202496,
                cached_lng           = -85.786514,
                address_city         = "Louisville",
                service_time         = 600,
                schedule             = new List <Schedule>()
                {
                    sched2
                }
            };

            scheduledContact2Response = route4Me.AddAddressBookContact(scheduledContact2, out errorString);

            PrintExampleScheduledContact(
                scheduledContact2Response,
                "weekly",
                errorString);
            #endregion

            #region // Add a location, scheduled monthly (dates mode).
            var sched3 = new Schedule("monthly", false)
            {
                Enabled = true,
                From    = DateTime.Today.ToString("yyyy-MM-dd"),
                Monthly = new ScheduleMonthly(_every: 1, _mode: "dates", _dates: new int[] { 20, 22, 23, 24, 25 })
            };

            scheduledContact3 = new AddressBookContact()
            {
                address_1            = "4805 BELLEVUE AVE, Louisville, KY, 40215",
                address_2            = "4806 BELLEVUE AVE, Louisville, KY, 40215",
                address_alias        = "4805 BELLEVUE AVE 40215",
                address_group        = "Scheduled monthly",
                first_name           = "Bart",
                last_name            = "Douglas",
                address_email        = "*****@*****.**",
                address_phone_number = "95487454",
                cached_lat           = 38.178844,
                cached_lng           = -85.774864,
                address_country_id   = "US",
                address_state_id     = "KY",
                address_zip          = "40215",
                address_city         = "Louisville",
                service_time         = 750,
                schedule             = new List <Schedule>()
                {
                    sched3
                },
                color = "red"
            };

            scheduledContact3Response = route4Me.AddAddressBookContact(scheduledContact3, out errorString);

            PrintExampleScheduledContact(
                scheduledContact3Response,
                "monthly (dates mode)",
                errorString);
            #endregion

            #region // Add a location, scheduled monthly (nth mode).
            var sched4 = new Schedule("monthly", false)
            {
                Enabled = true,
                From    = DateTime.Today.ToString("yyyy-MM-dd"),
                Monthly = new ScheduleMonthly(_every: 1, _mode: "nth", _nth: new Dictionary <int, int>()
                {
                    { 1, 4 }
                })
            };

            scheduledContact4 = new AddressBookContact()
            {
                address_1            = "730 CECIL AVENUE, Louisville, KY, 40211",
                address_alias        = "730 CECIL AVENUE 40211",
                address_group        = "Scheduled monthly",
                first_name           = "David",
                last_name            = "Silvester",
                address_email        = "*****@*****.**",
                address_phone_number = "36985214",
                cached_lat           = 38.248684,
                cached_lng           = -85.821121,
                address_city         = "Louisville",
                service_time         = 450,
                address_custom_data  = new Dictionary <string, string>()
                {
                    { "scheduled", "yes" }, { "service type", "library" }
                },
                schedule = new List <Schedule>()
                {
                    sched4
                },
                address_icon = "emoji/emoji-bus"
            };

            scheduledContact4Response = route4Me.AddAddressBookContact(scheduledContact4, out errorString);

            PrintExampleScheduledContact(
                scheduledContact4Response,
                "monthly (nth mode)",
                errorString);
            #endregion

            #region // Add a location with the daily scheduling and blacklist.
            var sched5 = new Schedule("daily", false)
            {
                Enabled = true,
                Mode    = "daily",
                From    = DateTime.Today.ToString("yyyy-MM-dd"),
                Daily   = new ScheduleDaily(1)
            };

            scheduledContact5 = new AddressBookContact()
            {
                address_1            = "4629 HILLSIDE DRIVE, Louisville, KY, 40216",
                address_alias        = "4629 HILLSIDE DRIVE 40216",
                address_group        = "Scheduled daily",
                first_name           = "Kim",
                last_name            = "Shandor",
                address_email        = "*****@*****.**",
                address_phone_number = "9874152",
                cached_lat           = 38.176067,
                cached_lng           = -85.824638,
                address_city         = "Louisville",
                address_custom_data  = new Dictionary <string, string>()
                {
                    { "scheduled", "yes" }, { "service type", "appliance" }
                },
                schedule = new List <Schedule>()
                {
                    sched5
                },
                schedule_blacklist = new string[] { "2017-12-22", "2017-12-23" },
                service_time       = 300
            };

            scheduledContact5Response = route4Me.AddAddressBookContact(scheduledContact5, out errorString);

            PrintExampleScheduledContact(
                scheduledContact5Response,
                "daily (with blacklist)",
                errorString);
            #endregion

            RemoveTestContacts();
        }
        public void HybridOptimizationFrom1000Addresses()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager("11111111111111111111111111111111");

            #region ======= Add scheduled address book locations to an user account ================================
            string   sAddressFile = @"Data/addresses_1000.csv";
            Schedule sched0       = new Schedule("daily", false);
            //var csv = new CsvReader(File.OpenText("file.csv"));

            using (TextReader reader = File.OpenText(sAddressFile))
            {
                var csv = new CsvReader(reader);
                //int iCount = 0;
                while (csv.Read())
                {
                    var lng      = csv.GetField(0);
                    var lat      = csv.GetField(1);
                    var alias    = csv.GetField(2);
                    var address1 = csv.GetField(3);
                    var city     = csv.GetField(4);
                    var state    = csv.GetField(5);
                    var zip      = csv.GetField(6);
                    var phone    = csv.GetField(7);
                    //var sched_date = csv.GetField(8);
                    var sched_mode            = csv.GetField(8);
                    var sched_enabled         = csv.GetField(9);
                    var sched_every           = csv.GetField(10);
                    var sched_weekdays        = csv.GetField(11);
                    var sched_monthly_mode    = csv.GetField(12);
                    var sched_monthly_dates   = csv.GetField(13);
                    var sched_annually_usenth = csv.GetField(14);
                    var sched_annually_months = csv.GetField(15);
                    var sched_nth_n           = csv.GetField(16);
                    var sched_nth_what        = csv.GetField(17);

                    string sAddress = "";

                    if (address1 != null)
                    {
                        sAddress += address1.ToString().Trim();
                    }
                    if (city != null)
                    {
                        sAddress += ", " + city.ToString().Trim();
                    }
                    if (state != null)
                    {
                        sAddress += ", " + state.ToString().Trim();
                    }
                    if (zip != null)
                    {
                        sAddress += ", " + zip.ToString().Trim();
                    }

                    if (sAddress == "")
                    {
                        continue;
                    }

                    AddressBookContact newLocation = new AddressBookContact();

                    if (lng != null)
                    {
                        newLocation.cached_lng = Convert.ToDouble(lng);
                    }
                    if (lat != null)
                    {
                        newLocation.cached_lat = Convert.ToDouble(lat);
                    }
                    if (alias != null)
                    {
                        newLocation.address_alias = alias.ToString().Trim();
                    }
                    newLocation.address_1 = sAddress;
                    if (phone != null)
                    {
                        newLocation.address_phone_number = phone.ToString().Trim();
                    }

                    //newLocation.schedule = new Schedule[]{};
                    if (!sched0.ValidateScheduleMode(sched_mode))
                    {
                        continue;
                    }

                    bool blNth = false;
                    if (sched0.ValidateScheduleMonthlyMode(sched_monthly_mode))
                    {
                        if (sched_monthly_mode == "nth")
                        {
                            blNth = true;
                        }
                    }
                    if (sched0.ValidateScheduleUseNth(sched_annually_usenth))
                    {
                        if (sched_annually_usenth.ToString().ToLower() == "true")
                        {
                            blNth = true;
                        }
                    }

                    Schedule schedule = new Schedule(sched_mode.ToString(), blNth);

                    DateTime dt = DateTime.Now;
                    //if (schedule.ValidateScheduleMode(sched_mode))
                    //{
                    schedule.mode = sched_mode.ToString();
                    if (schedule.ValidateScheduleEnabled(sched_enabled))
                    {
                        schedule.enabled = Convert.ToBoolean(sched_enabled);
                        if (schedule.ValidateScheduleEvery(sched_every))
                        {
                            int iEvery = Convert.ToInt32(sched_every);
                            switch (schedule.mode)
                            {
                            case "daily":
                                schedule.daily.every = iEvery;
                                break;

                            case "weekly":
                                if (schedule.ValidateScheduleWeekdays(sched_weekdays))
                                {
                                    schedule.weekly.every = iEvery;
                                    string[]   arWeekdays = sched_weekdays.Split(',');
                                    List <int> lsWeekdays = new List <int>();
                                    for (int i = 0; i < arWeekdays.Length; i++)
                                    {
                                        lsWeekdays.Add(Convert.ToInt32(arWeekdays[i]));
                                    }
                                    schedule.weekly.weekdays = lsWeekdays.ToArray();
                                }
                                break;

                            case "monthly":
                                if (schedule.ValidateScheduleMonthlyMode(sched_monthly_mode))
                                {
                                    schedule.monthly.every = iEvery;
                                    schedule.monthly.mode  = sched_monthly_mode.ToString();
                                    switch (schedule.monthly.mode)
                                    {
                                    case "dates":
                                        if (schedule.ValidateScheduleMonthDays(sched_monthly_dates))
                                        {
                                            string[]   arMonthdays = sched_monthly_dates.Split(',');
                                            List <int> lsMonthdays = new List <int>();
                                            for (int i = 0; i < arMonthdays.Length; i++)
                                            {
                                                lsMonthdays.Add(Convert.ToInt32(arMonthdays[i]));
                                            }
                                            schedule.monthly.dates = lsMonthdays.ToArray();
                                        }
                                        break;

                                    case "nth":
                                        if (schedule.ValidateScheduleNthN(sched_nth_n))
                                        {
                                            schedule.monthly.nth.n = Convert.ToInt32(sched_nth_n);
                                        }
                                        if (schedule.ValidateScheduleNthWhat(sched_nth_what))
                                        {
                                            schedule.monthly.nth.what = Convert.ToInt32(sched_nth_what);
                                        }
                                        break;
                                    }
                                }
                                break;

                            case "annually":
                                if (schedule.ValidateScheduleUseNth(sched_annually_usenth))
                                {
                                    schedule.annually.every   = iEvery;
                                    schedule.annually.use_nth = Convert.ToBoolean(sched_annually_usenth);
                                    if (schedule.annually.use_nth)
                                    {
                                        if (schedule.ValidateScheduleNthN(sched_nth_n))
                                        {
                                            schedule.annually.nth.n = Convert.ToInt32(sched_nth_n);
                                        }
                                        if (schedule.ValidateScheduleNthWhat(sched_nth_what))
                                        {
                                            schedule.annually.nth.what = Convert.ToInt32(sched_nth_what);
                                        }
                                    }
                                    else
                                    {
                                        if (schedule.ValidateScheduleYearMonths(sched_annually_months))
                                        {
                                            string[]   arYearmonths = sched_annually_months.Split(',');
                                            List <int> lsMonths     = new List <int>();
                                            for (int i = 0; i < arYearmonths.Length; i++)
                                            {
                                                lsMonths.Add(Convert.ToInt32(arYearmonths[i]));
                                            }
                                            schedule.annually.months = lsMonths.ToArray();
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                    newLocation.schedule = (new List <Schedule>()
                    {
                        schedule
                    }).ToArray();
                    //}

                    string             errorString;
                    AddressBookContact resultContact = route4Me.AddAddressBookContact(newLocation, out errorString);

                    showResult(resultContact, errorString);

                    Thread.Sleep(1000);
                }
            };

            #endregion

            Thread.Sleep(2000);

            #region ======= Get Hybrid Optimization ================================
            TimeSpan      tsp1day         = new TimeSpan(1, 0, 0, 0);
            List <string> lsScheduledDays = new List <string>();
            DateTime      curDate         = DateTime.Now;
            for (int i = 0; i < 5; i++)
            {
                curDate += tsp1day;
                lsScheduledDays.Add(curDate.ToString("yyyy-MM-dd"));
            }
            //string[] ScheduledDays = new string[] { "2017-03-06", "2017-03-07", "2017-03-08", "2017-03-09", "2017-03-10" };

            Address[] Depots = new Address[] {
                new Address {
                    AddressString     = "2017 Ambler Ave, Abilene, TX, 79603-2239",
                    IsDepot           = true,
                    Latitude          = 32.474395,
                    Longitude         = -99.7447021,
                    CurbsideLatitude  = 32.474395,
                    CurbsideLongitude = -99.7447021
                },
                new Address {
                    AddressString     = "807 Ridge Rd, Alamo, TX, 78516-9596",
                    IsDepot           = true,
                    Latitude          = 26.170834,
                    Longitude         = -98.116201,
                    CurbsideLatitude  = 26.170834,
                    CurbsideLongitude = -98.116201
                },
                new Address {
                    AddressString     = "1430 W Amarillo Blvd, Amarillo, TX, 79107-5505",
                    IsDepot           = true,
                    Latitude          = 35.221969,
                    Longitude         = -101.835288,
                    CurbsideLatitude  = 35.221969,
                    CurbsideLongitude = -101.835288
                },
                new Address {
                    AddressString     = "3611 Ne 24Th Ave, Amarillo, TX, 79107-7242",
                    IsDepot           = true,
                    Latitude          = 35.236626,
                    Longitude         = -101.795117,
                    CurbsideLatitude  = 35.236626,
                    CurbsideLongitude = -101.795117
                },
                new Address {
                    AddressString     = "1525 New York Ave, Arlington, TX, 76010-4723",
                    IsDepot           = true,
                    Latitude          = 32.720524,
                    Longitude         = -97.080195,
                    CurbsideLatitude  = 32.720524,
                    CurbsideLongitude = -97.080195
                }
            };

            string errorString1;
            string errorString2;
            string errorString3;

            foreach (string ScheduledDay in lsScheduledDays)
            {
                HybridOptimizationParameters hparams = new HybridOptimizationParameters()
                {
                    target_date_string      = ScheduledDay,
                    timezone_offset_minutes = -240
                };

                DataObject resultOptimization = route4Me.GetOHybridptimization(hparams, out errorString1);

                string HybridOptimizationId = "";

                if (resultOptimization != null)
                {
                    HybridOptimizationId = resultOptimization.OptimizationProblemId;
                    Console.WriteLine("Hybrid optimization generating executed successfully");

                    Console.WriteLine("Generated hybrid optimization ID: {0}", HybridOptimizationId);
                }
                else
                {
                    Console.WriteLine("Hybrid optimization generating error: {0}", errorString1);
                    continue;
                }

                //============== Add Depot To Hybrid Optimization ===============
                HybridDepotParameters hDepotParams = new HybridDepotParameters()
                {
                    optimization_problem_id = HybridOptimizationId,
                    delete_old_depots       = true,
                    new_depots = new Address[] { Depots[lsScheduledDays.IndexOf(ScheduledDay)] }
                };

                var addDepotResult = route4Me.AddDepotsToHybridOptimization(hDepotParams, out errorString3);

                Thread.Sleep(5000);

                //============== Reoptimization =================================
                OptimizationParameters optimizationParameters = new OptimizationParameters()
                {
                    OptimizationProblemID = HybridOptimizationId,
                    ReOptimize            = true
                };

                DataObject finalOptimization = route4Me.UpdateOptimization(optimizationParameters, out errorString2);

                Console.WriteLine("");

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

                    Console.WriteLine("Optimization Problem ID: {0}", finalOptimization.OptimizationProblemId);
                    Console.WriteLine("State: {0}", finalOptimization.State);
                }
                else
                {
                    Console.WriteLine("ReOptimization error: {0}", errorString2);
                }

                Thread.Sleep(5000);
                //=================================================================
            }

            #endregion
        }
        public void AddScheduledAddressBookContact()
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

            List <string> lsRemoveContacts = new List <string>();

            #region // Add a location, scheduled daily.
            Schedule sched1 = new Schedule("daily", false)
            {
                enabled = true,
                mode    = "daily",
                daily   = new schedule_daily(1)
            };

            AddressBookContact scheduledContact1 = new AddressBookContact()
            {
                address_1            = "1604 PARKRIDGE PKWY, Louisville, KY, 40214",
                address_alias        = "1604 PARKRIDGE PKWY 40214",
                address_group        = "Scheduled daily",
                first_name           = "Peter",
                last_name            = "Newman",
                address_email        = "*****@*****.**",
                address_phone_number = "65432178",
                cached_lat           = 38.141598,
                cached_lng           = -85.793846,
                address_city         = "Louisville",
                address_custom_data  = new Dictionary <string, string>()
                {
                    { "scheduled", "yes" }, { "service type", "publishing" }
                },
                schedule = new List <Schedule>()
                {
                    sched1
                }
            };

            string errorString;
            var    scheduledContact1Response = route4Me.AddAddressBookContact(scheduledContact1, out errorString);

            int location1 = scheduledContact1Response.address_id != null?Convert.ToInt32(scheduledContact1Response.address_id) : -1;

            if (location1 > 0)
            {
                lsRemoveContacts.Add(location1.ToString());
                Console.WriteLine("A location with the daily scheduling was created. AddressId: {0}", location1);
            }
            else
            {
                Console.WriteLine("Creating if a location with daily scheduling failed");
            }
            #endregion

            #region // Add a location, scheduled weekly.
            Schedule sched2 = new Schedule("weekly", false)
            {
                enabled = true,
                weekly  = new schedule_weekly(1, new int[] { 1, 2, 3, 4, 5 })
            };

            AddressBookContact scheduledContact2 = new AddressBookContact()
            {
                address_1            = "1407 MCCOY, Louisville, KY, 40215",
                address_alias        = "1407 MCCOY 40215",
                address_group        = "Scheduled weekly",
                first_name           = "Bart",
                last_name            = "Douglas",
                address_email        = "*****@*****.**",
                address_phone_number = "95487454",
                cached_lat           = 38.202496,
                cached_lng           = -85.786514,
                address_city         = "Louisville",
                service_time         = 600,
                schedule             = new List <Schedule>()
                {
                    sched2
                }
            };

            var scheduledContact2Response = route4Me.AddAddressBookContact(scheduledContact2, out errorString);

            int location2 = scheduledContact2Response.address_id != null?Convert.ToInt32(scheduledContact2Response.address_id) : -1;

            if (location2 > 0)
            {
                lsRemoveContacts.Add(location2.ToString());
                Console.WriteLine("A location with the weekly scheduling was created. AddressId: {0}", location2);
            }
            else
            {
                Console.WriteLine("Creating if a location with weekly scheduling failed");
            }

            #endregion

            #region // Add a location, scheduled monthly (dates mode).
            Schedule sched3 = new Schedule("monthly", false)
            {
                enabled = true,
                monthly = new schedule_monthly(_every: 1, _mode: "dates", _dates: new int[] { 20, 22, 23, 24, 25 })
            };

            AddressBookContact scheduledContact3 = new AddressBookContact()
            {
                address_1            = "4805 BELLEVUE AVE, Louisville, KY, 40215",
                address_2            = "4806 BELLEVUE AVE, Louisville, KY, 40215",
                address_alias        = "4805 BELLEVUE AVE 40215",
                address_group        = "Scheduled monthly",
                first_name           = "Bart",
                last_name            = "Douglas",
                address_email        = "*****@*****.**",
                address_phone_number = "95487454",
                cached_lat           = 38.178844,
                cached_lng           = -85.774864,
                address_country_id   = "US",
                address_state_id     = "KY",
                address_zip          = "40215",
                address_city         = "Louisville",
                service_time         = 750,
                schedule             = new List <Schedule>()
                {
                    sched3
                },
                color = "red"
            };

            var scheduledContact3Response = route4Me.AddAddressBookContact(scheduledContact3, out errorString);

            int location3 = scheduledContact3Response.address_id != null?Convert.ToInt32(scheduledContact3Response.address_id) : -1;

            if (location3 > 0)
            {
                lsRemoveContacts.Add(location3.ToString());
                Console.WriteLine("A location with the monthly scheduling (mode 'dates') was created. AddressId: {0}", location3);
            }
            else
            {
                Console.WriteLine("Creating if a location with monthly scheduling (mode 'dates') failed");
            }
            #endregion

            #region // Add a location, scheduled monthly (nth mode).
            Schedule sched4 = new Schedule("monthly", false)
            {
                enabled = true,
                monthly = new schedule_monthly(_every: 1, _mode: "nth", _nth: new Dictionary <int, int>()
                {
                    { 1, 4 }
                })
            };

            AddressBookContact scheduledContact4 = new AddressBookContact()
            {
                address_1            = "730 CECIL AVENUE, Louisville, KY, 40211",
                address_alias        = "730 CECIL AVENUE 40211",
                address_group        = "Scheduled monthly",
                first_name           = "David",
                last_name            = "Silvester",
                address_email        = "*****@*****.**",
                address_phone_number = "36985214",
                cached_lat           = 38.248684,
                cached_lng           = -85.821121,
                address_city         = "Louisville",
                service_time         = 450,
                address_custom_data  = new Dictionary <string, string>()
                {
                    { "scheduled", "yes" }, { "service type", "library" }
                },
                schedule = new List <Schedule>()
                {
                    sched4
                },
                address_icon = "emoji/emoji-bus"
            };

            var scheduledContact4Response = route4Me.AddAddressBookContact(scheduledContact4, out errorString);

            int location4 = scheduledContact4Response.address_id != null?Convert.ToInt32(scheduledContact4Response.address_id) : -1;

            if (location4 > 0)
            {
                lsRemoveContacts.Add(location4.ToString());
                Console.WriteLine("A location with the monthly scheduling (mode 'nth') was created. AddressId: {0}", location4);
            }
            else
            {
                Console.WriteLine("Creating if a location with monthly scheduling (mode 'nth') failed");
            }
            #endregion

            #region // Add a location with the daily scheduling and blacklist.
            Schedule sched5 = new Schedule("daily", false)
            {
                enabled = true,
                mode    = "daily",
                daily   = new schedule_daily(1)
            };

            AddressBookContact scheduledContact5 = new AddressBookContact()
            {
                address_1            = "4629 HILLSIDE DRIVE, Louisville, KY, 40216",
                address_alias        = "4629 HILLSIDE DRIVE 40216",
                address_group        = "Scheduled daily",
                first_name           = "Kim",
                last_name            = "Shandor",
                address_email        = "*****@*****.**",
                address_phone_number = "9874152",
                cached_lat           = 38.176067,
                cached_lng           = -85.824638,
                address_city         = "Louisville",
                address_custom_data  = new Dictionary <string, string>()
                {
                    { "scheduled", "yes" }, { "service type", "appliance" }
                },
                schedule = new List <Schedule>()
                {
                    sched5
                },
                schedule_blacklist = new string[] { "2017-12-22", "2017-12-23" },
                service_time       = 300
            };

            var scheduledContact5Response = route4Me.AddAddressBookContact(scheduledContact5, out errorString);

            int location5 = scheduledContact5Response.address_id != null?Convert.ToInt32(scheduledContact5Response.address_id) : -1;

            if (location5 > 0)
            {
                lsRemoveContacts.Add(location5.ToString());
                Console.WriteLine("A location with the blacklist was created. AddressId: {0}", location5);
            }
            else
            {
                Console.WriteLine("Creating of a location with the blacklist failed");
            }
            #endregion

            var removed = route4Me.RemoveAddressBookContacts(lsRemoveContacts.ToArray(), out errorString);

            if ((bool)removed)
            {
                Console.WriteLine("The added testing address book locations were removed successfuly");
            }
            else
            {
                Console.WriteLine("Remvoving of the added testing address book locations failed");
            }
        }