예제 #1
0
        public void TestWriteCsv()
        {
            MacroscopeJobMaster             JobMaster    = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE);
            MacroscopeCustomFilters         CustomFilter = new MacroscopeCustomFilters(1);
            MacroscopeCsvCustomFilterReport ReportFile   = new MacroscopeCsvCustomFilterReport(NewCustomFilter: CustomFilter);
            string Filename = string.Join(".", Path.GetTempFileName(), ".csv");

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

        private void CallbackSaveCustomFilterCsvReport(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-Custom-Filters.csv";

            this.Enabled = false;

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string Path = Dialog.FileName;
                MacroscopeCsvCustomFilterReport CsvReport = new MacroscopeCsvCustomFilterReport(NewCustomFilter: this.CustomFilter);

                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    CsvReport.WriteCsv(this.JobMaster, Path);
                    Cursor.Current = Cursors.Default;
                }
                catch (MacroscopeSaveCsvFileException ex)
                {
                    this.DialogueBoxError("Error saving Custom Filters CSV Report", ex.Message);
                }
                catch (Exception ex)
                {
                    this.DialogueBoxError("Error saving Custom Filters CSV Report", ex.Message);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }

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

            this.Enabled = true;
        }