Tidy: Sort/remove usings, simplify names

This commit is contained in:
Gary Sharp
2017-03-25 15:29:51 +11:00
parent 526f8547f7
commit ed66f4f285
168 changed files with 708 additions and 1175 deletions
@@ -1,4 +1,5 @@
using Disco.Data.Repository;
using Disco.Models.Services.Devices.Importing;
using Disco.Services.Tasks;
using Quartz;
using System;
@@ -13,10 +14,10 @@ namespace Disco.Services.Devices.Importing
public override bool SingleInstanceTask { get { return false; } }
public override bool CancelInitiallySupported { get { return false; } }
public static ScheduledTaskStatus ScheduleNow(DeviceImportContext Context)
public static ScheduledTaskStatus ScheduleNow(IDeviceImportContext Context)
{
if (Context == null)
throw new ArgumentNullException("Context");
throw new ArgumentNullException(nameof(Context));
// Build Data Map
var task = new DeviceImportApplyTask();
@@ -28,14 +29,14 @@ namespace Disco.Services.Devices.Importing
protected override void ExecuteTask()
{
var context = (DeviceImportContext)this.ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
var context = (IDeviceImportContext)ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
using (DiscoDataContext Database = new DiscoDataContext())
{
context.AffectedRecords = context.ApplyRecords(Database, this.Status);
context.AffectedRecords = context.ApplyRecords(Database, Status);
}
Status.SetFinishedMessage(string.Format("Successfully imported/updated {0} device{1}", context.AffectedRecords, context.AffectedRecords == 1 ? null : "s"));
Status.SetFinishedMessage($"Successfully imported/updated {context.AffectedRecords} device{(context.AffectedRecords == 1 ? null : "s")}");
}
}
}
@@ -0,0 +1,21 @@
using Disco.Models.Services.Devices.Importing;
using System;
namespace Disco.Services.Devices.Importing
{
public class DeviceImportColumn : IDeviceImportColumn
{
public int Index { get; set; }
public string Name { get; set; }
public DeviceImportFieldTypes Type { get; set; }
public Type Handler { get; set; }
public IDeviceImportField GetHandlerInstance()
{
if (Handler == null)
throw new InvalidOperationException($"No field handler available for this type {Type.ToString()}.");
return (IDeviceImportField)Activator.CreateInstance(Handler);
}
}
}
@@ -19,10 +19,10 @@ namespace Disco.Services.Devices.Importing
{
this.Database = Database;
this.devices = new Lazy<IEnumerable<Device>>(() => Database.Devices.Include("DeviceDetails").ToList());
this.deviceModels = new Lazy<IEnumerable<DeviceModel>>(() => Database.DeviceModels.ToList());
this.deviceProfiles = new Lazy<IEnumerable<DeviceProfile>>(() => Database.DeviceProfiles.ToList());
this.deviceBatches = new Lazy<IEnumerable<DeviceBatch>>(() => Database.DeviceBatches.ToList());
devices = new Lazy<IEnumerable<Device>>(() => Database.Devices.Include("DeviceDetails").ToList());
deviceModels = new Lazy<IEnumerable<DeviceModel>>(() => Database.DeviceModels.ToList());
deviceProfiles = new Lazy<IEnumerable<DeviceProfile>>(() => Database.DeviceProfiles.ToList());
deviceBatches = new Lazy<IEnumerable<DeviceBatch>>(() => Database.DeviceBatches.ToList());
}
public Device FindDevice(string DeviceSerialNumber)