internal override RepositoryItem GetEditor(TreeListNode senderNode, TreeListColumn senderColumn)
 {
     try
     {
         //assess whether the policy is switchable for the specific system, i.e. is controlled via the switches-dialog and the run-tool
         if (ExtensionAndGroupManager.ShowExtensionSwitchEditor(_policyRows[(senderColumn.Tag as SystemTreeListTag).GetSystemRow().ID]))
         {
             return(GetSwitchEditor());
         }
     }
     catch (Exception exception) { Tools.UserInfoHandler.RecordIgnoredException("PolicyTreeListTag.GetEditor", exception); }
     return(_mainForm.OnOffToggleEditor); //if no return the (standard) combobox, which allows selecting the switch (on, off, ...)
 }
Пример #2
0
 // avoid that user's paste something else than on/off/etc. into policy- and function-switches
 internal bool IsPermittedPasteValue(string value, string systemID)
 {
     if (GetDefaultParameterRow() != null)
     {
         return(true);                                  // no check for parameters
     }
     if ((GetDefaultFunctionRow() != null && ExtensionAndGroupManager.ShowExtensionSwitchEditor(GetDefaultFunctionRow())) ||
         (GetDefaultPolicyRow() != null && ExtensionAndGroupManager.ShowExtensionSwitchEditor(GetDefaultPolicyRow())))
     {
         return(false); // if switch='switch' the cell is not-editable
     }
     return(value.ToLower() == DefPar.Value.ON || value.ToLower() == DefPar.Value.OFF ||
            value.ToLower() == DefPar.Value.TOGGLE || value.ToLower() == DefPar.Value.NA);
 }
Пример #3
0
        void FillPolicyNodeWithFunctions(CountryConfig.SystemRow systemRow, CountryConfig.PolicyRow policyRow, TreeListNode policyNode, bool isFirstSystem)
        {
            //generate the functions of the policy
            int functionIndex = 0;
            var functionQuery = (from function in policyRow.GetFunctionRows() select function).OrderBy(function => long.Parse(function.Order));

            foreach (CountryConfig.FunctionRow functionRow in functionQuery.ToList <CountryConfig.FunctionRow>())
            {
                TreeListNode functionNode = isFirstSystem ? BuildFunctionNode(policyNode, functionRow) : policyNode.Nodes[functionIndex++];
                (functionNode.Tag as FunctionTreeListTag).AddFunctionRowOfSystem(systemRow.ID, functionRow);
                functionNode.SetValue(systemRow.Name, ExtensionAndGroupManager.GetExtensionAdaptedSwitch(functionRow));

                //generate the parameters of the function
                FillFunctionNodeWithParameters(systemRow, functionRow, functionNode, isFirstSystem);
            }
        }
        internal override void PerformAction()
        {
            CountryConfig.SystemRow systemRow = (_senderColumn == null) ? null : (_senderColumn.Tag as SystemTreeListTag).GetSystemRow();
            TreeList countryTreeList          = (_senderColumn != null) ? _senderColumn.TreeList : null;
            string   systemName = systemRow == null ? string.Empty : systemRow.Name;
            string   systemYear = systemRow == null ? string.Empty : systemRow.Year;

            if (!SystemValidation.GetSystemNameAndYear(!_isAddOn, ref systemName, ref systemYear, countryTreeList))
            {
                _actionIsCanceled = true;
                return;
            }

            CountryConfig.SystemRow newSystemRow;
            if (_senderColumn == null) //add very first system
            {
                newSystemRow = _countryConfigFacade.AddFirstSystemRow(systemName);
            }
            else //add system by copying an existing system
            {
                CountryConfig.SystemRow toCopySystemRow = (_senderColumn.Tag as SystemTreeListTag).GetSystemRow();

                //copy system itself
                newSystemRow = CountryConfigFacade.CopySystemRow(systemName, toCopySystemRow);

                //copy all references of the system with datasets (i.e. new system can be used with same datasets as its template)
                if (!_isAddOn)
                {
                    _dataConfigFacade.CopyDBSystemConfigRows(toCopySystemRow, newSystemRow);
                }

                //copy system formats
                _countryConfigFacade.CopySystemFormatting(toCopySystemRow, newSystemRow);

                //rename output filename of default outputs
                RenameOutputFiles(_countryConfigFacade, newSystemRow, toCopySystemRow.Name);

                //adapt exchange-rate in global table
                //note that the exchange-rate-config is not included in the undo-procedure, thus this will not be undone
                AddToExchangeRatesTable(systemName, toCopySystemRow);

                ExtensionAndGroupManager.CopyExtensionAndGroupMemberships(_countryConfigFacade.GetCountryConfig(), newSystemRow.ID, toCopySystemRow.ID);
            }
            newSystemRow.Year = systemYear;
        }
Пример #5
0
        internal void InsertFunctionNode(List <CountryConfig.FunctionRow> functionRowsOfAllSystems, TreeListNode policyNode, int nodeIndex = -1)
        {
            TreeListNode functionNode  = null;
            bool         isFirstSystem = true;

            foreach (CountryConfig.FunctionRow functionRow in functionRowsOfAllSystems)
            {
                CountryConfig.SystemRow systemRow = functionRow.PolicyRow.SystemRow;
                functionNode = isFirstSystem ? BuildFunctionNode(policyNode, functionRow) : policyNode.Nodes.LastNode;
                (functionNode.Tag as FunctionTreeListTag).AddFunctionRowOfSystem(systemRow.ID, functionRow);
                functionNode.SetValue(systemRow.Name, ExtensionAndGroupManager.GetExtensionAdaptedSwitch(functionRow));

                FillFunctionNodeWithParameters(systemRow, functionRow, functionNode, isFirstSystem);
                isFirstSystem = false;
            }
            if (nodeIndex != -1)
            {
                _mainForm.treeList.SetNodeIndex(functionNode, nodeIndex);
            }
        }
Пример #6
0
        void InsertExtensionsColumns(bool global, bool countrySpecific)
        {
            Worksheet sheetExtensions           = global & countrySpecific ? sheetExtensionsContent : global ? sheetGlobalExtensions : sheetCountriesExtensions;
            Dictionary <string, int> extensions = global & countrySpecific ? allExtensions : global ? globalExtensions : countriesExtensions;

            int colSwitches = 1;
            List <Tuple <string, string> > ext = new List <Tuple <string, string> >();

            if (global)
            {
                foreach (GlobLocExtensionRow gle in ExtensionAndGroupManager.GetGlobalExtensions())
                {
                    ext.Add(new Tuple <string, string>(gle.ID, gle.Name));
                }
            }
            if (countrySpecific)
            {
                foreach (Tuple <string, string, bool> e in countriesExtensionInfo)
                {
                    ext.Add(new Tuple <string, string>(e.Item1, $"{e.Item2}{(e.Item3 ? " (whole content private)" : string.Empty)}"));
                }
            }

            for (int c = 0; c < ext.Count - 2; ++c)
            {
                int cIns = colSwitches + 1 + c;
                sheetExtensions.Columns[cIns].Insert(InsertCellsMode.ShiftCellsRight);
                sheetExtensions.Columns[cIns].CopyFrom(sheetExtensions.Columns[colSwitches]); // to overtake the format
            }
            int cLabel = -1;

            for (int c = 0; c < ext.Count; ++c)
            {
                cLabel = colSwitches + c;
                sheetExtensions[1, cLabel].Value = ext[c].Item2;
                extensions.Add(ext[c].Item1, cLabel);
            }
        }
Пример #7
0
        internal void InsertPolicyNode(CountryConfig.PolicyRow distinctPolicyRow, int nodeIndex = -1)
        {
            TreeListNode policyNode = _mainForm.treeList.AppendNode(null, null);

            if (nodeIndex != -1)
            {
                _mainForm.treeList.SetNodeIndex(policyNode, nodeIndex);
            }

            //a reference policy is a policy that does not really exist, but marks (in the spine)
            //the re-calculation of a policy that was already calculated further up in the spine
            CountryConfig.PolicyRow referencePolicy = null;

            if (distinctPolicyRow.ReferencePolID != null && distinctPolicyRow.ReferencePolID != string.Empty)
            {
                referencePolicy = _countryConfigFacade.GetPolicyRowByID(distinctPolicyRow.ReferencePolID); //get the "real" policy to assess the necessary information (in essence the name)
            }
            //equip the node with the non system specific information about the policy
            policyNode.SetValue(_policyColumnName, referencePolicy == null ? distinctPolicyRow.Name : referencePolicy.Name);
            policyNode.SetValue(_commentColumnName, distinctPolicyRow.Comment);
            policyNode.Tag             = new PolicyTreeListTag(_mainForm); //here create the tag - (system specific) information will be filled in below
            policyNode.StateImageIndex = policyNode.SelectImageIndex = PolicyTreeListTag.GetStateImageIndex(distinctPolicyRow);
            policyNode.ImageIndex      = -1;                               //not used

            bool isFirstSystem = true;

            foreach (CountryConfig.SystemRow systemRow in _countryConfigFacade.GetSystemRowsOrdered())
            {
                //equip the policy node with the system specific information about the policy
                CountryConfig.PolicyRow policyRow = _countryConfigFacade.GetPolicyRowByNameOrderAndSystemID(distinctPolicyRow.Name,
                                                                                                            distinctPolicyRow.Order, systemRow.ID);
                (policyNode.Tag as PolicyTreeListTag).AddPolicyRowOfSystem(systemRow.ID, policyRow);
                policyNode.SetValue(systemRow.Name, ExtensionAndGroupManager.GetExtensionAdaptedSwitch(policyRow));

                FillPolicyNodeWithFunctions(systemRow, policyRow, policyNode, isFirstSystem);
                isFirstSystem = false;
            }
        }
 void AddSwitchablePolicyConfig(bool local)
 {
     foreach (string ID in GetRelevantIDs(_mcSwitchablePolicyConfig, local, true))
     {
         ExtensionAndGroupMergeHelper.CopyGlobalExtensionFromAnotherConfig(_vcLocal, ExtensionAndGroupManager.GetGlobalExtension(ID));
     }
 }
Пример #9
0
        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();
        }
Пример #10
0
        internal override void PerformAction()
        {
            TreeListNode policyNode = _senderNode;

            if (_senderNode.ParentNode != null)
            {
                policyNode = _senderNode.ParentNode;
            }

            int newFunctionNodeIndex = -1;
            List <CountryConfig.FunctionRow> newFunctionRows = new List <CountryConfig.FunctionRow>();

            foreach (CountryConfig.PolicyRow policyRow in (policyNode.Tag as PolicyTreeListTag).GetPolicyRows()) //loop over systems
            {
                CountryConfig.FunctionRow newFunctionRow = null;

                //(1) add function
                //if the sender node is a policy node: insert as last function ('Add Function' was called from policy node or 'Add Function After' was called from last function node in policy)
                if (_senderNode == policyNode)
                {
                    newFunctionRow = CountryConfigFacade.AddFunctionRowAtTail(_functionName, policyRow,
                                                                              // the switch of a function inside an extension-policy cannot be changed, therefore add as on (otherwise one would need to remove the policy from the extension to be able to change the switch to on)
                                                                              ExtensionAndGroupManager.ShowExtensionSwitchEditor(policyRow) ? DefPar.Value.ON : DefPar.Value.NA);
                }

                //if the sender node is a function node: insert before ('Add Function Before' was called from function node)
                else
                {
                    CountryConfig.FunctionRow neighbourFunction = (_senderNode.Tag as FunctionTreeListTag).GetFunctionRowOfSystem(policyRow.SystemRow.ID);
                    newFunctionRow = CountryConfigFacade.AddFunctionRow(_functionName, neighbourFunction, true,
                                                                        ExtensionAndGroupManager.ShowExtensionSwitchEditor(policyRow) ? DefPar.Value.ON : DefPar.Value.NA); // see comment above
                    newFunctionNodeIndex = _mainForm.treeList.GetNodeIndex(_senderNode);
                }
                _addedFunctionsIDs.Add(newFunctionRow.ID);

                //(2) add compulsory parameters
                DefinitionAdmin.Fun fun = DefinitionAdmin.GetFunDefinition(_functionName, false);
                if (fun != null)
                {
                    for (short doCommon = 0; doCommon < 2; ++doCommon) // add function-specific parameters before common
                    {
                        foreach (var p in fun.GetParList())
                        {
                            AddPar(p, false);
                        }
                        foreach (var pg in fun.GetGroupParList())
                        {
                            if (pg.minCount > 0)
                            {
                                foreach (var p in pg.par)
                                {
                                    AddPar(p, true);
                                }
                            }
                        }

                        void AddPar(KeyValuePair <string, DefinitionAdmin.Par> p, bool group)
                        {
                            string parName = p.Key.ToUpper() == DefPar.PAR_TYPE.PLACEHOLDER.ToString().ToUpper() ? DefinitionAdmin.ParTypeToString(DefPar.PAR_TYPE.PLACEHOLDER) : p.Key;

                            DefinitionAdmin.Par parDef = p.Value;
                            if (parDef.minCount > 0 && ((doCommon == 0 && !parDef.isCommon) || (doCommon == 1 && parDef.isCommon)))
                            {
                                CountryConfigFacade.AddParameterRowAtTail(newFunctionRow, parName, parDef, group ? "1" : string.Empty);
                            }
                        }
                    }
                }
                newFunctionRows.Add(newFunctionRow);
            }

            _mainForm.GetTreeListBuilder().InsertFunctionNode(newFunctionRows, policyNode, newFunctionNodeIndex);
        }
Пример #11
0
        private Dictionary <string, string> EM2_CreateConfig(string countryShortName, string outputPath, DataConfig.DataBaseRow dbr, CountryConfig.SystemRow sr, bool useTempCountry = true)
        {
            Dictionary <string, string> contentEMConfig = new Dictionary <string, string>();

            string emVersion = EM_AppContext.Instance.GetProjectName();

            if (emVersion.Trim() == string.Empty)
            {
                UserInfoHandler.ShowError($"{DefGeneral.BRAND_TITLE} version is not defined. Please define it via the menu 'Configuration'.");
                return(null);
            }
            //fill EMConfig-entry-list
            string dateTimePrefix = string.Format("{0:yyyyMMddHHmm}", DateTime.Now);

            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_ERRLOG_FILE, outputPath + dateTimePrefix + EM_XmlHandler.TAGS.EM2CONFIG_errLogFileName);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_LOG_WARNINGS, DefPar.Value.YES);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_EMVERSION, emVersion);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_UIVERSION, DefGeneral.UI_VERSION);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_PARAMPATH, useTempCountry ? EMPath.AddSlash(EMPath.Folder_Temp(EM_AppContext.FolderEuromodFiles)) : EMPath.AddSlash(Path.Combine(EMPath.Folder_Countries(EM_AppContext.FolderEuromodFiles), countryShortName)));
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_CONFIGPATH, EMPath.Folder_Config(EM_AppContext.FolderEuromodFiles));
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_OUTPUTPATH, outputPath);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_DATAPATH, EM_AppContext.FolderInput);
            string executablePath = EnvironmentInfo.GetEM2ExecutableFile();

            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_EMCONTENTPATH, EM_AppContext.FolderEuromodFiles);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_HEADER_DATE, dateTimePrefix);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_OUTFILE_DATE, "-");
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_LOG_RUNTIME, DefPar.Value.NO);
            if (EM_AppContext.Instance.IsPublicVersion())
            {
                contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_ISPUBLICVERSION, DefPar.Value.YES);
            }
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_DECSIGN_PARAM, EM_Helpers.uiDecimalSeparator);
            string startHH = EM_XmlHandler.TAGS.EM2CONFIG_defaultHHID;
            string lastHH  = EM_XmlHandler.TAGS.EM2CONFIG_defaultHHID;

            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_STARTHH, startHH);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_LASTHH, lastHH);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_COUNTRY_FILE, CountryAdministrator.GetCountryFileName(countryShortName));
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_DATACONFIG_FILE, CountryAdministrator.GetDataFileName(countryShortName));
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_DATASET_ID, dbr.ID);
            contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_SYSTEM_ID, sr.ID);

            //generate for each (available) switchable policy a POLICY_SWITCH-entry
            Dictionary <string, string> extIDAndPattern = new Dictionary <string, string>();

            foreach (GlobLocExtensionRow e in ExtensionAndGroupManager.GetExtensions(countryShortName))
            {
                extIDAndPattern.Add(e.ID, e.ShortName);
            }

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

            foreach (var e in extIDAndPattern)
            {
                string extID = e.Key, extShortName = e.Value;
                string policySwitchValue = string.Empty;
                if (dbr.GetDBSystemConfigRows().Count(x => x.SystemID == sr.ID) > 0)
                {
                    policySwitchValue = ExtensionAndGroupManager.GetExtensionDefaultSwitch(dbr.GetDBSystemConfigRows().First(x => x.SystemID == sr.ID), extID);
                }

                //generate the POLICY_SWITCH-entry
                //taking into account that there is no need to generate it if the switch is set to n/a (i.e. the switchable policy is not switchable for this db-system-combination or does not even exist)
                if (policySwitchValue != string.Empty && policySwitchValue != DefPar.Value.NA)
                {
                    string policySwitchEntry =                            //the executable needs three pieces of information to overwrite the default value of the policy switch:
                                               extShortName               //which switchable policy (e.g. BTA_??)
                                               + "=" + sr.ID              //which system
                                               + "=" + policySwitchValue; //and the respective value (on or off)
                    policySwitchEntries.Add(policySwitchEntry);
                }
            }

            //for each (available) switchable policy add a POLICY_SWITCH-entry
            foreach (string policySwitchEntry in policySwitchEntries)
            {
                contentEMConfig.Add(EM_XmlHandler.TAGS.EM2CONFIG_POLICY_SWITCH + Guid.NewGuid().ToString(), policySwitchEntry);
            }


            //now actually write the EMConfigXXX.xml files and hand them over to the run-manager
            string configurationFileNameAndPath = EMPath.Folder_Temp(EM_AppContext.FolderEuromodFiles) + EM_XmlHandler.TAGS.EM2CONFIG_labelEMConfig + Guid.NewGuid().ToString() + ".xml";

            using (XmlTextWriter configurationFileWriter = new XmlTextWriter(configurationFileNameAndPath, null))
            {
                configurationFileWriter.Formatting = System.Xml.Formatting.Indented;
                configurationFileWriter.WriteStartDocument(true);
                configurationFileWriter.WriteStartElement(EM_XmlHandler.TAGS.EM2CONFIG_labelEMConfig);

                string runFormInfoText = string.Empty;
                foreach (string key in contentEMConfig.Keys)
                {
                    if (key.StartsWith(EM_XmlHandler.TAGS.EM2CONFIG_SYSTEM_ID)) //remove Guid, see above
                    {
                        configurationFileWriter.WriteElementString(EM_XmlHandler.TAGS.EM2CONFIG_SYSTEM_ID, contentEMConfig[key]);
                    }
                    else if (key.StartsWith(EM_XmlHandler.TAGS.EM2CONFIG_POLICY_SWITCH)) //remove Guid, see above
                    {
                        configurationFileWriter.WriteElementString(EM_XmlHandler.TAGS.EM2CONFIG_POLICY_SWITCH, contentEMConfig[key]);
                    }
                    else
                    {
                        configurationFileWriter.WriteElementString(key, contentEMConfig[key]);
                    }
                }

                configurationFileWriter.WriteElementString(EM_XmlHandler.TAGS.EM2CONFIG_LAST_RUN, DefPar.Value.NO);
                configurationFileWriter.WriteEndElement();
                configurationFileWriter.WriteEndDocument();
            }
            // EM3 returns the config-dictionary, therefore (mis)use this structure to just store the file-path as the first entry (to avoid extra variables for EM2)
            return(new Dictionary <string, string>()
            {
                { configurationFileNameAndPath, null }
            });
        }