private WorktimeRangeAdmin PrepareWorktimeRangeAdmin() { if (!radioBudget.Checked) // for charts per scenario and per HH-type just avoid ranges { return(new WorktimeRangeAdmin(WorktimeRangeAdmin.RangeType.None, true, years, radioCountryYear.Checked ? GetSelectedHHTypes() : null)); } WorktimeRangeAdmin.RangeType t = WorktimeRangeAdmin.RangeType.None; if (radioRangeHoursFixedWage.Checked) { t = WorktimeRangeAdmin.RangeType.RangeHours_FixWage; } else if (radioRangeWageFixedHours.Checked) { t = WorktimeRangeAdmin.RangeType.RangeWage_FixHours; } else if (radioRangeIncomeFixedHours.Checked) { t = WorktimeRangeAdmin.RangeType.RangeInc_FixHours; } else if (radioRangeIncomeFixedWage.Checked) { t = WorktimeRangeAdmin.RangeType.RangeInc_FixWage; } WorktimeRangeAdmin worktimeRangeAdmin = new WorktimeRangeAdmin(t, true, years, GetSelectedHHTypes()); foreach (var hhType in GetInfoHHTypes()) // find the HH-type ... { int hhTypeId = hhType.Key; string hhTypeName = hhType.Value; foreach (string pName in GetHHTypePersonNames(hhTypeId)) // ... and person ... { if (hhTypeName == GetSelectedHHTypes().First() && pName == comboPerson.Text) { worktimeRangeAdmin.AddPersonWorktimeRange(hhTypeName, pName, new WorktimeRange() // ... for whom to range income { fixValue = double.Parse(txtFixedValue.Text), rangeFrom = double.Parse(txtRangeFrom.Text), rangeTo = double.Parse(txtRangeTo.Text), rangeStep = double.Parse(txtRangeStep.Text) }); } } } return(worktimeRangeAdmin); }
private void GenerateStatistics() { try { dataGenerator = new DataGenerator(inputForm, plugin); WorktimeRangeAdmin worktimeRangeAdmin = PrepareWorktimeRangeAdmin(); if (!dataGenerator.getAllFileDetails(out generationDetails, out List <string> errors, worktimeRangeAdmin)) { throw new Exception(String.Join("\n", errors)); } if (worktimeRangeAdmin.HasReducedRanges(out List <string> rangeAvertInfo) && MessageBox.Show("The following range-variables were reduced to their average value:" + Environment.NewLine + String.Join(Environment.NewLine, rangeAvertInfo), string.Empty, MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } if (!Directory.Exists(tempPathData)) { Directory.CreateDirectory(tempPathData); } btnStart.Enabled = false; Refresh(); backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerSupportsCancellation = true; backgroundWorker.WorkerReportsProgress = true; backgroundWorker.DoWork += backgroundWorker_DoWork; backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; backgroundWorker.ProgressChanged += backgroundWorker_ProgressChanged; backgroundWorker.RunWorkerAsync(); } catch (Exception e) { MessageBox.Show("Statistics generation aborted with errors:" + Environment.NewLine + e.Message); } }