Tidy: Sort/remove usings, simplify names
This commit is contained in:
@@ -10,8 +10,6 @@ using Exceptionless;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Services
|
||||
{
|
||||
|
||||
@@ -344,7 +344,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
if (domain == null)
|
||||
domain = ActiveDirectory.Context.GetDomainByName(Request.DNSDomainName);
|
||||
|
||||
if (!authenticatedToken.User.UserId.Equals(string.Format(@"{0}\{1}$", domain.NetBiosName, Request.ComputerName), System.StringComparison.OrdinalIgnoreCase))
|
||||
if (!authenticatedToken.User.UserId.Equals(string.Format(@"{0}\{1}$", domain.NetBiosName, Request.ComputerName), StringComparison.OrdinalIgnoreCase))
|
||||
throw new EnrolmentSafeException(string.Format("Connection not correctly authenticated (SN: {0}; Auth User: {1})", Request.SerialNumber, authenticatedToken.User.UserId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Disco.Services.Devices.Enrolment
|
||||
namespace Disco.Services.Devices.Enrolment
|
||||
{
|
||||
public enum EnrolmentTypes
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
var trigger = TriggerBuilder.Create()
|
||||
.StartAt(DateTimeOffset.Now.AddMinutes(5));
|
||||
|
||||
this.ScheduleTask(trigger);
|
||||
ScheduleTask(trigger);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Devices.Exporting;
|
||||
using Disco.Models.Services.Devices.Exporting;
|
||||
using Disco.Services.Tasks;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Disco.Data.Repository;
|
||||
|
||||
namespace Disco.Services.Devices.Exporting
|
||||
@@ -34,13 +30,13 @@ namespace Disco.Services.Devices.Exporting
|
||||
|
||||
protected override void ExecuteTask()
|
||||
{
|
||||
var context = (DeviceExportTaskContext)this.ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
|
||||
var context = (DeviceExportTaskContext)ExecutionContext.JobDetail.JobDataMap[JobDataMapContext];
|
||||
|
||||
Status.UpdateStatus(10, "Exporting Device Records", "Starting...");
|
||||
|
||||
using (DiscoDataContext Database = new DiscoDataContext())
|
||||
{
|
||||
context.Result = DeviceExport.GenerateExport(Database, context.Options, this.Status);
|
||||
context.Result = DeviceExport.GenerateExport(Database, context.Options, Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Disco.Models.Services.Devices.Exporting;
|
||||
using Disco.Services.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.Services.Devices.Exporting
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
private DeviceBatchAssignedUsersManagedGroup(string Key, ADManagedGroupConfiguration Configuration, DeviceBatch DeviceBatch)
|
||||
: base(Key, Configuration)
|
||||
{
|
||||
this.DeviceBatchId = DeviceBatch.Id;
|
||||
this.DeviceBatchName = DeviceBatch.Name;
|
||||
DeviceBatchId = DeviceBatch.Id;
|
||||
DeviceBatchName = DeviceBatch.Name;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
@@ -125,7 +125,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
public override IEnumerable<string> DetermineMembers(DiscoDataContext Database)
|
||||
{
|
||||
return Database.Devices
|
||||
.Where(d => d.DeviceBatchId == this.DeviceBatchId)
|
||||
.Where(d => d.DeviceBatchId == DeviceBatchId)
|
||||
.Where(d => d.AssignedUserId != null)
|
||||
.Select(d => d.AssignedUserId);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
AddMember(device.AssignedUserId);
|
||||
break;
|
||||
case RepositoryMonitorEventType.Modified:
|
||||
if (device.DeviceBatchId == this.DeviceBatchId)
|
||||
if (device.DeviceBatchId == DeviceBatchId)
|
||||
{
|
||||
if (device.AssignedUserId != null)
|
||||
AddMember(device.AssignedUserId);
|
||||
@@ -152,7 +152,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
{
|
||||
if (previousUserId != null)
|
||||
RemoveMember(previousUserId, (database) =>
|
||||
!database.Devices.Any(d => d.DeviceBatchId == this.DeviceBatchId && d.AssignedUserId == previousUserId)
|
||||
!database.Devices.Any(d => d.DeviceBatchId == DeviceBatchId && d.AssignedUserId == previousUserId)
|
||||
? new string[] { previousUserId }
|
||||
: null);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
{
|
||||
if (previousUserId != null)
|
||||
RemoveMember(previousUserId, (database) =>
|
||||
!database.Devices.Any(d => d.DeviceBatchId == this.DeviceBatchId && d.AssignedUserId == previousUserId)
|
||||
!database.Devices.Any(d => d.DeviceBatchId == DeviceBatchId && d.AssignedUserId == previousUserId)
|
||||
? new string[] { previousUserId }
|
||||
: null);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
case RepositoryMonitorEventType.Deleted:
|
||||
if (previousUserId != null)
|
||||
RemoveMember(previousUserId, (database) =>
|
||||
!database.Devices.Any(d => d.DeviceBatchId == this.DeviceBatchId && d.AssignedUserId == previousUserId)
|
||||
!database.Devices.Any(d => d.DeviceBatchId == DeviceBatchId && d.AssignedUserId == previousUserId)
|
||||
? new string[] { previousUserId }
|
||||
: null);
|
||||
break;
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
private DeviceBatchDevicesManagedGroup(string Key, ADManagedGroupConfiguration Configuration, DeviceBatch DeviceBatch)
|
||||
: base(Key, Configuration)
|
||||
{
|
||||
this.DeviceBatchId = DeviceBatch.Id;
|
||||
this.DeviceBatchName = DeviceBatch.Name;
|
||||
DeviceBatchId = DeviceBatch.Id;
|
||||
DeviceBatchName = DeviceBatch.Name;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
@@ -123,7 +123,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
public override IEnumerable<string> DetermineMembers(DiscoDataContext Database)
|
||||
{
|
||||
return Database.Devices
|
||||
.Where(d => d.DeviceBatchId == this.DeviceBatchId)
|
||||
.Where(d => d.DeviceBatchId == DeviceBatchId)
|
||||
.Where(d => d.DeviceDomainId != null)
|
||||
.Select(d => d.DeviceDomainId)
|
||||
.ToList()
|
||||
@@ -144,7 +144,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
AddMember(device.DeviceDomainId + "$");
|
||||
break;
|
||||
case RepositoryMonitorEventType.Modified:
|
||||
if (device.DeviceBatchId == this.DeviceBatchId)
|
||||
if (device.DeviceBatchId == DeviceBatchId)
|
||||
{
|
||||
if (ActiveDirectory.IsValidDomainAccountId(device.DeviceDomainId))
|
||||
AddMember(device.DeviceDomainId + "$");
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
private DeviceProfileAssignedUsersManagedGroup(string Key, ADManagedGroupConfiguration Configuration, DeviceProfile DeviceProfile)
|
||||
: base(Key, Configuration)
|
||||
{
|
||||
this.DeviceProfileId = DeviceProfile.Id;
|
||||
this.DeviceProfileName = DeviceProfile.Name;
|
||||
DeviceProfileId = DeviceProfile.Id;
|
||||
DeviceProfileName = DeviceProfile.Name;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
@@ -125,7 +125,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
public override IEnumerable<string> DetermineMembers(DiscoDataContext Database)
|
||||
{
|
||||
return Database.Devices
|
||||
.Where(d => d.DeviceProfileId == this.DeviceProfileId)
|
||||
.Where(d => d.DeviceProfileId == DeviceProfileId)
|
||||
.Where(d => d.AssignedUserId != null)
|
||||
.Select(d => d.AssignedUserId);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
AddMember(device.AssignedUserId);
|
||||
break;
|
||||
case RepositoryMonitorEventType.Modified:
|
||||
if (device.DeviceProfileId == this.DeviceProfileId)
|
||||
if (device.DeviceProfileId == DeviceProfileId)
|
||||
{
|
||||
if (device.AssignedUserId != null)
|
||||
AddMember(device.AssignedUserId);
|
||||
@@ -152,7 +152,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
{
|
||||
if (previousUserId != null)
|
||||
RemoveMember(previousUserId, (database) =>
|
||||
!database.Devices.Any(d => d.DeviceProfileId == this.DeviceProfileId && d.AssignedUserId == previousUserId)
|
||||
!database.Devices.Any(d => d.DeviceProfileId == DeviceProfileId && d.AssignedUserId == previousUserId)
|
||||
? new string[] { previousUserId }
|
||||
: null);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
{
|
||||
if (previousUserId != null)
|
||||
RemoveMember(previousUserId, (database) =>
|
||||
!database.Devices.Any(d => d.DeviceProfileId == this.DeviceProfileId && d.AssignedUserId == previousUserId)
|
||||
!database.Devices.Any(d => d.DeviceProfileId == DeviceProfileId && d.AssignedUserId == previousUserId)
|
||||
? new string[] { previousUserId }
|
||||
: null);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
case RepositoryMonitorEventType.Deleted:
|
||||
if (previousUserId != null)
|
||||
RemoveMember(previousUserId, (database) =>
|
||||
!database.Devices.Any(d => d.DeviceProfileId == this.DeviceProfileId && d.AssignedUserId == previousUserId)
|
||||
!database.Devices.Any(d => d.DeviceProfileId == DeviceProfileId && d.AssignedUserId == previousUserId)
|
||||
? new string[] { previousUserId }
|
||||
: null);
|
||||
break;
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
private DeviceProfileDevicesManagedGroup(string Key, ADManagedGroupConfiguration Configuration, DeviceProfile DeviceProfile)
|
||||
: base(Key, Configuration)
|
||||
{
|
||||
this.DeviceProfileId = DeviceProfile.Id;
|
||||
this.DeviceProfileName = DeviceProfile.Name;
|
||||
DeviceProfileId = DeviceProfile.Id;
|
||||
DeviceProfileName = DeviceProfile.Name;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
@@ -124,7 +124,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
public override IEnumerable<string> DetermineMembers(DiscoDataContext Database)
|
||||
{
|
||||
return Database.Devices
|
||||
.Where(d => d.DeviceProfileId == this.DeviceProfileId)
|
||||
.Where(d => d.DeviceProfileId == DeviceProfileId)
|
||||
.Where(d => d.DeviceDomainId != null)
|
||||
.Select(d => d.DeviceDomainId)
|
||||
.ToList()
|
||||
@@ -145,7 +145,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
AddMember(device.DeviceDomainId + "$");
|
||||
break;
|
||||
case RepositoryMonitorEventType.Modified:
|
||||
if (device.DeviceProfileId == this.DeviceProfileId)
|
||||
if (device.DeviceProfileId == DeviceProfileId)
|
||||
{
|
||||
if (ActiveDirectory.IsValidDomainAccountId(device.DeviceDomainId))
|
||||
AddMember(device.DeviceDomainId + "$");
|
||||
|
||||
Reference in New Issue
Block a user