public void TestWriteCsv()
        {
            MacroscopeJobMaster         JobMaster  = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE);
            MacroscopeCsvOverviewReport ReportFile = new MacroscopeCsvOverviewReport();
            string Filename = string.Join(".", Path.GetTempFileName(), ".csv");

            ReportFile.WriteCsv(JobMaster: JobMaster, OutputFilename: Filename);
            Assert.IsTrue(File.Exists(Filename));
            File.Delete(Filename);
        }
        /**************************************************************************/

        private void CallbackSaveOverviewCsvReport(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-Overview.csv";

            this.Enabled = false;

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string Path = Dialog.FileName;
                MacroscopeCsvOverviewReport CsvReport = new MacroscopeCsvOverviewReport();

                try
                {
                    CsvReport.WriteCsv(this.JobMaster, Path);
                }
                catch (MacroscopeSaveCsvFileException ex)
                {
                    this.DialogueBoxError("Error saving Overview CSV Report", ex.Message);
                }
                catch (Exception ex)
                {
                    this.DialogueBoxError("Error saving Overview CSV Report", ex.Message);
                }
            }

            if (Dialog != null)
            {
                Dialog.Dispose();
            }

            this.Enabled = true;
        }
Ejemplo n.º 3
0
        /**************************************************************************/

        private void CallbackSaveOverviewCsvReport(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-Overview.csv";

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string Path = Dialog.FileName;
                MacroscopeCsvOverviewReport CsvReport = new MacroscopeCsvOverviewReport();

                try
                {
                    if (Macroscope.MemoryGuard(RequiredMegabytes: CsvReportMegabytesRamRequired))
                    {
                        CsvReport.WriteCsv(this.JobMaster, Path);
                    }
                }
                catch (MacroscopeInsufficientMemoryException ex)
                {
                    this.DialogueBoxError("Error saving Overview CSV Report", ex.Message);
                }
                catch (MacroscopeSaveCsvFileException ex)
                {
                    this.DialogueBoxError("Error saving Overview CSV Report", ex.Message);
                }
                catch (Exception ex)
                {
                    this.DialogueBoxError("Error saving Overview CSV Report", ex.Message);
                }
            }

            Dialog.Dispose();
        }