예제 #1
0
        }         // end of method btnAdd_Click

        private void btnDeleteKey_Click(object sender, EventArgs e)
        {
            if (txtKeyName == null || txtKeyName.Text.Length == 0 ||
                txtKeyName.Text.Equals(""))
            {
                UtilityMethod.ShowMessage("Please enter a valid key name as given by the provider!", this,
                                          WeatherLionMain.PROGRAM_NAME + " - No Key Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtKeyName.Focus();
            }// end of if block
            else
            {
                // confirm that user really wishes to delete the key
                string prompt = $"Are you sure that you wish to delete the " +
                                $"{txtKeyName.Text}\nkey assinged by {cboAccessProvider.SelectedItem}?\n" +
                                "This cannot be undone!";

                DialogResult result = MessageBox.Show(prompt, $"{WeatherLionMain.PROGRAM_NAME} + Delete Key", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button1);

                if (result == DialogResult.Yes)
                {
                    if (UtilityMethod.DeleteSiteKeyFromDatabase(cboAccessProvider.SelectedItem.ToString(),
                                                                txtKeyName.Text) == 1)
                    {
                        UtilityMethod.ShowMessage($"The {cboAccessProvider.SelectedItem} {txtKeyName.Text} has " +
                                                  $"been removed from the database.", this, WeatherLionMain.PROGRAM_NAME + " - Success",
                                                  MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtKeyName.Focus();
                    }// end of if block
                    else
                    {
                        UtilityMethod.ShowMessage($"An error occured while removing the {cboAccessProvider.SelectedItem} {txtKeyName.Text}" +
                                                  $"from the database!.\nPlease check the Key Provider and Key Name specified and try again.",
                                                  this, WeatherLionMain.PROGRAM_NAME + " - Deletion Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        txtKeyName.Focus();
                    } // end of else block
                }     // end of if block
                else
                {
                    UtilityMethod.ShowMessage("Key deletion aborted!",
                                              this, WeatherLionMain.PROGRAM_NAME + " - Deletion Aborted", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    txtKeyName.Focus();
                } // end of else block
            }     // end of else block
        }         // end of method btnDeleteKey_Click
        }// end of method BuildRequiredDatabases

        private static void Init()
        {
            if (!LocationCheck())
            {
                UtilityMethod.ShowMessage("The program will not run without a location set.\n"
                                          + "Enjoy the weather!", null, title: $"{PROGRAM_NAME} - Setup");

                Application.Exit(); // terminate the program
            }// end of if block
            else
            {
                UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, "Necessary requirements met...",
                                         $"{TAG}::Init");
                UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, "Launching Weather Widget...",
                                         $"{TAG}::Init");
            } // end of else block
        }     // end of method Init
예제 #3
0
        }// end of default constructor

        public static void Init()
        {
            // create all necessary files if they are not present
            if (!Directory.Exists(databasePath))
            {
                try
                {
                    Directory.CreateDirectory(databasePath);
                    File.Create(databaseFile);
                }// end of try black
                catch (Exception e)
                {
                    UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message,
                                             $"{TAG}::init [line: {UtilityMethod.GetExceptionLineNumber(e)}]");
                } // end of catch block
            }     // end of if block

            if (!File.Exists(databaseFile))
            {
                try
                {
                    File.Create(databaseFile);
                    UtilityMethod.CreateWSADatabase();
                    addKeys.Show();
                }// end of try block
                catch (Exception e)
                {
                    UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message,
                                             $"{TAG}::init [line: {UtilityMethod.GetExceptionLineNumber(e)}]");
                } // end of catch block
            }     // end of if block
            else if (!UtilityMethod.CheckIfTableExists("wak", "access_keys"))
            {
                UtilityMethod.CreateWSADatabase();
                UtilityMethod.ShowMessage(announcement, addKeys, WeatherLionMain.PROGRAM_NAME + " - IMPORTANT",
                                          MessageBoxButtons.OK, MessageBoxIcon.Information);
            }// end of else if block

            LoadAccessProviders();
        }// end of method init
예제 #4
0
        }     // end of method GetSiteKeyFromDatabase

        /**
         * Load all access providers stored in the database
         */
        public static void LoadAccessProviders()
        {
            ArrayList appKeys = new ArrayList();

            webAccessGranted = new List <string>();

            try
            {
                foreach (string provider in WeatherLionMain.providerNames)
                {
                    appKeys = GetSiteKeyFromDatabase(provider);

                    if (appKeys != null)
                    {
                        switch (provider)
                        {
                        case "Dark Sky Weather":

                            foreach (string key in appKeys)
                            {
                                string[] kv = key.Split(':');

                                if (((IList <string>)darkSkyRequiredKeys).Contains(kv[0].ToLower()))
                                {
                                    WidgetUpdateService.darkSkyApiKey = Decrypt(kv[1], kv[2], true);
                                } // end of if block
                            }     // end of for each loop

                            if (WidgetUpdateService.darkSkyApiKey != null)
                            {
                                webAccessGranted.Add("Dark Sky Weather");
                            }    // end of if block

                            break;

                        case "GeoNames":

                            foreach (string key in appKeys)
                            {
                                string[] kv = key.Split(':');

                                if (((IList <string>)geoNamesRequiredKeys).Contains(kv[0].ToLower()))
                                {
                                    WidgetUpdateService.geoNameAccount = Decrypt(kv[1], kv[2], true);
                                } // end of if block
                            }     // end of for each loop

                            if (WidgetUpdateService.geoNameAccount != null)
                            {
                                webAccessGranted.Add("GeoNames");
                                geoNamesAccountLoaded = true;
                            }    // end of if block

                            break;

                        case "Open Weather Map":

                            foreach (string key in appKeys)
                            {
                                string[] kv = key.Split(':');

                                if (((IList <string>)openWeatherMapRequiredKeys).Contains(kv[0].ToLower()))
                                {
                                    WidgetUpdateService.openWeatherMapApiKey = Decrypt(kv[1], kv[2], true);
                                } // end of if block
                            }     // end of for each loop

                            if (WidgetUpdateService.openWeatherMapApiKey != null)
                            {
                                webAccessGranted.Add("Open Weather Map");
                            }    // end of if block

                            break;

                        case "Weather Bit":

                            foreach (string key in appKeys)
                            {
                                string[] kv = key.Split(':');

                                if (((IList <string>)weatherBitRequiredKeys).Contains(kv[0].ToLower()))
                                {
                                    WidgetUpdateService.weatherBitApiKey = Decrypt(kv[1], kv[2], true);
                                } // end of if block
                            }     // end of for each loop

                            if (WidgetUpdateService.weatherBitApiKey != null)
                            {
                                webAccessGranted.Add("Weather Bit");
                            }    // end of if block

                            break;

                        case "Here Maps Weather":

                            foreach (string key in appKeys)
                            {
                                string[] kv = key.Split(':');

                                if (((IList <string>)hereMapsRequiredKeys).Contains(kv[0].ToLower()))
                                {
                                    switch (kv[0].ToLower())
                                    {
                                    case "app_id":
                                        WidgetUpdateService.hereAppId = Decrypt(kv[1], kv[2], true);
                                        break;

                                    case "app_code":
                                        WidgetUpdateService.hereAppCode = Decrypt(kv[1], kv[2], true);
                                        break;

                                    default:
                                        break;
                                    } // end of switch block
                                }     // end of if block
                            }         // end of for each loop

                            if (WidgetUpdateService.hereAppId != null && WidgetUpdateService.hereAppCode != null)
                            {
                                webAccessGranted.Add("Here Maps Weather");
                            }    // end of if block
                            else if (WidgetUpdateService.hereAppId != null && WidgetUpdateService.hereAppCode == null)
                            {
                                UtilityMethod.ShowMessage("Here Maps Weather requires an app_code which is"
                                                          + " not stored in the database.", title: WeatherLionMain.PROGRAM_NAME + " - Missing Key",
                                                          mbIcon: MessageBoxIcon.Error);
                            }    // end of if block
                            else if (WidgetUpdateService.hereAppId == null && WidgetUpdateService.hereAppCode != null)
                            {
                                UtilityMethod.ShowMessage("Here Maps Weather requires an app_id which is"
                                                          + " not stored in the database.", title: WeatherLionMain.PROGRAM_NAME + " - Missing Key",
                                                          mbIcon: MessageBoxIcon.Error);
                            }    // end of if block
                            break;

                        case "Yahoo! Weather":
                            List <string> keysFound = new List <string>();

                            foreach (string key in appKeys)
                            {
                                string[] kv = key.Split(':');

                                if (((IList <string>)yahooRequiredKeys).Contains(kv[0].ToLower()))
                                {
                                    switch (kv[0].ToLower())
                                    {
                                    case "app_id":
                                        WidgetUpdateService.yahooAppId = Decrypt(kv[1], kv[2], true);
                                        keysFound.Add("app_id");
                                        break;

                                    case "consumer_key":
                                        WidgetUpdateService.yahooConsumerKey = Decrypt(kv[1], kv[2], true);
                                        keysFound.Add("consumer_key");
                                        break;

                                    case "consumer_secret":
                                        WidgetUpdateService.yahooConsumerSecret = Decrypt(kv[1], kv[2], true);
                                        keysFound.Add("consumer_secret");
                                        break;

                                    default:
                                        break;
                                    } // end of switch block
                                }     // end of if block
                            }         // end of for each loop

                            // remove all the keys that were found from the list
                            keysMissing = new List <string>(((IList <string>)yahooRequiredKeys).Except(keysFound).ToList());

                            if (keysMissing.Count == 0)
                            {
                                webAccessGranted.Add("Yahoo! Weather");
                            }    // end of if block
                            else
                            {
                                // do not check for missing keys if the form is already displayed
                                if (!addKeys.Visible)
                                {
                                    if (CheckForMissingKeys() == DialogResult.Yes)
                                    {
                                        AccessKeysForm.frmKeys.cboAccessProvider.SelectedItem = "Yahoo! Weather";
                                        AccessKeysForm.frmKeys.Visible = true;
                                        AccessKeysForm.frmKeys.Focus();
                                    }    // end of if block
                                    else
                                    {
                                        string msg = "Yahoo!Weather cannot be used as a weather source without "
                                                     + "first adding the missing " + (keysMissing.Count > 1 ? "keys" : "key") + ".";

                                        UtilityMethod.ShowMessage(msg, AccessKeysForm.frmKeys, title: $"{WeatherLionMain.PROGRAM_NAME} - Missing Key", buttons: MessageBoxButtons.OK,
                                                                  mbIcon: MessageBoxIcon.Information);
                                    } // end of else block
                                }     // end of if block
                                else
                                {
                                    AccessKeysForm.frmKeys.txtKeyName.Focus();
                                } // end of else block
                            }     // end of else block

                            break;

                        default:
                            break;
                        } // end of switch block
                    }     // end of if block
                }         // end of outer for each loop
            }             // end of try block
            catch (Exception e)
            {
                UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, e.Message,
                                         $"{TAG}::LoadAccessProviders [line: {UtilityMethod.GetExceptionLineNumber(e)}]");
            }// end of catch block

            // add the only weather provider that does not require a key
            webAccessGranted.Add(WeatherLionMain.YR_WEATHER);

            if (webAccessGranted.Count > 0)
            {
                string s  = string.Join(", ", webAccessGranted);
                string fs = null;

                if (UtilityMethod.NumberOfCharacterOccurences(',', s) > 1)
                {
                    fs = UtilityMethod.ReplaceLast(",", ", and", s);
                }// end of if block
                else if (UtilityMethod.NumberOfCharacterOccurences(',', s) == 1)
                {
                    fs = s.Replace(",", " and");
                }// end of else block
                else
                {
                    fs = s;
                }// end of else block

                UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, $"The following access providers were loaded:\n{fs}.",
                                         $"{TAG}::LoadAccessProviders");
            }// end of if block
            else
            {
                UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, "No valid access privelages were stored in the database!",
                                         $"{TAG}::LoadAccessProviders");
            }// end of else block

            if (webAccessGranted.Count == 0)
            {
                if (NoAccessPrivialgesStored() == DialogResult.Yes)
                {
                    if (!AccessKeysForm.frmKeys.Visible)
                    {
                        AccessKeysForm.frmKeys.ShowDialog();
                        AccessKeysForm.frmKeys.Focus();
                    }// end of if block
                    else
                    {
                        AccessKeysForm.frmKeys.txtKeyName.Focus();
                    }// end of else block
                }
                else
                {
                    UtilityMethod.MissingRequirementsPrompt("Insufficient Access Privilages");
                } // end of if block
            }     // end of if block

            if (webAccessGranted.Count >= 1 && !geoNamesAccountLoaded)
            {
                UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE, "GeoNames user name not found!",
                                         $"{TAG}::LoadAccessProviders");

                // confirm that user has a GeoNames account and want's to store it
                string prompt = "This program requires a geonames username\n" +
                                "which was not stored in the database. IT IS FREE!" +
                                "\nDo you wish to add it now?";

                DialogResult result = MessageBox.Show(prompt, $"{WeatherLionMain.PROGRAM_NAME} - Add Access Privialges",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                if (result == DialogResult.Yes)
                {
                    //AccessKeysForm kf = AccessKeysForm.frmKeys;

                    if (!AccessKeysForm.frmKeys.Visible)
                    {
                        AccessKeysForm.frmKeys.m_key_provider = "GeoNames";
                        AccessKeysForm.frmKeys.ShowDialog();
                    }// end of if block
                    else
                    {
                        AccessKeysForm.frmKeys.cboAccessProvider.SelectedItem = "GeoNames";
                        AccessKeysForm.frmKeys.pwdKeyValue.Focus();
                    } // end of else block
                }     // end of if block
                else
                {
                    UtilityMethod.MissingRequirementsPrompt("Insufficient Access Privilages");
                } // end of else block
            }     // end of else if block

            // if valid access was not loaded for the provider previously used, take it into account
            if (WeatherLionMain.storedPreferences != null)
            {
                if (!webAccessGranted.Contains(WeatherLionMain.storedPreferences.StoredPreferences.Provider))
                {
                    WeatherLionMain.noAccessToStoredProvider = true;
                }// end of if block
                else
                {
                    WeatherLionMain.noAccessToStoredProvider = false;
                } // end of else block
            }     // end of if block
        }         // end of method LoadAccessProcviders
예제 #5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtKeyName == null || txtKeyName.Text.Length == 0 ||
                txtKeyName.Text.Equals(""))
            {
                UtilityMethod.ShowMessage("Please enter a valid key name as given by the provider!", this,
                                          WeatherLionMain.PROGRAM_NAME + " - No Key Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtKeyName.Focus();
            }// end of if block
            else if (pwdKeyValue == null || pwdKeyValue.Text.Length == 0 ||
                     pwdKeyValue.Text.Equals(""))
            {
                UtilityMethod.ShowMessage("Please enter a valid key value as given by the provider!", this,
                                          WeatherLionMain.PROGRAM_NAME + " - No Key Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
                pwdKeyValue.Focus();
            }// end of else if block
            else
            {
                string[] encryptedKey     = LionSecurityManager.Encrypt(pwdKeyValue.Text, true).Split(':');
                string   selectedProvider = cboAccessProvider.SelectedItem.ToString();

                switch (selectedProvider)
                {
                case "Here Maps Weather":
                    if (!LionSecurityManager.hereMapsRequiredKeys.Contains(txtKeyName.Text.ToLower()))
                    {
                        UtilityMethod.ShowMessage($"The {selectedProvider} does not require a key \"{ txtKeyName.Text}\"!",
                                                  this, $"{WeatherLionMain.PROGRAM_NAME} - Invalid Key Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtKeyName.Focus();

                        return;
                    }    // end of if block

                    break;

                case "Yahoo! Weather":
                    if (!LionSecurityManager.yahooRequiredKeys.Contains(txtKeyName.Text.ToLower()))
                    {
                        UtilityMethod.ShowMessage($"The {selectedProvider} does not require a key \"{ txtKeyName.Text}\"!",
                                                  this, $"{WeatherLionMain.PROGRAM_NAME} - Invalid Key Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtKeyName.Focus();

                        return;
                    }    // end of if block

                    break;

                default:
                    break;
                }// end of switch block

                if (UtilityMethod.AddSiteKeyToDatabase(cboAccessProvider.SelectedItem.ToString(),
                                                       txtKeyName.Text, encryptedKey[0], encryptedKey[1]) == 1)
                {
                    if (txtKeyName.Enabled)
                    {
                        txtKeyName.Text = ("");
                    }
                    pwdKeyValue.Text = "";

                    UtilityMethod.ShowMessage("The key was successfully added to the database.", this,
                                              WeatherLionMain.PROGRAM_NAME + " - Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtKeyName.Focus();
                }// end of if block
                else
                {
                    UtilityMethod.ShowMessage("The key could not be added to the database!"
                                              + "\nPlease recheck the key and try again.", this,
                                              WeatherLionMain.PROGRAM_NAME + " - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtKeyName.Focus();
                } // end of else block
            }     // end of else block
        }         // end of method btnAdd_Click
예제 #6
0
        }         // end of method btnDeleteKey_Click

        private void btnFinish_Click(object sender, EventArgs e)
        {
            LionSecurityManager.LoadAccessProviders();

            if (LionSecurityManager.keysMissing != null)
            {
                if (LionSecurityManager.keysMissing.Count > 0)
                {
                    DialogResult answer = LionSecurityManager.CheckForMissingKeys();
                    LionSecurityManager.accessGranted = false;

                    if (answer == DialogResult.Yes)
                    {
                        if (!Visible)
                        {
                            Visible = true;
                        }// end of if block
                        else
                        {
                            txtKeyName.Focus();
                        } // end of else block
                    }     // end of if block
                    else
                    {
                        string wp = null;
                        //string[] keys = null;

                        if (LionSecurityManager.keysMissing.Count > 1)
                        {
                            List <string> missingHereKeys  = new List <string>();
                            List <string> missingYahooKeys = new List <string>();

                            foreach (string keyName in LionSecurityManager.keysMissing)
                            {
                                if (LionSecurityManager.hereMapsRequiredKeys.Contains(keyName))
                                {
                                    missingHereKeys.Add(keyName);
                                }// end of if block
                                else if (LionSecurityManager.hereMapsRequiredKeys.Contains(keyName))
                                {
                                    missingYahooKeys.Add(keyName);
                                } // end of else if block
                            }     // end of for each loop

                            if (missingHereKeys.Count > 0)
                            {
                                string hKeys = string.Join(", ", missingHereKeys);
                                string fs    = null;

                                if (UtilityMethod.NumberOfCharacterOccurences(',', hKeys) > 1)
                                {
                                    fs = UtilityMethod.ReplaceLast(",", ", and", hKeys);
                                }// end of if block
                                else if (UtilityMethod.NumberOfCharacterOccurences(',', hKeys) == 1)
                                {
                                    fs = hKeys.Replace(",", " and");
                                }// end of else block
                                else
                                {
                                    fs = hKeys;
                                }// end of else block

                                wp = WeatherLionMain.HERE_MAPS;
                                string kc = missingHereKeys.Count > 1 ? "keys" : "key";

                                UtilityMethod.ShowMessage($"{wp} cannot be used as a weather source without\n"
                                                          + $"first adding the missing {kc} {fs}.", this, $"{WeatherLionMain.PROGRAM_NAME} - Missing Key", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }// end of if block

                            if (missingYahooKeys.Count > 0)
                            {
                                string hKeys = string.Join(", ", missingHereKeys);
                                string fs    = null;

                                if (UtilityMethod.NumberOfCharacterOccurences(',', hKeys) > 1)
                                {
                                    fs = UtilityMethod.ReplaceLast(",", ", and", hKeys);
                                }// end of if block
                                else if (UtilityMethod.NumberOfCharacterOccurences(',', hKeys) == 1)
                                {
                                    fs = hKeys.Replace(",", " and");
                                }// end of else block
                                else
                                {
                                    fs = hKeys;
                                }// end of else block

                                wp = WeatherLionMain.YAHOO_WEATHER;
                                string kc = missingHereKeys.Count > 1 ? "keys" : "key";

                                UtilityMethod.ShowMessage($"{wp} cannot be used as a weather source without\n"
                                                          + $"first adding the missing {kc} {fs}.", this,
                                                          title: $"{WeatherLionMain.PROGRAM_NAME} - Missing Key", buttons: MessageBoxButtons.OK,
                                                          mbIcon: MessageBoxIcon.Error);
                            } // end of if block
                        }     // end of if block
                    }         // end of else block
                }             // end of if block
            }                 // end of if block

            if (LionSecurityManager.webAccessGranted.Count >= 1 &&
                !LionSecurityManager.webAccessGranted.Contains("GeoNames"))
            {
                UtilityMethod.ShowMessage("This program requires a geonames username"
                                          + " which was not stored in the database.\nIT IS FREE!", this,
                                          title: $"{WeatherLionMain.PROGRAM_NAME} - Missing Key", buttons: MessageBoxButtons.OK,
                                          mbIcon: MessageBoxIcon.Error);
            }// end of else if block
            else if (LionSecurityManager.webAccessGranted.Count == 2 &&
                     LionSecurityManager.webAccessGranted.Contains("GeoNames") &&
                     LionSecurityManager.webAccessGranted.Contains("Yr.no (Norwegian Metrological Institute)"))
            {
                UtilityMethod.ShowMessage("The program will only display weather data from"
                                          + " Yr.no (Norwegian Metrological Institute).\nObtain access keys for"
                                          + " the others if you wish to use them.", this,
                                          title: $"{WeatherLionMain.PROGRAM_NAME} - Single Weather Providery", buttons: MessageBoxButtons.OK,
                                          mbIcon: MessageBoxIcon.Information);
                LionSecurityManager.accessGranted = true;
                Close();
            }// end of else if block
            else
            {
                LionSecurityManager.accessGranted = true;
                Close();
            } // end of else block
        }     // end of method btnFinish_Click
        }                     // end of method HealthCheck

        public static bool LocationCheck()
        {
            bool locationSet = false;

            if (storedPreferences.StoredPreferences.Location.Equals("not set"))
            {
                DialogResult setCurrentCity;

                if (systemLocation != null)
                {
                    string prompt = "You must specify a current location in order to run the program. " +
                                    $"Your current location is detected as {systemLocation}.\n" +
                                    "Would you like to use it as your current location?";

                    DialogResult useSystemLocation = UtilityMethod.ResponseBox(prompt, PROGRAM_NAME + " - Setup");

                    if (useSystemLocation == DialogResult.Yes)
                    {
                        storedPreferences.StoredPreferences.UseSystemLocation = true;
                        storedPreferences.StoredPreferences.Location          = systemLocation;

                        Preference.SaveProgramConfiguration("prefs", "UseSystemLocation", "true");
                        Preference.SaveProgramConfiguration("prefs", "Location", systemLocation);

                        // save the city to the local WorldCites database
                        UtilityMethod.AddCityToDatabase(
                            currentCity.cityName, currentCity.countryName, currentCity.countryCode,
                            currentCity.regionName, currentCity.regionCode, currentCity.latitude,
                            currentCity.longitude);

                        JSONHelper.ExportToJSON(currentCity);
                        XMLHelper.ExportToXML(currentCity);

                        locationSet = true;
                        Application.Run(new WidgetForm());
                    }// end of if block
                    else
                    {
                        prompt = "You must specify a current location in order to run the program.\n" +
                                 "Would you like to specify it now?";

                        setCurrentCity = UtilityMethod.ResponseBox(prompt, PROGRAM_NAME + " - Setup");

                        if (setCurrentCity == DialogResult.Yes)
                        {
                            preferences.ShowDialog();

                            // loop until a city is selected
                            while (PreferencesForm.locationSelected)
                            {
                                UtilityMethod.LogMessage(UtilityMethod.LogLevel.WARNING, "Waiting for location to be set!",
                                                         $"{TAG}::LocationCheck");
                            }// end of while loop

                            locationSet = PreferencesForm.locationSelected;
                        } // end of if block
                    }     // end of else block
                }         // end of if block
                else
                {
                    setCurrentCity = UtilityMethod.ResponseBox("You must specify a current location in order to run the program.\n"
                                                               + "Would you like to specify it now?",
                                                               WeatherLionMain.PROGRAM_NAME + " Setup");

                    if (setCurrentCity == DialogResult.Yes)
                    {
                        preferences.Show();

                        // loop until a city is selected
                        while (!PreferencesForm.locationSelected)
                        {
                            Console.WriteLine("Waiting for location to be set!");
                        }// end of while loop

                        locationSet = PreferencesForm.locationSelected;
                    }// end of if block
                    else
                    {
                        UtilityMethod.ShowMessage("The program will not run without a location set.\nGoodbye.", null,
                                                  title: $"{WeatherLionMain.PROGRAM_NAME}", buttons: MessageBoxButtons.OK,
                                                  mbIcon: MessageBoxIcon.Information);
                        Application.Exit();     //Exit the application.
                    }// end of else block
                }// end of else block
            }// end of if block
            else
            {
                // the location was already set
                locationSet = true;
            }// end of else block

            return(locationSet);
        } // end of method LocationCheck
        /// <summary>
        /// Load a required assets and prepare for program execution
        /// </summary>
        public static void Launch()
        {
            #region WeatherLion launch sequence

            UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO, "Initiating startup...", "WeatherLionMain::Launch");

            // build the required storage files
            if (BuildRequiredDatabases() == 1)
            {
                UtilityMethod.LogMessage(UtilityMethod.LogLevel.INFO,
                                         "All required databases constructed successfully.",
                                         "WeatherLionMain::Launch");
            }// end of if block
            else
            {
                UtilityMethod.LogMessage(UtilityMethod.LogLevel.SEVERE,
                                         "All required databases were not constructed successfully.",
                                         "WeatherLionMain::Launch");
            }// end of else block

            // check that the required access keys are available
            LionSecurityManager.Init();

            // Load only the providers who have access keys assigned to them
            List <string> wxOnly = LionSecurityManager.webAccessGranted;

            wxOnly.Sort();  // sort the list

            // GeoNames is not a weather provider so it cannot be select here
            wxOnly.Remove("GeoNames");

            authorizedProviders = wxOnly.ToArray();

            // ensure that program has all the default assets needed for functioning properly
            HealthCheck();

            // load user preferences
            storedPreferences = Preference.GetSavedPreferences();

            string previousWeatherData = $"{DATA_DIRECTORY_PATH}{WEATHER_DATA_XML}";

            connectedToInternet = UtilityMethod.HasInternetConnection();

            // check for an Internet connection or previous weather data stored local
            if (!connectedToInternet && !File.Exists(previousWeatherData))
            {
                UtilityMethod.ShowMessage("The program will not run without a working internet connection or "
                                          + "data that was previously stored locally" +
                                          "\nResolve your Internet connection and relaunch the program.", null);

                Application.Exit(); // terminate the program
            }// end of if block
            else if (connectedToInternet)
            {
                // obtain the current city of the connected Internet service
                currentCity = UtilityMethod.GetSystemLocation();

                if (currentCity != null)
                {
                    if (currentCity.regionCode != null)
                    {
                        systemLocation = $"{currentCity.cityName}, {currentCity.regionCode}";
                    }// end of if block
                    else
                    {
                        systemLocation = $"{currentCity.cityName}, {currentCity.countryName}";
                    } // end of else block
                }     // end of if block

                // if the user requires the current detected city location to be used as default
                if (storedPreferences.StoredPreferences.UseSystemLocation)
                {
                    if (systemLocation != null)
                    {
                        // use the detected city location as the default
                        storedPreferences.StoredPreferences.Location = systemLocation;

                        if (!storedPreferences.StoredPreferences.Location.Equals(systemLocation))
                        {
                            // update the preferences file
                            Preference.SaveProgramConfiguration("prefs", "Location", systemLocation);

                            // save the city to the local WorldCites database
                            UtilityMethod.AddCityToDatabase(
                                currentCity.cityName, currentCity.countryName,
                                currentCity.countryCode, currentCity.regionName,
                                currentCity.regionCode, currentCity.latitude,
                                currentCity.longitude);

                            JSONHelper.ExportToJSON(currentCity);
                            XMLHelper.ExportToXML(currentCity);
                        } // end of if block
                    }     // end of if block
                    else
                    {
                        UtilityMethod.ShowMessage("The program was unable to obtain your system's location."
                                                  + "\nYour location will have to be set manually using the preferences dialog.", null);

                        PreferencesForm pf = new PreferencesForm();
                        pf.Show();
                    } // end of else block
                }     // end of if block
            }         // end of else if block

            Init();

            #endregion
        }// end of method Launch