コード例 #1
0
        private void CallbackSavePageMetadataCsvReport(
            object sender,
            EventArgs e,
            MacroscopeCsvPageMetadataReport.OutputWorksheet SelectedOutputWorksheet,
            string OutputFilename
            )
        {
            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         = OutputFilename;

            this.Enabled = false;

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

                try
                {
                    Cursor.Current = Cursors.WaitCursor;

                    CsvReport.WriteCsv(
                        JobMaster: this.JobMaster,
                        SelectedOutputWorksheet: SelectedOutputWorksheet,
                        OutputFilename: Path
                        );

                    Cursor.Current = Cursors.Default;
                }
                catch (MacroscopeSaveCsvFileException ex)
                {
                    this.DialogueBoxError("Error saving Page Metadata CSV Report", ex.Message);
                }
                catch (Exception ex)
                {
                    this.DialogueBoxError("Error saving Page Metadata CSV Report", ex.Message);
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }

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

            this.Enabled = true;
        }
コード例 #2
0
        public void TestWriteCsv()
        {
            MacroscopeJobMaster             JobMaster  = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE);
            MacroscopeCsvPageMetadataReport ReportFile = new MacroscopeCsvPageMetadataReport();
            List <MacroscopeCsvPageMetadataReport.OutputWorksheet> SelectedOutputWorksheets = new List <MacroscopeCsvPageMetadataReport.OutputWorksheet>();

            SelectedOutputWorksheets.Add(MacroscopeCsvPageMetadataReport.OutputWorksheet.DESCRIPTIONS);
            SelectedOutputWorksheets.Add(MacroscopeCsvPageMetadataReport.OutputWorksheet.KEYWORDS);
            SelectedOutputWorksheets.Add(MacroscopeCsvPageMetadataReport.OutputWorksheet.TITLES);
            foreach (MacroscopeCsvPageMetadataReport.OutputWorksheet SelectedOutputWorksheet in SelectedOutputWorksheets)
            {
                string Filename = string.Join(".", Path.GetTempFileName(), ".csv");
                ReportFile.WriteCsv(JobMaster: JobMaster, SelectedOutputWorksheet: SelectedOutputWorksheet, OutputFilename: Filename);
                Assert.IsTrue(File.Exists(Filename));
                File.Delete(Filename);
            }
        }