feature: exports api refactoring

This commit is contained in:
Gary Sharp
2025-02-14 13:07:30 +11:00
parent 2c215e4856
commit d3cef11796
15 changed files with 239 additions and 232 deletions
+12 -3
View File
@@ -1,10 +1,19 @@
using System.Collections.Generic; using Disco.Models.Services.Exporting;
using System.Collections.Generic;
namespace Disco.Models.Exporting namespace Disco.Models.Exporting
{ {
public class ExportMetadata<T> public class ExportMetadata<O, R>
: List<ExportMetadataField<T>> where T : IExportRecord : List<ExportMetadataField<R>>
where O : IExportOptions
where R : IExportRecord
{ {
public List<string> IgnoreShortNames { get; } = new List<string>(); public List<string> IgnoreShortNames { get; } = new List<string>();
public O Options { get; set; }
public ExportMetadata(O options)
{
Options = options;
}
} }
} }
+44 -47
View File
@@ -2,16 +2,13 @@
using Disco.Models.Exporting; using Disco.Models.Exporting;
using Disco.Models.Repository; using Disco.Models.Repository;
using Disco.Models.Services.Devices; using Disco.Models.Services.Devices;
using Disco.Models.Services.Devices.DeviceFlag;
using Disco.Models.Services.Exporting; using Disco.Models.Services.Exporting;
using Disco.Services.Devices.DeviceFlags;
using Disco.Services.Exporting; using Disco.Services.Exporting;
using Disco.Services.Plugins.Features.DetailsProvider; using Disco.Services.Plugins.Features.DetailsProvider;
using Disco.Services.Tasks; using Disco.Services.Tasks;
using Disco.Services.Users; using Disco.Services.Users;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity; using System.Data.Entity;
using System.Linq; using System.Linq;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -184,56 +181,56 @@ namespace Disco.Services.Devices
return records; return records;
} }
public ExportMetadata<DeviceExportRecord> BuildMetadata(DiscoDataContext database, List<DeviceExportRecord> records, IScheduledTaskStatus taskStatus) public ExportMetadata<DeviceExportOptions, DeviceExportRecord> BuildMetadata(DiscoDataContext database, List<DeviceExportRecord> records, IScheduledTaskStatus taskStatus)
{ {
var metadata = new ExportMetadata<DeviceExportRecord>(); var metadata = new ExportMetadata<DeviceExportOptions, DeviceExportRecord>(Options);
metadata.IgnoreShortNames.Add("Device"); metadata.IgnoreShortNames.Add("Device");
metadata.IgnoreShortNames.Add("Details"); metadata.IgnoreShortNames.Add("Details");
// Device // Device
metadata.Add(Options, o => o.DeviceSerialNumber, r => r.Device.SerialNumber); metadata.Add(o => o.DeviceSerialNumber, r => r.Device.SerialNumber);
metadata.Add(Options, o => o.DeviceAssetNumber, r => r.Device.AssetNumber); metadata.Add(o => o.DeviceAssetNumber, r => r.Device.AssetNumber);
metadata.Add(Options, o => o.DeviceLocation, r => r.Device.Location); metadata.Add(o => o.DeviceLocation, r => r.Device.Location);
metadata.Add(Options, o => o.DeviceComputerName, r => r.Device.DeviceDomainId); metadata.Add(o => o.DeviceComputerName, r => r.Device.DeviceDomainId);
metadata.Add(Options, o => o.DeviceLastNetworkLogon, r => r.Device.LastNetworkLogonDate); metadata.Add(o => o.DeviceLastNetworkLogon, r => r.Device.LastNetworkLogonDate);
metadata.Add(Options, o => o.DeviceCreatedDate, r => r.Device.CreatedDate); metadata.Add(o => o.DeviceCreatedDate, r => r.Device.CreatedDate);
metadata.Add(Options, o => o.DeviceFirstEnrolledDate, r => r.Device.EnrolledDate); metadata.Add(o => o.DeviceFirstEnrolledDate, r => r.Device.EnrolledDate);
metadata.Add(Options, o => o.DeviceLastEnrolledDate, r => r.Device.LastEnrolDate); metadata.Add(o => o.DeviceLastEnrolledDate, r => r.Device.LastEnrolDate);
metadata.Add(Options, o => o.DeviceAllowUnauthenticatedEnrol, r => r.Device.AllowUnauthenticatedEnrol); metadata.Add(o => o.DeviceAllowUnauthenticatedEnrol, r => r.Device.AllowUnauthenticatedEnrol);
metadata.Add(Options, o => o.DeviceDecommissionedDate, r => r.Device.DecommissionedDate); metadata.Add(o => o.DeviceDecommissionedDate, r => r.Device.DecommissionedDate);
metadata.Add(Options, o => o.DeviceDecommissionedReason, r => r.Device.DecommissionReason?.ToString()); metadata.Add(o => o.DeviceDecommissionedReason, r => r.Device.DecommissionReason?.ToString());
// Model // Model
metadata.Add(Options, o => o.ModelId, r => r.ModelId); metadata.Add(o => o.ModelId, r => r.ModelId);
metadata.Add(Options, o => o.ModelDescription, r => r.ModelDescription); metadata.Add(o => o.ModelDescription, r => r.ModelDescription);
metadata.Add(Options, o => o.ModelManufacturer, r => r.ModelManufacturer); metadata.Add(o => o.ModelManufacturer, r => r.ModelManufacturer);
metadata.Add(Options, o => o.ModelModel, r => r.ModelModel); metadata.Add(o => o.ModelModel, r => r.ModelModel);
metadata.Add(Options, o => o.ModelType, r => r.ModelType); metadata.Add(o => o.ModelType, r => r.ModelType);
// Batch // Batch
metadata.Add(Options, o => o.BatchId, r => r.BatchId); metadata.Add(o => o.BatchId, r => r.BatchId);
metadata.Add(Options, o => o.BatchName, r => r.BatchName); metadata.Add(o => o.BatchName, r => r.BatchName);
metadata.Add(Options, o => o.BatchPurchaseDate, r => r.BatchPurchaseDate); metadata.Add(o => o.BatchPurchaseDate, r => r.BatchPurchaseDate);
metadata.Add(Options, o => o.BatchSupplier, r => r.BatchSupplier); metadata.Add(o => o.BatchSupplier, r => r.BatchSupplier);
metadata.Add(Options, o => o.BatchUnitCost, r => r.BatchUnitCost, Exporter.CsvEncoders.NullableCurrencyEncoder); metadata.Add(o => o.BatchUnitCost, r => r.BatchUnitCost, Exporter.CsvEncoders.NullableCurrencyEncoder);
metadata.Add(Options, o => o.BatchWarrantyValidUntilDate, r => r.BatchWarrantyValidUntilDate); metadata.Add(o => o.BatchWarrantyValidUntilDate, r => r.BatchWarrantyValidUntilDate);
metadata.Add(Options, o => o.BatchInsuredDate, r => r.BatchInsuredDate); metadata.Add(o => o.BatchInsuredDate, r => r.BatchInsuredDate);
metadata.Add(Options, o => o.BatchInsuranceSupplier, r => r.BatchInsuranceSupplier); metadata.Add(o => o.BatchInsuranceSupplier, r => r.BatchInsuranceSupplier);
metadata.Add(Options, o => o.BatchInsuredUntilDate, r => r.BatchInsuredUntilDate); metadata.Add(o => o.BatchInsuredUntilDate, r => r.BatchInsuredUntilDate);
// Profile // Profile
metadata.Add(Options, o => o.ProfileId, r => r.ProfileId); metadata.Add(o => o.ProfileId, r => r.ProfileId);
metadata.Add(Options, o => o.ProfileName, r => r.ProfileName); metadata.Add(o => o.ProfileName, r => r.ProfileName);
metadata.Add(Options, o => o.ProfileShortName, r => r.ProfileShortName); metadata.Add(o => o.ProfileShortName, r => r.ProfileShortName);
// User // User
metadata.Add(Options, o => o.AssignedUserId, r => r.AssignedUser?.UserId); metadata.Add(o => o.AssignedUserId, r => r.AssignedUser?.UserId);
metadata.Add(Options, o => o.AssignedUserDate, r => r.DeviceUserAssignment?.AssignedDate); metadata.Add(o => o.AssignedUserDate, r => r.DeviceUserAssignment?.AssignedDate);
metadata.Add(Options, o => o.AssignedUserDisplayName, r => r.AssignedUser?.DisplayName); metadata.Add(o => o.AssignedUserDisplayName, r => r.AssignedUser?.DisplayName);
metadata.Add(Options, o => o.AssignedUserSurname, r => r.AssignedUser?.Surname); metadata.Add(o => o.AssignedUserSurname, r => r.AssignedUser?.Surname);
metadata.Add(Options, o => o.AssignedUserGivenName, r => r.AssignedUser?.GivenName); metadata.Add(o => o.AssignedUserGivenName, r => r.AssignedUser?.GivenName);
metadata.Add(Options, o => o.AssignedUserPhoneNumber, r => r.AssignedUser?.PhoneNumber); metadata.Add(o => o.AssignedUserPhoneNumber, r => r.AssignedUser?.PhoneNumber);
metadata.Add(Options, o => o.AssignedUserEmailAddress, r => r.AssignedUser?.EmailAddress); metadata.Add(o => o.AssignedUserEmailAddress, r => r.AssignedUser?.EmailAddress);
// User Custom Details // User Custom Details
if (Options.AssignedUserDetailCustom) if (Options.AssignedUserDetailCustom)
@@ -246,11 +243,11 @@ namespace Disco.Services.Devices
} }
// Jobs // Jobs
metadata.Add(Options, o => o.JobsTotalCount, r => r.JobsTotalCount); metadata.Add(o => o.JobsTotalCount, r => r.JobsTotalCount);
metadata.Add(Options, o => o.JobsOpenCount, r => r.JobsOpenCount); metadata.Add(o => o.JobsOpenCount, r => r.JobsOpenCount);
// Attachments // Attachments
metadata.Add(Options, o => o.AttachmentsCount, r => r.AttachmentsCount); metadata.Add(o => o.AttachmentsCount, r => r.AttachmentsCount);
// Certificates // Certificates
if (Options.Certificates) if (Options.Certificates)
@@ -433,10 +430,10 @@ namespace Disco.Services.Devices
} }
} }
metadata.Add(Options, o => o.DetailACAdapter, r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyACAdapter).Select(dd => dd.Value).FirstOrDefault()); metadata.Add(o => o.DetailACAdapter, r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyACAdapter).Select(dd => dd.Value).FirstOrDefault());
// Batteries // Batteries
metadata.Add(Options, o => o.DetailBattery, r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyBattery).Select(dd => dd.Value).FirstOrDefault()); metadata.Add(o => o.DetailBattery, r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyBattery).Select(dd => dd.Value).FirstOrDefault());
if (Options.DetailBatteries) if (Options.DetailBatteries)
{ {
var batteriesMaxCount = Math.Max(1, records.Max(r => r.DeviceDetailBatteries?.Count ?? 0)); var batteriesMaxCount = Math.Max(1, records.Max(r => r.DeviceDetailBatteries?.Count ?? 0));
@@ -454,8 +451,8 @@ namespace Disco.Services.Devices
} }
} }
metadata.Add(Options, o => o.DetailKeyboard, r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyKeyboard).Select(dd => dd.Value).FirstOrDefault()); metadata.Add(o => o.DetailKeyboard, r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyKeyboard).Select(dd => dd.Value).FirstOrDefault());
metadata.Add(Options, o => o.DetailMdmHardwareData, r => r.DeviceDetails.MdmHardwareData()); metadata.Add(o => o.DetailMdmHardwareData, r => r.DeviceDetails.MdmHardwareData());
return metadata; return metadata;
} }
@@ -108,67 +108,67 @@ namespace Disco.Services.Devices.DeviceFlags
return records; return records;
} }
public ExportMetadata<DeviceFlagExportRecord> BuildMetadata(DiscoDataContext database, List<DeviceFlagExportRecord> records, IScheduledTaskStatus status) public ExportMetadata<DeviceFlagExportOptions, DeviceFlagExportRecord> BuildMetadata(DiscoDataContext database, List<DeviceFlagExportRecord> records, IScheduledTaskStatus status)
{ {
var metadata = new ExportMetadata<DeviceFlagExportRecord>(); var metadata = new ExportMetadata<DeviceFlagExportOptions, DeviceFlagExportRecord>(Options);
metadata.IgnoreShortNames.Add("Device Flag"); metadata.IgnoreShortNames.Add("Device Flag");
// Device Flag // Device Flag
metadata.Add(Options, o => o.Id, r => r.Assignment.DeviceFlagId); metadata.Add(o => o.Id, r => r.Assignment.DeviceFlagId);
metadata.Add(Options, o => o.Name, r => r.Assignment.DeviceFlag.Name); metadata.Add(o => o.Name, r => r.Assignment.DeviceFlag.Name);
metadata.Add(Options, o => o.Description, r => r.Assignment.DeviceFlag.Description); metadata.Add(o => o.Description, r => r.Assignment.DeviceFlag.Description);
metadata.Add(Options, o => o.Icon, r => r.Assignment.DeviceFlag.Icon); metadata.Add(o => o.Icon, r => r.Assignment.DeviceFlag.Icon);
metadata.Add(Options, o => o.IconColour, r => r.Assignment.DeviceFlag.IconColour); metadata.Add(o => o.IconColour, r => r.Assignment.DeviceFlag.IconColour);
metadata.Add(Options, o => o.AssignmentId, r => r.Assignment.Id); metadata.Add(o => o.AssignmentId, r => r.Assignment.Id);
metadata.Add(Options, o => o.AddedDate, r => r.Assignment.AddedDate); metadata.Add(o => o.AddedDate, r => r.Assignment.AddedDate);
metadata.Add(Options, o => o.AddedUserId, r => r.Assignment.AddedUserId); metadata.Add(o => o.AddedUserId, r => r.Assignment.AddedUserId);
metadata.Add(Options, o => o.RemovedUserId, r => r.Assignment.RemovedUserId); metadata.Add(o => o.RemovedUserId, r => r.Assignment.RemovedUserId);
metadata.Add(Options, o => o.RemovedDate, r => r.Assignment.RemovedDate); metadata.Add(o => o.RemovedDate, r => r.Assignment.RemovedDate);
metadata.Add(Options, o => o.Comments, r => r.Assignment.Comments); metadata.Add(o => o.Comments, r => r.Assignment.Comments);
// Device // Device
metadata.Add(Options, o => o.DeviceSerialNumber, r => r.Assignment.Device.SerialNumber); metadata.Add(o => o.DeviceSerialNumber, r => r.Assignment.Device.SerialNumber);
metadata.Add(Options, o => o.DeviceAssetNumber, r => r.Assignment.Device.AssetNumber); metadata.Add(o => o.DeviceAssetNumber, r => r.Assignment.Device.AssetNumber);
metadata.Add(Options, o => o.DeviceLocation, r => r.Assignment.Device.Location); metadata.Add(o => o.DeviceLocation, r => r.Assignment.Device.Location);
metadata.Add(Options, o => o.DeviceComputerName, r => r.Assignment.Device.DeviceDomainId); metadata.Add(o => o.DeviceComputerName, r => r.Assignment.Device.DeviceDomainId);
metadata.Add(Options, o => o.DeviceLastNetworkLogon, r => r.Assignment.Device.LastNetworkLogonDate); metadata.Add(o => o.DeviceLastNetworkLogon, r => r.Assignment.Device.LastNetworkLogonDate);
metadata.Add(Options, o => o.DeviceCreatedDate, r => r.Assignment.Device.CreatedDate); metadata.Add(o => o.DeviceCreatedDate, r => r.Assignment.Device.CreatedDate);
metadata.Add(Options, o => o.DeviceFirstEnrolledDate, r => r.Assignment.Device.EnrolledDate); metadata.Add(o => o.DeviceFirstEnrolledDate, r => r.Assignment.Device.EnrolledDate);
metadata.Add(Options, o => o.DeviceLastEnrolledDate, r => r.Assignment.Device.LastEnrolDate); metadata.Add(o => o.DeviceLastEnrolledDate, r => r.Assignment.Device.LastEnrolDate);
metadata.Add(Options, o => o.DeviceAllowUnauthenticatedEnrol, r => r.Assignment.Device.AllowUnauthenticatedEnrol); metadata.Add(o => o.DeviceAllowUnauthenticatedEnrol, r => r.Assignment.Device.AllowUnauthenticatedEnrol);
metadata.Add(Options, o => o.DeviceDecommissionedDate, r => r.Assignment.Device.DecommissionedDate); metadata.Add(o => o.DeviceDecommissionedDate, r => r.Assignment.Device.DecommissionedDate);
metadata.Add(Options, o => o.DeviceDecommissionedReason, r => r.Assignment.Device.DecommissionReason?.ToString()); metadata.Add(o => o.DeviceDecommissionedReason, r => r.Assignment.Device.DecommissionReason?.ToString());
// Model // Model
metadata.Add(Options, o => o.ModelId, r => r.Assignment.Device.DeviceModel.Id); metadata.Add(o => o.ModelId, r => r.Assignment.Device.DeviceModel.Id);
metadata.Add(Options, o => o.ModelDescription, r => r.Assignment.Device.DeviceModel.Description); metadata.Add(o => o.ModelDescription, r => r.Assignment.Device.DeviceModel.Description);
metadata.Add(Options, o => o.ModelManufacturer, r => r.Assignment.Device.DeviceModel.Manufacturer); metadata.Add(o => o.ModelManufacturer, r => r.Assignment.Device.DeviceModel.Manufacturer);
metadata.Add(Options, o => o.ModelModel, r => r.Assignment.Device.DeviceModel.Model); metadata.Add(o => o.ModelModel, r => r.Assignment.Device.DeviceModel.Model);
metadata.Add(Options, o => o.ModelType, r => r.Assignment.Device.DeviceModel.ModelType); metadata.Add(o => o.ModelType, r => r.Assignment.Device.DeviceModel.ModelType);
// Batch // Batch
metadata.Add(Options, o => o.BatchId, r => r.Assignment.Device.DeviceBatch?.Id); metadata.Add(o => o.BatchId, r => r.Assignment.Device.DeviceBatch?.Id);
metadata.Add(Options, o => o.BatchName, r => r.Assignment.Device.DeviceBatch?.Name); metadata.Add(o => o.BatchName, r => r.Assignment.Device.DeviceBatch?.Name);
metadata.Add(Options, o => o.BatchPurchaseDate, r => r.Assignment.Device.DeviceBatch?.PurchaseDate); metadata.Add(o => o.BatchPurchaseDate, r => r.Assignment.Device.DeviceBatch?.PurchaseDate);
metadata.Add(Options, o => o.BatchSupplier, r => r.Assignment.Device.DeviceBatch?.Supplier); metadata.Add(o => o.BatchSupplier, r => r.Assignment.Device.DeviceBatch?.Supplier);
metadata.Add(Options, o => o.BatchUnitCost, r => r.Assignment.Device.DeviceBatch?.UnitCost, Exporter.CsvEncoders.NullableCurrencyEncoder); metadata.Add(o => o.BatchUnitCost, r => r.Assignment.Device.DeviceBatch?.UnitCost, Exporter.CsvEncoders.NullableCurrencyEncoder);
metadata.Add(Options, o => o.BatchWarrantyValidUntilDate, r => r.Assignment.Device.DeviceBatch?.WarrantyValidUntil); metadata.Add(o => o.BatchWarrantyValidUntilDate, r => r.Assignment.Device.DeviceBatch?.WarrantyValidUntil);
metadata.Add(Options, o => o.BatchInsuredDate, r => r.Assignment.Device.DeviceBatch?.InsuredDate); metadata.Add(o => o.BatchInsuredDate, r => r.Assignment.Device.DeviceBatch?.InsuredDate);
metadata.Add(Options, o => o.BatchInsuranceSupplier, r => r.Assignment.Device.DeviceBatch?.InsuranceSupplier); metadata.Add(o => o.BatchInsuranceSupplier, r => r.Assignment.Device.DeviceBatch?.InsuranceSupplier);
metadata.Add(Options, o => o.BatchInsuredUntilDate, r => r.Assignment.Device.DeviceBatch?.InsuredUntil); metadata.Add(o => o.BatchInsuredUntilDate, r => r.Assignment.Device.DeviceBatch?.InsuredUntil);
// Profile // Profile
metadata.Add(Options, o => o.ProfileId, r => r.Assignment.Device.DeviceProfile?.Id); metadata.Add(o => o.ProfileId, r => r.Assignment.Device.DeviceProfile?.Id);
metadata.Add(Options, o => o.ProfileName, r => r.Assignment.Device.DeviceProfile?.Name); metadata.Add(o => o.ProfileName, r => r.Assignment.Device.DeviceProfile?.Name);
metadata.Add(Options, o => o.ProfileShortName, r => r.Assignment.Device.DeviceProfile?.ShortName); metadata.Add(o => o.ProfileShortName, r => r.Assignment.Device.DeviceProfile?.ShortName);
// User // User
metadata.Add(Options, o => o.AssignedUserId, r => r.Assignment.Device?.AssignedUser?.UserId); metadata.Add(o => o.AssignedUserId, r => r.Assignment.Device?.AssignedUser?.UserId);
metadata.Add(Options, o => o.AssignedUserDisplayName, r => r.Assignment.Device?.AssignedUser?.DisplayName); metadata.Add(o => o.AssignedUserDisplayName, r => r.Assignment.Device?.AssignedUser?.DisplayName);
metadata.Add(Options, o => o.AssignedUserSurname, r => r.Assignment.Device?.AssignedUser?.Surname); metadata.Add(o => o.AssignedUserSurname, r => r.Assignment.Device?.AssignedUser?.Surname);
metadata.Add(Options, o => o.AssignedUserGivenName, r => r.Assignment.Device?.AssignedUser?.GivenName); metadata.Add(o => o.AssignedUserGivenName, r => r.Assignment.Device?.AssignedUser?.GivenName);
metadata.Add(Options, o => o.AssignedUserPhoneNumber, r => r.Assignment.Device?.AssignedUser?.PhoneNumber); metadata.Add(o => o.AssignedUserPhoneNumber, r => r.Assignment.Device?.AssignedUser?.PhoneNumber);
metadata.Add(Options, o => o.AssignedUserEmailAddress, r => r.Assignment.Device?.AssignedUser?.EmailAddress); metadata.Add(o => o.AssignedUserEmailAddress, r => r.Assignment.Device?.AssignedUser?.EmailAddress);
// User Custom Details // User Custom Details
if (Options.AssignedUserDetailCustom) if (Options.AssignedUserDetailCustom)
+7 -6
View File
@@ -126,12 +126,12 @@ namespace Disco.Services.Exporting
return stream; return stream;
} }
public static void Add<T, O, V>(this ExportMetadata<T> metadata, O options, Expression<Func<O, bool>> optionAccessor, Func<T, V> valueAccessor, Func<object, string> csvValueEncoder = null, string columnName = null) public static void Add<O, R, V>(this ExportMetadata<O, R> metadata, Expression<Func<O, bool>> optionAccessor, Func<R, V> valueAccessor, Func<object, string> csvValueEncoder = null, string columnName = null)
where T : IExportRecord
where O : IExportOptions where O : IExportOptions
where R : IExportRecord
{ {
// is field enabled? // is field enabled?
if (!optionAccessor.Compile().Invoke(options)) if (!optionAccessor.Compile().Invoke(metadata.Options))
return; return;
if (columnName is null) if (columnName is null)
@@ -147,8 +147,9 @@ namespace Disco.Services.Exporting
metadata.Add(columnName, valueAccessor, csvValueEncoder); metadata.Add(columnName, valueAccessor, csvValueEncoder);
} }
public static void Add<T, V>(this ExportMetadata<T> metadata, string columnName, Func<T, V> valueAccessor, Func<object, string> csvValueEncoder = null) public static void Add<O, R, V>(this ExportMetadata<O, R> metadata, string columnName, Func<R, V> valueAccessor, Func<object, string> csvValueEncoder = null)
where T : IExportRecord where O : IExportOptions
where R : IExportRecord
{ {
var valueType = typeof(V); var valueType = typeof(V);
if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Nullable<>)) if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Nullable<>))
@@ -157,7 +158,7 @@ namespace Disco.Services.Exporting
if (csvValueEncoder is null) if (csvValueEncoder is null)
csvValueEncoder = CsvEncoders.GetEncoder<V>(); csvValueEncoder = CsvEncoders.GetEncoder<V>();
var field = new ExportMetadataField<T>(columnName, valueType, (T i) => valueAccessor(i), csvValueEncoder); var field = new ExportMetadataField<R>(columnName, valueType, (R i) => valueAccessor(i), csvValueEncoder);
metadata.Add(field); metadata.Add(field);
} }
+1 -1
View File
@@ -32,6 +32,6 @@ namespace Disco.Services.Exporting
T Options { get; set; } T Options { get; set; }
List<R> BuildRecords(DiscoDataContext database, IScheduledTaskStatus status); List<R> BuildRecords(DiscoDataContext database, IScheduledTaskStatus status);
ExportMetadata<R> BuildMetadata(DiscoDataContext database, List<R> records, IScheduledTaskStatus status); ExportMetadata<T, R> BuildMetadata(DiscoDataContext database, List<R> records, IScheduledTaskStatus status);
} }
} }
+99 -99
View File
@@ -216,100 +216,100 @@ namespace Disco.Services.Jobs
return records; return records;
} }
public ExportMetadata<JobExportRecord> BuildMetadata(DiscoDataContext database, List<JobExportRecord> records, IScheduledTaskStatus status) public ExportMetadata<JobExportOptions, JobExportRecord> BuildMetadata(DiscoDataContext database, List<JobExportRecord> records, IScheduledTaskStatus status)
{ {
var metadata = new ExportMetadata<JobExportRecord>(); var metadata = new ExportMetadata<JobExportOptions, JobExportRecord>(Options);
metadata.IgnoreShortNames.Add("Job"); metadata.IgnoreShortNames.Add("Job");
metadata.IgnoreShortNames.Add("Job Details"); metadata.IgnoreShortNames.Add("Job Details");
// Job // Job
metadata.Add(Options, o => o.JobId, r => r.Job.Id); metadata.Add(o => o.JobId, r => r.Job.Id);
metadata.Add(Options, o => o.JobStatus, r => Job.JobStatusIds.StatusDescriptions.TryGetValue(r.JobStatus, out var jobStatus) ? jobStatus : "Unknown"); metadata.Add(o => o.JobStatus, r => Job.JobStatusIds.StatusDescriptions.TryGetValue(r.JobStatus, out var jobStatus) ? jobStatus : "Unknown");
metadata.Add(Options, o => o.JobType, r => r.JobTypeDescription); metadata.Add(o => o.JobType, r => r.JobTypeDescription);
metadata.Add(Options, o => o.JobSubTypes, r => string.Join(", ", r.JobSubTypeDescriptions)); metadata.Add(o => o.JobSubTypes, r => string.Join(", ", r.JobSubTypeDescriptions));
metadata.Add(Options, o => o.JobOpenedDate, r => r.Job.OpenedDate); metadata.Add(o => o.JobOpenedDate, r => r.Job.OpenedDate);
metadata.Add(Options, o => o.JobOpenedUser, r => r.Job.OpenedTechUserId); metadata.Add(o => o.JobOpenedUser, r => r.Job.OpenedTechUserId);
metadata.Add(Options, o => o.JobExpectedClosedDate, r => r.Job.ExpectedClosedDate); metadata.Add(o => o.JobExpectedClosedDate, r => r.Job.ExpectedClosedDate);
metadata.Add(Options, o => o.JobClosedDate, r => r.Job.ClosedDate); metadata.Add(o => o.JobClosedDate, r => r.Job.ClosedDate);
metadata.Add(Options, o => o.JobClosedUser, r => r.Job.ClosedTechUserId); metadata.Add(o => o.JobClosedUser, r => r.Job.ClosedTechUserId);
// Job Details // Job Details
metadata.Add(Options, o => o.JobDeviceHeldDate, r => r.Job.DeviceHeld); metadata.Add(o => o.JobDeviceHeldDate, r => r.Job.DeviceHeld);
metadata.Add(Options, o => o.JobDeviceHeldUser, r => r.Job.DeviceHeldTechUserId); metadata.Add(o => o.JobDeviceHeldUser, r => r.Job.DeviceHeldTechUserId);
metadata.Add(Options, o => o.JobDeviceHeldLocation, r => r.Job.DeviceHeldLocation); metadata.Add(o => o.JobDeviceHeldLocation, r => r.Job.DeviceHeldLocation);
metadata.Add(Options, o => o.JobDeviceReadyForReturnDate, r => r.Job.DeviceReadyForReturn); metadata.Add(o => o.JobDeviceReadyForReturnDate, r => r.Job.DeviceReadyForReturn);
metadata.Add(Options, o => o.JobDeviceReadyForReturnUser, r => r.Job.DeviceReadyForReturnTechUserId); metadata.Add(o => o.JobDeviceReadyForReturnUser, r => r.Job.DeviceReadyForReturnTechUserId);
metadata.Add(Options, o => o.JobDeviceReturnedDate, r => r.Job.DeviceReturnedDate); metadata.Add(o => o.JobDeviceReturnedDate, r => r.Job.DeviceReturnedDate);
metadata.Add(Options, o => o.JobDeviceReturnedUser, r => r.Job.DeviceReturnedTechUserId); metadata.Add(o => o.JobDeviceReturnedUser, r => r.Job.DeviceReturnedTechUserId);
metadata.Add(Options, o => o.JobWaitingForUserActionDate, r => r.Job.WaitingForUserAction); metadata.Add(o => o.JobWaitingForUserActionDate, r => r.Job.WaitingForUserAction);
// Job Logs // Job Logs
metadata.Add(Options, o => o.LogCount, r => r.LogCount); metadata.Add(o => o.LogCount, r => r.LogCount);
metadata.Add(Options, o => o.LogFirstDate, r => r.FirstLog?.Timestamp); metadata.Add(o => o.LogFirstDate, r => r.FirstLog?.Timestamp);
metadata.Add(Options, o => o.LogFirstUser, r => r.FirstLog?.TechUserId); metadata.Add(o => o.LogFirstUser, r => r.FirstLog?.TechUserId);
metadata.Add(Options, o => o.LogFirstContent, r => r.FirstLog?.Comments); metadata.Add(o => o.LogFirstContent, r => r.FirstLog?.Comments);
metadata.Add(Options, o => o.LogLastDate, r => r.LastLog?.Timestamp); metadata.Add(o => o.LogLastDate, r => r.LastLog?.Timestamp);
metadata.Add(Options, o => o.LogLastUser, r => r.LastLog?.TechUserId); metadata.Add(o => o.LogLastUser, r => r.LastLog?.TechUserId);
metadata.Add(Options, o => o.LogLastContent, r => r.LastLog?.Comments); metadata.Add(o => o.LogLastContent, r => r.LastLog?.Comments);
// Attachments // Attachments
metadata.Add(Options, o => o.AttachmentsCount, r => r.AttachmentsCount); metadata.Add(o => o.AttachmentsCount, r => r.AttachmentsCount);
// Job Queues // Job Queues
metadata.Add(Options, o => o.JobQueueCount, r => r.QueueCount); metadata.Add(o => o.JobQueueCount, r => r.QueueCount);
metadata.Add(Options, o => o.JobQueueActiveCount, r => r.QueueActiveCount); metadata.Add(o => o.JobQueueActiveCount, r => r.QueueActiveCount);
metadata.Add(Options, o => o.JobQueueActiveLatest, r => r.QueueLatestActive?.JobQueueId == null ? null : JobQueueService.GetQueue(r.QueueLatestActive.JobQueueId).JobQueue.Name); metadata.Add(o => o.JobQueueActiveLatest, r => r.QueueLatestActive?.JobQueueId == null ? null : JobQueueService.GetQueue(r.QueueLatestActive.JobQueueId).JobQueue.Name);
metadata.Add(Options, o => o.JobQueueActiveLatestAddedDate, r => r.QueueLatestActive?.AddedDate); metadata.Add(o => o.JobQueueActiveLatestAddedDate, r => r.QueueLatestActive?.AddedDate);
metadata.Add(Options, o => o.JobQueueActiveLatestAddedUser, r => r.QueueLatestActive?.AddedUserId); metadata.Add(o => o.JobQueueActiveLatestAddedUser, r => r.QueueLatestActive?.AddedUserId);
// Warranty // Warranty
metadata.Add(Options, o => o.JobWarrantyExternalName, r => r.JobMetaWarranty?.ExternalName); metadata.Add(o => o.JobWarrantyExternalName, r => r.JobMetaWarranty?.ExternalName);
metadata.Add(Options, o => o.JobWarrantyExternalReference, r => r.JobMetaWarranty?.ExternalReference); metadata.Add(o => o.JobWarrantyExternalReference, r => r.JobMetaWarranty?.ExternalReference);
metadata.Add(Options, o => o.JobWarrantyExternalLoggedDate, r => r.JobMetaWarranty?.ExternalLoggedDate); metadata.Add(o => o.JobWarrantyExternalLoggedDate, r => r.JobMetaWarranty?.ExternalLoggedDate);
metadata.Add(Options, o => o.JobWarrantyExternalCompletedDate, r => r.JobMetaWarranty?.ExternalCompletedDate); metadata.Add(o => o.JobWarrantyExternalCompletedDate, r => r.JobMetaWarranty?.ExternalCompletedDate);
// Non-Warranty // Non-Warranty
metadata.Add(Options, o => o.JobNonWarrantyAccountingChargeRequiredDate, r => r.JobMetaNonWarranty?.AccountingChargeRequiredDate); metadata.Add(o => o.JobNonWarrantyAccountingChargeRequiredDate, r => r.JobMetaNonWarranty?.AccountingChargeRequiredDate);
metadata.Add(Options, o => o.JobNonWarrantyAccountingChargeAddedDate, r => r.JobMetaNonWarranty?.AccountingChargeAddedDate); metadata.Add(o => o.JobNonWarrantyAccountingChargeAddedDate, r => r.JobMetaNonWarranty?.AccountingChargeAddedDate);
metadata.Add(Options, o => o.JobNonWarrantyAccountingChargePaidDate, r => r.JobMetaNonWarranty?.AccountingChargePaidDate); metadata.Add(o => o.JobNonWarrantyAccountingChargePaidDate, r => r.JobMetaNonWarranty?.AccountingChargePaidDate);
metadata.Add(Options, o => o.JobNonWarrantyPurchaseOrderRaisedDate, r => r.JobMetaNonWarranty?.PurchaseOrderRaisedDate); metadata.Add(o => o.JobNonWarrantyPurchaseOrderRaisedDate, r => r.JobMetaNonWarranty?.PurchaseOrderRaisedDate);
metadata.Add(Options, o => o.JobNonWarrantyPurchaseOrderReference, r => r.JobMetaNonWarranty?.PurchaseOrderReference); metadata.Add(o => o.JobNonWarrantyPurchaseOrderReference, r => r.JobMetaNonWarranty?.PurchaseOrderReference);
metadata.Add(Options, o => o.JobNonWarrantyPurchaseOrderSentDate, r => r.JobMetaNonWarranty?.PurchaseOrderSentDate); metadata.Add(o => o.JobNonWarrantyPurchaseOrderSentDate, r => r.JobMetaNonWarranty?.PurchaseOrderSentDate);
metadata.Add(Options, o => o.JobNonWarrantyInvoiceReceivedDate, r => r.JobMetaNonWarranty?.InvoiceReceivedDate); metadata.Add(o => o.JobNonWarrantyInvoiceReceivedDate, r => r.JobMetaNonWarranty?.InvoiceReceivedDate);
metadata.Add(Options, o => o.JobNonWarrantyRepairerName, r => r.JobMetaNonWarranty?.RepairerName); metadata.Add(o => o.JobNonWarrantyRepairerName, r => r.JobMetaNonWarranty?.RepairerName);
metadata.Add(Options, o => o.JobNonWarrantyRepairerLoggedDate, r => r.JobMetaNonWarranty?.RepairerLoggedDate); metadata.Add(o => o.JobNonWarrantyRepairerLoggedDate, r => r.JobMetaNonWarranty?.RepairerLoggedDate);
metadata.Add(Options, o => o.JobNonWarrantyRepairerReference, r => r.JobMetaNonWarranty?.RepairerReference); metadata.Add(o => o.JobNonWarrantyRepairerReference, r => r.JobMetaNonWarranty?.RepairerReference);
metadata.Add(Options, o => o.JobNonWarrantyRepairerCompletedDate, r => r.JobMetaNonWarranty?.RepairerCompletedDate); metadata.Add(o => o.JobNonWarrantyRepairerCompletedDate, r => r.JobMetaNonWarranty?.RepairerCompletedDate);
// Insurance // Insurance
metadata.Add(Options, o => o.JobMetaInsuranceLossOrDamageDate, r => r.JobMetaInsurance?.LossOrDamageDate); metadata.Add(o => o.JobMetaInsuranceLossOrDamageDate, r => r.JobMetaInsurance?.LossOrDamageDate);
metadata.Add(Options, o => o.JobMetaInsuranceEventLocation, r => r.JobMetaInsurance?.EventLocation); metadata.Add(o => o.JobMetaInsuranceEventLocation, r => r.JobMetaInsurance?.EventLocation);
metadata.Add(Options, o => o.JobMetaInsuranceDescription, r => r.JobMetaInsurance?.Description); metadata.Add(o => o.JobMetaInsuranceDescription, r => r.JobMetaInsurance?.Description);
metadata.Add(Options, o => o.JobMetaInsuranceThirdPartyCausedName, r => r.JobMetaInsurance?.ThirdPartyCausedName); metadata.Add(o => o.JobMetaInsuranceThirdPartyCausedName, r => r.JobMetaInsurance?.ThirdPartyCausedName);
metadata.Add(Options, o => o.JobMetaInsuranceThirdPartyCausedWhy, r => r.JobMetaInsurance?.ThirdPartyCausedWhy); metadata.Add(o => o.JobMetaInsuranceThirdPartyCausedWhy, r => r.JobMetaInsurance?.ThirdPartyCausedWhy);
metadata.Add(Options, o => o.JobMetaInsuranceWitnessesNamesAddresses, r => r.JobMetaInsurance?.WitnessesNamesAddresses); metadata.Add(o => o.JobMetaInsuranceWitnessesNamesAddresses, r => r.JobMetaInsurance?.WitnessesNamesAddresses);
metadata.Add(Options, o => o.JobMetaInsuranceBurglaryTheftMethodOfEntry, r => r.JobMetaInsurance?.BurglaryTheftMethodOfEntry); metadata.Add(o => o.JobMetaInsuranceBurglaryTheftMethodOfEntry, r => r.JobMetaInsurance?.BurglaryTheftMethodOfEntry);
metadata.Add(Options, o => o.JobMetaInsurancePropertyLastSeenDate, r => r.JobMetaInsurance?.PropertyLastSeenDate); metadata.Add(o => o.JobMetaInsurancePropertyLastSeenDate, r => r.JobMetaInsurance?.PropertyLastSeenDate);
metadata.Add(Options, o => o.JobMetaInsurancePoliceNotifiedStation, r => r.JobMetaInsurance?.PoliceNotifiedStation); metadata.Add(o => o.JobMetaInsurancePoliceNotifiedStation, r => r.JobMetaInsurance?.PoliceNotifiedStation);
metadata.Add(Options, o => o.JobMetaInsurancePoliceNotifiedDate, r => r.JobMetaInsurance?.PoliceNotifiedDate); metadata.Add(o => o.JobMetaInsurancePoliceNotifiedDate, r => r.JobMetaInsurance?.PoliceNotifiedDate);
metadata.Add(Options, o => o.JobMetaInsurancePoliceNotifiedCrimeReportNo, r => r.JobMetaInsurance?.PoliceNotifiedCrimeReportNo); metadata.Add(o => o.JobMetaInsurancePoliceNotifiedCrimeReportNo, r => r.JobMetaInsurance?.PoliceNotifiedCrimeReportNo);
metadata.Add(Options, o => o.JobMetaInsuranceRecoverReduceAction, r => r.JobMetaInsurance?.RecoverReduceAction); metadata.Add(o => o.JobMetaInsuranceRecoverReduceAction, r => r.JobMetaInsurance?.RecoverReduceAction);
metadata.Add(Options, o => o.JobMetaInsuranceOtherInterestedParties, r => r.JobMetaInsurance?.OtherInterestedParties); metadata.Add(o => o.JobMetaInsuranceOtherInterestedParties, r => r.JobMetaInsurance?.OtherInterestedParties);
metadata.Add(Options, o => o.JobMetaInsuranceDateOfPurchase, r => r.JobMetaInsurance?.DateOfPurchase); metadata.Add(o => o.JobMetaInsuranceDateOfPurchase, r => r.JobMetaInsurance?.DateOfPurchase);
metadata.Add(Options, o => o.JobMetaInsuranceClaimFormSentDate, r => r.JobMetaInsurance?.ClaimFormSentDate); metadata.Add(o => o.JobMetaInsuranceClaimFormSentDate, r => r.JobMetaInsurance?.ClaimFormSentDate);
metadata.Add(Options, o => o.JobMetaInsuranceInsurer, r => r.JobMetaInsurance?.Insurer); metadata.Add(o => o.JobMetaInsuranceInsurer, r => r.JobMetaInsurance?.Insurer);
metadata.Add(Options, o => o.JobMetaInsuranceInsurerReference, r => r.JobMetaInsurance?.InsurerReference); metadata.Add(o => o.JobMetaInsuranceInsurerReference, r => r.JobMetaInsurance?.InsurerReference);
// User Management // User Management
metadata.Add(Options, o => o.JobUserManagementFlags, r => r.Job.Flags?.ToString()); metadata.Add(o => o.JobUserManagementFlags, r => r.Job.Flags?.ToString());
// User // User
metadata.Add(Options, o => o.UserId, r => r.User?.UserId); metadata.Add(o => o.UserId, r => r.User?.UserId);
metadata.Add(Options, o => o.UserDisplayName, r => r.User?.DisplayName); metadata.Add(o => o.UserDisplayName, r => r.User?.DisplayName);
metadata.Add(Options, o => o.UserSurname, r => r.User?.Surname); metadata.Add(o => o.UserSurname, r => r.User?.Surname);
metadata.Add(Options, o => o.UserGivenName, r => r.User?.GivenName); metadata.Add(o => o.UserGivenName, r => r.User?.GivenName);
metadata.Add(Options, o => o.UserPhoneNumber, r => r.User?.PhoneNumber); metadata.Add(o => o.UserPhoneNumber, r => r.User?.PhoneNumber);
metadata.Add(Options, o => o.UserEmailAddress, r => r.User?.EmailAddress); metadata.Add(o => o.UserEmailAddress, r => r.User?.EmailAddress);
// User Custom Details // User Custom Details
if (Options.UserDetailCustom) if (Options.UserDetailCustom)
@@ -322,40 +322,40 @@ namespace Disco.Services.Jobs
} }
// Device // Device
metadata.Add(Options, o => o.DeviceSerialNumber, r => r.Device?.SerialNumber); metadata.Add(o => o.DeviceSerialNumber, r => r.Device?.SerialNumber);
metadata.Add(Options, o => o.DeviceAssetNumber, r => r.Device?.AssetNumber); metadata.Add(o => o.DeviceAssetNumber, r => r.Device?.AssetNumber);
metadata.Add(Options, o => o.DeviceLocation, r => r.Device?.Location); metadata.Add(o => o.DeviceLocation, r => r.Device?.Location);
metadata.Add(Options, o => o.DeviceComputerName, r => r.Device?.DeviceDomainId); metadata.Add(o => o.DeviceComputerName, r => r.Device?.DeviceDomainId);
metadata.Add(Options, o => o.DeviceLastNetworkLogon, r => r.Device?.LastNetworkLogonDate); metadata.Add(o => o.DeviceLastNetworkLogon, r => r.Device?.LastNetworkLogonDate);
metadata.Add(Options, o => o.DeviceCreatedDate, r => r.Device?.CreatedDate); metadata.Add(o => o.DeviceCreatedDate, r => r.Device?.CreatedDate);
metadata.Add(Options, o => o.DeviceFirstEnrolledDate, r => r.Device?.EnrolledDate); metadata.Add(o => o.DeviceFirstEnrolledDate, r => r.Device?.EnrolledDate);
metadata.Add(Options, o => o.DeviceLastEnrolledDate, r => r.Device?.LastEnrolDate); metadata.Add(o => o.DeviceLastEnrolledDate, r => r.Device?.LastEnrolDate);
metadata.Add(Options, o => o.DeviceAllowUnauthenticatedEnrol, r => r.Device?.AllowUnauthenticatedEnrol); metadata.Add(o => o.DeviceAllowUnauthenticatedEnrol, r => r.Device?.AllowUnauthenticatedEnrol);
metadata.Add(Options, o => o.DeviceDecommissionedDate, r => r.Device?.DecommissionedDate); metadata.Add(o => o.DeviceDecommissionedDate, r => r.Device?.DecommissionedDate);
metadata.Add(Options, o => o.DeviceDecommissionedReason, r => r.Device?.DecommissionReason?.ToString()); metadata.Add(o => o.DeviceDecommissionedReason, r => r.Device?.DecommissionReason?.ToString());
// Model // Model
metadata.Add(Options, o => o.DeviceModelId, r => r.DeviceModelId); metadata.Add(o => o.DeviceModelId, r => r.DeviceModelId);
metadata.Add(Options, o => o.DeviceModelDescription, r => r.DeviceModelDescription); metadata.Add(o => o.DeviceModelDescription, r => r.DeviceModelDescription);
metadata.Add(Options, o => o.DeviceModelManufacturer, r => r.DeviceModelManufacturer); metadata.Add(o => o.DeviceModelManufacturer, r => r.DeviceModelManufacturer);
metadata.Add(Options, o => o.DeviceModelModel, r => r.DeviceModelModel); metadata.Add(o => o.DeviceModelModel, r => r.DeviceModelModel);
metadata.Add(Options, o => o.DeviceModelType, r => r.DeviceModelType); metadata.Add(o => o.DeviceModelType, r => r.DeviceModelType);
// Batch // Batch
metadata.Add(Options, o => o.DeviceBatchId, r => r.DeviceBatchId); metadata.Add(o => o.DeviceBatchId, r => r.DeviceBatchId);
metadata.Add(Options, o => o.DeviceBatchName, r => r.DeviceBatchName); metadata.Add(o => o.DeviceBatchName, r => r.DeviceBatchName);
metadata.Add(Options, o => o.DeviceBatchPurchaseDate, r => r.DeviceBatchPurchaseDate); metadata.Add(o => o.DeviceBatchPurchaseDate, r => r.DeviceBatchPurchaseDate);
metadata.Add(Options, o => o.DeviceBatchSupplier, r => r.DeviceBatchSupplier); metadata.Add(o => o.DeviceBatchSupplier, r => r.DeviceBatchSupplier);
metadata.Add(Options, o => o.DeviceBatchUnitCost, r => r.DeviceBatchUnitCost); metadata.Add(o => o.DeviceBatchUnitCost, r => r.DeviceBatchUnitCost);
metadata.Add(Options, o => o.DeviceBatchWarrantyValidUntilDate, r => r.DeviceBatchWarrantyValidUntilDate); metadata.Add(o => o.DeviceBatchWarrantyValidUntilDate, r => r.DeviceBatchWarrantyValidUntilDate);
metadata.Add(Options, o => o.DeviceBatchInsuredDate, r => r.DeviceBatchInsuredDate); metadata.Add(o => o.DeviceBatchInsuredDate, r => r.DeviceBatchInsuredDate);
metadata.Add(Options, o => o.DeviceBatchInsuranceSupplier, r => r.DeviceBatchInsuranceSupplier); metadata.Add(o => o.DeviceBatchInsuranceSupplier, r => r.DeviceBatchInsuranceSupplier);
metadata.Add(Options, o => o.DeviceBatchInsuredUntilDate, r => r.DeviceBatchInsuredUntilDate); metadata.Add(o => o.DeviceBatchInsuredUntilDate, r => r.DeviceBatchInsuredUntilDate);
// Profile // Profile
metadata.Add(Options, o => o.DeviceProfileId, r => r.DeviceProfileId); metadata.Add(o => o.DeviceProfileId, r => r.DeviceProfileId);
metadata.Add(Options, o => o.DeviceProfileName, r => r.DeviceProfileName); metadata.Add(o => o.DeviceProfileName, r => r.DeviceProfileName);
metadata.Add(Options, o => o.DeviceProfileShortName, r => r.DeviceProfileShortName); metadata.Add(o => o.DeviceProfileShortName, r => r.DeviceProfileShortName);
return metadata; return metadata;
} }
+2 -2
View File
@@ -50,9 +50,9 @@ namespace Disco.Services.Logging
return logRetriever.Query(database); return logRetriever.Query(database);
} }
public ExportMetadata<LogLiveEvent> BuildMetadata(DiscoDataContext database, List<LogLiveEvent> records, IScheduledTaskStatus status) public ExportMetadata<LogExportOptions, LogLiveEvent> BuildMetadata(DiscoDataContext database, List<LogLiveEvent> records, IScheduledTaskStatus status)
{ {
var metadata = new ExportMetadata<LogLiveEvent> var metadata = new ExportMetadata<LogExportOptions, LogLiveEvent>(Options)
{ {
{ nameof(LogLiveEvent.Timestamp), r => r.Timestamp }, { nameof(LogLiveEvent.Timestamp), r => r.Timestamp },
{ nameof(LogLiveEvent.ModuleId), r => r.ModuleId }, { nameof(LogLiveEvent.ModuleId), r => r.ModuleId },
@@ -91,33 +91,33 @@ namespace Disco.Services.Users.UserFlags
return records; return records;
} }
public ExportMetadata<UserFlagExportRecord> BuildMetadata(DiscoDataContext database, List<UserFlagExportRecord> records, IScheduledTaskStatus status) public ExportMetadata<UserFlagExportOptions, UserFlagExportRecord> BuildMetadata(DiscoDataContext database, List<UserFlagExportRecord> records, IScheduledTaskStatus status)
{ {
status.UpdateStatus(80, "Building metadata"); status.UpdateStatus(80, "Building metadata");
var metadata = new ExportMetadata<UserFlagExportRecord>(); var metadata = new ExportMetadata<UserFlagExportOptions, UserFlagExportRecord>(Options);
metadata.IgnoreShortNames.Add("User Flag"); metadata.IgnoreShortNames.Add("User Flag");
// User Flag // User Flag
metadata.Add(Options, o => o.Id, r => r.Assignment.UserFlagId); metadata.Add(o => o.Id, r => r.Assignment.UserFlagId);
metadata.Add(Options, o => o.Name, r => r.Assignment.UserFlag.Name); metadata.Add(o => o.Name, r => r.Assignment.UserFlag.Name);
metadata.Add(Options, o => o.Description, r => r.Assignment.UserFlag.Description); metadata.Add(o => o.Description, r => r.Assignment.UserFlag.Description);
metadata.Add(Options, o => o.Icon, r => r.Assignment.UserFlag.Icon); metadata.Add(o => o.Icon, r => r.Assignment.UserFlag.Icon);
metadata.Add(Options, o => o.IconColour, r => r.Assignment.UserFlag.IconColour); metadata.Add(o => o.IconColour, r => r.Assignment.UserFlag.IconColour);
metadata.Add(Options, o => o.AssignmentId, r => r.Assignment.Id); metadata.Add(o => o.AssignmentId, r => r.Assignment.Id);
metadata.Add(Options, o => o.AddedDate, r => r.Assignment.AddedDate); metadata.Add(o => o.AddedDate, r => r.Assignment.AddedDate);
metadata.Add(Options, o => o.AddedUserId, r => r.Assignment.AddedUserId); metadata.Add(o => o.AddedUserId, r => r.Assignment.AddedUserId);
metadata.Add(Options, o => o.RemovedUserId, r => r.Assignment.RemovedUserId); metadata.Add(o => o.RemovedUserId, r => r.Assignment.RemovedUserId);
metadata.Add(Options, o => o.RemovedDate, r => r.Assignment.RemovedDate); metadata.Add(o => o.RemovedDate, r => r.Assignment.RemovedDate);
metadata.Add(Options, o => o.Comments, r => r.Assignment.Comments); metadata.Add(o => o.Comments, r => r.Assignment.Comments);
// User // User
metadata.Add(Options, o => o.UserId, r => r.Assignment.User?.UserId); metadata.Add(o => o.UserId, r => r.Assignment.User?.UserId);
metadata.Add(Options, o => o.UserDisplayName, r => r.Assignment.User?.DisplayName); metadata.Add(o => o.UserDisplayName, r => r.Assignment.User?.DisplayName);
metadata.Add(Options, o => o.UserSurname, r => r.Assignment.User?.Surname); metadata.Add(o => o.UserSurname, r => r.Assignment.User?.Surname);
metadata.Add(Options, o => o.UserGivenName, r => r.Assignment.User?.GivenName); metadata.Add(o => o.UserGivenName, r => r.Assignment.User?.GivenName);
metadata.Add(Options, o => o.UserPhoneNumber, r => r.Assignment.User?.PhoneNumber); metadata.Add(o => o.UserPhoneNumber, r => r.Assignment.User?.PhoneNumber);
metadata.Add(Options, o => o.UserEmailAddress, r => r.Assignment.User?.EmailAddress); metadata.Add(o => o.UserEmailAddress, r => r.Assignment.User?.EmailAddress);
// User Custom Details // User Custom Details
if (Options.UserDetailCustom) if (Options.UserDetailCustom)
@@ -12,7 +12,6 @@ using Disco.Web.Areas.Config.Models.UserFlag;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers namespace Disco.Web.Areas.Config.Controllers
@@ -123,7 +122,8 @@ namespace Disco.Web.Areas.Config.Controllers
#region Export #region Export
[DiscoAuthorizeAny(Claims.Config.UserFlag.Export), HttpGet] [HttpGet]
[DiscoAuthorizeAny(Claims.Config.UserFlag.Export)]
public virtual ActionResult Export(Guid? exportId, int? userFlagId, bool? currentOnly) public virtual ActionResult Export(Guid? exportId, int? userFlagId, bool? currentOnly)
{ {
var m = new ExportModel() var m = new ExportModel()
@@ -205,5 +205,5 @@
<button type="button" class="button" disabled title="Requires Manage Saved Exports Permission">Save Export</button> <button type="button" class="button" disabled title="Requires Manage Saved Exports Permission">Save Export</button>
} }
<button type="button" id="DeviceFlag_Export_Button" class="button">Export Device Flags</button> <button type="button" id="DeviceFlag_Export_Button" class="button">Export Now</button>
</div> </div>
@@ -809,7 +809,7 @@ WriteLiteral(" id=\"DeviceFlag_Export_Button\"");
WriteLiteral(" class=\"button\""); WriteLiteral(" class=\"button\"");
WriteLiteral(">Export Device Flags</button>\r\n</div>\r\n"); WriteLiteral(">Export Now</button>\r\n</div>\r\n");
} }
} }
@@ -205,5 +205,5 @@
<button type="button" class="button" disabled title="Requires Manage Saved Exports Permission">Save Export</button> <button type="button" class="button" disabled title="Requires Manage Saved Exports Permission">Save Export</button>
} }
<button type="button" id="UserFlag_Export_Button" class="button">Export User Flags</button> <button type="button" id="UserFlag_Export_Button" class="button">Export Now</button>
</div> </div>
@@ -809,7 +809,7 @@ WriteLiteral(" id=\"UserFlag_Export_Button\"");
WriteLiteral(" class=\"button\""); WriteLiteral(" class=\"button\"");
WriteLiteral(">Export User Flags</button>\r\n</div>\r\n"); WriteLiteral(">Export Now</button>\r\n</div>\r\n");
} }
} }
+1 -1
View File
@@ -296,5 +296,5 @@
<button type="button" class="button" disabled title="Requires Manage Saved Exports Permission">Save Export</button> <button type="button" class="button" disabled title="Requires Manage Saved Exports Permission">Save Export</button>
} }
<button id="Jobs_Export_Button" type="button" class="button">Export Jobs</button> <button id="Jobs_Export_Button" type="button" class="button">Export Now</button>
</div> </div>
+1 -1
View File
@@ -1154,7 +1154,7 @@ WriteLiteral(" type=\"button\"");
WriteLiteral(" class=\"button\""); WriteLiteral(" class=\"button\"");
WriteLiteral(">Export Jobs</button>\r\n</div>\r\n"); WriteLiteral(">Export Now</button>\r\n</div>\r\n");
} }
} }