public void TestWriteCsv() { MacroscopeJobMaster JobMaster = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE); MaroscopeCsvRemarksReport ReportFile = new MaroscopeCsvRemarksReport(); string Filename = string.Join(".", Path.GetTempFileName(), ".csv"); ReportFile.WriteCsv(JobMaster: JobMaster, OutputFilename: Filename); Assert.IsTrue(File.Exists(Filename)); File.Delete(Filename); }
/** Remarks ------------------------------------------------------------ **/ private void CallbackSaveRemarksCsvReport(object sender, EventArgs e) { SaveFileDialog Dialog = new SaveFileDialog(); Dialog.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"; Dialog.FilterIndex = 2; Dialog.RestoreDirectory = true; Dialog.DefaultExt = "csv"; Dialog.AddExtension = true; Dialog.FileName = "Macroscope-Remarks.csv"; this.Enabled = false; if (Dialog.ShowDialog() == DialogResult.OK) { string Path = Dialog.FileName; MaroscopeCsvRemarksReport CsvReport = new MaroscopeCsvRemarksReport(); try { Cursor.Current = Cursors.WaitCursor; CsvReport.WriteCsv(this.JobMaster, Path); Cursor.Current = Cursors.Default; } catch (MacroscopeSaveCsvFileException ex) { this.DialogueBoxError("Error saving Remarks CSV Report", ex.Message); } catch (Exception ex) { this.DialogueBoxError("Error saving Remarks CSV Report", ex.Message); } finally { Cursor.Current = Cursors.Default; } } if (Dialog != null) { Dialog.Dispose(); } this.Enabled = true; }