Beispiel #1
0
        private string GetOutPath(string outFile = null)
        {
            string resDir = "ResultsVariablesCheck";

            return(outFile == null?Path.Combine(UISessionInfo.GetOutputFolder(), resDir)
                       : Path.Combine(UISessionInfo.GetOutputFolder(), resDir, outFile + ".txt"));
        }
        List <int> selectedIndices = new List <int>();    // store the order of selection for Alts

        public SelectBaseAltsForm(Template.TemplateInfo templateInfo)
        {
            InitializeComponent();

            this.templateInfo = templateInfo;

            labCaption.Text = templateInfo.name;

            // try to retieve selected paths from UI-user-settings, if not successful set to UI-output-folder
            string storedBaseOutputFolder = UISessionInfo.GetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER);

            textBasePath.Text = string.IsNullOrEmpty(storedBaseOutputFolder) ? UISessionInfo.GetOutputFolder() : storedBaseOutputFolder;
            string storedAltOutputFolder = UISessionInfo.GetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.REFORM_OUTPUT_FOLDER);

            textAltPath.Text = string.IsNullOrEmpty(storedAltOutputFolder) ? textBasePath.Text : storedAltOutputFolder;

            //template.FilePackageDefinition.GetMinMaxNumberOfAlternatives(out minAlts, out maxAlts, template.TemplateType);
            if (templateInfo.maxFiles == 1)
            {
                listAlt.SelectionMode    = SelectionMode.One;
                lblMultiSelect.Visible   = false;
                lblOrderRetained.Visible = false;
            }
            else
            {
                listAlt.SelectionMode = SelectionMode.MultiExtended;
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            int selCount = listFiles.SelectedIndices.Count;

            if (selCount < templateInfo.minFiles || selCount > templateInfo.maxFiles)
            {
                if (templateInfo.maxFiles == 1)
                {
                    MessageBox.Show("Please select a file.");                             // is the same as selCount=0 (as list is in single-selection mode)
                }
                else if (templateInfo.minFiles == templateInfo.maxFiles)
                {
                    MessageBox.Show(string.Format("Please select {0} files.", templateInfo.maxFiles));
                }
                else if (templateInfo.maxFiles == int.MaxValue)
                {
                    MessageBox.Show(string.Format("Please select at least {0} files.", templateInfo.minFiles));
                }
                else
                {
                    MessageBox.Show(string.Format("Please select {0} to {1} files.", templateInfo.minFiles, templateInfo.maxFiles));
                }
                return;
            }

            filePackages = new List <FilePackageContent>();
            foreach (var file in selectedIndices.Select(i => listFiles.Items[i]))
            {
                string fileFullPath = Path.Combine(textPath.Text, file.ToString());
                if (templateInfo.templateType == HardDefinitions.TemplateType.Default)
                {
                    filePackages.Add(new FilePackageContent()
                    {
                        PathBase = fileFullPath
                    });
                }
                else // MULTI_ALT
                {
                    if (filePackages.Count == 0)
                    {
                        filePackages.Add(new FilePackageContent());
                    }
                    filePackages[0].PathsAlt.Add(fileFullPath);
                }
            }

            // save selected paths in UI-user-settings (see EM_UI.PlugInService.SessionInfo.cs, about why not using an own settings-file)
            if (!EMPath.IsSamePath(textPath.Text.ToLower(), UISessionInfo.GetOutputFolder().ToLower())) // if the path was changed: save in user-settings ...
            {
                UISessionInfo.SetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER, textPath.Text);
            }
            else // ... if path corresponds with default-output-folder: remove from user-settings, to avoid that it will remain, if user changes the default-path in project settings
            {
                UISessionInfo.RemoveRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        public SelectFilesForm(Template.TemplateInfo _templateInfo)
        {
            InitializeComponent();

            templateInfo      = _templateInfo;
            requiredVariables = templateInfo.GetRequiredVariables();
            requiredVariables.Add(DataGenerator.HHTYPE_NAME);
            labCaption.Text = templateInfo.name;
            textPath.Text   = UISessionInfo.GetOutputFolder();
        }
        private void GenerateOutput(string country, string year, string dataFullPath, BackgroundWorkerResult result)
        {
            backgroundWorker.ReportProgress(0, $"Generating output for {country} {year} ...");

            bool success = new ExeCaller().RunExe(country, year, dataFullPath, chkOutputInEuro.Checked, out List <string> errors);

            AddErrors(errors, result, country, year);

            string outputFile = Path.Combine(UISessionInfo.GetOutputFolder(), $"{country}_{year}_std.txt");

            if (success && File.Exists(outputFile))
            {
                result.generatedOutputFiles.Add(outputFile);
            }
        }
Beispiel #6
0
        internal bool RunExe(string country, string year, string dataFullPath, bool outputInEuro, out List <string> errors)
        {
            Dictionary <string, string> config = ExeRunConfig.GetBasicConfig(
                UISessionInfo.GetEuromodFilesFolder(),                               // EurmodFiles-folder
                country, $"{country}_{year}",                                        // country and system
                Path.GetDirectoryName(dataFullPath), Path.GetFileName(dataFullPath), // data-folder and data-file
                UISessionInfo.GetOutputFolder());                                    // output-folder

            if (outputInEuro)
            {
                config.Add(TAGS.CONFIG_FORCE_OUTPUT_EURO, DefPar.Value.YES);
            }

            List <string> err     = new List <string>();
            bool          success = new Control().Run(config, null, e => { err.Add((e.isWarning ? "Warning: " : "Error: ") + e.message); });

            errors = err;

            return(success);
        }
        readonly List <int> selectedIndices             = new List <int>(); // store the order of selection for Alts

        public SelectFilesForm(Template.TemplateInfo templateInfo)
        {
            InitializeComponent();

            this.templateInfo = templateInfo;

            labCaption.Text = templateInfo.name;

            // try to retieve selected path from UI-user-settings, if not successful set to UI-output-folder
            string storedBaseOutputFolder = UISessionInfo.GetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER);

            textPath.Text = string.IsNullOrEmpty(storedBaseOutputFolder) ? UISessionInfo.GetOutputFolder() : storedBaseOutputFolder;

            if (templateInfo.maxFiles == 1)
            {
                listFiles.SelectionMode  = SelectionMode.One;
                lblMultiSelect.Visible   = false;
                lblOrderRetained.Visible = false;
            }
            else
            {
                listFiles.SelectionMode = SelectionMode.MultiExtended;
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (listBase.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a file for the base scenario."); return;
            }

            int selCount = listAlt.SelectedIndices.Count;

            if (selCount < templateInfo.minFiles || selCount > templateInfo.maxFiles)
            {
                if (templateInfo.maxFiles == 1)
                {
                    MessageBox.Show("Please select a file for the alternative scenario.");                             // is the same as selCount=0 (as list is in single-selection mode)
                }
                else if (templateInfo.minFiles == templateInfo.maxFiles)
                {
                    MessageBox.Show(string.Format("Please select {0} files for the alternative scenarios.", templateInfo.maxFiles));
                }
                else if (templateInfo.maxFiles == int.MaxValue)
                {
                    MessageBox.Show(string.Format("Please select at least {0} files for the alternative scenarios.", templateInfo.minFiles));
                }
                else
                {
                    MessageBox.Show(string.Format("Please select {0} to {1} files for the alternative scenarios.", templateInfo.minFiles, templateInfo.maxFiles));
                }
                return;
            }

            FilePackageContent filePackage = new FilePackageContent()
            {
                PathBase = Path.Combine(textBasePath.Text, listBase.SelectedItem.ToString())
            };

            foreach (string altFile in selectedIndices.Select(i => listAlt.Items[i]))  // get alt selections in order
            {
                filePackage.PathsAlt.Add(Path.Combine(textAltPath.Text, altFile));
            }

            // in fact the dialog always returns exactly one file-package, the list is just for consistency-reasons with SelectFilesForm and SelectTemplateForm
            filePackages = new List <FilePackageContent>()
            {
                filePackage
            };

            // save selected paths in UI-user-settings (see description in SelectFileForm.cs )
            if (!EMPath.IsSamePath(textBasePath.Text.ToLower(), UISessionInfo.GetOutputFolder().ToLower()))
            {
                UISessionInfo.SetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER, textBasePath.Text);
            }
            else
            {
                UISessionInfo.RemoveRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.BASE_OUTPUT_FOLDER);
            }
            if (!EMPath.IsSamePath(textAltPath.Text.ToLower(), UISessionInfo.GetOutputFolder().ToLower()))
            {
                UISessionInfo.SetRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.REFORM_OUTPUT_FOLDER, textAltPath.Text);
            }
            else
            {
                UISessionInfo.RemoveRetainedUserSetting(StatisticsPresenter.USER_SETTINGS_ID, StatisticsPresenter.REFORM_OUTPUT_FOLDER);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }