static internal void ShowDialog() { RVConfigurationForm rvConfigurationForm = new RVConfigurationForm(rvForm.GetValidationItemNames()); if (rvConfigurationForm.ShowDialog() == DialogResult.Cancel) { return; } // loading Country- and DataConfigFacades requires reading all not yet read country-XML-files, as this is time-consuming use progress-bar List <string> loadedCountries = null; if (rvConfigurationForm.selectedFunction != RVConfigurationForm.COMPARE_VERSIONS) { loadedCountries = LoadCountryConfigFacades(rvConfigurationForm); if (loadedCountries == null) { return; } } // note that it is important to close the RVConfigurationForm before starting the non-modal RVForm, otherwise it disappears with closing the configuration form (see RVConfigurationForm.btnValidate_Click) if (rvConfigurationForm.selectedFunction == RVConfigurationForm.PERFORM_VALIDATION) { rvForm.PerformValidation(rvConfigurationForm.validationItems, loadedCountries, rvConfigurationForm.showProblemsOnly); } if (rvConfigurationForm.selectedFunction == RVConfigurationForm.CREATE_INFO_FILE) { (new RVExcelInfo()).GenerateInfo(rvConfigurationForm.infoFilePath, loadedCountries); } if (rvConfigurationForm.selectedFunction == RVConfigurationForm.COMPARE_VERSIONS) { (new RVCompareVersionsForm(rvConfigurationForm.compareCountryFolder)).ShowDialog(); } }
static List <string> LoadCountryConfigFacades(RVConfigurationForm rvConfigurationForm) { // if validation is to be performed: load the selected countries only; if info-file is to be generated: load all countries List <string> countries = rvConfigurationForm.selectedFunction == RVConfigurationForm.CREATE_INFO_FILE ? (from c in CountryAdministrator.GetCountries() select c._shortName).ToList() : rvConfigurationForm.countries; //the handler passed to the progress indicator will do the work (see below) ProgressIndicator progressIndicator = new ProgressIndicator(GetCountryInfo_BackgroundEventHandler, "Assessing Country Info ...", countries); if (progressIndicator.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(null); // user pressed Cancel } List <string> result = progressIndicator.Result as List <string>; if (result == null) // an exception was thrown while loading countries { UserInfoHandler.ShowError(string.Format("Validation failed with the following error:{0}{1}", Environment.NewLine, progressIndicator.Result.ToString())); return(null); } return(result); // overtake the perhaps now shorter list of countries (due to non-ability to load a country) }