//build columns and initiate interpolation process for a give file. public void process_file(configCols rec)//string units, string dir, string file, decimal conv_factor, //int first_header, int last_header, char delim, bool use_cumulative, //bool consolidate_file, string path_out) { //MessageBox.Show("data: \n" + fileName); process_srf srf = new process_srf(); srf.h1 = rec.first_header; srf.h2 = rec.last_header; srf.process_header(rec.file, rec.delim); List <columns> cols = new List <columns>(); if (rec.columns.Count > 0) { //MessageBox.Show("data: using custom column names"); cols = build_custom_cols(rec.columns, rec.conv_factor); } else { //MessageBox.Show("data: using file defined column names"); cols = build_orig_cols(srf.line_header1, rec.conv_factor); } interpolate_data interp = new interpolate_data(); outputs outfile = new outputs(rec.units); srf.process_file(rec.file, rec.delim); interp.convert_time_yearly(srf.data, cols, rec.use_cumulative, rec.step_wise); if (rec.consolidate_file == false) { outfile.build_yearly_csv_by_def(interp.year_data, rec.path_out, ",", rec.file); outfile.build_cum_csv_by_def(interp.c_data, rec.path_out, rec.file); } else { outfile.build_yearly_csv_single_file(interp.year_data, rec.path_out, ",", rec.file); outfile.build_cum_csv_by_single_file(interp.c_data, rec.path_out, rec.file); } }
private void data_by_year(object sender, RoutedEventArgs e) { string message = ""; string caption = ""; MessageBoxButton buttons = MessageBoxButton.OK; using (new WaitCursor()) { if (files == null || files.Length < 1) { // Initializes the variables to pass to the MessageBox.Show method. message = "No files are selected."; caption = "Error Detected in Input"; // Displays the MessageBox. MessageBox.Show(message, caption, buttons); return; } interpolate_data interp = new interpolate_data(); string units = "[1/year]"; if (ckbx_ci_pci.IsChecked == true) { units = "[pCi/year]"; } else if (ckbx_g_ug.IsChecked == true) { units = "[ug/year]"; } else if (tb_custom_unit.Text.Length > 0) { units = "[" + tb_custom_unit.Text + "/year]"; } outputs outfile = new outputs(units); foreach (string fileName in files) { process_srf srf = new process_srf(); srf.h1 = string_to_int(tb_h1_row.Text); srf.h2 = string_to_int(tb_h2_row.Text); srf.process_file(fileName, delim); //srf.data = srf.data; bool useCum = false; bool stepwise = false; if (ckbx_cumulative.IsChecked == true) { useCum = true; } if (ckbx_stepwise.IsChecked == true) { stepwise = true; } interp.convert_time_yearly(srf.data, colSet.column_def, useCum, stepwise); //outfile.build_ecf(interp.year_data, interp.f_data, path); //outfile.build_yearly_csv_by_def(interp.year_data, path, "\t"); if (ckbx_Consolidate_file.IsChecked == false) { outfile.build_yearly_csv_by_def(interp.year_data, path, ",", fileName); outfile.build_cum_csv_by_def(interp.c_data, path, fileName); } else { outfile.build_yearly_csv_single_file(interp.year_data, path, ",", fileName); outfile.build_cum_csv_by_single_file(interp.c_data, path, fileName); } } } // Initializes the variables to pass to the MessageBox.Show method. message = "Process Completed Successfully."; caption = "Process Complete"; // Displays the MessageBox. MessageBox.Show(message, caption, buttons); }