protected override void ItemExport(Run run) { if (run.Status == Run.RunStatus.NotRun) { MessageBox.Show("Run Is not complete. Click 'Run' to complete", "Cannot export"); return; } Run.ValidationResult runValidationResult = run.Validate(); if (!runValidationResult.IsValid) { MessageBox.Show( string.Format( "Run data not valid. Please correct them and try again. {0}{0}Details: {0}{1}", Environment.NewLine, runValidationResult.Error), "Cannot export"); return; } Exporter exporter = new Exporter(run.Trial); exporter.export(run); string folderPath = String.Format(String.Format("{0}/{1}/text/", Exporter.EXPORT_DIRECTORY, Exporter.ToFriendlyFilename(Researcher.Current.ActiveProject.ToString()))); DialogResult dialogResult = MessageBox.Show( string.Format( "Export Successfull in the following directory: {0}\n\nOpen Containing Folder?", System.IO.Path.GetFullPath(folderPath)), "Exported Trial", MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start(System.IO.Path.GetFullPath(folderPath)); } }
public void export(Trial trial) { ExportRun exportRun = ExportRun.Create(trial.Runs[0], exportSettings); List <string> dataRows = new List <string>(); string headerRow = String.Join <String>("\t", exportRun.Headers()); foreach (Run run in trial.Runs) { exportRun = ExportRun.Create(run, exportSettings); if (run.Status == Run.RunStatus.Complete) { Run.ValidationResult runValidationResult = run.Validate(); if (runValidationResult.IsValid) { dataRows.Add(String.Join <String>("\t", exportRun.RunData())); } } } string exportFilename = exportPath(trial); string exportDirectory = Path.GetDirectoryName(exportFilename); if (!Directory.Exists(exportDirectory)) { Directory.CreateDirectory(exportDirectory); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(exportFilename)) { file.WriteLine(headerRow); foreach (string dataRow in dataRows) { file.WriteLine(dataRow); } } }