initial refactor of device export so it can be reused for future exporting
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace Disco.Models.Exporting
|
||||
{
|
||||
public class ExportFieldMetadata<T> where T : IExportRecord
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ColumnName { get; set; }
|
||||
public Type ValueType { get; set; }
|
||||
public Func<T, object> Accessor { get; set; }
|
||||
public Func<object, string> CsvEncoder { get; set; }
|
||||
|
||||
public ExportFieldMetadata(string name, Type valueType, Func<T, object> accessor, Func<object, string> csvEncoder)
|
||||
{
|
||||
Name = name;
|
||||
ValueType = valueType;
|
||||
Accessor = accessor;
|
||||
CsvEncoder = csvEncoder;
|
||||
}
|
||||
|
||||
public ExportFieldMetadata(string name, string columnName, Type valueType, Func<T, object> accessor, Func<object, string> csvEncoder)
|
||||
: this(name, valueType, accessor, csvEncoder)
|
||||
{
|
||||
ColumnName = columnName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Disco.Models.Exporting
|
||||
{
|
||||
public enum ExportFormat
|
||||
{
|
||||
Csv,
|
||||
Xlsx,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.Models.Services.Exporting
|
||||
{
|
||||
public class ExportResult
|
||||
{
|
||||
public MemoryStream Result { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public int RecordCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Disco.Models.Exporting;
|
||||
|
||||
namespace Disco.Models.Services.Exporting
|
||||
{
|
||||
public interface IExportOptions
|
||||
{
|
||||
ExportFormat Format { get; }
|
||||
string FilenamePrefix { get; }
|
||||
string ExcelWorksheetName { get; }
|
||||
string ExcelTableName { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Disco.Models.Exporting
|
||||
{
|
||||
public interface IExportRecord
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user