public static void ExportResults(ConsoleOptions options)
        {
            ReportType type = ReportType.Summary;

            if (options.ReportType == "summary")
            {
                type = ReportType.Summary;
            }
            else if (options.ReportType == "detailed")
            {
                type = ReportType.Detailed;
            }

            if (options.CsvPath != null)
            {
                CsvUtils.ExportResults(History, options.CsvPath, type);
                Logger.Info("Results successfuly exported to CSV.");
            }

            if (options.JsonPath != null)
            {
                var configuration = SystemUtils.GetComputerConfiguration();

                JsonUtils.ExportToJson(options.JsonPath, configuration, History, type);
                Logger.Info("Results successfuly exported to JSON.");
            }
        }
示例#2
0
        private void Export(ReportFormat reportFormat, ReportType reportType, SaveFileDialog dialog)
        {
            string postfix = reportType == ReportType.Detailed ? "detailed" : "summary";

            dialog.FileName = String.Format("DatabaseBenchmark-{0:yyyy-MM-dd HH.mm}-{1}", DateTime.Now, postfix);

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    // Start loading and disable MainForm.
                    LoadingFrame.Start(string.Format("Exporting to {0}...", reportFormat), Bounds);
                    Enabled = false;

                    switch (reportFormat)
                    {
                    case ReportFormat.CSV:
                        CsvUtils.ExportResults(History, saveFileDialogCsv.FileName, reportType);
                        break;

                    case ReportFormat.JSON:
                        ComputerConfiguration configuration = SystemUtils.GetComputerConfiguration();
                        JsonUtils.ExportToJson(saveFileDialogJson.FileName, configuration, History, reportType);
                        break;

                    case ReportFormat.PDF:
                        // TODO: Fix this.
                        //BenchmarkSession test = History[0];
                        //PdfUtils.Export(saveFileDialogPdf.FileName, MainLayout.StepFrames, test.FlowCount, test.RecordCount, test.Randomness, SystemUtils.GetComputerConfiguration(), reportType);
                        break;
                    }

                    // Stop loading end enable MainForm
                    LoadingFrame.Stop();
                    Enabled = true;
                }
                catch (Exception exc)
                {
                    string message = string.Format("Export results to {0} failed...", reportFormat);

                    Logger.Error(message, exc);
                    ReportError(message);
                    Enabled = true;
                    LoadingFrame.Stop();
                }
            }
        }