initial refactor of device export so it can be reused for future exporting
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Disco.Models.Services.Devices.Exporting
|
||||
{
|
||||
public class DeviceExportFieldMetadata
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ColumnName { get; set; }
|
||||
public Type ValueType { get; set; }
|
||||
public Func<DeviceExportRecord, object> Accessor { get; set; }
|
||||
public Func<object, string> CsvEncoder { get; set; }
|
||||
|
||||
public DeviceExportFieldMetadata(string name, Type valueType, Func<DeviceExportRecord, object> accessor, Func<object, string> csvEncoder)
|
||||
{
|
||||
Name = name;
|
||||
ValueType = valueType;
|
||||
Accessor = accessor;
|
||||
CsvEncoder = csvEncoder;
|
||||
}
|
||||
|
||||
public DeviceExportFieldMetadata(string name, string columnName, Type valueType, Func<DeviceExportRecord, object> accessor, Func<object, string> csvEncoder)
|
||||
: this(name, valueType, accessor, csvEncoder)
|
||||
{
|
||||
ColumnName = columnName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Disco.Models.Exporting;
|
||||
using Disco.Models.Services.Exporting;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Disco.Models.Services.Devices.Exporting
|
||||
{
|
||||
public class DeviceExportOptions
|
||||
public class DeviceExportOptions : IExportOptions
|
||||
{
|
||||
public DeviceExportTypes ExportType { get; set; }
|
||||
public int? ExportTypeTargetId { get; set; }
|
||||
|
||||
public bool ExcelFormat { get; set; }
|
||||
public ExportFormat Format { get; set; }
|
||||
public string FilenamePrefix { get; } = "DiscoDeviceExport";
|
||||
public string ExcelWorksheetName { get; } = "DeviceExport";
|
||||
public string ExcelTableName { get; } = "Devices";
|
||||
|
||||
// Device
|
||||
[Display(ShortName = "Device", Name = "Serial Number", Description = "The device serial number")]
|
||||
@@ -136,7 +141,7 @@ namespace Disco.Models.Services.Devices.Exporting
|
||||
return new DeviceExportOptions()
|
||||
{
|
||||
ExportType = DeviceExportTypes.All,
|
||||
ExcelFormat = true,
|
||||
Format = ExportFormat.Xlsx,
|
||||
DeviceSerialNumber = true,
|
||||
ModelId = true,
|
||||
ProfileId = true,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using Disco.Models.ClientServices.EnrolmentInformation;
|
||||
using Disco.Models.Exporting;
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Disco.Models.Services.Devices.Exporting
|
||||
{
|
||||
public class DeviceExportRecord
|
||||
public class DeviceExportRecord : IExportRecord
|
||||
{
|
||||
public Device Device { get; set; }
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.Models.Services.Devices.Exporting
|
||||
{
|
||||
public class DeviceExportResult
|
||||
{
|
||||
public MemoryStream Result { get; set; }
|
||||
public int RecordCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Models.Services.Devices.Exporting
|
||||
namespace Disco.Models.Services.Devices.Exporting
|
||||
{
|
||||
public enum DeviceExportTypes
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user