private ForecastEquation GetEquation(string forecastName) { currentForecast = forecastName; var fileName = FileUtility.GetTempFileName(".csv"); xls.SaveSheetToCsv(forecastName, fileName); Logger.WriteLine("Run " + forecastName); ForecastEquation eq = new ForecastEquation(fileName); return(eq); }
private void buttonRecomputeCoeficients_Click(object sender, EventArgs e) { // Performance perf = new Performance(); string fn = FileUtility.GetTempFileName(".csv"); xls.SaveSheetToCsv(xls.ActiveSheetName, fn); xls.Save(); // must save to get back to *.xls from *.csv eq = new ForecastEquation(fn); var cache = new HydrometDataCache(); cache.Add(eq.GetCbttPcodeList().ToArray(), new DateTime(eq.StartYear - 1, 10, 1), new DateTime(eq.EndYear, 9, 30)); HydrometMonthlySeries.Cache = cache; var dir = Path.GetDirectoryName(this.textBoxExcelFileName.Text); try { Cursor = Cursors.WaitCursor; Application.DoEvents(); R = new CoefficientCalculator(); var newCoefficients = R.ComputeCoefficients(eq, Path.GetDirectoryName(Application.ExecutablePath)); var dlg = new RegressionResults(); dlg.CompareToHistoryClicked += new EventHandler <EventArgs>(dlg_CompareToHistoryClicked); dlg.Output = R.Output; dlg.DataFile = R.dataFile; dlg.CoeficientsExisting = CoefficientCalculator.FormatCoefficients(eq.coefficients); dlg.CoefficientsComputed = CoefficientCalculator.FormatCoefficients(newCoefficients); if (dlg.ShowDialog() == DialogResult.OK) // save { // save back to excel. xls.UpdateCoeficients(xls.ActiveSheetName, newCoefficients); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Cursor = Cursors.Default; } }