internal static List <AddOnSystemInfo> GetAddOnSystemInfo(string addOnShortName) { List <AddOnSystemInfo> addOnSystemInfoList = new List <AddOnSystemInfo>(); CountryConfigFacade countryConfigFacade = CountryAdministrator.GetCountryConfigFacade(addOnShortName); foreach (CountryConfig.SystemRow addOnSystemRow in countryConfigFacade.GetSystemRows()) { AddOnSystemInfo addOnSystemInfo = new AddOnSystemInfo(addOnShortName, addOnSystemRow.Name); //assess supported/excluded systems from func_AddOn_Applic List <CountryConfig.FunctionRow> functionAddOnApplic = countryConfigFacade.GetFunctionRowsBySystemIDAndFunctionName(addOnSystemRow.ID, DefFun.AddOn_Applic); if (functionAddOnApplic.Count <= 0) { continue; //no AddOn_Applic found - system is in fact not available } foreach (CountryConfig.ParameterRow parameterRow in functionAddOnApplic.First().GetParameterRows()) { if (parameterRow.Name.ToLower().StartsWith(DefPar.AddOn_Applic.Sys.ToLower())) { addOnSystemInfo._supportedSystems.Add(parameterRow.Value.ToLower()); } if (parameterRow.Name.ToLower().StartsWith(DefPar.AddOn_Applic.SysNA.ToLower())) { addOnSystemInfo._notSupportedSystems.Add(parameterRow.Value.ToLower()); } } addOnSystemInfoList.Add(addOnSystemInfo); } return(addOnSystemInfoList); }
string HasActiveFunction(string country, string functionName) { CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); string faulty = string.Empty; foreach (CountryConfig.SystemRow system in GetPublicSystems(country)) { foreach (CountryConfig.PolicyRow pol in system.GetPolicyRows()) { if (pol.Private != DefPar.Value.YES && pol.Switch == DefPar.Value.ON) { foreach (CountryConfig.FunctionRow fun in pol.GetFunctionRows()) { if (fun.Name == functionName && fun.Private != DefPar.Value.YES && fun.Switch == DefPar.Value.ON) { faulty += system.Name + ", "; break; } } } } } return(faulty); }
static void GetCountryInfo_BackgroundEventHandler(object sender, DoWorkEventArgs e) { BackgroundWorker backgroundWorker = sender as BackgroundWorker; if (backgroundWorker.CancellationPending) { e.Result = null; e.Cancel = true; return; } //user pressed Cancel button: stop the process and allow progress indicator to set dialog result to Cancel try // this is just to read the country- and data-XML-files, not to do anything with them or store the ConfigFacades { // the CountryAdministrator will keept them in memory and thus quick-access by the RVTable-derived classes is possible List <string> countries = e.Argument as List <string>; List <int> faultyCountries = new List <int>(); for (int i = 0; i < countries.Count; ++i) { if (CountryAdministrator.GetCountryConfigFacade(countries[i]) == null || CountryAdministrator.GetDataConfigFacade(countries[i]) == null) { faultyCountries.Add(i); } backgroundWorker.ReportProgress(Convert.ToInt32((i + 1.0) / (countries.Count * 1.0) * 100.0)); } for (int f = faultyCountries.Count - 1; f >= 0; --f) { countries.RemoveAt(f); } e.Result = countries; } catch (Exception exception) { e.Result = exception.Message; backgroundWorker.ReportProgress(100); } }
internal CountryConfig.SystemRow PerformAddOnGeneration(string newSystemName, string countryShortName, string addOnShortName, string baseSystemName, string addOnSystemName) { //get the county's and add-on's data CountryConfigFacade baseCountryConfigFacade = CountryAdministrator.GetCountryConfigFacade(countryShortName); _addOnCountryConfigFacade = CountryAdministrator.GetCountryConfigFacade(addOnShortName); //get the base-system and the add-on-system CountryConfig.SystemRow baseSystemRow = baseCountryConfigFacade.GetSystemRowByName(baseSystemName); _addOnSystemRow = _addOnCountryConfigFacade.GetSystemRowByName(addOnSystemName); //add-on-system will be stored in an CountryConfig generated for the purpose of storing it _mergeCountryConfigFacade = new CountryConfigFacade(countryShortName); //generate a copy of the base-system, by keeping all ids except the system id identically: otherwise the id-references (e.g. in ChangeParam, AddOn_Par, etc. would not work) _mergeSystemRow = CountryConfigFacade.CopySystemRowToAnotherCountry(baseSystemRow, _addOnSystemRow.Name, _mergeCountryConfigFacade.GetCountryConfig(), true); _mergeSystemRow.Name = newSystemName; //add policies following instructions in AddOn_Pol-functions AddPolicies(); //add functions following instructions in AddOn_Func-functions AddFunctions(); //add parameters following instructions in AddOn_Par-functions AddParameters(); //replace e.g. yse_uk_#2 respectively yse_uk_#2.4 by the actual id of this function respectively parameter ReplaceSymbolicIDsInChangeParam(); return(_errorMessages == string.Empty ? _mergeSystemRow : null); }
internal override void PerformAction() { CountryConfig countryConfig = CountryAdministrator.GetCountryConfigFacade(cc).GetCountryConfig(); ExtensionAndGroupMenuManager.GetSelectionPolFunPar(cc, out selectedPolRows, out selectedFunRows, out List <CountryConfig.ParameterRow> parRows); string extensionID = (from e in ExtensionAndGroupManager.GetExtensions(cc) where e.Name == extensionName select e.ID).FirstOrDefault(); if (extensionID == null) { return; } List <CountryConfig.Extension_PolicyRow> delPolicyRows = new List <CountryConfig.Extension_PolicyRow>(); List <CountryConfig.Extension_FunctionRow> delFunctionRows = new List <CountryConfig.Extension_FunctionRow>(); List <CountryConfig.Extension_ParameterRow> delParameterRows = new List <CountryConfig.Extension_ParameterRow>(); foreach (CountryConfig.PolicyRow policyRow in selectedPolRows) { selectedFunRows.AddRange(policyRow.GetFunctionRows()); // to make sure that all functions of the policy are removed as well - note: the AddContent-function // does not remove a single function if its parent-policy is added (later) foreach (CountryConfig.Extension_PolicyRow del in from pe in countryConfig.Extension_Policy where pe.ExtensionID == extensionID& pe.PolicyID == policyRow.ID select pe) { if (!delPolicyRows.Contains(del)) { delPolicyRows.Add(del); // theoretically (but stupidly) this can be 2 (off and on) } } } foreach (CountryConfig.FunctionRow functionRow in selectedFunRows) { parRows.AddRange(functionRow.GetParameterRows()); // see above foreach (CountryConfig.Extension_FunctionRow del in from fe in countryConfig.Extension_Function where fe.ExtensionID == extensionID& fe.FunctionID == functionRow.ID select fe) { if (!delFunctionRows.Contains(del)) { delFunctionRows.Add(del); } } } foreach (CountryConfig.ParameterRow parameterRow in parRows) { foreach (CountryConfig.Extension_ParameterRow del in from pe in countryConfig.Extension_Parameter where pe.ExtensionID == extensionID& pe.ParameterID == parameterRow.ID select pe) { if (!delParameterRows.Contains(del)) { delParameterRows.Add(del); } } } for (int i = delPolicyRows.Count - 1; i >= 0; --i) { delPolicyRows[i].Delete(); } for (int i = delFunctionRows.Count - 1; i >= 0; --i) { delFunctionRows[i].Delete(); } for (int i = delParameterRows.Count - 1; i >= 0; --i) { delParameterRows[i].Delete(); } }
internal static Dictionary <string, string> GetSystemAssignement(EM_UI_MainForm copyCountryMainForm, EM_UI_MainForm pasteCountryMainForm, List <string> pasteCountryHiddenSystems) { Dictionary <string, string> pasteSystemsNamesAndIDs = new Dictionary <string, string>(); Dictionary <string, string> copySystemNamesAndIDs = new Dictionary <string, string>(); foreach (CountryConfig.SystemRow systemRow in CountryAdministrator.GetCountryConfigFacade(pasteCountryMainForm.GetCountryShortName()).GetSystemRows()) { if (!pasteCountryHiddenSystems.Contains(systemRow.ID)) { pasteSystemsNamesAndIDs.Add(systemRow.Name, systemRow.ID); } } foreach (CountryConfig.SystemRow systemRow in CountryAdministrator.GetCountryConfigFacade(copyCountryMainForm.GetCountryShortName()).GetSystemRows()) { copySystemNamesAndIDs.Add(systemRow.Name, systemRow.ID); } AssignSystemsForm assignSystemsForm = new AssignSystemsForm(pasteCountryMainForm.GetCountryShortName(), pasteSystemsNamesAndIDs, copyCountryMainForm.GetCountryShortName(), copySystemNamesAndIDs); if (assignSystemsForm.ShowDialog() == DialogResult.Cancel) { return(null); } return(assignSystemsForm.GetSystemAssignment()); }
private void lstCountries_SelectedIndexChanged(object sender = null, EventArgs e = null) { if (radShowYears.Checked) { return; } Cursor = Cursors.WaitCursor; try { lstSystems.Items.Clear(); foreach (string c in lstCountries.SelectedItems) { if (!ccSystems.ContainsKey(c)) { ccSystems.Add(c, (from s in CountryAdministrator.GetCountryConfigFacade(c).GetSystemRowsOrdered() select s.Name).ToList()); } foreach (string s in ccSystems[c]) { lstSystems.Items.Add(s); } } } catch (Exception exception) { UserInfoHandler.ShowError(exception.Message); } Cursor = Cursors.Default; }
internal override void PerformAction() { ExtensionAndGroupMenuManager.GetSelectionPolFunPar(cc, out List <CountryConfig.PolicyRow> polRows, out List <CountryConfig.FunctionRow> funRows, out List <CountryConfig.ParameterRow> parRows); CountryConfig countryConfig = CountryAdministrator.GetCountryConfigFacade(cc).GetCountryConfig(); CountryConfig.LookGroupRow groupRow = (from lg in countryConfig.LookGroup where lg.Name.ToLower() == groupName.ToLower() select lg).First(); foreach (CountryConfig.PolicyRow policyRow in polRows) { if (!(from pg in countryConfig.LookGroup_Policy where pg.PolicyID == policyRow.ID && pg.LookGroupID == groupRow.ID select pg).Any()) { countryConfig.LookGroup_Policy.AddLookGroup_PolicyRow(groupRow, policyRow); // make sure to not add twice (and thus crash) } } foreach (CountryConfig.FunctionRow functionRow in funRows) { if (!(from fg in countryConfig.LookGroup_Function where fg.FunctionID == functionRow.ID && fg.LookGroupID == groupRow.ID select fg).Any()) { countryConfig.LookGroup_Function.AddLookGroup_FunctionRow(groupRow, functionRow); } } foreach (CountryConfig.ParameterRow parameterRow in parRows) { if (!(from pg in countryConfig.LookGroup_Parameter where pg.ParameterID == parameterRow.ID && pg.LookGroupID == groupRow.ID select pg).Any()) { countryConfig.LookGroup_Parameter.AddLookGroup_ParameterRow(groupRow, parameterRow); } } }
internal override void PerformValidation(List <string> countries, bool showProblemsOnly) { base.PerformValidation(countries, showProblemsOnly); string noHICP = string.Empty, notDollarF = string.Empty, emptyFactors = string.Empty, zeroFactors = string.Empty, noYearForSystem = string.Empty, noYearForData = string.Empty, noIncomeYear = string.Empty; foreach (string country in countries) { CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); DataConfigFacade dcf = CountryAdministrator.GetDataConfigFacade(country); List <CountryConfig.UpratingIndexRow> indices = (from ui in ccf.GetUpratingIndices() select ui).ToList(); List <CountryConfig.SystemRow> publicSystems = GetPublicSystems(country); List <DataConfig.DataBaseRow> datasets = (from d in dcf.GetDataBaseRows() where d.Private != DefPar.Value.YES select d).ToList(); List <string> indexYears = ccf.GetAllUpratingIndexYears(); RegisterProblems(country, NotDollarF(indices), ref notDollarF); RegisterProblems(country, NoYearForSystem(publicSystems, indexYears), ref noYearForSystem); RegisterProblems(country, NoYearForData(datasets, indexYears), ref noYearForData); RegisterProblems(country, NoIncomeYear(datasets), ref noIncomeYear); RegisterProblems(country, EmptyFactors(ccf, indices, false), ref emptyFactors); RegisterProblems(country, EmptyFactors(ccf, indices, true), ref zeroFactors); } AddDataGridRow("Factors not starting with $f_", notDollarF); AddDataGridRow("Systems for which factor-table does not provide year", noYearForSystem); AddDataGridRow("Databases for which factor-table does not provide year", noYearForData); AddDataGridRow("Databases with undefined income year", noIncomeYear); AddDataGridRow("Factors with empty values", emptyFactors); AddDataGridRow("Factors with zero values (warning)", zeroFactors); }
void InitSwitchTable() { dgvSwitches.Rows.Clear(); dgvSwitches.Columns.Clear(); //add systems as columns foreach (CountryConfig.SystemRow systemRow in CountryAdministrator.GetCountryConfigFacade(_countryShortName).GetSystemRows()) { DataGridViewComboBoxColumn dgvColumn = CreateSystemColumn("col" + systemRow.Name, systemRow.Name); //create the combo-boxes with values on, off and n/a if (systemRow.Private == DefPar.Value.YES) { dgvColumn.HeaderCell.Style.ForeColor = _privateColor; } dgvColumn.Tag = systemRow; } //add datasets as rows foreach (DataConfig.DataBaseRow dataBaseRow in from db in _dataConfig.DataBase select db) { int rowIndex = dgvSwitches.Rows.Add(); DataGridViewRow dgvRow = dgvSwitches.Rows[rowIndex]; dgvRow.HeaderCell.Value = dataBaseRow.Name; dgvRow.Tag = dataBaseRow.ID; if (dataBaseRow.Private == DefPar.Value.YES) { dgvRow.HeaderCell.Style.ForeColor = _privateColor; dgvRow.HeaderCell.Style.SelectionForeColor = _privateColor; } } }
private Dictionary <string, Dictionary <string, ILInfo> > AssessILInfo(string country, bool core) { Dictionary <string, Dictionary <string, ILInfo> > ilInfos = new Dictionary <string, Dictionary <string, ILInfo> >(); CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); foreach (CountryConfig.SystemRow system in GetPublicSystems(country)) { // UDB (aka non-core) ILS are kept in a separate policy CountryConfig.PolicyRow ilPol = ccf.GetPolicyRowByName(system.ID, core ? DefPol.SPECIAL_POL_ILSDEF : DefPol.SPECIAL_POL_ILSUDBDEF); if (ilPol == null || ilPol.Switch != DefPar.Value.ON || ilPol.Private == DefPar.Value.YES) { continue; } foreach (CountryConfig.FunctionRow ilFunc in ccf.GetFunctionRowsByPolicyIDAndFunctionName(ilPol.ID, DefFun.DefIl)) { if (ilFunc.Switch != DefPar.Value.ON || ilFunc.Private == DefPar.Value.YES) { continue; } ILInfo ilInfo = new ILInfo() { LabelEmpty = ilFunc.Comment == string.Empty }; string ilName = string.Empty; foreach (CountryConfig.ParameterRow ilPar in ilFunc.GetParameterRows()) { if (ilPar.Name.ToLower() == DefPar.DefIl.Name.ToLower()) { ilName = ilPar.Value.ToLower(); continue; } if (ilPar.Value == DefPar.Value.NA || ilPar.Private == DefPar.Value.YES) { continue; } ilInfo.Components.Add(ilPar); } if (ilName == string.Empty) { continue; // rather unlikely } if (!ilInfos.ContainsKey(ilName)) { ilInfos.Add(ilName, new Dictionary <string, ILInfo>()); } if (!ilInfos[ilName].ContainsKey(system.Name.ToLower())) // this is a security-request: ilName should be unique per system { ilInfos[ilName].Add(system.Name.ToLower(), ilInfo); } } } return(ilInfos); }
internal static void UpdateCountryFiles(Dictionary <string, List <Tuple <string, string> > > changesCountryFiles, Form showWaitCursorForm = null) { try { if (showWaitCursorForm == null) { showWaitCursorForm = EM_AppContext.Instance.GetActiveCountryMainForm(); } showWaitCursorForm.Cursor = Cursors.WaitCursor; bool showOpenWarning = true; foreach (var ccChange in changesCountryFiles) { string country = ccChange.Key; EM_UI_MainForm ccMainForm = EM_AppContext.Instance.GetCountryMainForm(country); if (ccMainForm != null) { if (showOpenWarning) { switch (UserInfoHandler.GetInfo(country.ToUpper() + " is open." + Environment.NewLine + "Updating exchange rates requires a reset of the undo-functionality." + Environment.NewLine + "That means you will not be able to undo any of your changes so far." + Environment.NewLine + Environment.NewLine + "Do you still want to update exchange rates of " + country.ToUpper() + "?" + Environment.NewLine + Environment.NewLine + "(Press Cancel to not be requested with respect to further open countries.)", MessageBoxButtons.YesNoCancel)) { case DialogResult.No: continue; case DialogResult.Cancel: showOpenWarning = false; break; } } ccMainForm.GetUndoManager().Commit(); ccMainForm.GetUndoManager().Reset(); } CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); foreach (var change in ccChange.Value) { ccf.GetSystemRowByName(change.Item1).ExchangeRateEuro = change.Item2; } if (ccMainForm != null) { ccMainForm.GetUndoManager().Commit(); ccMainForm.GetUndoManager().Reset(); ccMainForm.WriteXml(); } else { CountryAdministrator.WriteXML(country); } } } catch (Exception) { } finally { showWaitCursorForm.Cursor = Cursors.Default; } }
internal override void PerformAction() { ExtensionAndGroupMenuManager.GetSelectionPolFunPar(cc, out List <CountryConfig.PolicyRow> polRows, out List <CountryConfig.FunctionRow> funRows, out List <CountryConfig.ParameterRow> parRows); CountryConfig countryConfig = CountryAdministrator.GetCountryConfigFacade(cc).GetCountryConfig(); CountryConfig.LookGroupRow groupRow = (from lg in countryConfig.LookGroup where lg.Name.ToLower() == groupName.ToLower() select lg).First(); List <CountryConfig.LookGroup_PolicyRow> delPolicyRows = new List <CountryConfig.LookGroup_PolicyRow>(); List <CountryConfig.LookGroup_FunctionRow> delFunctionRows = new List <CountryConfig.LookGroup_FunctionRow>(); List <CountryConfig.LookGroup_ParameterRow> delParameterRows = new List <CountryConfig.LookGroup_ParameterRow>(); foreach (CountryConfig.PolicyRow policyRow in polRows) { funRows.AddRange(policyRow.GetFunctionRows()); // to make sure that all functions of the policy are removed as well - note: the AddContent-function // does not remove a single function if its parent-policy is added (later) var del = from pg in countryConfig.LookGroup_Policy where pg.LookGroupID == groupRow.ID && pg.PolicyID == policyRow.ID select pg; if (del.Any() && !delPolicyRows.Contains(del.First())) { delPolicyRows.Add(del.First()); } } foreach (CountryConfig.FunctionRow functionRow in funRows) { parRows.AddRange(functionRow.GetParameterRows()); // see above var del = from fg in countryConfig.LookGroup_Function where fg.LookGroupID == groupRow.ID && fg.FunctionID == functionRow.ID select fg; if (del.Any() && !delFunctionRows.Contains(del.First())) { delFunctionRows.Add(del.First()); } } foreach (CountryConfig.ParameterRow parameterRow in parRows) { var del = from pg in countryConfig.LookGroup_Parameter where pg.LookGroupID == groupRow.ID && pg.ParameterID == parameterRow.ID select pg; if (del.Any() && !delParameterRows.Contains(del.First())) { delParameterRows.Add(del.First()); } } for (int i = delPolicyRows.Count - 1; i >= 0; --i) { delPolicyRows[i].Delete(); } for (int i = delFunctionRows.Count - 1; i >= 0; --i) { delFunctionRows[i].Delete(); } for (int i = delParameterRows.Count - 1; i >= 0; --i) { delParameterRows[i].Delete(); } }
internal static void SaveDirectXMLAction(EM_UI_MainForm mainForm) { string countryShortName = mainForm.GetCountryShortName(); CountryAdministrator.GetCountryConfigFacade(countryShortName).GetCountryConfig().AcceptChanges(); if (!CountryAdministrator.IsAddOn(countryShortName)) { CountryAdministrator.GetDataConfigFacade(countryShortName).GetDataConfig().AcceptChanges(); } mainForm.GetUndoManager().Reset(); //reset undo-manager with the drawback that actions up until now cannot be undone lock (EM_UI_MainForm._performActionLock) //to not get into conflict with auto-saving { CountryAdministrator.WriteXML(countryShortName); } }
internal void SaveTable() { List <Tuple <string, string, string> > indTaxes = new List <Tuple <string, string, string> >(); foreach (DataGridViewRow row in table.Rows) { if (row.Cells[colName.Name].Value == null || string.IsNullOrEmpty(row.Cells[colName.Name].Value.ToString())) { continue; //probably an empty row } string name = row.Cells[colName.Name].Value == null ? string.Empty : row.Cells[colName.Name].Value.ToString(); string comment = row.Cells[colComment.Name].Value == null ? string.Empty : row.Cells[colComment.Name].Value.ToString(); string yearValues = string.Empty; foreach (DataGridViewColumn yearColumn in GetYearColumnsAsDisplayed()) { if (row.Cells[yearColumn.Index].Value != null) { yearValues += yearColumn.HeaderText + separatorYear + row.Cells[yearColumn.Index].Value.ToString(); } yearValues += separator; } indTaxes.Add(new Tuple <string, string, string>(name, comment, yearValues.TrimEnd(new char[] { separator }))); } CountryConfig countryConfig = CountryAdministrator.GetCountryConfigFacade(mainForm.GetCountryShortName()).GetCountryConfig(); foreach (var indTax in indTaxes) { List <CountryConfig.IndirectTaxRow> its = (from it in countryConfig.IndirectTax where it.Name.ToLower() == indTax.Item1.ToLower() select it).ToList(); if (its.Count == 0) { countryConfig.IndirectTax.AddIndirectTaxRow(Guid.NewGuid().ToString(), indTax.Item1, indTax.Item2, indTax.Item3); } else { its[0].Name = indTax.Item1; its[0].Comment = indTax.Item2; its[0].YearValues = indTax.Item3; } } List <string> itNames = (from i in indTaxes select i.Item1.ToLower()).ToList(); for (int i = countryConfig.IndirectTax.Count - 1; i >= 0; --i) { if (!itNames.Contains(countryConfig.IndirectTax[i].Name.ToLower())) { countryConfig.IndirectTax.ElementAt(i).Delete(); } } }
private void AddSystemToDGV(DataGridView dgv, string systemID) { DataGridViewComboBoxColumn cmbApplicable = new DataGridViewComboBoxColumn(); cmbApplicable.HeaderText = _systemInfo[systemID]; cmbApplicable.Items.AddRange(_comboEntryApplicable, _comboEntryNA, _comboEntryBestMatch); int columnIndex = dgv.Columns.Add(cmbApplicable); dgv.Columns[columnIndex].Tag = systemID; dgv.Columns[columnIndex].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; if (CountryAdministrator.GetCountryConfigFacade(_countryShortName).GetSystemRowByID(systemID).Private == DefPar.Value.YES) { dgv.Columns[columnIndex].HeaderCell.Style.ForeColor = _privateForeColor; } }
void displayCountrySystems() { //list systems lstSystems.Items.Clear(); List <CountryConfig.SystemRow> importSystemRows = _importCountry.GetCountryConfigFacade().GetSystemRows(); foreach (CountryConfig.SystemRow systemRow in importSystemRows) { lstSystems.Items.Add(systemRow.Name); } //if the country to import contains at least one system with the same unique ID as a system in the active country a match by unique ID is principally possible CountryConfigFacade activeCountryConfigFacade = CountryAdministrator.GetCountryConfigFacade(EM_AppContext.Instance.GetActiveCountryMainForm().GetCountryShortName()); chkMatchByUniqueIdentifier.Enabled = ImportByIDAssistant.DoesMatchSystemExist(activeCountryConfigFacade.GetSystemRows(), importSystemRows); }
void Load_BackgroundEventHandler(object sender, System.ComponentModel.DoWorkEventArgs e) { BackgroundWorker backgroundWorker = sender as BackgroundWorker; if (backgroundWorker.CancellationPending) { e.Cancel = true; return; } //user pressed Cancel button: stop the process and allow progress indicator to set dialog result to Cancel //initialisations const double progressPart_LoadingCountries = 0.3; const double progressPart_CheckingVariables = 0.6; const double progressPart_CheckingAcronyms = 0.1; _allCountriesParameters = new List <string>(); _variablesToDelete = new List <string>(); //load all countries' parameter files List <string> countryShortNames = _varConfigFacade.GetCountriesShortNames(); for (int i = 0; i < countryShortNames.Count; ++i) //not the very best solution to get the countries from the descriptions in VarConfig.xml (would be cleaner to have a country administration) { if (backgroundWorker.CancellationPending) { e.Cancel = true; return; } //user pressed Cancel button string countryShortName = countryShortNames.ElementAt(i); CountryConfigFacade countryConfigFacade = CountryAdministrator.GetCountryConfigFacade(countryShortName); if (countryConfigFacade == null) { continue; //VarConfig.xml may contain country specific descriptions for countries which are not (yet) implemented } _allCountriesParameters.AddRange(countryConfigFacade.GetParameterValuesPossiblyContainingVariables()); //get all parameters of the country which may contain a variable double progressPart = (i + 1.0) / (countryShortNames.Count) * progressPart_LoadingCountries; backgroundWorker.ReportProgress(Convert.ToInt32(progressPart * 100.0)); } //check for unused variables and acronyms to be displayed in btnLoad_Click, as displaying them here isn't possible, as the list and tree belong to another thread if (!CheckForUnusedVariables(progressPart_LoadingCountries, progressPart_CheckingVariables, backgroundWorker) || !CheckForUnusedAcronyms(progressPart_LoadingCountries + progressPart_CheckingVariables, progressPart_CheckingAcronyms, backgroundWorker)) { e.Cancel = true; //user pressed Cancel button } }
string IsPolicyMissing(string country, string policyName) { CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); string faulty = string.Empty; foreach (CountryConfig.SystemRow system in GetPublicSystems(country)) { CountryConfig.PolicyRow pol = ccf.GetPolicyRowByFullName(system.ID, policyName + "_" + country); if (pol != null && pol.Private != DefPar.Value.YES && (pol.Switch == DefPar.Value.ON || (policyName == DefPol.SPECIAL_POL_OUTPUT_STD_HH && pol.Switch == DefPar.Value.OFF))) { continue; } faulty += system.Name + ", "; } return(faulty); }
internal SelectSystemsForm(string countryName, List <string> noShowSystemsIDs = null, bool showAllSystems = false) { InitializeComponent(); _systemRows = new List <CountryConfig.SystemRow>(); foreach (CountryConfig.SystemRow systemRow in CountryAdministrator.GetCountryConfigFacade(countryName).GetSystemRows()) { if (noShowSystemsIDs == null || !noShowSystemsIDs.Contains(systemRow.ID)) { _systemRows.Add(systemRow); lstSystems.Items.Add(systemRow.Name); } } if (showAllSystems) { lstSystems.Items.Add(ALL_SYSTEMS); } }
void LoadTableContent() { CountryConfig countryConfig = CountryAdministrator.GetCountryConfigFacade(mainForm.GetCountryShortName()).GetCountryConfig(); keepUndoData = false; dataTable.PrimaryKey = new DataColumn[] { dataTable.Columns.Add("ID", typeof(Int16)) }; dataTable.PrimaryKey[0].AutoIncrement = true; dataTable.Columns.Add(colName.Name); List <string> years = new List <string>(); foreach (CountryConfig.IndirectTaxRow itr in countryConfig.IndirectTax) { foreach (string year in DecomposeYearValues(itr.YearValues).Keys) { if (!years.Contains(year)) { years.Add(year); } } } foreach (string year in years) { AddYearColumn(year); } dataTable.Columns.Add(colComment.Name); foreach (CountryConfig.IndirectTaxRow itr in countryConfig.IndirectTax) { DataRow row = dataTable.Rows.Add(); row.SetField(colName.Name, itr.Name); row.SetField(colComment.Name, itr.Comment); foreach (var yv in DecomposeYearValues(itr.YearValues)) { row.SetField(colYear + yv.Key.ToString(), yv.Value); } } dataSet.AcceptChanges(); undoManager.AddDataSet(dataSet); keepUndoData = true; }
List <SystemAndBase> AssessBases(List <CountryConfig.SystemRow> systems, string country) { List <SystemAndBase> systemsAndBases = new List <SystemAndBase>(); CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); { foreach (CountryConfig.SystemRow system in systems) { CountryConfig.SystemRow baseSystem = null; foreach (CountryConfig.ConditionalFormatRow conditionalFormatRow in ccf.GetConditionalFormatRowsOfSystem(system)) { if (conditionalFormatRow.BaseSystemName != null && conditionalFormatRow.BaseSystemName != string.Empty) { baseSystem = ccf.GetSystemRowByName(conditionalFormatRow.BaseSystemName); break; } } systemsAndBases.Add(new SystemAndBase(system, baseSystem)); } } return(systemsAndBases); }
void Generate_BackgroundEventHandler(object sender, System.ComponentModel.DoWorkEventArgs e) { try { BackgroundWorker backgroundWorker = sender as BackgroundWorker; //gather the country-configs of the selected countries, to be used by the tabel filling functions List <CountryConfigFacade> countryConfigFacades = new List <CountryConfigFacade>(); List <DataConfigFacade> dataConfigFacades = new List <DataConfigFacade>(); int actionCounter = 0; List <string> selectedCountries = e.Argument as List <string>; foreach (string countryShortName in selectedCountries) { if (backgroundWorker.CancellationPending) { e.Cancel = true; return; } //user pressed Cancel button countryConfigFacades.Add(CountryAdministrator.GetCountryConfigFacade(countryShortName)); dataConfigFacades.Add(CountryAdministrator.GetDataConfigFacade(countryShortName)); backgroundWorker.ReportProgress(Convert.ToInt32((actionCounter++ + 1) / (selectedCountries.Count * 1.0) * 100.0)); } //rather difficult to put two-fold information in the result-object, but List<object> works List <object> configFacades = new List <object>(); configFacades.Add(countryConfigFacades); configFacades.Add(dataConfigFacades); e.Result = configFacades; } catch (Exception exception) { e.Cancel = true; UserInfoHandler.ShowException(exception); } }
internal override void PerformAction() { string extensionID = (from e in ExtensionAndGroupManager.GetExtensions(cc) where e.Name.ToLower() == extensionName.ToLower() select e.ID).FirstOrDefault(); if (extensionID == null) { actionIsCanceled = true; return; } CountryConfigFacade countryConfigFacade = CountryAdministrator.GetCountryConfigFacade(cc); CountryConfig countryConfig = CountryAdministrator.GetCountryConfigFacade(cc).GetCountryConfig(); List <string> polIDs = (from pe in countryConfig.Extension_Policy where pe.ExtensionID == extensionID && pe.BaseOff == false select pe.PolicyID).ToList(); List <string> funIDs = (from fe in countryConfig.Extension_Function where fe.ExtensionID == extensionID && fe.BaseOff == false select fe.FunctionID).ToList(); List <string> parIDs = (from pe in countryConfig.Extension_Parameter where pe.ExtensionID == extensionID && pe.BaseOff == false select pe.ParameterID).ToList(); if (!polIDs.Any() && !funIDs.Any() && !polIDs.Any()) { actionIsCanceled = true; return; } string yn = set ? DefPar.Value.YES : DefPar.Value.NO; foreach (string polID in polIDs) { countryConfigFacade.GetPolicyRowByID(polID).Private = yn; } foreach (string funID in funIDs) { countryConfigFacade.GetFunctionRowByID(funID).Private = yn; } foreach (string parID in parIDs) { countryConfigFacade.GetParameterRowByID(parID).Private = yn; } }
void AssessCountryInfo() { rvCountryInfo = new List <RVCountryInfo>(); systemYears = new List <int>(); systemYearsPublic = new List <int>(); CountryConfigFacade ccfMTR = CountryAdministrator.GetCountryConfigFacade("MTR"); CountryConfigFacade ccfLMA = CountryAdministrator.GetCountryConfigFacade("LMA"); CountryConfigFacade ccfNRR = CountryAdministrator.GetCountryConfigFacade("NRR"); foreach (string country in countries) { CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); DataConfigFacade dcf = CountryAdministrator.GetDataConfigFacade(country); RVCountryInfo ccInfo = new RVCountryInfo(country); List <int> ccSystemYearsPublic = new List <int>(); foreach (CountryConfig.SystemRow system in CountryAdministrator.GetCountryConfigFacade(country).GetSystemRows()) { int year = RVItem_SystemConfiguration.GetSystemYear(system); if (year == -1) { continue; } bool isPrivate = system.Private == DefPar.Value.YES; if (!ccInfo.systemYearInfo.ContainsKey(year)) { ccInfo.systemYearInfo.Add(year, isPrivate); } else if (ccInfo.systemYearInfo[year] == true) { ccInfo.systemYearInfo[year] = isPrivate; // if there is a public and a private system for the year, let the public dominate } if (!systemYears.Contains(year)) { systemYears.Add(year); } if (!isPrivate) { ccSystemYearsPublic.Add(year); if (!systemYearsPublic.Contains(year)) { systemYearsPublic.Add(year); } } List <DataConfig.DBSystemConfigRow> bm = (from d in dcf.GetDataConfig().DBSystemConfig where d.SystemID == system.ID & d.BestMatch == DefPar.Value.YES select d).ToList(); if (bm.Count > 0 && !ccInfo.bestMatchInfo.ContainsKey(year)) { ccInfo.bestMatchInfo.Add(year, bm.First().DataBaseRow.Name); } } //ccInfo.privateComponents = (from p in ccf.GetPolicyRowsOrderedAndDistinct() // where p.Private == DefPar.Value.YES select p.Name).ToList(); int oPol = 0; foreach (CountryConfig.PolicyRow pol in ccf.GetPolicyRowsOrderedAndDistinct()) { ++oPol; int oFun = 0; string privFun = string.Empty; ccInfo.idOrderInfo.Add(pol.ID, $"{oPol}"); if (pol.Private == DefPar.Value.YES) { ccInfo.privatePolicies.Add(string.Format("{0} {1}", oPol, pol.Name)); continue; } foreach (CountryConfig.FunctionRow fun in (from f in pol.GetFunctionRows() select f).OrderBy(f => long.Parse(f.Order))) { ++oFun; int oPar = 0; string privPar = string.Empty; ccInfo.idOrderInfo.Add(fun.ID, $"{oPol}.{oFun}"); if (fun.Private == DefPar.Value.YES) { privFun += string.Format("{0} {1} ", oFun, fun.Name); continue; } foreach (CountryConfig.ParameterRow par in (from p in fun.GetParameterRows() select p).OrderBy(p => long.Parse(p.Order))) { ++oPar; ccInfo.idOrderInfo.Add(par.ID, $"{oPol}.{oFun}.{oPar}"); if (par.Private == DefPar.Value.YES) { privPar += string.Format("{0} {1} ", oPar, par.Name); continue; } } if (privPar != string.Empty) { ccInfo.privateParameters.Add(string.Format("{0}.{1} {2}/{3}/...: {4}", oPol.ToString(), oFun.ToString(), pol.Name, fun.Name, privPar)); } } if (privFun != string.Empty) { ccInfo.privateFunctions.Add(string.Format("{0} {1}/...: {2}", oPol, pol.Name, privFun)); } } foreach (DataConfig.DataBaseRow data in dcf.GetDataBaseRows()) { if (ccInfo.dataInfo.ContainsKey(data.Name)) { continue; } bool isPrivate = data.Private == DefPar.Value.YES; ccInfo.dataInfo.Add(data.Name, isPrivate); if (data.Name.ToLower().StartsWith("training")) { ccInfo.hasTrainingData = true; ccInfo.isTrainingPublic = !isPrivate; } if (data.Name.ToLower().StartsWith("hypo")) { ccInfo.hasHypoData = true; } if (isPrivate) { continue; } ccInfo.dataNA.Add(data.Name, new List <string>()); if (!data.Name.ToLower().Contains("hhot")) { foreach (int systemYearPublic in ccSystemYearsPublic) { bool isAvailable = false; foreach (DataConfig.DBSystemConfigRow dbs in dcf.GetDBSystemConfigRows(data.ID)) { CountryConfig.SystemRow systemRow = CountryAdministrator.GetCountryConfigFacade(country).GetSystemRowByName(dbs.SystemName); if (RVItem_SystemConfiguration.GetSystemYear(systemRow) == systemYearPublic) { isAvailable = true; break; } } if (!isAvailable) { ccInfo.dataNA[data.Name].Add(systemYearPublic.ToString()); } } } } foreach (string extId in (from s in dcf.GetDataConfig().PolicySwitch select s.SwitchablePolicyID).Distinct()) { AssessExtensionInfo(ccf, dcf, extId, DefPar.Value.ON, ref ccInfo.switchInfoOn); AssessExtensionInfo(ccf, dcf, extId, DefPar.Value.OFF, ref ccInfo.switchInfoOff); } AssessExtensionContent(ccf, dcf, ccInfo.idOrderInfo, ref ccInfo.extensionContent); foreach (DataConfig.ExtensionRow er in dcf.GetDataConfig().Extension) { ; } foreach (GlobLocExtensionRow er in ExtensionAndGroupManager.GetLocalExtensions(ccInfo.country)) { countriesExtensionInfo.Add(new Tuple <string, string, bool>(er.ID, er.Name, IsWholeContentPrivate(ccf.GetCountryConfig(), er.ID))); } ccInfo.mtrImplemented = AddOnImplemented(ccfMTR, country, "mtr"); ccInfo.lmaImplemented = AddOnImplemented(ccfLMA, country, "lma"); ccInfo.nrrImplemented = AddOnImplemented(ccfNRR, country, "nrr"); rvCountryInfo.Add(ccInfo); } systemYears.Sort(); systemYearsPublic.Sort(); }
private void EM3_WriteLog() { List <RunLogger.RunInfo> runInfoList = new List <RunLogger.RunInfo>(); foreach (Run run in _runs) { // some info needs to be looked up in country-files string country = run._contentConfig[TAGS.EM2CONFIG_COUNTRY_FILE]; if (country.ToLower().EndsWith(".xml")) { country = country.Substring(0, country.Length - 4); } CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); DataConfigFacade dcf = CountryAdministrator.GetDataConfigFacade(country); string sysID = (from e in run._contentConfig where e.Key.StartsWith(TAGS.EM2CONFIG_SYSTEM_ID) select e.Value).FirstOrDefault(); // SYSTEM_ID is followed by a GUID string dataID = run._contentConfig[TAGS.EM2CONFIG_DATASET_ID]; if (!EM_AppContext.Instance._runExeViaLib && run._process != null) { run.em3RunInfo.duration = new RunLogger.Duration(run._process.StartTime, run._process.ExitTime); run.em3RunInfo.finishStatus = run._processStatus == Run._processStatus_Finished ? RunLogger.RunInfo.FINISH_STATUS.finished : RunLogger.RunInfo.FINISH_STATUS.aborted; } run.em3RunInfo.systemName = ccf.GetSystemRowByID(sysID).Name; run.em3RunInfo.ExtractAddonSystemNames(run._contentConfig, TAGS.EM2CONFIG_ADDON); run.em3RunInfo.databaseName = dcf.GetDataBaseRow(dataID).Name; run.em3RunInfo.currency = run._contentConfig.ContainsKey(TAGS.EM2CONFIG_EXCHANGE_RATE_DATE) ? DefPar.Value.EURO : ccf.GetSystemRowByID(sysID).CurrencyOutput; // config contains entry EXCHANGE_RATE_DATE only if "All Output in €" is checked run.em3RunInfo.exchangeRate = GetExchangeRate(run, country, ccf.GetSystemRowByID(sysID).Name); run.em3RunInfo.ExtractExtensionSwitches(run._contentConfig, TAGS.EM2CONFIG_POLICY_SWITCH); string runOutputPath = run._contentConfig.GetOrEmpty(TAGS.EM2CONFIG_OUTPUTPATH); if (!string.IsNullOrEmpty(runOutputPath) && !EMPath.IsSamePath(runOutputPath, _outputPath)) { run.em3RunInfo.nonDefaultOutputPath = runOutputPath; } runInfoList.Add(run.em3RunInfo); } new RunLogger(EM_AppContext.Instance.GetProjectName(), runInfoList).TxtWriteEMLog(_outputPath); string GetExchangeRate(Run run, string country, string sysName) { ExchangeRatesConfigFacade excf = EM_AppContext.Instance.GetExchangeRatesConfigFacade(false); if (excf == null) { return(Dialogs.ConfigureSystemsForm.DEFAULT_EXCHANGE_RATE); } foreach (ExchangeRatesConfig.ExchangeRatesRow exRate in excf.GetExchangeRates(country)) { if (!exRate.ValidFor.ToLower().Trim().EndsWith(sysName.ToLower()) && !exRate.ValidFor.ToLower().Contains(sysName.ToLower() + ",")) { continue; } string date = run._contentConfig.ContainsKey(TAGS.EM2CONFIG_EXCHANGE_RATE_DATE) && run._contentConfig[TAGS.EM2CONFIG_EXCHANGE_RATE_DATE].ToLower() != "default" ? run._contentConfig[TAGS.EM2CONFIG_EXCHANGE_RATE_DATE].ToLower() : exRate.Default.ToLower(); double value = 1.0; if (date.StartsWith("june")) { value = exRate.June30; } else if (date.StartsWith("year")) { value = exRate.YearAverage; } else if (date.StartsWith("first")) { value = exRate.FirstSemester; } else if (date.StartsWith("second")) { value = exRate.SecondSemester; } return(value.ToString()); } return(Dialogs.ConfigureSystemsForm.DEFAULT_EXCHANGE_RATE); } }
private void dgvRates_CellClick(object sender, DataGridViewCellEventArgs e) { try { Cursor = Cursors.WaitCursor; if (e.ColumnIndex < 0 || e.RowIndex < 0 || dgvRates.Columns[e.ColumnIndex].Name != colValidFor.Name) { return; // one needs to request the Name, the index of colValidFor does not work (seems to be 0) } DataGridViewRow clickedRow = dgvRates.Rows[e.RowIndex]; string country = clickedRow.Cells[colCountry.Index].Value.ToString().ToLower(); // gether the systems for which rates exist List <string> sysDel = new List <string>(), sysMove = new List <string>(); foreach (DataGridViewRow row in dgvRates.Rows) { if (row.Cells[colCountry.Name].Value.ToString().ToLower() != country || row.Cells[colValidFor.Name].Value == null || row.Cells[colValidFor.Name].Value.ToString() == string.Empty) { continue; } List <string> sys = ExchangeRate.ValidForToList(row.Cells[colValidFor.Name].Value.ToString()); if (row.Index == e.RowIndex) { sysDel = sys.ToList(); } else { sysMove.AddRange(sys); } } // gether the systems for which no rates exist List <string> sysAdd = new List <string>(); CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); foreach (CountryConfig.SystemRow sys in ccf.GetSystemRows()) { if (!sysDel.Contains(sys.Name.ToLower()) && !sysMove.Contains(sys.Name.ToLower())) { sysAdd.Add(sys.Name.ToLower()); } } // construct menu with systems to delete (from the clicked row), systems to move (from other rows of the country), systems to add (not yet existent in any row) ContextMenuStrip menu = new ContextMenuStrip(); menu.ShowImageMargin = false; menu.ShowCheckMargin = false; if (sysAdd.Count > 0) { ToolStripMenuItem menuItemAdd = new ToolStripMenuItem("Add ..."); foreach (string sys in sysAdd) { menuItemAdd.DropDownItems.Add(sys, null, menuItemAddSys_Click).Tag = clickedRow; } menu.Items.Add(menuItemAdd); } if (sysDel.Count > 0) { ToolStripMenuItem menuItem = new ToolStripMenuItem("Delete ..."); foreach (string sys in sysDel) { menuItem.DropDownItems.Add(sys, null, menuItemDelSys_Click).Tag = clickedRow; } menu.Items.Add(menuItem); } if (sysMove.Count > 0) { ToolStripMenuItem menuItem = new ToolStripMenuItem("Move ..."); foreach (string sys in sysMove) { menuItem.DropDownItems.Add(sys, null, menuItemMoveSys_Click).Tag = clickedRow; } menu.Items.Add(menuItem); } menu.Show(MousePosition); } catch (Exception exception) { UserInfoHandler.ShowException(exception); } finally { Cursor = Cursors.Default; } }
private static CountryConfig GetCountryConfig(string cc) { return(CountryAdministrator.GetCountryConfigFacade(cc).GetCountryConfig()); }
internal static bool IsOldStyleExtensions(string cc, out bool openReadOnly) { openReadOnly = false; bool isOldStyle = false; // check for all policies with switch='switch' whether they are part of any extension ... foreach (CountryConfig.PolicyRow pol in from p in GetCountryConfig(cc).Policy where p.Switch == DefPar.Value.SWITCH select p) { if (!(from ep in GetCountryConfig(cc).Extension_Policy where ep.PolicyID == pol.ID && !ep.BaseOff select ep).Any()) { isOldStyle = true; break; } } if (!isOldStyle) { return(false); } // ... if not - suggest transformation to new style if (UserInfoHandler.GetInfo("The country needs to be updated to the new handling for Extensions (aka Switchable Policies)." + Environment.NewLine + "If you click Cancel the country will be opened in read-only mode.", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { openReadOnly = true; return(true); } // transform to new style: this assumes that the 'switch' settings in the spine are ok and just adds policies to extensions, which fulfill the name-pattern requirements CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(cc); try { foreach (GlobLocExtensionRow ext in GetGlobalExtensions()) { foreach (CountryConfig.PolicyRow polRow in ccf.GetPolicyRowsOrderedAndDistinct()) { string polName = string.IsNullOrEmpty(polRow.ReferencePolID) ? polRow.Name : ccf.GetPolicyRowByID(polRow.ReferencePolID).Name; if (!EM_Helpers.DoesValueMatchPattern(ext.ShortName, polName)) { continue; } foreach (CountryConfig.SystemRow sysRow in ccf.GetSystemRows()) { CountryConfig.PolicyRow polSysRow = ccf.GetPolicyRowByOrder(polRow.Order, sysRow.ID); if (!(from e in ccf.GetCountryConfig().Extension_Policy where e.ExtensionID == ext.ID & e.PolicyID == polSysRow.ID select e).Any()) // avoid double adding, which could actually only be caused by "playing" { ccf.GetCountryConfig().Extension_Policy.AddExtension_PolicyRow(ext.ID, polSysRow, false); } } } } GetCountryConfig(cc).AcceptChanges(); CountryAdministrator.WriteXML(cc); } catch (Exception exception) { UserInfoHandler.ShowException(exception, "Adapting Extensions failed.", false); ccf.GetCountryConfig().RejectChanges(); } return(true); }
internal override void PerformAction() { CountryConfig countryConfig = CountryAdministrator.GetCountryConfigFacade(cc).GetCountryConfig(); ExtensionAndGroupMenuManager.GetSelectionPolFunPar(cc, out List <CountryConfig.PolicyRow> polRows, out List <CountryConfig.FunctionRow> funRows, out List <CountryConfig.ParameterRow> parRows); string extensionID = (from e in ExtensionAndGroupManager.GetExtensions(cc) where e.Name == extensionName select e.ID).FirstOrDefault(); if (extensionID == null) { return; } bool baseOff = !on; foreach (CountryConfig.PolicyRow polRow in polRows) { if (!(from pe in countryConfig.Extension_Policy where pe.PolicyID == polRow.ID && pe.ExtensionID == extensionID && pe.BaseOff == baseOff select pe).Any()) { countryConfig.Extension_Policy.AddExtension_PolicyRow(extensionID, polRow, baseOff); // make sure to not add twice (and thus crash) if (polRow.Switch == DefPar.Value.NA) { polRow.Switch = DefPar.Value.OFF; // if set to n/a the xml-reader would ignore the policy, before extensions are taken into account } } } foreach (CountryConfig.FunctionRow funRow in funRows) { if (!(from fe in countryConfig.Extension_Function where fe.FunctionID == funRow.ID && fe.ExtensionID == extensionID && fe.BaseOff == baseOff select fe).Any()) { countryConfig.Extension_Function.AddExtension_FunctionRow(extensionID, funRow, baseOff); if (funRow.Switch == DefPar.Value.NA) { funRow.Switch = DefPar.Value.OFF; } } } foreach (CountryConfig.ParameterRow parRow in parRows) { if (!(from pe in countryConfig.Extension_Parameter where pe.ParameterID == parRow.ID && pe.ExtensionID == extensionID && pe.BaseOff == baseOff select pe).Any()) { countryConfig.Extension_Parameter.AddExtension_ParameterRow(extensionID, parRow, baseOff); } } if (!on) { return; } // adapt switches in treelist directly, as a full update takes too long foreach (CountryConfig.PolicyRow polRow in polRows) { SetSwitch(polRow.ID, polRow.SystemID, false, DefPar.Value.SWITCH); // for functions, which are part of an extension-policy one still needs to show off and n/a instead of switch (see GetExtensionAdaptedSwitch) foreach (CountryConfig.FunctionRow funRow in polRow.GetFunctionRows()) { SetSwitch(funRow.ID, polRow.SystemID, true, ExtensionAndGroupManager.GetExtensionAdaptedSwitch(funRow)); } } foreach (CountryConfig.FunctionRow funRow in funRows) { SetSwitch(funRow.ID, funRow.PolicyRow.SystemID, true, DefPar.Value.SWITCH); } void SetSwitch(string rowID, string sysID, bool isFun, string switchValue) { KeyValuePair <TreeListNode, TreeListColumn> cell = mainForm.GetTreeListBuilder().GetCellByDataRow(rowID, sysID, isFun); if (cell.Key != null && cell.Value != null) { cell.Key.SetValue(cell.Value, switchValue); } } }