From 0d4085590260f4c100b7466da38f68366d5f7084 Mon Sep 17 00:00:00 2001 From: Neal Geilen Date: Sat, 4 Jun 2022 13:36:33 +0200 Subject: [PATCH] Made changes to support new export architecture --- .../ExcelModuleExporter.cs} | 18 +++++++++++++----- .../CoreServiceCollectionExtensions.cs | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) rename Epsilon/Export/{ExcelCanvasModuleFileExporter.cs => Exporters/ExcelModuleExporter.cs} (85%) diff --git a/Epsilon/Export/ExcelCanvasModuleFileExporter.cs b/Epsilon/Export/Exporters/ExcelModuleExporter.cs similarity index 85% rename from Epsilon/Export/ExcelCanvasModuleFileExporter.cs rename to Epsilon/Export/Exporters/ExcelModuleExporter.cs index fff98cd3..9f1e67f8 100644 --- a/Epsilon/Export/ExcelCanvasModuleFileExporter.cs +++ b/Epsilon/Export/Exporters/ExcelModuleExporter.cs @@ -1,12 +1,20 @@ using Epsilon.Abstractions.Export; using Epsilon.Canvas.Abstractions.Data; using ExcelLibrary.SpreadSheet; +using Microsoft.Extensions.Options; -namespace Epsilon.Export; +namespace Epsilon.Export.Exporters; -public class ExcelCanvasModuleFileExporter : ICanvasModuleFileExporter +public class ExcelModuleExporter : ICanvasModuleExporter { - public bool CanExport(string format) => format.ToLower() == "xls"; + private readonly ExportOptions _options; + + public ExcelModuleExporter(IOptions options) + { + _options = options.Value; + } + + public IEnumerable Formats { get; } = new[] { "xls" }; public List GetAllOutcomesTypes(Module module) { @@ -39,7 +47,7 @@ public int GetOutcomeRow(List outcomes, Outcome outcome) return 0; } - public void Export(IEnumerable modules, string path) + public void Export(IEnumerable modules, string format) { Workbook workbook = new Workbook(); @@ -83,6 +91,6 @@ public void Export(IEnumerable modules, string path) } } - workbook.Save(path + ".xls"); + workbook.Save($"{_options.FormattedOutputName}.{format}"); } } \ No newline at end of file diff --git a/Epsilon/Extensions/CoreServiceCollectionExtensions.cs b/Epsilon/Extensions/CoreServiceCollectionExtensions.cs index 1b5afb09..47e35cef 100644 --- a/Epsilon/Extensions/CoreServiceCollectionExtensions.cs +++ b/Epsilon/Extensions/CoreServiceCollectionExtensions.cs @@ -23,6 +23,7 @@ private static IServiceCollection AddExport(this IServiceCollection services, IC services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddScoped();