Example #1
0
        public static bool GetCAOInfo(out TSDictionary info, bool includeCountries = true, bool includeAddOns = true, bool openOnly = false)
        {
            info = new TSDictionary();

            try
            {
                List <Country> caos = new List <Country>();
                if (includeCountries)
                {
                    caos.AddRange(CountryAdministrator.GetCountries());
                }
                if (includeAddOns)
                {
                    caos.AddRange(CountryAdministrator.GetAddOns());
                }

                Dictionary <string, EM_UI_MainForm> openMainForms = new Dictionary <string, EM_UI_MainForm>();
                foreach (EM_UI_MainForm mf in EM_AppContext.Instance.GetOpenCountriesMainForms())
                {
                    openMainForms.Add(mf.GetCountryShortName().ToLower(), mf);
                }

                List <Form>   mainForms        = new List <Form>();
                List <string> shortNames       = new List <string>();
                List <string> longNames        = new List <string>();
                List <bool>   isAddOn          = new List <bool>();
                List <bool>   isOpen           = new List <bool>();
                List <string> mainXMLFileNames = new List <string>();
                List <string> dataXMLFileNames = new List <string>();
                List <string> filePaths        = new List <string>();
                foreach (Country cao in caos)
                {
                    bool open = openMainForms.ContainsKey(cao._shortName.ToLower());
                    if (openOnly && !open)
                    {
                        continue;
                    }
                    mainForms.Add(open ? openMainForms[cao._shortName.ToLower()] : null);
                    shortNames.Add(cao._shortName);
                    // long name is only availabel through CountryConfig (it doesn't seem appropriate to open the country just to get the long-name)
                    longNames.Add(open ? openMainForms[cao._shortName.ToLower()].GetCountryLongName() : cao._shortName);
                    isAddOn.Add(cao._isAddOn);
                    isOpen.Add(open);
                    mainXMLFileNames.Add(CountryAdministrator.GetCountryFileName(cao._shortName));
                    dataXMLFileNames.Add(cao._isAddOn ? string.Empty : CountryAdministrator.GetDataFileName(cao._shortName));
                    filePaths.Add(CountryAdministrator.GetCountryPath(cao._shortName));
                }
                info.SetItem(UISessionInfo.CAO_INFO_MainForms, mainForms);
                info.SetItem(UISessionInfo.CAO_INFO_ShortNames, shortNames);
                info.SetItem(UISessionInfo.CAO_INFO_LongNames, longNames);
                info.SetItem(UISessionInfo.CAO_INFO_IsAddOn, isAddOn);
                info.SetItem(UISessionInfo.CAO_INFO_IsOpen, isOpen);
                info.SetItem(UISessionInfo.CAO_INFO_MainXMLFileNames, mainXMLFileNames);
                info.SetItem(UISessionInfo.CAO_INFO_DataXMLFileNames, dataXMLFileNames);
                info.SetItem(UISessionInfo.CAO_INFO_FilePaths, filePaths);
                return(true);
            }
            catch { return(false); }
        }
        internal ImportAddOnForm(List <string> BaseSystemNames)
        {
            InitializeComponent();
            _baseSystemNames = BaseSystemNames;

            foreach (Country addOn in CountryAdministrator.GetAddOns())
            {
                cmbAddOns.Items.Add(addOn._shortName);
            }
        }
        static void RemovePrivate_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

            //then adapt the copy
            try
            {
                List <Country> countries = CountryAdministrator.GetCountries();

                //remove private systems, policies and datasets of each country
                for (int i = 0; i < countries.Count; ++i)
                {
                    if (backgroundWorker.CancellationPending)
                    {
                        e.Cancel = true; return;
                    }                                                                      //user pressed Cancel button: see above

                    Country             country             = countries[i];
                    CountryConfigFacade countryConfigFacade = country.GetCountryConfigFacade();
                    DataConfigFacade    dataConfigFacade    = country.GetDataConfigFacade();

                    //assess which systems, policies and datasets are private
                    List <CountryConfig.SystemRow>    privateSystems    = new List <CountryConfig.SystemRow>();    //systems
                    List <CountryConfig.PolicyRow>    privatePolicies   = new List <CountryConfig.PolicyRow>();    //policies
                    List <CountryConfig.FunctionRow>  privateFunctions  = new List <CountryConfig.FunctionRow>();  //functions
                    List <CountryConfig.ParameterRow> privateParameters = new List <CountryConfig.ParameterRow>(); //parameters
                    List <string> privateSystemIDs = new List <string>();                                          //necessary for afterwards identifying database-connections of private systems
                    foreach (CountryConfig.SystemRow system in countryConfigFacade.GetSystemRows())
                    {
                        if (system.Private.ToLower() == DefPar.Value.YES.ToLower())
                        {
                            privateSystems.Add(system);
                            privateSystemIDs.Add(system.ID);
                        }
                        else
                        {
                            foreach (CountryConfig.PolicyRow policy in system.GetPolicyRows())
                            {
                                if (policy.Private == DefPar.Value.YES)
                                {
                                    privatePolicies.Add(policy);
                                }
                                else
                                {
                                    if (policy.PrivateComment != null && policy.PrivateComment != string.Empty)
                                    {
                                        policy.PrivateComment = string.Empty; //remove private policy-comment if there is any
                                    }
                                    foreach (CountryConfig.FunctionRow function in policy.GetFunctionRows())
                                    {
                                        if (function.Private == DefPar.Value.YES)
                                        {
                                            privateFunctions.Add(function);
                                        }
                                        else
                                        {
                                            if (function.PrivateComment != null && function.PrivateComment != string.Empty)
                                            {
                                                function.PrivateComment = string.Empty; //remove private function-comment if there is any
                                            }
                                            foreach (CountryConfig.ParameterRow parameter in function.GetParameterRows())
                                            {
                                                if (parameter.Private == DefPar.Value.YES)
                                                {
                                                    privateParameters.Add(parameter);
                                                }
                                                else if (parameter.PrivateComment != null && parameter.PrivateComment != string.Empty)
                                                {
                                                    parameter.PrivateComment = string.Empty; //remove private parameter-comment if there is any
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    List <DataConfig.DataBaseRow>       privateDataSets        = new List <DataConfig.DataBaseRow>();       //datasets
                    List <DataConfig.DBSystemConfigRow> privateDBSystemConfigs = new List <DataConfig.DBSystemConfigRow>(); //database-connections of private systems
                    foreach (DataConfig.DataBaseRow dataSet in dataConfigFacade.GetDataBaseRows())
                    {
                        if (dataSet.Private.ToLower() == DefPar.Value.YES.ToLower())
                        {
                            privateDataSets.Add(dataSet);
                        }
                        else
                        {
                            foreach (DataConfig.DBSystemConfigRow dbSystemConfig in dataConfigFacade.GetDBSystemConfigRows(dataSet.ID))
                            {
                                if (privateSystemIDs.Contains(dbSystemConfig.SystemID))
                                {
                                    privateDBSystemConfigs.Add(dbSystemConfig);
                                }
                            }
                        }
                    }

                    //remove user-set node colors
                    countryConfigFacade.RemoveAllNodeColors();

                    //restore or install default base-system-colouring
                    countryConfigFacade.setAutomaticConditionalFormatting(true);

                    //remove private systems
                    if (countryConfigFacade.GetCountryRow().Private == DefPar.Value.YES || //if country is private or
                        privateSystems.Count == countryConfigFacade.GetSystemRows().Count) //there are no systems left, delete country
                    {
                        Directory.Delete(EMPath.Folder_Countries(EM_AppContext.FolderEuromodFiles) + country._shortName, true);
                        country.SetCountryConfigFacade(null);
                        country.SetDataConfigFacade(null);
                        continue;
                    }
                    else //otherwise delete private systems
                    {
                        foreach (CountryConfig.SystemRow privateSystem in privateSystems)
                        {
                            privateSystem.Delete();
                        }
                    }

                    //remove private parameters
                    foreach (CountryConfig.ParameterRow privateParameter in privateParameters)
                    {
                        privateParameter.Delete();
                    }

                    //remove private functions
                    foreach (CountryConfig.FunctionRow privateFunction in privateFunctions)
                    {
                        privateFunction.Delete();
                    }

                    //remove private policies
                    foreach (CountryConfig.PolicyRow privatePolicy in privatePolicies)
                    {
                        privatePolicy.Delete();
                    }

                    //remove private datasets
                    foreach (DataConfig.DataBaseRow privateDataSet in privateDataSets)
                    {
                        privateDataSet.Delete();
                    }

                    //remove database-connections of private systems
                    foreach (DataConfig.DBSystemConfigRow privateDBSystemConfig in privateDBSystemConfigs)
                    {
                        privateDBSystemConfig.Delete();
                    }

                    country.WriteXML();
                    country.SetCountryConfigFacade(null);
                    country.SetDataConfigFacade(null);

                    backgroundWorker.ReportProgress(Convert.ToInt32((i + 1.0) / (countries.Count * 1.0) * 100.0));
                }

                //remove private add-ons
                foreach (Country addOn in CountryAdministrator.GetAddOns())
                {
                    bool oldStyle = CountryAdministrator.ConsiderOldAddOnFileStructure(true);
                    CountryConfigFacade addOnConfigFacade = addOn.GetCountryConfigFacade();
                    if (addOnConfigFacade.GetCountryRow().Private != DefPar.Value.YES)
                    {
                        continue;
                    }
                    if (oldStyle)
                    {
                        File.Delete(EMPath.Folder_AddOns(EM_AppContext.FolderEuromodFiles) + addOn._shortName + ".xml");
                    }
                    else
                    {
                        Directory.Delete(EMPath.Folder_AddOns(EM_AppContext.FolderEuromodFiles) + addOn._shortName, true);
                    }
                    addOn.SetCountryConfigFacade(null);
                }

                // remove the "other" column from the variables file
                VarConfigFacade vcf = EM_AppContext.Instance.GetVarConfigFacade();
                foreach (VarConfig.CountryLabelRow r in from l in vcf._varConfig.CountryLabel where l.Country.ToLower() == "other" select l)
                {
                    r.Delete();
                }
                vcf.Commit(); vcf.WriteXML();

                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true; return;
                }                                                                      //user pressed Cancel button: see above
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
                e.Cancel = true; //stop the process and allow progress indicator to set dialog result to Cancel
            }
        }
        static void CheckPrivateComponents_BackgroundEventHandler(object sender, System.ComponentModel.DoWorkEventArgs e)
        { //assess which datasets, systems and policies are private (as a background process of the progress indicator)
            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

            try
            {
                List <Country> countries = CountryAdministrator.GetCountries();

                _privateComponents = string.Empty;
                for (int i = 0; i < countries.Count; i++)
                {
                    if (backgroundWorker.CancellationPending)
                    {
                        e.Cancel = true; return;
                    }                                                                      //user pressed Cancel button: see above

                    Country             country             = countries[i];
                    CountryConfigFacade countryConfigFacade = country.GetCountryConfigFacade();
                    DataConfigFacade    dataConfigFacade    = country.GetDataConfigFacade();

                    //assess which systems are private
                    List <CountryConfig.SystemRow> privateSystems = new List <CountryConfig.SystemRow>();
                    foreach (CountryConfig.SystemRow system in countryConfigFacade.GetSystemRows())
                    {
                        if (backgroundWorker.CancellationPending)
                        {
                            e.Cancel = true; return;
                        }                                                                      //user pressed Cancel button: see above

                        if (system.Private.ToLower() == DefPar.Value.YES.ToLower())
                        {
                            privateSystems.Add(system);
                        }
                    }

                    //assess which policies are private
                    List <CountryConfig.PolicyRow>    privatePolicies   = new List <CountryConfig.PolicyRow>();
                    List <CountryConfig.FunctionRow>  privateFunctions  = new List <CountryConfig.FunctionRow>();
                    List <CountryConfig.ParameterRow> privateParameters = new List <CountryConfig.ParameterRow>();
                    if (countryConfigFacade.GetSystemRows().Count > privateSystems.Count)
                    {//only necessary to do for first system, as policies can only be marked private for all systems, but check if not all systems are private
                        foreach (CountryConfig.PolicyRow policy in countryConfigFacade.GetSystemRows()[0].GetPolicyRows())
                        {
                            if (backgroundWorker.CancellationPending)
                            {
                                e.Cancel = true; return;
                            }                                                                      //user pressed Cancel button: see above

                            if (policy.Private == DefPar.Value.YES)
                            {
                                privatePolicies.Add(policy);
                            }
                            else
                            {
                                foreach (CountryConfig.FunctionRow function in policy.GetFunctionRows())
                                {
                                    if (function.Private == DefPar.Value.YES)
                                    {
                                        privateFunctions.Add(function);
                                    }
                                    else
                                    {
                                        foreach (CountryConfig.ParameterRow parameter in function.GetParameterRows())
                                        {
                                            if (parameter.Private == DefPar.Value.YES)
                                            {
                                                privateParameters.Add(parameter);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    //assess which datasets are private
                    List <DataConfig.DataBaseRow> privateDataSets = new List <DataConfig.DataBaseRow>();
                    foreach (DataConfig.DataBaseRow dataSet in dataConfigFacade.GetDataBaseRows())
                    {
                        if (backgroundWorker.CancellationPending)
                        {
                            e.Cancel = true; return;
                        }                                                                      //user pressed Cancel button: see above

                        if (dataSet.Private.ToLower() == DefPar.Value.YES.ToLower())
                        {
                            privateDataSets.Add(dataSet);
                        }
                    }

                    backgroundWorker.ReportProgress(Convert.ToInt32((i + 1.0) / (countries.Count * 1.0) * 100.0)); //increase progress (for each country)

                    if (privateDataSets.Count == 0 && privateSystems.Count == 0 && privatePolicies.Count == 0)
                    {
                        continue;
                    }

                    //fill _privateComponents into string which is to be output in btnCheckPrivate_Click
                    _privateComponents += country._shortName.ToUpper() + Environment.NewLine;

                    if (countryConfigFacade.GetCountryRow().Private == DefPar.Value.YES)
                    {
                        _privateComponents += "\tPRIVATE COUNTRY" + Environment.NewLine;
                    }

                    if (privateDataSets.Count != 0)
                    {
                        _privateComponents += "\tPRIVATE DATASETS" + Environment.NewLine;
                        foreach (DataConfig.DataBaseRow dataSet in privateDataSets)
                        {
                            _privateComponents += "\t\t" + dataSet.Name + Environment.NewLine;
                        }
                    }
                    if (privateSystems.Count != 0)
                    {
                        _privateComponents += "\tPRIVATE SYSTEMS" + Environment.NewLine;
                        foreach (CountryConfig.SystemRow system in privateSystems)
                        {
                            _privateComponents += "\t\t" + system.Name + Environment.NewLine;
                        }
                    }
                    if (privatePolicies.Count != 0)
                    {
                        _privateComponents += "\tPRIVATE POLICIES" + Environment.NewLine;
                        foreach (CountryConfig.PolicyRow policy in privatePolicies)
                        {
                            _privateComponents += "\t\t" + policy.Name + Environment.NewLine;
                        }
                    }
                    if (privateFunctions.Count != 0)
                    {
                        _privateComponents += "\tPRIVATE FUNCTIONS" + Environment.NewLine;
                        foreach (CountryConfig.FunctionRow function in privateFunctions)
                        {
                            _privateComponents += "\t\t" + function.Name + " in policy " + function.PolicyRow.Name + " (order " + function.Order + ")" + Environment.NewLine;
                        }
                    }
                    if (privateParameters.Count != 0)
                    {
                        _privateComponents += "\tPRIVATE PARAMETERS" + Environment.NewLine;
                        foreach (CountryConfig.ParameterRow parameter in privateParameters)
                        {
                            _privateComponents += "\t\t" + parameter.Name + " in function " + parameter.FunctionRow.Name + " in policy " + parameter.FunctionRow.PolicyRow.Name +
                                                  " (function-order " + parameter.FunctionRow.Order + ", parameter-order " + parameter.Order + ")" + Environment.NewLine;
                        }
                    }
                    _privateComponents += "_________________________________________________________" + Environment.NewLine;
                }

                foreach (Country addOn in CountryAdministrator.GetAddOns())
                {
                    CountryConfigFacade addOnConfigFacade = addOn.GetCountryConfigFacade();
                    if (addOnConfigFacade.GetCountryRow().Private != DefPar.Value.YES)
                    {
                        continue;
                    }
                    _privateComponents += addOn._shortName.ToUpper() + Environment.NewLine;
                    _privateComponents += "\tPRIVATE ADD-ON" + Environment.NewLine;
                    _privateComponents += "_________________________________________________________" + Environment.NewLine;
                }
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
                e.Cancel = true; //stop the process and allow progress indicator to set dialog result to Cancel
            }
        }
Example #5
0
        static void Generate_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

            //assess the name of the new EuromodFiles-folder in accordance to the version number
            DirectoryInfo sourceFolder = new DirectoryInfo(EM_AppContext.FolderEuromodFiles);
            string        folderEMF    = "EuromodFiles_" + _publicVersionNumber;

            if (!EM_Helpers.IsValidFileName(folderEMF))
            {
                UserInfoHandler.ShowInfo(folderEMF + " is not a valid folder name. Please change the version number.");
                e.Cancel = true; return;
            }

            //first copy the whole EuromodFiles folder to the respective path
            if (!XCopy.Folder(EM_AppContext.FolderEuromodFiles, _publicVersionPath, folderEMF))
            {
                e.Cancel = true; return;
            }

            string fullPublicPath = _publicVersionPath + EMPath.AddSlash(folderEMF);

            //then adapt the copy
            string folderCountries =
                EMPath.AddSlash( //at the new path assess the folder that contains the files (usually EuromodFiles)
                    EMPath.Folder_Countries(EM_AppContext.FolderEuromodFiles).Replace(EM_AppContext.FolderEuromodFiles, fullPublicPath));

            try
            {
                List <Country> countries = CountryAdministrator.GetCountries();

                //remove private systems, policies and datasets of each country
                for (int i = 0; i < countries.Count; ++i)
                {
                    if (backgroundWorker.CancellationPending)
                    {
                        e.Cancel = true; return;
                    }                                                                      //user pressed Cancel button: see above

                    Country             country             = countries[i];
                    CountryConfigFacade countryConfigFacade = country.GetCountryConfigFacade(true, folderCountries + country._shortName);
                    DataConfigFacade    dataConfigFacade    = country.GetDataConfigFacade(true, folderCountries + country._shortName);

                    //assess which systems, policies and datasets are private
                    List <CountryConfig.SystemRow>    privateSystems    = new List <CountryConfig.SystemRow>();    //systems
                    List <CountryConfig.PolicyRow>    privatePolicies   = new List <CountryConfig.PolicyRow>();    //policies
                    List <CountryConfig.FunctionRow>  privateFunctions  = new List <CountryConfig.FunctionRow>();  //functions
                    List <CountryConfig.ParameterRow> privateParameters = new List <CountryConfig.ParameterRow>(); //parameters
                    List <string> privateSystemIDs = new List <string>();                                          //necessary for afterwards identifying database-connections of private systems
                    foreach (CountryConfig.SystemRow system in countryConfigFacade.GetSystemRows())
                    {
                        if (system.Private.ToLower() == DefPar.Value.YES.ToLower())
                        {
                            privateSystems.Add(system);
                            privateSystemIDs.Add(system.ID);
                        }
                        else
                        {
                            foreach (CountryConfig.PolicyRow policy in system.GetPolicyRows())
                            {
                                if (policy.Private == DefPar.Value.YES)
                                {
                                    privatePolicies.Add(policy);
                                }
                                else
                                {
                                    if (policy.PrivateComment != null && policy.PrivateComment != string.Empty)
                                    {
                                        policy.PrivateComment = string.Empty; //remove private policy-comment if there is any
                                    }
                                    foreach (CountryConfig.FunctionRow function in policy.GetFunctionRows())
                                    {
                                        if (function.Private == DefPar.Value.YES)
                                        {
                                            privateFunctions.Add(function);
                                        }
                                        else
                                        {
                                            if (function.PrivateComment != null && function.PrivateComment != string.Empty)
                                            {
                                                function.PrivateComment = string.Empty; //remove private function-comment if there is any
                                            }
                                            foreach (CountryConfig.ParameterRow parameter in function.GetParameterRows())
                                            {
                                                if (parameter.Private == DefPar.Value.YES)
                                                {
                                                    privateParameters.Add(parameter);
                                                }
                                                else if (parameter.PrivateComment != null && parameter.PrivateComment != string.Empty)
                                                {
                                                    parameter.PrivateComment = string.Empty; //remove private parameter-comment if there is any
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    List <DataConfig.DataBaseRow>       privateDataSets        = new List <DataConfig.DataBaseRow>();       //datasets
                    List <DataConfig.DBSystemConfigRow> privateDBSystemConfigs = new List <DataConfig.DBSystemConfigRow>(); //database-connections of private systems
                    foreach (DataConfig.DataBaseRow dataSet in dataConfigFacade.GetDataBaseRows())
                    {
                        if (dataSet.Private.ToLower() == DefPar.Value.YES.ToLower())
                        {
                            privateDataSets.Add(dataSet);
                        }
                        else
                        {
                            foreach (DataConfig.DBSystemConfigRow dbSystemConfig in dataConfigFacade.GetDBSystemConfigRows(dataSet.ID))
                            {
                                if (privateSystemIDs.Contains(dbSystemConfig.SystemID))
                                {
                                    privateDBSystemConfigs.Add(dbSystemConfig);
                                }
                            }
                        }
                    }

                    //remove user-set node colors
                    countryConfigFacade.RemoveAllNodeColors();

                    //restore or install default base-system-colouring
                    countryConfigFacade.setAutomaticConditionalFormatting(true);

                    //remove private systems
                    if (countryConfigFacade.GetCountryRow().Private == DefPar.Value.YES || //if country is private or
                        privateSystems.Count == countryConfigFacade.GetSystemRows().Count) //there are no systems left, delete country
                    {
                        Directory.Delete(folderCountries + country._shortName, true);
                        country.SetCountryConfigFacade(null);
                        country.SetDataConfigFacade(null);
                        continue;
                    }
                    else //otherwise delete private systems
                    {
                        foreach (CountryConfig.SystemRow privateSystem in privateSystems)
                        {
                            privateSystem.Delete();
                        }
                    }

                    //remove private parameters
                    foreach (CountryConfig.ParameterRow privateParameter in privateParameters)
                    {
                        privateParameter.Delete();
                    }

                    //remove private functions
                    foreach (CountryConfig.FunctionRow privateFunction in privateFunctions)
                    {
                        privateFunction.Delete();
                    }

                    //remove private policies
                    foreach (CountryConfig.PolicyRow privatePolicy in privatePolicies)
                    {
                        privatePolicy.Delete();
                    }

                    //remove private datasets
                    foreach (DataConfig.DataBaseRow privateDataSet in privateDataSets)
                    {
                        privateDataSet.Delete();
                    }

                    //remove database-connections of private systems
                    foreach (DataConfig.DBSystemConfigRow privateDBSystemConfig in privateDBSystemConfigs)
                    {
                        privateDBSystemConfig.Delete();
                    }

                    country.WriteXML(folderCountries + country._shortName);
                    country.SetCountryConfigFacade(null);
                    country.SetDataConfigFacade(null);

                    backgroundWorker.ReportProgress(Convert.ToInt32((i + 1.0) / (countries.Count * 1.0) * 80.0));
                }

                //remove private add-ons
                string folderAddOns = EMPath.AddSlash( //at the new path assess the folder that contains the files (usually EuromodFiles)
                    EMPath.Folder_AddOns(EM_AppContext.FolderEuromodFiles).Replace(EM_AppContext.FolderEuromodFiles, fullPublicPath));
                foreach (Country addOn in CountryAdministrator.GetAddOns())
                {
                    bool oldStyle = CountryAdministrator.ConsiderOldAddOnFileStructure(true);
                    CountryConfigFacade addOnConfigFacade = addOn.GetCountryConfigFacade(true, folderAddOns + (oldStyle ? string.Empty : addOn._shortName));
                    if (addOnConfigFacade.GetCountryRow().Private != DefPar.Value.YES)
                    {
                        continue;
                    }
                    if (oldStyle)
                    {
                        File.Delete(folderAddOns + addOn._shortName + ".xml");
                    }
                    else
                    {
                        Directory.Delete(folderAddOns + addOn._shortName, true);
                    }
                    addOn.SetCountryConfigFacade(null);
                }

                // remove the "other" column from the variables file
                string          pathVarConfig = new EMPath(EM_AppContext.FolderEuromodFiles).GetVarFilePath(true).Replace(EM_AppContext.FolderEuromodFiles, fullPublicPath);
                VarConfigFacade vcf           = new VarConfigFacade(pathVarConfig);
                if (vcf.LoadVarConfig())
                {
                    foreach (VarConfig.CountryLabelRow r in
                             from l in vcf._varConfig.CountryLabel where l.Country.ToLower() == "other" select l)
                    {
                        r.Delete();
                    }
                    vcf.Commit(); vcf.WriteXML(pathVarConfig);
                }

                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true; return;
                }                                                                      //user pressed Cancel button: see above

                //change version number
                string txtVersionPath = EMPath.Folder_Config(EM_AppContext.FolderEuromodFiles) + "EuromodVersion.txt";
                txtVersionPath = txtVersionPath.Replace(EM_AppContext.FolderEuromodFiles, fullPublicPath);
                using (StreamWriter versionFile = new StreamWriter(txtVersionPath))
                {
                    versionFile.WriteLine(_publicVersionNumber);
                    versionFile.WriteLine("PUBLIC VERSION");
                }

                //remove private rows from log file
                string logFile = new EMPath(EM_AppContext.FolderEuromodFiles).GetEmLogFilePath(); // determine the path of the em_log-file in the public folder
                logFile = logFile.Replace(EM_AppContext.FolderEuromodFiles, fullPublicPath);
                backgroundWorker.ReportProgress(100);
                if (File.Exists(logFile))
                {
                    AdaptLogFile(logFile);
                }

                //take care to not have any "xx_in_use.txt" files in the release
                try
                {
                    foreach (string inUseFile in Directory.GetFiles(fullPublicPath, "*_in_use.txt", SearchOption.AllDirectories))
                    {
                        File.Delete(inUseFile);
                    }
                }
                catch (Exception exception)
                {
                    //do nothing if this fails
                    UserInfoHandler.RecordIgnoredException("PublicVersion.Generate_BackgroundEventHandler", exception);
                }
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
                e.Cancel = true; //stop the process and allow progress indicator to set dialog result to Cancel
            }
        }