Example #1
0
        //This will create texture from the pictue image path
        void LoadContactPictures(AddressBookContact[] _contactList)
        {
            m_contactPictures = new Texture[_contactList.Length];

            for (int _i = 0; _i < _contactList.Length; _i++)
            {
                AddressBookContact _each = _contactList[_i];

                if (!string.IsNullOrEmpty(_each.ImagePath))
                {
                    //Create callback receiver and save the index to pass to completion block.
                    int _textureIndex = _i;
                    DownloadTexture.Completion _onCompletion = (Texture2D _texture, string _error) => {
                        if (!string.IsNullOrEmpty(_error))
                        {
                            Console.LogError(Constants.kDebugTag, "[AddressBook] Contact Picture download failed " + _error);
                            m_contactPictures[_textureIndex] = null;
                        }
                        else
                        {
                            m_contactPictures[_textureIndex] = _texture;
                        }
                    };

                    //Start the texture fetching
                    _each.GetImageAsync(_onCompletion);
                }
            }
        }
Example #2
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);
            }
        }
Example #3
0
        private void showResult(object result, string errorString)
        {
            if (result == null)
            {
                Console.WriteLine("AddAddressBookContact error: {0}", errorString); return;
            }

            string addressId        = "";
            string sAddressbookType = "Route4MeSDK.DataTypes.AddressBookContact";

            if (result.GetType().ToString() == sAddressbookType)
            {
                AddressBookContact contact = (AddressBookContact)result;
                addressId = contact.address_id.ToString();
            }
            else
            {
                Order order = (Order)result;
                addressId = order.order_id.ToString();
            }
            Console.WriteLine("");

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

                Console.WriteLine("AddressId: {0}", addressId);
            }
            else
            {
                Console.WriteLine("AddAddressBookContact error: {0}", errorString);
            }
        }
Example #4
0
        public async void ImportJsonDataToDataBaseTest()
        {
            string testDataFile = @"TestData/one_complex_contact.json";

            DataExchangeHelper dataExchange = new DataExchangeHelper();

            using (StreamReader reader = new StreamReader(testDataFile))
            {
                var jsonContent = reader.ReadToEnd();
                reader.Close();

                AddressBookContact importedContact = dataExchange.ConvertSdkJsonContentToEntity <AddressBookContact>(jsonContent, out string errorString);

                fixture._route4meDbContext.AddressBookContacts.Add(importedContact);

                await fixture._route4meDbContext.SaveChangesAsync();

                int addressDbId = importedContact.AddressDbId;

                var addressSpec = new AddressBookContactSpecification(addressDbId);

                var addressBookContactFromRepo = await fixture.r4mdbManager.ContactsRepository.GetByIdAsync(addressSpec);

                Assert.IsType <AddressBookContact>(addressBookContactFromRepo);
            }
        }
 public EditorAddressBookContact(AddressBookContact _source) : base(_source)
 {
     // Change the Image path here
     if (!string.IsNullOrEmpty(ImagePath))
     {
         ImagePath = Application.dataPath + "/" + ImagePath.TrimStart('/');
     }
 }
Example #6
0
        public async Task <AddressBookContact> CreateAddressBookContactAsync(AddressBookContact addressBookContactParameters)
        {
            var propertyNames = addressBookContactParameters.GetType().GetProperties()
                                .ToList().Where(x => x.GetValue(addressBookContactParameters) != null && x.Name != "AddressId")
                                .Select(y => y.Name).ToList();

            var addressBookContact = new AddressBookContact(addressBookContactParameters, propertyNames);

            return(await _addressBookContactRepository.AddAsync(addressBookContact));
        }
Example #7
0
        private void DrawContactsInfoList()
        {
            if (m_contactsInfo == null || m_contactsInfo.Length == 0)
            {
                return;
            }

            m_eachColumnWidth = (GetWindowWidth() - GetWindowWidth() * 0.1f) / 5;
            GUILayoutOption _entryWidthOption      = GUILayout.Width(m_eachColumnWidth);
            GUILayoutOption _entryHeightOption     = GUILayout.Height(m_eachRowHeight);
            GUILayoutOption _entryHalfHeightOption = GUILayout.Height(m_eachRowHeight / 2);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Box("Picture", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                GUILayout.Box("First Name", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                GUILayout.Box("Last Name", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                GUILayout.Box("Phone #'s", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                GUILayout.Box("Email ID's", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
            }
            GUILayout.EndHorizontal();

            m_contactsScrollView.BeginScrollView();
            {
                for (int _i = 0; _i < m_contactsInfo.Length; _i++)
                {
                    if (_i > m_maxContactsToRender)                     //This is just to limit drawing
                    {
                        break;
                    }

                    AddressBookContact _eachContact = m_contactsInfo[_i];
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(m_contactPictures[_i], _entryWidthOption, _entryHeightOption);
                        GUILayout.Label(_eachContact.FirstName, _entryWidthOption, _entryHeightOption);
                        GUILayout.Label(_eachContact.LastName, _entryWidthOption, _entryHeightOption);

                        int _oldFontSize = UISkin.label.fontSize;
                        UISkin.label.fontSize = (int)(_oldFontSize * 0.5);

                        GUILayout.Label(_eachContact.PhoneNumberList.ToJSON(), _entryWidthOption, _entryHeightOption);
                        GUILayout.Label(_eachContact.EmailIDList.ToJSON(), _entryWidthOption, _entryHeightOption);

                        UISkin.label.fontSize = _oldFontSize;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            m_contactsScrollView.EndScrollView();
        }
Example #8
0
        private static void OnAuthorizedToReadContacts()
        {
            AddressBookContact[] _contactsList = Instance.ContactsList;
            int _totalContacts = _contactsList.Length;

            AddressBookContact[] _contactsListCopy = new AddressBookContact[_totalContacts];

            for (int _iter = 0; _iter < _totalContacts; _iter++)
            {
                _contactsListCopy[_iter] = new EditorAddressBookContact(_contactsList[_iter]);
            }

            // Callback is sent to binding event listener
            NPBinding.AddressBook.InvokeMethod(kABReadContactsFinishedEvent, _contactsListCopy);
        }
Example #9
0
        private void LoadContactsImageAtIndex(int _index)
        {
            AddressBookContact _contactInfo = m_contactsInfo[_index];

            _contactInfo.GetImageAsync((Texture2D _texture, string _error) => {
                if (!string.IsNullOrEmpty(_error))
                {
                    DebugUtility.Logger.LogError(Constants.kDebugTag, "[AddressBook] Contact Picture download failed " + _error);
                    m_contactPictures[_index] = null;
                }
                else
                {
                    m_contactPictures[_index] = _texture;
                }
            });
        }
Example #10
0
        public override void OnEnter()
        {
#if USES_ADDRESS_BOOK
            try
            {
                AddressBookContact _contactInfo = AddressBookUtils.contactsInfoList[atIndex.Value];

                // Update properties
                firstName.Value       = _contactInfo.FirstName;
                lastName.Value        = _contactInfo.LastName;
                phoneNumberList.Value = (_contactInfo.PhoneNumberList == null) ? null : string.Join(";", _contactInfo.PhoneNumberList);
                emailList.Value       = (_contactInfo.EmailIDList == null) ? null : string.Join(";", _contactInfo.EmailIDList);

                // If required, download the image
                if (loadImage.Value)
                {
                    _contactInfo.GetImageAsync((Texture2D _image, string _error) => {
                        // Update image property value
                        image.Value = _image;

                        OnActionDidFinish();

                        return;
                    });
                }
                else
                {
                    // Update image property value
                    image.Value = null;

                    OnActionDidFinish();

                    return;
                }
            }
            catch (System.Exception _exception)
            {
                Debug.Log(_exception.Message);

                OnActionDidFail();

                return;
            }
#endif
        }
Example #11
0
        /// <summary>
        /// Update a contact by modifying the specified parameters.
        /// </summary>
        /// <param name="contact">Initial address book contact</param>
        public void UpdateAddressBookContact(AddressBookContact contact = null)
        {
            // Create the manager with the api key
            var route4Me = new Route4MeManager(ActualApiKey);

            CreateTestContacts();

            if (contact != null)
            {
                contact1 = contact;
            }

            contact1.address_group       = "Updated";
            contact1.schedule_blacklist  = new string[] { "2020-03-14", "2020-03-15" };
            contact1.address_custom_data = new Dictionary <string, string>
            {
                { "key1", "value1" }, { "key2", "value2" }
            };
            contact1.local_time_window_start = R4MeUtils.DDHHMM2Seconds("7:03", out _);
            contact1.local_time_window_end   = R4MeUtils.DDHHMM2Seconds("7:37", out _);
            contact1.AddressCube             = 5;
            contact1.AddressPieces           = 6;
            contact1.AddressRevenue          = 700;
            contact1.AddressWeight           = 80;
            contact1.AddressPriority         = 9;

            var updatableProperties = new List <string>()
            {
                "address_id", "address_group", "schedule_blacklist",
                "address_custom_data", "local_time_window_start", "local_time_window_end",
                "AddressCube", "AddressPieces", "AddressRevenue", "AddressWeight", "AddressPriority", "ConvertBooleansToInteger"
            };

            // Run the query
            var updatedContact = route4Me.UpdateAddressBookContact(
                contact1,
                updatableProperties,
                out string errorString);

            PrintExampleContact(updatedContact, 0, errorString);

            RemoveTestContacts();
        }
        private void DoAction()
        {
#if USES_ADDRESS_BOOK
            int _startIndex        = startIndex.Value;
            int _endIndex          = _startIndex + count.Value - 1;
            int _totalContacts     = AddressBookUtils.GetContactsCount();
            int _imagesToLoad      = count.Value;
            int _loadedImagesCount = 0;

            if (_startIndex < 0 || _startIndex >= _totalContacts)
            {
                OnActionDidFail();

                return;
            }

            if (_endIndex < _startIndex || _endIndex >= _totalContacts)
            {
                OnActionDidFail();

                return;
            }

            // Start downloading contacts image
            for (int _iter = _startIndex; _iter <= _endIndex; _iter++)
            {
                AddressBookContact _currentContact = AddressBookUtils.contactsInfoList[_iter];

                _currentContact.GetImageAsync((Texture2D _image, string _error) => {
                    // Update download completed count
                    _loadedImagesCount++;

                    // Check if we are done with downloading
                    if (_loadedImagesCount == _imagesToLoad)
                    {
                        OnActionDidFinish();

                        return;
                    }
                });
            }
#endif
        }
        public void UpdateAddressBookContact(AddressBookContact contact)
        {
            // Create the manager with the api key
            Route4MeManager route4Me = new Route4MeManager(c_ApiKey);

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

            Console.WriteLine("");

            if (updatedContact != null)
            {
                Console.WriteLine("UpdateAddressBookContact executed successfully");
            }
            else
            {
                Console.WriteLine("UpdateAddressBookContact error: {0}", errorString);
            }
        }
        /// <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();
        }
        public void ReadContacts()
        {
            eABAuthorizationStatus _authStatus = GetAuthorizationStatus();

            if (_authStatus == eABAuthorizationStatus.AUTHORIZED)
            {
                int _totalContacts = m_contactsList.Length;
                AddressBookContact[] _contactsListCopy = new AddressBookContact[_totalContacts];

                for (int _iter = 0; _iter < _totalContacts; _iter++)
                {
                    _contactsListCopy[_iter] = new EditorAddressBookContact(m_contactsList[_iter]);
                }

                // Callback is sent to binding event listener
                SendReadContactsFinishedEvent(eABAuthorizationStatus.AUTHORIZED, _contactsListCopy);
            }
            else
            {
                SendReadContactsFinishedEvent(_authStatus, null);
                return;
            }
        }
 public EditorAddressBookContact(AddressBookContact _source) : base(_source)
 {
 }
Example #17
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");
            }
        }
Example #20
0
        public async Task <AddressBookContact> UpdateAddressBookContactAsync(int addressDbId, AddressBookContact addressBookContactParameters)
        {
            //var addressBookContact = await this.GetAddressBookContactByIdAsync(addressId);
            var contactSpec        = new AddressBookContactSpecification(addressDbId);
            var addressBookContact = _addressBookContactRepository.GetByIdAsync(contactSpec).Result;

            addressBookContactParameters.GetType().GetProperties().ToList()
            .ForEach(async x => {
                if (x.GetValue(addressBookContactParameters) != null && x.Name != "AddressDbId")
                {
                    x.SetValue(addressBookContact, x.GetValue(addressBookContactParameters));
                }
            });

            await this._addressBookContactRepository.UpdateAsync(addressBookContact);

            return(await Task.Run(() =>
            {
                return addressBookContact;
            }));
        }
Example #21
0
        protected override void OnGUIWindow()
        {
            base.OnGUIWindow();

            RootScrollView.BeginScrollView();
            {
                if (GUILayout.Button("Get Authorization Status"))
                {
                    AddNewResult("Authorization Status = " + GetAuthorizationStatus());
                }

                if (GUILayout.Button("Read Contacts"))
                {
                    AddNewResult("Started reading contacts in background. Please wait...");

                    // Read contact info
                    ReadContacts();
                }

                if (m_contactsInfo != null)
                {
                    m_eachColumnWidth = (GetWindowWidth() - GetWindowWidth() * 0.1f) / 5;
                    GUILayoutOption _entryWidthOption      = GUILayout.Width(m_eachColumnWidth);
                    GUILayoutOption _entryHeightOption     = GUILayout.Height(m_eachRowHeight);
                    GUILayoutOption _entryHalfHeightOption = GUILayout.Height(m_eachRowHeight / 2);

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Box("Picture", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                        GUILayout.Box("First Name", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                        GUILayout.Box("Last Name", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                        GUILayout.Box("Phone #'s", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                        GUILayout.Box("Email ID's", kSubTitleStyle, _entryWidthOption, _entryHalfHeightOption);
                    }
                    GUILayout.EndHorizontal();

                    m_contactsScrollView.BeginScrollView();
                    {
                        for (int _i = 0; _i < m_contactsInfo.Length; _i++)
                        {
                            if (_i > m_maxContactsToRender)                             //This is just to limit drawing
                            {
                                break;
                            }

                            AddressBookContact _eachContact = m_contactsInfo[_i];
                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.Label(m_contactPictures[_i], _entryWidthOption, _entryHeightOption);
                                GUILayout.Label(_eachContact.FirstName, _entryWidthOption, _entryHeightOption);
                                GUILayout.Label(_eachContact.LastName, _entryWidthOption, _entryHeightOption);

                                int _oldFontSize = UISkin.label.fontSize;
                                UISkin.label.fontSize = (int)(_oldFontSize * 0.5);

                                GUILayout.Label(_eachContact.PhoneNumberList.ToJSON(), _entryWidthOption, _entryHeightOption);
                                GUILayout.Label(_eachContact.EmailIDList.ToJSON(), _entryWidthOption, _entryHeightOption);

                                UISkin.label.fontSize = _oldFontSize;
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    m_contactsScrollView.EndScrollView();
                }
            }
            RootScrollView.EndScrollView();

            DrawResults();
            DrawPopButton();
        }
Example #22
0
        static void Main(string[] args)
        {
            Route4MeExamples examples = new Route4MeExamples();

            DataObject dataObject = null;

            DataObject dataObject1 = examples.SingleDriverRoute10Stops();

            dataObject = dataObject1;
            string routeId_SingleDriverRoute10Stops = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null;

            int[] destinationIds = examples.AddRouteDestinations(routeId_SingleDriverRoute10Stops);
            if (destinationIds != null && destinationIds.Length > 0)
            {
                examples.RemoveRouteDestination(routeId_SingleDriverRoute10Stops, destinationIds[0]);
            }

            DataObject dataObject2 = examples.SingleDriverRoundTrip();

            dataObject = dataObject2;
            string routeId_SingleDriverRoundTrip = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null;

            string routeIdToMoveTo               = routeId_SingleDriverRoundTrip;
            int    routeDestinationIdToMove      = (dataObject1 != null && dataObject1.Routes != null && dataObject1.Routes.Length > 0 && dataObject1.Routes[0].Addresses.Length > 1 && dataObject1.Routes[0].Addresses[1].RouteDestinationId != null) ? dataObject1.Routes[0].Addresses[1].RouteDestinationId.Value : 0;
            int    afterDestinationIdToMoveAfter = (dataObject2 != null && dataObject2.Routes != null && dataObject2.Routes.Length > 0 && dataObject2.Routes[0].Addresses.Length > 1 && dataObject2.Routes[0].Addresses[0].RouteDestinationId != null) ? dataObject2.Routes[0].Addresses[0].RouteDestinationId.Value : 0;

            if (routeIdToMoveTo != null && routeDestinationIdToMove != 0 && afterDestinationIdToMoveAfter != 0)
            {
                examples.MoveDestinationToRoute(routeIdToMoveTo, routeDestinationIdToMove, afterDestinationIdToMoveAfter);
            }
            else
            {
                System.Console.WriteLine("MoveDestinationToRoute not called. routeDestinationId = {0}, afterDestinationId = {1}.", routeDestinationIdToMove, afterDestinationIdToMoveAfter);
            }

            string optimizationProblemID = examples.SingleDriverRoundTripGeneric();

            dataObject = examples.MultipleDepotMultipleDriver();
            string routeId_MultipleDepotMultipleDriver = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null;

            dataObject = examples.MultipleDepotMultipleDriverTimeWindow();
            string routeId_MultipleDepotMultipleDriverTimeWindow = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null;

            dataObject = examples.SingleDepotMultipleDriverNoTimeWindow();
            string routeId_SingleDepotMultipleDriverNoTimeWindow = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null;

            dataObject = examples.MultipleDepotMultipleDriverWith24StopsTimeWindow();
            string routeId_MultipleDepotMultipleDriverWith24StopsTimeWindow = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null;

            dataObject = examples.SingleDriverMultipleTimeWindows();
            string routeId_SingleDriverMultipleTimeWindows = (dataObject != null && dataObject.Routes != null && dataObject.Routes.Length > 0) ? dataObject.Routes[0].RouteID : null;

            if (optimizationProblemID != null)
            {
                examples.GetOptimization(optimizationProblemID);
            }
            else
            {
                System.Console.WriteLine("GetOptimization not called. optimizationProblemID == null.");
            }

            examples.GetOptimizations();

            if (optimizationProblemID != null)
            {
                examples.AddDestinationToOptimization(optimizationProblemID, true);
            }
            else
            {
                System.Console.WriteLine("AddDestinationToOptimization not called. optimizationProblemID == null.");
            }

            if (optimizationProblemID != null)
            {
                examples.ReOptimization(optimizationProblemID);
            }
            else
            {
                System.Console.WriteLine("ReOptimization not called. optimizationProblemID == null.");
            }

            if (routeId_SingleDriverRoute10Stops != null)
            {
                examples.UpdateRoute(routeId_SingleDriverRoute10Stops);
                examples.ReoptimizeRoute(routeId_SingleDriverRoute10Stops);
                examples.GetRoute(routeId_SingleDriverRoute10Stops);
            }
            else
            {
                System.Console.WriteLine("UpdateRoute, ReoptimizeRoute, GetRoute not called. routeId_SingleDriverRoute10Stops == null.");
            }

            examples.GetRoutes();
            examples.GetUsers();

            if (routeId_SingleDriverRoute10Stops != null)
            {
                examples.GetActivities(routeId_SingleDriverRoute10Stops);
            }
            else
            {
                System.Console.WriteLine("GetActivities not called. routeId_SingleDriverRoute10Stops == null.");
            }

            if (routeIdToMoveTo != null && routeDestinationIdToMove != 0)
            {
                examples.GetAddress(routeIdToMoveTo, routeDestinationIdToMove);

                examples.AddAddressNote(routeIdToMoveTo, routeDestinationIdToMove);
                examples.GetAddressNotes(routeIdToMoveTo, routeDestinationIdToMove);
            }
            else
            {
                System.Console.WriteLine("AddAddressNote, GetAddress, GetAddressNotes not called. routeIdToMoveTo == null || routeDestinationIdToMove == 0.");
            }

            string routeId_DuplicateRoute = null;

            if (routeId_SingleDriverRoute10Stops != null)
            {
                routeId_DuplicateRoute = examples.DuplicateRoute(routeId_SingleDriverRoute10Stops);
            }
            else
            {
                System.Console.WriteLine("DuplicateRoute not called. routeId_SingleDriverRoute10Stops == null.");
            }

            //disabled by default, not necessary for optimization tests
            //not all accounts are capable of storing gps data

            /*if (routeId_SingleDriverRoute10Stops != null)
             * {
             * examples.SetGPSPosition(routeId_SingleDriverRoute10Stops);
             * examples.TrackDeviceLastLocationHistory(routeId_SingleDriverRoute10Stops);
             * }
             * else
             * {
             * System.Console.WriteLine("SetGPSPosition, TrackDeviceLastLocationHistory not called. routeId_SingleDriverRoute10Stops == null.");
             * }*/

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

            if (routeId_SingleDriverRoute10Stops != null)
            {
                routeIdsToDelete.Add(routeId_SingleDriverRoute10Stops);
            }
            if (routeId_SingleDriverRoundTrip != null)
            {
                routeIdsToDelete.Add(routeId_SingleDriverRoundTrip);
            }
            if (routeId_DuplicateRoute != null)
            {
                routeIdsToDelete.Add(routeId_DuplicateRoute);
            }
            if (routeId_MultipleDepotMultipleDriver != null)
            {
                routeIdsToDelete.Add(routeId_MultipleDepotMultipleDriver);
            }
            if (routeId_MultipleDepotMultipleDriverTimeWindow != null)
            {
                routeIdsToDelete.Add(routeId_MultipleDepotMultipleDriverTimeWindow);
            }
            if (routeId_SingleDepotMultipleDriverNoTimeWindow != null)
            {
                routeIdsToDelete.Add(routeId_SingleDepotMultipleDriverNoTimeWindow);
            }
            if (routeId_MultipleDepotMultipleDriverWith24StopsTimeWindow != null)
            {
                routeIdsToDelete.Add(routeId_MultipleDepotMultipleDriverWith24StopsTimeWindow);
            }
            if (routeId_SingleDriverMultipleTimeWindows != null)
            {
                routeIdsToDelete.Add(routeId_SingleDriverMultipleTimeWindows);
            }

            if (routeIdsToDelete.Count > 0)
            {
                examples.DeleteRoutes(routeIdsToDelete.ToArray());
            }
            else
            {
                System.Console.WriteLine("routeIdsToDelete.Count == 0. DeleteRoutes not called.");
            }

            AddressBookContact contact1 = examples.AddAddressBookContact();
            AddressBookContact contact2 = examples.AddAddressBookContact();

            examples.GetAddressBookContacts();
            if (contact1 != null)
            {
                contact1.LastName = "Updated " + (new Random()).Next().ToString();
                examples.UpdateAddressBookContact(contact1);
            }
            else
            {
                System.Console.WriteLine("contact1 == null. UpdateAddressBookContact not called.");
            }
            List <string> addressIdsToRemove = new List <string>();

            if (contact1 != null)
            {
                addressIdsToRemove.Add(contact1.AddressId);
            }
            if (contact2 != null)
            {
                addressIdsToRemove.Add(contact2.AddressId);
            }
            examples.RemoveAddressBookContacts(addressIdsToRemove.ToArray());

            // Avoidance Zones
            string territoryId = examples.AddAvoidanceZone();

            examples.GetAvoidanceZones();
            if (territoryId != null)
            {
                examples.GetAvoidanceZone(territoryId);
            }
            else
            {
                System.Console.WriteLine("GetAvoidanceZone not called. territoryId == null.");
            }
            if (territoryId != null)
            {
                examples.UpdateAvoidanceZone(territoryId);
            }
            else
            {
                System.Console.WriteLine("UpdateAvoidanceZone not called. territoryId == null.");
            }
            if (territoryId != null)
            {
                examples.DeleteAvoidanceZone(territoryId);
            }
            else
            {
                System.Console.WriteLine("DeleteAvoidanceZone not called. territoryId == null.");
            }

            examples.GenericExample();
            examples.GenericExampleShortcut();

            System.Console.WriteLine("");
            System.Console.WriteLine("Press any key");
            System.Console.ReadKey();
        }