diff --git a/Disco.Models/Exporting/ExportMetadata.cs b/Disco.Models/Exporting/ExportMetadata.cs index 6d3ca343..50800aa6 100644 --- a/Disco.Models/Exporting/ExportMetadata.cs +++ b/Disco.Models/Exporting/ExportMetadata.cs @@ -1,10 +1,19 @@ -using System.Collections.Generic; +using Disco.Models.Services.Exporting; +using System.Collections.Generic; namespace Disco.Models.Exporting { - public class ExportMetadata - : List> where T : IExportRecord + public class ExportMetadata + : List> + where O : IExportOptions + where R : IExportRecord { public List IgnoreShortNames { get; } = new List(); + public O Options { get; set; } + + public ExportMetadata(O options) + { + Options = options; + } } } diff --git a/Disco.Services/Devices/DeviceExport.cs b/Disco.Services/Devices/DeviceExport.cs index a71f3360..86f55729 100644 --- a/Disco.Services/Devices/DeviceExport.cs +++ b/Disco.Services/Devices/DeviceExport.cs @@ -2,16 +2,13 @@ using Disco.Models.Exporting; using Disco.Models.Repository; using Disco.Models.Services.Devices; -using Disco.Models.Services.Devices.DeviceFlag; using Disco.Models.Services.Exporting; -using Disco.Services.Devices.DeviceFlags; using Disco.Services.Exporting; using Disco.Services.Plugins.Features.DetailsProvider; using Disco.Services.Tasks; using Disco.Services.Users; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Data.Entity; using System.Linq; using System.Text.Json.Serialization; @@ -184,56 +181,56 @@ namespace Disco.Services.Devices return records; } - public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus taskStatus) + public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus taskStatus) { - var metadata = new ExportMetadata(); + var metadata = new ExportMetadata(Options); metadata.IgnoreShortNames.Add("Device"); metadata.IgnoreShortNames.Add("Details"); // Device - metadata.Add(Options, o => o.DeviceSerialNumber, r => r.Device.SerialNumber); - metadata.Add(Options, o => o.DeviceAssetNumber, r => r.Device.AssetNumber); - metadata.Add(Options, o => o.DeviceLocation, r => r.Device.Location); - metadata.Add(Options, o => o.DeviceComputerName, r => r.Device.DeviceDomainId); - metadata.Add(Options, o => o.DeviceLastNetworkLogon, r => r.Device.LastNetworkLogonDate); - metadata.Add(Options, o => o.DeviceCreatedDate, r => r.Device.CreatedDate); - metadata.Add(Options, o => o.DeviceFirstEnrolledDate, r => r.Device.EnrolledDate); - metadata.Add(Options, o => o.DeviceLastEnrolledDate, r => r.Device.LastEnrolDate); - metadata.Add(Options, o => o.DeviceAllowUnauthenticatedEnrol, r => r.Device.AllowUnauthenticatedEnrol); - metadata.Add(Options, o => o.DeviceDecommissionedDate, r => r.Device.DecommissionedDate); - metadata.Add(Options, o => o.DeviceDecommissionedReason, r => r.Device.DecommissionReason?.ToString()); + metadata.Add(o => o.DeviceSerialNumber, r => r.Device.SerialNumber); + metadata.Add(o => o.DeviceAssetNumber, r => r.Device.AssetNumber); + metadata.Add(o => o.DeviceLocation, r => r.Device.Location); + metadata.Add(o => o.DeviceComputerName, r => r.Device.DeviceDomainId); + metadata.Add(o => o.DeviceLastNetworkLogon, r => r.Device.LastNetworkLogonDate); + metadata.Add(o => o.DeviceCreatedDate, r => r.Device.CreatedDate); + metadata.Add(o => o.DeviceFirstEnrolledDate, r => r.Device.EnrolledDate); + metadata.Add(o => o.DeviceLastEnrolledDate, r => r.Device.LastEnrolDate); + metadata.Add(o => o.DeviceAllowUnauthenticatedEnrol, r => r.Device.AllowUnauthenticatedEnrol); + metadata.Add(o => o.DeviceDecommissionedDate, r => r.Device.DecommissionedDate); + metadata.Add(o => o.DeviceDecommissionedReason, r => r.Device.DecommissionReason?.ToString()); // Model - metadata.Add(Options, o => o.ModelId, r => r.ModelId); - metadata.Add(Options, o => o.ModelDescription, r => r.ModelDescription); - metadata.Add(Options, o => o.ModelManufacturer, r => r.ModelManufacturer); - metadata.Add(Options, o => o.ModelModel, r => r.ModelModel); - metadata.Add(Options, o => o.ModelType, r => r.ModelType); + metadata.Add(o => o.ModelId, r => r.ModelId); + metadata.Add(o => o.ModelDescription, r => r.ModelDescription); + metadata.Add(o => o.ModelManufacturer, r => r.ModelManufacturer); + metadata.Add(o => o.ModelModel, r => r.ModelModel); + metadata.Add(o => o.ModelType, r => r.ModelType); // Batch - metadata.Add(Options, o => o.BatchId, r => r.BatchId); - metadata.Add(Options, o => o.BatchName, r => r.BatchName); - metadata.Add(Options, o => o.BatchPurchaseDate, r => r.BatchPurchaseDate); - metadata.Add(Options, o => o.BatchSupplier, r => r.BatchSupplier); - metadata.Add(Options, o => o.BatchUnitCost, r => r.BatchUnitCost, Exporter.CsvEncoders.NullableCurrencyEncoder); - metadata.Add(Options, o => o.BatchWarrantyValidUntilDate, r => r.BatchWarrantyValidUntilDate); - metadata.Add(Options, o => o.BatchInsuredDate, r => r.BatchInsuredDate); - metadata.Add(Options, o => o.BatchInsuranceSupplier, r => r.BatchInsuranceSupplier); - metadata.Add(Options, o => o.BatchInsuredUntilDate, r => r.BatchInsuredUntilDate); + metadata.Add(o => o.BatchId, r => r.BatchId); + metadata.Add(o => o.BatchName, r => r.BatchName); + metadata.Add(o => o.BatchPurchaseDate, r => r.BatchPurchaseDate); + metadata.Add(o => o.BatchSupplier, r => r.BatchSupplier); + metadata.Add(o => o.BatchUnitCost, r => r.BatchUnitCost, Exporter.CsvEncoders.NullableCurrencyEncoder); + metadata.Add(o => o.BatchWarrantyValidUntilDate, r => r.BatchWarrantyValidUntilDate); + metadata.Add(o => o.BatchInsuredDate, r => r.BatchInsuredDate); + metadata.Add(o => o.BatchInsuranceSupplier, r => r.BatchInsuranceSupplier); + metadata.Add(o => o.BatchInsuredUntilDate, r => r.BatchInsuredUntilDate); // Profile - metadata.Add(Options, o => o.ProfileId, r => r.ProfileId); - metadata.Add(Options, o => o.ProfileName, r => r.ProfileName); - metadata.Add(Options, o => o.ProfileShortName, r => r.ProfileShortName); + metadata.Add(o => o.ProfileId, r => r.ProfileId); + metadata.Add(o => o.ProfileName, r => r.ProfileName); + metadata.Add(o => o.ProfileShortName, r => r.ProfileShortName); // User - metadata.Add(Options, o => o.AssignedUserId, r => r.AssignedUser?.UserId); - metadata.Add(Options, o => o.AssignedUserDate, r => r.DeviceUserAssignment?.AssignedDate); - metadata.Add(Options, o => o.AssignedUserDisplayName, r => r.AssignedUser?.DisplayName); - metadata.Add(Options, o => o.AssignedUserSurname, r => r.AssignedUser?.Surname); - metadata.Add(Options, o => o.AssignedUserGivenName, r => r.AssignedUser?.GivenName); - metadata.Add(Options, o => o.AssignedUserPhoneNumber, r => r.AssignedUser?.PhoneNumber); - metadata.Add(Options, o => o.AssignedUserEmailAddress, r => r.AssignedUser?.EmailAddress); + metadata.Add(o => o.AssignedUserId, r => r.AssignedUser?.UserId); + metadata.Add(o => o.AssignedUserDate, r => r.DeviceUserAssignment?.AssignedDate); + metadata.Add(o => o.AssignedUserDisplayName, r => r.AssignedUser?.DisplayName); + metadata.Add(o => o.AssignedUserSurname, r => r.AssignedUser?.Surname); + metadata.Add(o => o.AssignedUserGivenName, r => r.AssignedUser?.GivenName); + metadata.Add(o => o.AssignedUserPhoneNumber, r => r.AssignedUser?.PhoneNumber); + metadata.Add(o => o.AssignedUserEmailAddress, r => r.AssignedUser?.EmailAddress); // User Custom Details if (Options.AssignedUserDetailCustom) @@ -246,11 +243,11 @@ namespace Disco.Services.Devices } // Jobs - metadata.Add(Options, o => o.JobsTotalCount, r => r.JobsTotalCount); - metadata.Add(Options, o => o.JobsOpenCount, r => r.JobsOpenCount); + metadata.Add(o => o.JobsTotalCount, r => r.JobsTotalCount); + metadata.Add(o => o.JobsOpenCount, r => r.JobsOpenCount); // Attachments - metadata.Add(Options, o => o.AttachmentsCount, r => r.AttachmentsCount); + metadata.Add(o => o.AttachmentsCount, r => r.AttachmentsCount); // 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 - 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) { 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(Options, o => o.DetailMdmHardwareData, r => r.DeviceDetails.MdmHardwareData()); + metadata.Add(o => o.DetailKeyboard, r => r.DeviceDetails.Where(dd => dd.Key == DeviceDetail.HardwareKeyKeyboard).Select(dd => dd.Value).FirstOrDefault()); + metadata.Add(o => o.DetailMdmHardwareData, r => r.DeviceDetails.MdmHardwareData()); return metadata; } diff --git a/Disco.Services/Devices/DeviceFlags/DeviceFlagExport.cs b/Disco.Services/Devices/DeviceFlags/DeviceFlagExport.cs index 5cb57e3f..b6cee3bf 100644 --- a/Disco.Services/Devices/DeviceFlags/DeviceFlagExport.cs +++ b/Disco.Services/Devices/DeviceFlags/DeviceFlagExport.cs @@ -108,67 +108,67 @@ namespace Disco.Services.Devices.DeviceFlags return records; } - public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status) + public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status) { - var metadata = new ExportMetadata(); + var metadata = new ExportMetadata(Options); metadata.IgnoreShortNames.Add("Device Flag"); // Device Flag - metadata.Add(Options, o => o.Id, r => r.Assignment.DeviceFlagId); - metadata.Add(Options, o => o.Name, r => r.Assignment.DeviceFlag.Name); - metadata.Add(Options, o => o.Description, r => r.Assignment.DeviceFlag.Description); - metadata.Add(Options, o => o.Icon, r => r.Assignment.DeviceFlag.Icon); - metadata.Add(Options, o => o.IconColour, r => r.Assignment.DeviceFlag.IconColour); - metadata.Add(Options, o => o.AssignmentId, r => r.Assignment.Id); - metadata.Add(Options, o => o.AddedDate, r => r.Assignment.AddedDate); - metadata.Add(Options, o => o.AddedUserId, r => r.Assignment.AddedUserId); - metadata.Add(Options, o => o.RemovedUserId, r => r.Assignment.RemovedUserId); - metadata.Add(Options, o => o.RemovedDate, r => r.Assignment.RemovedDate); - metadata.Add(Options, o => o.Comments, r => r.Assignment.Comments); + metadata.Add(o => o.Id, r => r.Assignment.DeviceFlagId); + metadata.Add(o => o.Name, r => r.Assignment.DeviceFlag.Name); + metadata.Add(o => o.Description, r => r.Assignment.DeviceFlag.Description); + metadata.Add(o => o.Icon, r => r.Assignment.DeviceFlag.Icon); + metadata.Add(o => o.IconColour, r => r.Assignment.DeviceFlag.IconColour); + metadata.Add(o => o.AssignmentId, r => r.Assignment.Id); + metadata.Add(o => o.AddedDate, r => r.Assignment.AddedDate); + metadata.Add(o => o.AddedUserId, r => r.Assignment.AddedUserId); + metadata.Add(o => o.RemovedUserId, r => r.Assignment.RemovedUserId); + metadata.Add(o => o.RemovedDate, r => r.Assignment.RemovedDate); + metadata.Add(o => o.Comments, r => r.Assignment.Comments); // Device - metadata.Add(Options, o => o.DeviceSerialNumber, r => r.Assignment.Device.SerialNumber); - metadata.Add(Options, o => o.DeviceAssetNumber, r => r.Assignment.Device.AssetNumber); - metadata.Add(Options, o => o.DeviceLocation, r => r.Assignment.Device.Location); - metadata.Add(Options, o => o.DeviceComputerName, r => r.Assignment.Device.DeviceDomainId); - metadata.Add(Options, o => o.DeviceLastNetworkLogon, r => r.Assignment.Device.LastNetworkLogonDate); - metadata.Add(Options, o => o.DeviceCreatedDate, r => r.Assignment.Device.CreatedDate); - metadata.Add(Options, o => o.DeviceFirstEnrolledDate, r => r.Assignment.Device.EnrolledDate); - metadata.Add(Options, o => o.DeviceLastEnrolledDate, r => r.Assignment.Device.LastEnrolDate); - metadata.Add(Options, o => o.DeviceAllowUnauthenticatedEnrol, r => r.Assignment.Device.AllowUnauthenticatedEnrol); - metadata.Add(Options, o => o.DeviceDecommissionedDate, r => r.Assignment.Device.DecommissionedDate); - metadata.Add(Options, o => o.DeviceDecommissionedReason, r => r.Assignment.Device.DecommissionReason?.ToString()); + metadata.Add(o => o.DeviceSerialNumber, r => r.Assignment.Device.SerialNumber); + metadata.Add(o => o.DeviceAssetNumber, r => r.Assignment.Device.AssetNumber); + metadata.Add(o => o.DeviceLocation, r => r.Assignment.Device.Location); + metadata.Add(o => o.DeviceComputerName, r => r.Assignment.Device.DeviceDomainId); + metadata.Add(o => o.DeviceLastNetworkLogon, r => r.Assignment.Device.LastNetworkLogonDate); + metadata.Add(o => o.DeviceCreatedDate, r => r.Assignment.Device.CreatedDate); + metadata.Add(o => o.DeviceFirstEnrolledDate, r => r.Assignment.Device.EnrolledDate); + metadata.Add(o => o.DeviceLastEnrolledDate, r => r.Assignment.Device.LastEnrolDate); + metadata.Add(o => o.DeviceAllowUnauthenticatedEnrol, r => r.Assignment.Device.AllowUnauthenticatedEnrol); + metadata.Add(o => o.DeviceDecommissionedDate, r => r.Assignment.Device.DecommissionedDate); + metadata.Add(o => o.DeviceDecommissionedReason, r => r.Assignment.Device.DecommissionReason?.ToString()); // Model - metadata.Add(Options, o => o.ModelId, r => r.Assignment.Device.DeviceModel.Id); - metadata.Add(Options, o => o.ModelDescription, r => r.Assignment.Device.DeviceModel.Description); - metadata.Add(Options, o => o.ModelManufacturer, r => r.Assignment.Device.DeviceModel.Manufacturer); - metadata.Add(Options, 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.ModelId, r => r.Assignment.Device.DeviceModel.Id); + metadata.Add(o => o.ModelDescription, r => r.Assignment.Device.DeviceModel.Description); + metadata.Add(o => o.ModelManufacturer, r => r.Assignment.Device.DeviceModel.Manufacturer); + metadata.Add(o => o.ModelModel, r => r.Assignment.Device.DeviceModel.Model); + metadata.Add(o => o.ModelType, r => r.Assignment.Device.DeviceModel.ModelType); // Batch - metadata.Add(Options, o => o.BatchId, r => r.Assignment.Device.DeviceBatch?.Id); - metadata.Add(Options, o => o.BatchName, r => r.Assignment.Device.DeviceBatch?.Name); - metadata.Add(Options, o => o.BatchPurchaseDate, r => r.Assignment.Device.DeviceBatch?.PurchaseDate); - metadata.Add(Options, 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(Options, o => o.BatchWarrantyValidUntilDate, r => r.Assignment.Device.DeviceBatch?.WarrantyValidUntil); - metadata.Add(Options, o => o.BatchInsuredDate, r => r.Assignment.Device.DeviceBatch?.InsuredDate); - metadata.Add(Options, 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.BatchId, r => r.Assignment.Device.DeviceBatch?.Id); + metadata.Add(o => o.BatchName, r => r.Assignment.Device.DeviceBatch?.Name); + metadata.Add(o => o.BatchPurchaseDate, r => r.Assignment.Device.DeviceBatch?.PurchaseDate); + metadata.Add(o => o.BatchSupplier, r => r.Assignment.Device.DeviceBatch?.Supplier); + metadata.Add(o => o.BatchUnitCost, r => r.Assignment.Device.DeviceBatch?.UnitCost, Exporter.CsvEncoders.NullableCurrencyEncoder); + metadata.Add(o => o.BatchWarrantyValidUntilDate, r => r.Assignment.Device.DeviceBatch?.WarrantyValidUntil); + metadata.Add(o => o.BatchInsuredDate, r => r.Assignment.Device.DeviceBatch?.InsuredDate); + metadata.Add(o => o.BatchInsuranceSupplier, r => r.Assignment.Device.DeviceBatch?.InsuranceSupplier); + metadata.Add(o => o.BatchInsuredUntilDate, r => r.Assignment.Device.DeviceBatch?.InsuredUntil); // Profile - metadata.Add(Options, o => o.ProfileId, r => r.Assignment.Device.DeviceProfile?.Id); - metadata.Add(Options, 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.ProfileId, r => r.Assignment.Device.DeviceProfile?.Id); + metadata.Add(o => o.ProfileName, r => r.Assignment.Device.DeviceProfile?.Name); + metadata.Add(o => o.ProfileShortName, r => r.Assignment.Device.DeviceProfile?.ShortName); // User - metadata.Add(Options, o => o.AssignedUserId, r => r.Assignment.Device?.AssignedUser?.UserId); - metadata.Add(Options, o => o.AssignedUserDisplayName, r => r.Assignment.Device?.AssignedUser?.DisplayName); - metadata.Add(Options, o => o.AssignedUserSurname, r => r.Assignment.Device?.AssignedUser?.Surname); - metadata.Add(Options, o => o.AssignedUserGivenName, r => r.Assignment.Device?.AssignedUser?.GivenName); - metadata.Add(Options, 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.AssignedUserId, r => r.Assignment.Device?.AssignedUser?.UserId); + metadata.Add(o => o.AssignedUserDisplayName, r => r.Assignment.Device?.AssignedUser?.DisplayName); + metadata.Add(o => o.AssignedUserSurname, r => r.Assignment.Device?.AssignedUser?.Surname); + metadata.Add(o => o.AssignedUserGivenName, r => r.Assignment.Device?.AssignedUser?.GivenName); + metadata.Add(o => o.AssignedUserPhoneNumber, r => r.Assignment.Device?.AssignedUser?.PhoneNumber); + metadata.Add(o => o.AssignedUserEmailAddress, r => r.Assignment.Device?.AssignedUser?.EmailAddress); // User Custom Details if (Options.AssignedUserDetailCustom) diff --git a/Disco.Services/Exporting/Exporter.cs b/Disco.Services/Exporting/Exporter.cs index b2a67a8c..541e49a0 100644 --- a/Disco.Services/Exporting/Exporter.cs +++ b/Disco.Services/Exporting/Exporter.cs @@ -126,12 +126,12 @@ namespace Disco.Services.Exporting return stream; } - public static void Add(this ExportMetadata metadata, O options, Expression> optionAccessor, Func valueAccessor, Func csvValueEncoder = null, string columnName = null) - where T : IExportRecord + public static void Add(this ExportMetadata metadata, Expression> optionAccessor, Func valueAccessor, Func csvValueEncoder = null, string columnName = null) where O : IExportOptions + where R : IExportRecord { // is field enabled? - if (!optionAccessor.Compile().Invoke(options)) + if (!optionAccessor.Compile().Invoke(metadata.Options)) return; if (columnName is null) @@ -147,8 +147,9 @@ namespace Disco.Services.Exporting metadata.Add(columnName, valueAccessor, csvValueEncoder); } - public static void Add(this ExportMetadata metadata, string columnName, Func valueAccessor, Func csvValueEncoder = null) - where T : IExportRecord + public static void Add(this ExportMetadata metadata, string columnName, Func valueAccessor, Func csvValueEncoder = null) + where O : IExportOptions + where R : IExportRecord { var valueType = typeof(V); if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof(Nullable<>)) @@ -157,7 +158,7 @@ namespace Disco.Services.Exporting if (csvValueEncoder is null) csvValueEncoder = CsvEncoders.GetEncoder(); - var field = new ExportMetadataField(columnName, valueType, (T i) => valueAccessor(i), csvValueEncoder); + var field = new ExportMetadataField(columnName, valueType, (R i) => valueAccessor(i), csvValueEncoder); metadata.Add(field); } diff --git a/Disco.Services/Exporting/IExport.cs b/Disco.Services/Exporting/IExport.cs index f37d4011..3cc0d7df 100644 --- a/Disco.Services/Exporting/IExport.cs +++ b/Disco.Services/Exporting/IExport.cs @@ -32,6 +32,6 @@ namespace Disco.Services.Exporting T Options { get; set; } List BuildRecords(DiscoDataContext database, IScheduledTaskStatus status); - ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status); + ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status); } } diff --git a/Disco.Services/Jobs/JobExport.cs b/Disco.Services/Jobs/JobExport.cs index a1126465..1f32b620 100644 --- a/Disco.Services/Jobs/JobExport.cs +++ b/Disco.Services/Jobs/JobExport.cs @@ -216,100 +216,100 @@ namespace Disco.Services.Jobs return records; } - public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status) + public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status) { - var metadata = new ExportMetadata(); + var metadata = new ExportMetadata(Options); metadata.IgnoreShortNames.Add("Job"); metadata.IgnoreShortNames.Add("Job Details"); // Job - metadata.Add(Options, 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(Options, o => o.JobType, r => r.JobTypeDescription); - metadata.Add(Options, o => o.JobSubTypes, r => string.Join(", ", r.JobSubTypeDescriptions)); - metadata.Add(Options, o => o.JobOpenedDate, r => r.Job.OpenedDate); - metadata.Add(Options, o => o.JobOpenedUser, r => r.Job.OpenedTechUserId); - metadata.Add(Options, o => o.JobExpectedClosedDate, r => r.Job.ExpectedClosedDate); - metadata.Add(Options, o => o.JobClosedDate, r => r.Job.ClosedDate); - metadata.Add(Options, o => o.JobClosedUser, r => r.Job.ClosedTechUserId); + metadata.Add(o => o.JobId, r => r.Job.Id); + metadata.Add(o => o.JobStatus, r => Job.JobStatusIds.StatusDescriptions.TryGetValue(r.JobStatus, out var jobStatus) ? jobStatus : "Unknown"); + metadata.Add(o => o.JobType, r => r.JobTypeDescription); + metadata.Add(o => o.JobSubTypes, r => string.Join(", ", r.JobSubTypeDescriptions)); + metadata.Add(o => o.JobOpenedDate, r => r.Job.OpenedDate); + metadata.Add(o => o.JobOpenedUser, r => r.Job.OpenedTechUserId); + metadata.Add(o => o.JobExpectedClosedDate, r => r.Job.ExpectedClosedDate); + metadata.Add(o => o.JobClosedDate, r => r.Job.ClosedDate); + metadata.Add(o => o.JobClosedUser, r => r.Job.ClosedTechUserId); // Job Details - metadata.Add(Options, o => o.JobDeviceHeldDate, r => r.Job.DeviceHeld); - metadata.Add(Options, o => o.JobDeviceHeldUser, r => r.Job.DeviceHeldTechUserId); - metadata.Add(Options, o => o.JobDeviceHeldLocation, r => r.Job.DeviceHeldLocation); - metadata.Add(Options, o => o.JobDeviceReadyForReturnDate, r => r.Job.DeviceReadyForReturn); - metadata.Add(Options, o => o.JobDeviceReadyForReturnUser, r => r.Job.DeviceReadyForReturnTechUserId); - metadata.Add(Options, o => o.JobDeviceReturnedDate, r => r.Job.DeviceReturnedDate); - metadata.Add(Options, o => o.JobDeviceReturnedUser, r => r.Job.DeviceReturnedTechUserId); - metadata.Add(Options, o => o.JobWaitingForUserActionDate, r => r.Job.WaitingForUserAction); + metadata.Add(o => o.JobDeviceHeldDate, r => r.Job.DeviceHeld); + metadata.Add(o => o.JobDeviceHeldUser, r => r.Job.DeviceHeldTechUserId); + metadata.Add(o => o.JobDeviceHeldLocation, r => r.Job.DeviceHeldLocation); + metadata.Add(o => o.JobDeviceReadyForReturnDate, r => r.Job.DeviceReadyForReturn); + metadata.Add(o => o.JobDeviceReadyForReturnUser, r => r.Job.DeviceReadyForReturnTechUserId); + metadata.Add(o => o.JobDeviceReturnedDate, r => r.Job.DeviceReturnedDate); + metadata.Add(o => o.JobDeviceReturnedUser, r => r.Job.DeviceReturnedTechUserId); + metadata.Add(o => o.JobWaitingForUserActionDate, r => r.Job.WaitingForUserAction); // Job Logs - metadata.Add(Options, o => o.LogCount, r => r.LogCount); - metadata.Add(Options, o => o.LogFirstDate, r => r.FirstLog?.Timestamp); - metadata.Add(Options, o => o.LogFirstUser, r => r.FirstLog?.TechUserId); - metadata.Add(Options, o => o.LogFirstContent, r => r.FirstLog?.Comments); - metadata.Add(Options, o => o.LogLastDate, r => r.LastLog?.Timestamp); - metadata.Add(Options, o => o.LogLastUser, r => r.LastLog?.TechUserId); - metadata.Add(Options, o => o.LogLastContent, r => r.LastLog?.Comments); + metadata.Add(o => o.LogCount, r => r.LogCount); + metadata.Add(o => o.LogFirstDate, r => r.FirstLog?.Timestamp); + metadata.Add(o => o.LogFirstUser, r => r.FirstLog?.TechUserId); + metadata.Add(o => o.LogFirstContent, r => r.FirstLog?.Comments); + metadata.Add(o => o.LogLastDate, r => r.LastLog?.Timestamp); + metadata.Add(o => o.LogLastUser, r => r.LastLog?.TechUserId); + metadata.Add(o => o.LogLastContent, r => r.LastLog?.Comments); // Attachments - metadata.Add(Options, o => o.AttachmentsCount, r => r.AttachmentsCount); + metadata.Add(o => o.AttachmentsCount, r => r.AttachmentsCount); // Job Queues - metadata.Add(Options, o => o.JobQueueCount, r => r.QueueCount); - metadata.Add(Options, 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(Options, o => o.JobQueueActiveLatestAddedDate, r => r.QueueLatestActive?.AddedDate); - metadata.Add(Options, o => o.JobQueueActiveLatestAddedUser, r => r.QueueLatestActive?.AddedUserId); + metadata.Add(o => o.JobQueueCount, r => r.QueueCount); + metadata.Add(o => o.JobQueueActiveCount, r => r.QueueActiveCount); + metadata.Add(o => o.JobQueueActiveLatest, r => r.QueueLatestActive?.JobQueueId == null ? null : JobQueueService.GetQueue(r.QueueLatestActive.JobQueueId).JobQueue.Name); + metadata.Add(o => o.JobQueueActiveLatestAddedDate, r => r.QueueLatestActive?.AddedDate); + metadata.Add(o => o.JobQueueActiveLatestAddedUser, r => r.QueueLatestActive?.AddedUserId); // Warranty - metadata.Add(Options, o => o.JobWarrantyExternalName, r => r.JobMetaWarranty?.ExternalName); - metadata.Add(Options, o => o.JobWarrantyExternalReference, r => r.JobMetaWarranty?.ExternalReference); - metadata.Add(Options, o => o.JobWarrantyExternalLoggedDate, r => r.JobMetaWarranty?.ExternalLoggedDate); - metadata.Add(Options, o => o.JobWarrantyExternalCompletedDate, r => r.JobMetaWarranty?.ExternalCompletedDate); + metadata.Add(o => o.JobWarrantyExternalName, r => r.JobMetaWarranty?.ExternalName); + metadata.Add(o => o.JobWarrantyExternalReference, r => r.JobMetaWarranty?.ExternalReference); + metadata.Add(o => o.JobWarrantyExternalLoggedDate, r => r.JobMetaWarranty?.ExternalLoggedDate); + metadata.Add(o => o.JobWarrantyExternalCompletedDate, r => r.JobMetaWarranty?.ExternalCompletedDate); // Non-Warranty - metadata.Add(Options, o => o.JobNonWarrantyAccountingChargeRequiredDate, r => r.JobMetaNonWarranty?.AccountingChargeRequiredDate); - metadata.Add(Options, o => o.JobNonWarrantyAccountingChargeAddedDate, r => r.JobMetaNonWarranty?.AccountingChargeAddedDate); - metadata.Add(Options, o => o.JobNonWarrantyAccountingChargePaidDate, r => r.JobMetaNonWarranty?.AccountingChargePaidDate); - metadata.Add(Options, o => o.JobNonWarrantyPurchaseOrderRaisedDate, r => r.JobMetaNonWarranty?.PurchaseOrderRaisedDate); - metadata.Add(Options, o => o.JobNonWarrantyPurchaseOrderReference, r => r.JobMetaNonWarranty?.PurchaseOrderReference); - metadata.Add(Options, o => o.JobNonWarrantyPurchaseOrderSentDate, r => r.JobMetaNonWarranty?.PurchaseOrderSentDate); - metadata.Add(Options, o => o.JobNonWarrantyInvoiceReceivedDate, r => r.JobMetaNonWarranty?.InvoiceReceivedDate); - metadata.Add(Options, o => o.JobNonWarrantyRepairerName, r => r.JobMetaNonWarranty?.RepairerName); - metadata.Add(Options, o => o.JobNonWarrantyRepairerLoggedDate, r => r.JobMetaNonWarranty?.RepairerLoggedDate); - metadata.Add(Options, o => o.JobNonWarrantyRepairerReference, r => r.JobMetaNonWarranty?.RepairerReference); - metadata.Add(Options, o => o.JobNonWarrantyRepairerCompletedDate, r => r.JobMetaNonWarranty?.RepairerCompletedDate); + metadata.Add(o => o.JobNonWarrantyAccountingChargeRequiredDate, r => r.JobMetaNonWarranty?.AccountingChargeRequiredDate); + metadata.Add(o => o.JobNonWarrantyAccountingChargeAddedDate, r => r.JobMetaNonWarranty?.AccountingChargeAddedDate); + metadata.Add(o => o.JobNonWarrantyAccountingChargePaidDate, r => r.JobMetaNonWarranty?.AccountingChargePaidDate); + metadata.Add(o => o.JobNonWarrantyPurchaseOrderRaisedDate, r => r.JobMetaNonWarranty?.PurchaseOrderRaisedDate); + metadata.Add(o => o.JobNonWarrantyPurchaseOrderReference, r => r.JobMetaNonWarranty?.PurchaseOrderReference); + metadata.Add(o => o.JobNonWarrantyPurchaseOrderSentDate, r => r.JobMetaNonWarranty?.PurchaseOrderSentDate); + metadata.Add(o => o.JobNonWarrantyInvoiceReceivedDate, r => r.JobMetaNonWarranty?.InvoiceReceivedDate); + metadata.Add(o => o.JobNonWarrantyRepairerName, r => r.JobMetaNonWarranty?.RepairerName); + metadata.Add(o => o.JobNonWarrantyRepairerLoggedDate, r => r.JobMetaNonWarranty?.RepairerLoggedDate); + metadata.Add(o => o.JobNonWarrantyRepairerReference, r => r.JobMetaNonWarranty?.RepairerReference); + metadata.Add(o => o.JobNonWarrantyRepairerCompletedDate, r => r.JobMetaNonWarranty?.RepairerCompletedDate); // Insurance - metadata.Add(Options, o => o.JobMetaInsuranceLossOrDamageDate, r => r.JobMetaInsurance?.LossOrDamageDate); - metadata.Add(Options, o => o.JobMetaInsuranceEventLocation, r => r.JobMetaInsurance?.EventLocation); - metadata.Add(Options, o => o.JobMetaInsuranceDescription, r => r.JobMetaInsurance?.Description); - metadata.Add(Options, o => o.JobMetaInsuranceThirdPartyCausedName, r => r.JobMetaInsurance?.ThirdPartyCausedName); - metadata.Add(Options, o => o.JobMetaInsuranceThirdPartyCausedWhy, r => r.JobMetaInsurance?.ThirdPartyCausedWhy); - metadata.Add(Options, o => o.JobMetaInsuranceWitnessesNamesAddresses, r => r.JobMetaInsurance?.WitnessesNamesAddresses); - metadata.Add(Options, o => o.JobMetaInsuranceBurglaryTheftMethodOfEntry, r => r.JobMetaInsurance?.BurglaryTheftMethodOfEntry); - metadata.Add(Options, o => o.JobMetaInsurancePropertyLastSeenDate, r => r.JobMetaInsurance?.PropertyLastSeenDate); - metadata.Add(Options, o => o.JobMetaInsurancePoliceNotifiedStation, r => r.JobMetaInsurance?.PoliceNotifiedStation); - metadata.Add(Options, o => o.JobMetaInsurancePoliceNotifiedDate, r => r.JobMetaInsurance?.PoliceNotifiedDate); - metadata.Add(Options, o => o.JobMetaInsurancePoliceNotifiedCrimeReportNo, r => r.JobMetaInsurance?.PoliceNotifiedCrimeReportNo); - metadata.Add(Options, o => o.JobMetaInsuranceRecoverReduceAction, r => r.JobMetaInsurance?.RecoverReduceAction); - metadata.Add(Options, o => o.JobMetaInsuranceOtherInterestedParties, r => r.JobMetaInsurance?.OtherInterestedParties); - metadata.Add(Options, o => o.JobMetaInsuranceDateOfPurchase, r => r.JobMetaInsurance?.DateOfPurchase); - metadata.Add(Options, o => o.JobMetaInsuranceClaimFormSentDate, r => r.JobMetaInsurance?.ClaimFormSentDate); - metadata.Add(Options, o => o.JobMetaInsuranceInsurer, r => r.JobMetaInsurance?.Insurer); - metadata.Add(Options, o => o.JobMetaInsuranceInsurerReference, r => r.JobMetaInsurance?.InsurerReference); + metadata.Add(o => o.JobMetaInsuranceLossOrDamageDate, r => r.JobMetaInsurance?.LossOrDamageDate); + metadata.Add(o => o.JobMetaInsuranceEventLocation, r => r.JobMetaInsurance?.EventLocation); + metadata.Add(o => o.JobMetaInsuranceDescription, r => r.JobMetaInsurance?.Description); + metadata.Add(o => o.JobMetaInsuranceThirdPartyCausedName, r => r.JobMetaInsurance?.ThirdPartyCausedName); + metadata.Add(o => o.JobMetaInsuranceThirdPartyCausedWhy, r => r.JobMetaInsurance?.ThirdPartyCausedWhy); + metadata.Add(o => o.JobMetaInsuranceWitnessesNamesAddresses, r => r.JobMetaInsurance?.WitnessesNamesAddresses); + metadata.Add(o => o.JobMetaInsuranceBurglaryTheftMethodOfEntry, r => r.JobMetaInsurance?.BurglaryTheftMethodOfEntry); + metadata.Add(o => o.JobMetaInsurancePropertyLastSeenDate, r => r.JobMetaInsurance?.PropertyLastSeenDate); + metadata.Add(o => o.JobMetaInsurancePoliceNotifiedStation, r => r.JobMetaInsurance?.PoliceNotifiedStation); + metadata.Add(o => o.JobMetaInsurancePoliceNotifiedDate, r => r.JobMetaInsurance?.PoliceNotifiedDate); + metadata.Add(o => o.JobMetaInsurancePoliceNotifiedCrimeReportNo, r => r.JobMetaInsurance?.PoliceNotifiedCrimeReportNo); + metadata.Add(o => o.JobMetaInsuranceRecoverReduceAction, r => r.JobMetaInsurance?.RecoverReduceAction); + metadata.Add(o => o.JobMetaInsuranceOtherInterestedParties, r => r.JobMetaInsurance?.OtherInterestedParties); + metadata.Add(o => o.JobMetaInsuranceDateOfPurchase, r => r.JobMetaInsurance?.DateOfPurchase); + metadata.Add(o => o.JobMetaInsuranceClaimFormSentDate, r => r.JobMetaInsurance?.ClaimFormSentDate); + metadata.Add(o => o.JobMetaInsuranceInsurer, r => r.JobMetaInsurance?.Insurer); + metadata.Add(o => o.JobMetaInsuranceInsurerReference, r => r.JobMetaInsurance?.InsurerReference); // User Management - metadata.Add(Options, o => o.JobUserManagementFlags, r => r.Job.Flags?.ToString()); + metadata.Add(o => o.JobUserManagementFlags, r => r.Job.Flags?.ToString()); // User - metadata.Add(Options, o => o.UserId, r => r.User?.UserId); - metadata.Add(Options, o => o.UserDisplayName, r => r.User?.DisplayName); - metadata.Add(Options, o => o.UserSurname, r => r.User?.Surname); - metadata.Add(Options, o => o.UserGivenName, r => r.User?.GivenName); - metadata.Add(Options, o => o.UserPhoneNumber, r => r.User?.PhoneNumber); - metadata.Add(Options, o => o.UserEmailAddress, r => r.User?.EmailAddress); + metadata.Add(o => o.UserId, r => r.User?.UserId); + metadata.Add(o => o.UserDisplayName, r => r.User?.DisplayName); + metadata.Add(o => o.UserSurname, r => r.User?.Surname); + metadata.Add(o => o.UserGivenName, r => r.User?.GivenName); + metadata.Add(o => o.UserPhoneNumber, r => r.User?.PhoneNumber); + metadata.Add(o => o.UserEmailAddress, r => r.User?.EmailAddress); // User Custom Details if (Options.UserDetailCustom) @@ -322,40 +322,40 @@ namespace Disco.Services.Jobs } // Device - metadata.Add(Options, o => o.DeviceSerialNumber, r => r.Device?.SerialNumber); - metadata.Add(Options, o => o.DeviceAssetNumber, r => r.Device?.AssetNumber); - metadata.Add(Options, o => o.DeviceLocation, r => r.Device?.Location); - metadata.Add(Options, o => o.DeviceComputerName, r => r.Device?.DeviceDomainId); - metadata.Add(Options, o => o.DeviceLastNetworkLogon, r => r.Device?.LastNetworkLogonDate); - metadata.Add(Options, o => o.DeviceCreatedDate, r => r.Device?.CreatedDate); - metadata.Add(Options, o => o.DeviceFirstEnrolledDate, r => r.Device?.EnrolledDate); - metadata.Add(Options, o => o.DeviceLastEnrolledDate, r => r.Device?.LastEnrolDate); - metadata.Add(Options, o => o.DeviceAllowUnauthenticatedEnrol, r => r.Device?.AllowUnauthenticatedEnrol); - metadata.Add(Options, o => o.DeviceDecommissionedDate, r => r.Device?.DecommissionedDate); - metadata.Add(Options, o => o.DeviceDecommissionedReason, r => r.Device?.DecommissionReason?.ToString()); + metadata.Add(o => o.DeviceSerialNumber, r => r.Device?.SerialNumber); + metadata.Add(o => o.DeviceAssetNumber, r => r.Device?.AssetNumber); + metadata.Add(o => o.DeviceLocation, r => r.Device?.Location); + metadata.Add(o => o.DeviceComputerName, r => r.Device?.DeviceDomainId); + metadata.Add(o => o.DeviceLastNetworkLogon, r => r.Device?.LastNetworkLogonDate); + metadata.Add(o => o.DeviceCreatedDate, r => r.Device?.CreatedDate); + metadata.Add(o => o.DeviceFirstEnrolledDate, r => r.Device?.EnrolledDate); + metadata.Add(o => o.DeviceLastEnrolledDate, r => r.Device?.LastEnrolDate); + metadata.Add(o => o.DeviceAllowUnauthenticatedEnrol, r => r.Device?.AllowUnauthenticatedEnrol); + metadata.Add(o => o.DeviceDecommissionedDate, r => r.Device?.DecommissionedDate); + metadata.Add(o => o.DeviceDecommissionedReason, r => r.Device?.DecommissionReason?.ToString()); // Model - metadata.Add(Options, o => o.DeviceModelId, r => r.DeviceModelId); - metadata.Add(Options, o => o.DeviceModelDescription, r => r.DeviceModelDescription); - metadata.Add(Options, o => o.DeviceModelManufacturer, r => r.DeviceModelManufacturer); - metadata.Add(Options, o => o.DeviceModelModel, r => r.DeviceModelModel); - metadata.Add(Options, o => o.DeviceModelType, r => r.DeviceModelType); + metadata.Add(o => o.DeviceModelId, r => r.DeviceModelId); + metadata.Add(o => o.DeviceModelDescription, r => r.DeviceModelDescription); + metadata.Add(o => o.DeviceModelManufacturer, r => r.DeviceModelManufacturer); + metadata.Add(o => o.DeviceModelModel, r => r.DeviceModelModel); + metadata.Add(o => o.DeviceModelType, r => r.DeviceModelType); // Batch - metadata.Add(Options, o => o.DeviceBatchId, r => r.DeviceBatchId); - metadata.Add(Options, o => o.DeviceBatchName, r => r.DeviceBatchName); - metadata.Add(Options, o => o.DeviceBatchPurchaseDate, r => r.DeviceBatchPurchaseDate); - metadata.Add(Options, o => o.DeviceBatchSupplier, r => r.DeviceBatchSupplier); - metadata.Add(Options, o => o.DeviceBatchUnitCost, r => r.DeviceBatchUnitCost); - metadata.Add(Options, o => o.DeviceBatchWarrantyValidUntilDate, r => r.DeviceBatchWarrantyValidUntilDate); - metadata.Add(Options, o => o.DeviceBatchInsuredDate, r => r.DeviceBatchInsuredDate); - metadata.Add(Options, o => o.DeviceBatchInsuranceSupplier, r => r.DeviceBatchInsuranceSupplier); - metadata.Add(Options, o => o.DeviceBatchInsuredUntilDate, r => r.DeviceBatchInsuredUntilDate); + metadata.Add(o => o.DeviceBatchId, r => r.DeviceBatchId); + metadata.Add(o => o.DeviceBatchName, r => r.DeviceBatchName); + metadata.Add(o => o.DeviceBatchPurchaseDate, r => r.DeviceBatchPurchaseDate); + metadata.Add(o => o.DeviceBatchSupplier, r => r.DeviceBatchSupplier); + metadata.Add(o => o.DeviceBatchUnitCost, r => r.DeviceBatchUnitCost); + metadata.Add(o => o.DeviceBatchWarrantyValidUntilDate, r => r.DeviceBatchWarrantyValidUntilDate); + metadata.Add(o => o.DeviceBatchInsuredDate, r => r.DeviceBatchInsuredDate); + metadata.Add(o => o.DeviceBatchInsuranceSupplier, r => r.DeviceBatchInsuranceSupplier); + metadata.Add(o => o.DeviceBatchInsuredUntilDate, r => r.DeviceBatchInsuredUntilDate); // Profile - metadata.Add(Options, o => o.DeviceProfileId, r => r.DeviceProfileId); - metadata.Add(Options, o => o.DeviceProfileName, r => r.DeviceProfileName); - metadata.Add(Options, o => o.DeviceProfileShortName, r => r.DeviceProfileShortName); + metadata.Add(o => o.DeviceProfileId, r => r.DeviceProfileId); + metadata.Add(o => o.DeviceProfileName, r => r.DeviceProfileName); + metadata.Add(o => o.DeviceProfileShortName, r => r.DeviceProfileShortName); return metadata; } diff --git a/Disco.Services/Logging/LogExport.cs b/Disco.Services/Logging/LogExport.cs index 7a67f818..b88dcb20 100644 --- a/Disco.Services/Logging/LogExport.cs +++ b/Disco.Services/Logging/LogExport.cs @@ -50,9 +50,9 @@ namespace Disco.Services.Logging return logRetriever.Query(database); } - public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status) + public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status) { - var metadata = new ExportMetadata + var metadata = new ExportMetadata(Options) { { nameof(LogLiveEvent.Timestamp), r => r.Timestamp }, { nameof(LogLiveEvent.ModuleId), r => r.ModuleId }, diff --git a/Disco.Services/Users/UserFlags/UserFlagExport.cs b/Disco.Services/Users/UserFlags/UserFlagExport.cs index 1973cc94..a2279f94 100644 --- a/Disco.Services/Users/UserFlags/UserFlagExport.cs +++ b/Disco.Services/Users/UserFlags/UserFlagExport.cs @@ -91,33 +91,33 @@ namespace Disco.Services.Users.UserFlags return records; } - public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status) + public ExportMetadata BuildMetadata(DiscoDataContext database, List records, IScheduledTaskStatus status) { status.UpdateStatus(80, "Building metadata"); - var metadata = new ExportMetadata(); + var metadata = new ExportMetadata(Options); metadata.IgnoreShortNames.Add("User Flag"); // User Flag - metadata.Add(Options, o => o.Id, r => r.Assignment.UserFlagId); - metadata.Add(Options, o => o.Name, r => r.Assignment.UserFlag.Name); - metadata.Add(Options, o => o.Description, r => r.Assignment.UserFlag.Description); - metadata.Add(Options, o => o.Icon, r => r.Assignment.UserFlag.Icon); - metadata.Add(Options, o => o.IconColour, r => r.Assignment.UserFlag.IconColour); - metadata.Add(Options, o => o.AssignmentId, r => r.Assignment.Id); - metadata.Add(Options, o => o.AddedDate, r => r.Assignment.AddedDate); - metadata.Add(Options, o => o.AddedUserId, r => r.Assignment.AddedUserId); - metadata.Add(Options, o => o.RemovedUserId, r => r.Assignment.RemovedUserId); - metadata.Add(Options, o => o.RemovedDate, r => r.Assignment.RemovedDate); - metadata.Add(Options, o => o.Comments, r => r.Assignment.Comments); + metadata.Add(o => o.Id, r => r.Assignment.UserFlagId); + metadata.Add(o => o.Name, r => r.Assignment.UserFlag.Name); + metadata.Add(o => o.Description, r => r.Assignment.UserFlag.Description); + metadata.Add(o => o.Icon, r => r.Assignment.UserFlag.Icon); + metadata.Add(o => o.IconColour, r => r.Assignment.UserFlag.IconColour); + metadata.Add(o => o.AssignmentId, r => r.Assignment.Id); + metadata.Add(o => o.AddedDate, r => r.Assignment.AddedDate); + metadata.Add(o => o.AddedUserId, r => r.Assignment.AddedUserId); + metadata.Add(o => o.RemovedUserId, r => r.Assignment.RemovedUserId); + metadata.Add(o => o.RemovedDate, r => r.Assignment.RemovedDate); + metadata.Add(o => o.Comments, r => r.Assignment.Comments); // User - metadata.Add(Options, o => o.UserId, r => r.Assignment.User?.UserId); - metadata.Add(Options, o => o.UserDisplayName, r => r.Assignment.User?.DisplayName); - metadata.Add(Options, o => o.UserSurname, r => r.Assignment.User?.Surname); - metadata.Add(Options, o => o.UserGivenName, r => r.Assignment.User?.GivenName); - metadata.Add(Options, o => o.UserPhoneNumber, r => r.Assignment.User?.PhoneNumber); - metadata.Add(Options, o => o.UserEmailAddress, r => r.Assignment.User?.EmailAddress); + metadata.Add(o => o.UserId, r => r.Assignment.User?.UserId); + metadata.Add(o => o.UserDisplayName, r => r.Assignment.User?.DisplayName); + metadata.Add(o => o.UserSurname, r => r.Assignment.User?.Surname); + metadata.Add(o => o.UserGivenName, r => r.Assignment.User?.GivenName); + metadata.Add(o => o.UserPhoneNumber, r => r.Assignment.User?.PhoneNumber); + metadata.Add(o => o.UserEmailAddress, r => r.Assignment.User?.EmailAddress); // User Custom Details if (Options.UserDetailCustom) diff --git a/Disco.Web/Areas/Config/Controllers/UserFlagController.cs b/Disco.Web/Areas/Config/Controllers/UserFlagController.cs index 55f9161e..a8578830 100644 --- a/Disco.Web/Areas/Config/Controllers/UserFlagController.cs +++ b/Disco.Web/Areas/Config/Controllers/UserFlagController.cs @@ -12,7 +12,6 @@ using Disco.Web.Areas.Config.Models.UserFlag; using System; using System.Collections.Generic; using System.Linq; -using System.Web; using System.Web.Mvc; namespace Disco.Web.Areas.Config.Controllers @@ -123,7 +122,8 @@ namespace Disco.Web.Areas.Config.Controllers #region Export - [DiscoAuthorizeAny(Claims.Config.UserFlag.Export), HttpGet] + [HttpGet] + [DiscoAuthorizeAny(Claims.Config.UserFlag.Export)] public virtual ActionResult Export(Guid? exportId, int? userFlagId, bool? currentOnly) { var m = new ExportModel() diff --git a/Disco.Web/Areas/Config/Views/DeviceFlag/Export.cshtml b/Disco.Web/Areas/Config/Views/DeviceFlag/Export.cshtml index 8ad17871..ccaf65c6 100644 --- a/Disco.Web/Areas/Config/Views/DeviceFlag/Export.cshtml +++ b/Disco.Web/Areas/Config/Views/DeviceFlag/Export.cshtml @@ -205,5 +205,5 @@ } - + diff --git a/Disco.Web/Areas/Config/Views/DeviceFlag/Export.generated.cs b/Disco.Web/Areas/Config/Views/DeviceFlag/Export.generated.cs index 1eaabe18..747b53fc 100644 --- a/Disco.Web/Areas/Config/Views/DeviceFlag/Export.generated.cs +++ b/Disco.Web/Areas/Config/Views/DeviceFlag/Export.generated.cs @@ -809,7 +809,7 @@ WriteLiteral(" id=\"DeviceFlag_Export_Button\""); WriteLiteral(" class=\"button\""); -WriteLiteral(">Export Device Flags\r\n\r\n"); +WriteLiteral(">Export Now\r\n\r\n"); } } diff --git a/Disco.Web/Areas/Config/Views/UserFlag/Export.cshtml b/Disco.Web/Areas/Config/Views/UserFlag/Export.cshtml index eaf4d4e2..2ce72335 100644 --- a/Disco.Web/Areas/Config/Views/UserFlag/Export.cshtml +++ b/Disco.Web/Areas/Config/Views/UserFlag/Export.cshtml @@ -205,5 +205,5 @@ } - + diff --git a/Disco.Web/Areas/Config/Views/UserFlag/Export.generated.cs b/Disco.Web/Areas/Config/Views/UserFlag/Export.generated.cs index 702870f5..93541069 100644 --- a/Disco.Web/Areas/Config/Views/UserFlag/Export.generated.cs +++ b/Disco.Web/Areas/Config/Views/UserFlag/Export.generated.cs @@ -809,7 +809,7 @@ WriteLiteral(" id=\"UserFlag_Export_Button\""); WriteLiteral(" class=\"button\""); -WriteLiteral(">Export User Flags\r\n\r\n"); +WriteLiteral(">Export Now\r\n\r\n"); } } diff --git a/Disco.Web/Views/Job/Export.cshtml b/Disco.Web/Views/Job/Export.cshtml index 7cfe7a1d..183b302e 100644 --- a/Disco.Web/Views/Job/Export.cshtml +++ b/Disco.Web/Views/Job/Export.cshtml @@ -296,5 +296,5 @@ } - + diff --git a/Disco.Web/Views/Job/Export.generated.cs b/Disco.Web/Views/Job/Export.generated.cs index 77cdaeb5..8a0241d4 100644 --- a/Disco.Web/Views/Job/Export.generated.cs +++ b/Disco.Web/Views/Job/Export.generated.cs @@ -1154,7 +1154,7 @@ WriteLiteral(" type=\"button\""); WriteLiteral(" class=\"button\""); -WriteLiteral(">Export Jobs\r\n\r\n"); +WriteLiteral(">Export Now\r\n\r\n"); } }