}// end of method init /// <summary> /// Checks to see if any provider stored in the database is missing a key /// that is required. /// </summary> /// <returns></returns> public static DialogResult CheckForMissingKeys() { string mks = string.Join(", ", keysMissing); string fMks = null; if (UtilityMethod.NumberOfCharacterOccurences(',', mks) > 1) { fMks = UtilityMethod.ReplaceLast(",", ", and", mks); }// end of if block else if (UtilityMethod.NumberOfCharacterOccurences(',', mks) == 1) { fMks = mks.Replace(",", " and"); }// end of else block else { fMks = mks; }// end of else block string prompt = "Yahoo! Weather requires the following missing " + (keysMissing.Count > 1 ? "keys" : "key") + ":\n" + fMks + "\nDo you wish to add " + (keysMissing.Count > 1 ? "them" : "it") + " now?"; DialogResult result = UtilityMethod.ResponseBox(prompt, WeatherLionMain.PROGRAM_NAME + " - Add Missing Key"); return(result); }// end of message CheckForMissingKeys
} // 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