예제 #1
0
        private void OnReportPDF(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog dlg = new SaveFileDialog()
                {
                    InitialDirectory = Properties.Settings.Default.ReportInitialDirectory,
                    FileName         = Path.ChangeExtension(CleanString(Analysis.Name), "pdf"),
                    Filter           = Properties.Resources.ID_FILTER_PDF,
                    DefaultExt       = "pdf",
                    ValidateNames    = true
                };

                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // save directory
                    Properties.Settings.Default.ReportInitialDirectory = Path.GetDirectoryName(dlg.FileName);
                    // generate report
                    ReporterPDF reporter = new ReporterPDF(
                        new ReportData(_analysis)
                        , ref _rnRoot
                        , Reporter.TemplatePath
                        , dlg.FileName);
                    Process.Start(new ProcessStartInfo(dlg.FileName));
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }
예제 #2
0
        private void OnReportPDF(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog dlg = new SaveFileDialog()
                {
                    InitialDirectory = Settings.Default.ReportInitialDirectory,
                    FileName         = Path.ChangeExtension(CleanString(Data.SuggestedFileName), "pdf"),
                    Filter           = Resources.ID_FILTER_PDF,
                    DefaultExt       = "pdf",
                    ValidateNames    = true
                };

                if (DialogResult.OK == dlg.ShowDialog())
                {
                    // save directory
                    Settings.Default.ReportInitialDirectory = Path.GetDirectoryName(dlg.FileName);
                    // generate report
                    ReporterPDF reporter = new ReporterPDF(
                        Data
                        , ref _rnRoot
                        , Reporter.TemplatePath
                        , dlg.FileName);
                    Process.Start(new ProcessStartInfo(dlg.FileName));

                    // try and delete html file
                    string htmlFilePath = Path.ChangeExtension(dlg.FileName, "html");
                    if (File.Exists(htmlFilePath))
                    {
                        File.Delete(htmlFilePath);
                    }
                    // try and delete image directory
                    string imagesDirPath = Path.Combine(Path.GetDirectoryName(dlg.FileName), "Images");
                    if (Directory.Exists(imagesDirPath))
                    {
                        Directory.Delete(imagesDirPath, true);
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }