diff --git a/Disco.Services/Authorization/AccessDeniedException.cs b/Disco.Services/Authorization/AccessDeniedException.cs index 7507bd50..5aced150 100644 --- a/Disco.Services/Authorization/AccessDeniedException.cs +++ b/Disco.Services/Authorization/AccessDeniedException.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Authorization { @@ -13,21 +9,21 @@ namespace Disco.Services.Authorization public AccessDeniedException(string Message, string Resource) { - this.message = Message; - this.resource = Resource; + message = Message; + resource = Resource; } public override string Message { get { - if (this.message == null) + if (message == null) { return "Your account does not have the required permission to access this Disco feature."; } else { - return this.message; + return message; } } } @@ -36,7 +32,7 @@ namespace Disco.Services.Authorization { get { - return this.resource; + return resource; } } } diff --git a/Disco.Services/Authorization/AuthorizationLog.cs b/Disco.Services/Authorization/AuthorizationLog.cs index 71c669b5..a929b34a 100644 --- a/Disco.Services/Authorization/AuthorizationLog.cs +++ b/Disco.Services/Authorization/AuthorizationLog.cs @@ -1,11 +1,7 @@ using Disco.Models.Repository; using Disco.Services.Logging; using Disco.Services.Logging.Models; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Authorization { diff --git a/Disco.Services/Authorization/AuthorizationToken.cs b/Disco.Services/Authorization/AuthorizationToken.cs index c10f0a9c..2bda4bec 100644 --- a/Disco.Services/Authorization/AuthorizationToken.cs +++ b/Disco.Services/Authorization/AuthorizationToken.cs @@ -5,9 +5,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Disco.Services.Interop.ActiveDirectory; namespace Disco.Services.Authorization { diff --git a/Disco.Services/Authorization/ClaimNavigatorItem.cs b/Disco.Services/Authorization/ClaimNavigatorItem.cs index 5590c386..4e0383ba 100644 --- a/Disco.Services/Authorization/ClaimNavigatorItem.cs +++ b/Disco.Services/Authorization/ClaimNavigatorItem.cs @@ -3,8 +3,6 @@ using Disco.Services.Authorization.Roles; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Authorization { @@ -26,9 +24,9 @@ namespace Disco.Services.Authorization { this.Key = Key; var details = Claims.GetClaimDetails(Key); - this.Name = details.Item1; - this.Description = details.Item2; - this.accessor = Claims.GetClaimAccessor(Key); + Name = details.Item1; + Description = details.Item2; + accessor = Claims.GetClaimAccessor(Key); this.Hidden = Hidden; } @@ -52,13 +50,13 @@ namespace Disco.Services.Authorization { return new ClaimNavigatorItem() { - Key = this.Key, - Name = this.Name, - Description = this.Description, - Hidden = this.Hidden, - accessor = this.accessor, - Value = this.accessor == null ? (bool?)null : this.accessor(RoleClaims), - Children = this.Children == null ? null : this.Children.Cast().Select(c => c.BuildClaimTree(RoleClaims)).ToList() + Key = Key, + Name = Name, + Description = Description, + Hidden = Hidden, + accessor = accessor, + Value = accessor == null ? (bool?)null : accessor(RoleClaims), + Children = Children == null ? null : Children.Cast().Select(c => c.BuildClaimTree(RoleClaims)).ToList() }; } @@ -66,19 +64,19 @@ namespace Disco.Services.Authorization { return new ClaimNavigatorItem() { - Key = this.Key, - Name = this.Name, - Description = this.Description, - Hidden = this.Hidden, - accessor = this.accessor, - Value = this.accessor == null ? (bool?)null : RoleClaims.Any(rc => this.accessor(rc)), - Children = this.Children == null ? null : this.Children.Cast().Select(c => c.BuildClaimTree(RoleClaims)).ToList() + Key = Key, + Name = Name, + Description = Description, + Hidden = Hidden, + accessor = accessor, + Value = accessor == null ? (bool?)null : RoleClaims.Any(rc => accessor(rc)), + Children = Children == null ? null : Children.Cast().Select(c => c.BuildClaimTree(RoleClaims)).ToList() }; } public override string ToString() { - return string.Format("{0}: {1}={2}", this.Name, this.Key, this.Value); + return string.Format("{0}: {1}={2}", Name, Key, Value); } } } diff --git a/Disco.Services/Authorization/DiscoAuthorizeAllAttribute.cs b/Disco.Services/Authorization/DiscoAuthorizeAllAttribute.cs index 15cc425d..25666881 100644 --- a/Disco.Services/Authorization/DiscoAuthorizeAllAttribute.cs +++ b/Disco.Services/Authorization/DiscoAuthorizeAllAttribute.cs @@ -1,10 +1,4 @@ -using Disco.Services.Users; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Mvc; +using System; namespace Disco.Services.Authorization { @@ -17,7 +11,7 @@ namespace Disco.Services.Authorization if (AuthorisedClaims == null || AuthorisedClaims.Length == 0) throw new ArgumentNullException("AuthorisedClaims"); - this.authorizedClaims = AuthorisedClaims; + authorizedClaims = AuthorisedClaims; } public override bool IsAuthorized(System.Web.HttpContextBase httpContext) diff --git a/Disco.Services/Authorization/DiscoAuthorizeAnyAttribute.cs b/Disco.Services/Authorization/DiscoAuthorizeAnyAttribute.cs index d7e9f634..adeab010 100644 --- a/Disco.Services/Authorization/DiscoAuthorizeAnyAttribute.cs +++ b/Disco.Services/Authorization/DiscoAuthorizeAnyAttribute.cs @@ -1,10 +1,4 @@ -using Disco.Services.Users; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Mvc; +using System; namespace Disco.Services.Authorization { @@ -17,7 +11,7 @@ namespace Disco.Services.Authorization if (AuthorisedClaims == null || AuthorisedClaims.Length == 0) throw new ArgumentNullException("AuthorisedClaims"); - this.authorizedClaims = AuthorisedClaims; + authorizedClaims = AuthorisedClaims; } public override bool IsAuthorized(System.Web.HttpContextBase httpContext) diff --git a/Disco.Services/Authorization/DiscoAuthorizeAttribute.cs b/Disco.Services/Authorization/DiscoAuthorizeAttribute.cs index 51f5f4b0..cc6032c2 100644 --- a/Disco.Services/Authorization/DiscoAuthorizeAttribute.cs +++ b/Disco.Services/Authorization/DiscoAuthorizeAttribute.cs @@ -1,10 +1,4 @@ using Disco.Services.Users; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Mvc; namespace Disco.Services.Authorization { @@ -16,7 +10,7 @@ namespace Disco.Services.Authorization public DiscoAuthorizeAttribute(string AuthorisedClaim) { - this.authorizedClaim = AuthorisedClaim; + authorizedClaim = AuthorisedClaim; } public override bool IsAuthorized(System.Web.HttpContextBase httpContext) diff --git a/Disco.Services/Authorization/DiscoAuthorizeBaseAttribute.cs b/Disco.Services/Authorization/DiscoAuthorizeBaseAttribute.cs index d2f0002a..c27a1f69 100644 --- a/Disco.Services/Authorization/DiscoAuthorizeBaseAttribute.cs +++ b/Disco.Services/Authorization/DiscoAuthorizeBaseAttribute.cs @@ -1,10 +1,6 @@ using Disco.Services.Users; using System; -using System.Collections.Generic; -using System.Linq; using System.Net; -using System.Text; -using System.Threading.Tasks; using System.Web.Mvc; namespace Disco.Services.Authorization diff --git a/Disco.Services/Authorization/Roles/BaseRoleClaimGroup.cs b/Disco.Services/Authorization/Roles/BaseRoleClaimGroup.cs index c10a7e27..824a36ff 100644 --- a/Disco.Services/Authorization/Roles/BaseRoleClaimGroup.cs +++ b/Disco.Services/Authorization/Roles/BaseRoleClaimGroup.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles +namespace Disco.Services.Authorization.Roles { public abstract class BaseRoleClaimGroup { diff --git a/Disco.Services/Authorization/Roles/ClaimDetailsAttribute.cs b/Disco.Services/Authorization/Roles/ClaimDetailsAttribute.cs index 0021ae89..12ca968b 100644 --- a/Disco.Services/Authorization/Roles/ClaimDetailsAttribute.cs +++ b/Disco.Services/Authorization/Roles/ClaimDetailsAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Authorization.Roles { diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/ConfigClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/ConfigClaims.cs index ccf68ce9..daee3083 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/ConfigClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/ConfigClaims.cs @@ -19,19 +19,19 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration { public ConfigClaims() { - this.DeviceCertificate = new DeviceCertificateClaims(); - this.Enrolment = new EnrolmentClaims(); - this.DeviceBatch = new DeviceBatchClaims(); - this.DeviceModel = new DeviceModelClaims(); - this.DeviceProfile = new DeviceProfileClaims(); - this.DocumentTemplate = new DocumentTemplateClaims(); - this.Logging = new LoggingClaims(); - this.Plugin = new PluginClaims(); - this.System = new SystemClaims(); - this.Organisation = new OrganisationClaims(); - this.JobPreferences = new JobPreferencesClaims(); - this.JobQueue = new JobQueueClaims(); - this.UserFlag = new UserFlagClaims(); + DeviceCertificate = new DeviceCertificateClaims(); + Enrolment = new EnrolmentClaims(); + DeviceBatch = new DeviceBatchClaims(); + DeviceModel = new DeviceModelClaims(); + DeviceProfile = new DeviceProfileClaims(); + DocumentTemplate = new DocumentTemplateClaims(); + Logging = new LoggingClaims(); + Plugin = new PluginClaims(); + System = new SystemClaims(); + Organisation = new OrganisationClaims(); + JobPreferences = new JobPreferencesClaims(); + JobQueue = new JobQueueClaims(); + UserFlag = new UserFlagClaims(); } [ClaimDetails("Show Configuration", "Can show the configuration menu")] diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceBatch/DeviceBatchClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceBatch/DeviceBatchClaims.cs index 85b00cee..06580c07 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceBatch/DeviceBatchClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceBatch/DeviceBatchClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceBatch +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceBatch { [ClaimDetails("Device Batches", "Permissions related to Device Batches")] public class DeviceBatchClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceCertificate/DeviceCertificateClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceCertificate/DeviceCertificateClaims.cs index a25a8838..1887535b 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceCertificate/DeviceCertificateClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceCertificate/DeviceCertificateClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceCertificate +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceCertificate { [ClaimDetails("Device Certificates", "Permissions related to Device Certificates")] public class DeviceCertificateClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceModel/DeviceModelClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceModel/DeviceModelClaims.cs index ee6180fc..08a17ec1 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceModel/DeviceModelClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceModel/DeviceModelClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceModel +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceModel { [ClaimDetails("Device Models", "Permissions related to Device Models")] public class DeviceModelClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceProfile/DeviceProfileClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceProfile/DeviceProfileClaims.cs index a492d9ed..fee13000 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceProfile/DeviceProfileClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DeviceProfile/DeviceProfileClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceProfile +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceProfile { [ClaimDetails("Device Profiles", "Permissions related to Device Profiles")] public class DeviceProfileClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DocumentTemplate/DocumentTemplateClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DocumentTemplate/DocumentTemplateClaims.cs index 77920f3e..144e32df 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DocumentTemplate/DocumentTemplateClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/DocumentTemplate/DocumentTemplateClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DocumentTemplate +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DocumentTemplate { [ClaimDetails("Document Templates", "Permissions related to Document Templates")] public class DocumentTemplateClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Enrolment/EnrolmentClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Enrolment/EnrolmentClaims.cs index 8b478a07..cbaffda5 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Enrolment/EnrolmentClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Enrolment/EnrolmentClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Enrolment +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Enrolment { [ClaimDetails("Enrolment", "Permissions related to Device Enrolment")] public class EnrolmentClaims diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/JobQueue/JobQueueClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/JobQueue/JobQueueClaims.cs index 34f32731..69f0cf89 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/JobQueue/JobQueueClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/JobQueue/JobQueueClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.JobQueue +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.JobQueue { [ClaimDetails("Job Queues", "Permissions related to Job Queues")] public class JobQueueClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Logging/LoggingClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Logging/LoggingClaims.cs index 44752b03..f0611142 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Logging/LoggingClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Logging/LoggingClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Logging +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Logging { [ClaimDetails("Logging", "Permissions related to Logging")] public class LoggingClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Origanisation/OrganisationClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Origanisation/OrganisationClaims.cs index 203a5d57..602d3c8f 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Origanisation/OrganisationClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Origanisation/OrganisationClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Origanisation +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Origanisation { [ClaimDetails("Organisation Details", "Permissions related to the Organisation Details")] public class OrganisationClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Plugin/PluginClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Plugin/PluginClaims.cs index 822b4fc9..6ee4d171 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Plugin/PluginClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/Plugin/PluginClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Plugin +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Plugin { [ClaimDetails("Plugin", "Permissions related to Plugins")] public class PluginClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/System/SystemClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/System/SystemClaims.cs index 5290e7a3..f3fad582 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/System/SystemClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Configuration/System/SystemClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.System +namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.System { [ClaimDetails("System", "Permissions related to System Configuration")] public class SystemClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Device/DeviceActionsClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Device/DeviceActionsClaims.cs index 02135c86..1df4f3a3 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Device/DeviceActionsClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Device/DeviceActionsClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Device +namespace Disco.Services.Authorization.Roles.ClaimGroups.Device { [ClaimDetails("Actions", "Permissions related to Device Actions")] public class DeviceActionsClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Device/DeviceClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Device/DeviceClaims.cs index d2e2372b..895ad90f 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Device/DeviceClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Device/DeviceClaims.cs @@ -1,18 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Device +namespace Disco.Services.Authorization.Roles.ClaimGroups.Device { [ClaimDetails("Device", "Permissions related to Devices")] public class DeviceClaims : BaseRoleClaimGroup { public DeviceClaims() { - this.Properties = new DevicePropertiesClaims(); - this.Actions = new DeviceActionsClaims(); + Properties = new DevicePropertiesClaims(); + Actions = new DeviceActionsClaims(); } [ClaimDetails("Search Devices", "Can search devices")] diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Device/DevicePropertiesClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Device/DevicePropertiesClaims.cs index 1c278a9e..54add0c9 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Device/DevicePropertiesClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Device/DevicePropertiesClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Device +namespace Disco.Services.Authorization.Roles.ClaimGroups.Device { [ClaimDetails("Device Properties", "Permissions related to Device Properties")] public class DevicePropertiesClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobActionsClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobActionsClaims.cs index a0a4195c..5c595663 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobActionsClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobActionsClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Job +namespace Disco.Services.Authorization.Roles.ClaimGroups.Job { [ClaimDetails("Actions", "Permissions related to Job Actions")] public class JobActionsClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobClaims.cs index 808979ce..faf77252 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobClaims.cs @@ -1,20 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Job +namespace Disco.Services.Authorization.Roles.ClaimGroups.Job { [ClaimDetails("Job", "Permissions related to Jobs")] public class JobClaims : BaseRoleClaimGroup { public JobClaims() { - this.Lists = new JobListsClaims(); - this.Actions = new JobActionsClaims(); - this.Properties = new JobPropertiesClaims(); - this.Types = new JobTypesClaims(); + Lists = new JobListsClaims(); + Actions = new JobActionsClaims(); + Properties = new JobPropertiesClaims(); + Types = new JobTypesClaims(); } [ClaimDetails("Search Jobs", "Can search jobs")] diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobListsClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobListsClaims.cs index 97d1e8b5..c66bd424 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobListsClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobListsClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Job +namespace Disco.Services.Authorization.Roles.ClaimGroups.Job { [ClaimDetails("Lists", "Permissions related to Job Lists")] public class JobListsClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobNonWarrantyPropertiesClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobNonWarrantyPropertiesClaims.cs index e8ebc189..7750a3a7 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobNonWarrantyPropertiesClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobNonWarrantyPropertiesClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Job +namespace Disco.Services.Authorization.Roles.ClaimGroups.Job { [ClaimDetails("Non Warranty Properties", "Permissions related to Non-Warranty Job Properties")] public class JobNonWarrantyPropertiesClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobPropertiesClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobPropertiesClaims.cs index 780551b0..c1e710cc 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobPropertiesClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobPropertiesClaims.cs @@ -1,19 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Job +namespace Disco.Services.Authorization.Roles.ClaimGroups.Job { [ClaimDetails("Job Properties", "Permissions related to Job Properties")] public class JobPropertiesClaims : BaseRoleClaimGroup { public JobPropertiesClaims() { - this.WarrantyProperties = new JobWarrantyPropertiesClaims(); - this.NonWarrantyProperties = new JobNonWarrantyPropertiesClaims(); - this.JobQueueProperties = new JobQueuePropertiesClaims(); + WarrantyProperties = new JobWarrantyPropertiesClaims(); + NonWarrantyProperties = new JobNonWarrantyPropertiesClaims(); + JobQueueProperties = new JobQueuePropertiesClaims(); } public JobWarrantyPropertiesClaims WarrantyProperties { get; set; } diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobQueuePropertiesClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobQueuePropertiesClaims.cs index f9eb2a4e..643a55e5 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobQueuePropertiesClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobQueuePropertiesClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Job +namespace Disco.Services.Authorization.Roles.ClaimGroups.Job { [ClaimDetails("Job Queue Properties", "Permissions related to Job Queue Job Properties")] public class JobQueuePropertiesClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobTypesClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobTypesClaims.cs index 58d90d89..e4206827 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobTypesClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobTypesClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Job +namespace Disco.Services.Authorization.Roles.ClaimGroups.Job { [ClaimDetails("Types", "Permissions related to Job Types")] public class JobTypesClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobWarrantyPropertiesClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobWarrantyPropertiesClaims.cs index c2a7c491..1f5f7a90 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobWarrantyPropertiesClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Job/JobWarrantyPropertiesClaims.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.Job +namespace Disco.Services.Authorization.Roles.ClaimGroups.Job { [ClaimDetails("Warranty Properties", "Permissions related to Warranty Job Properties")] public class JobWarrantyPropertiesClaims : BaseRoleClaimGroup diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/User/UserClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/User/UserClaims.cs index f76927b5..b37fbdab 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/User/UserClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/User/UserClaims.cs @@ -1,17 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Authorization.Roles.ClaimGroups.User +namespace Disco.Services.Authorization.Roles.ClaimGroups.User { [ClaimDetails("User", "Permissions related to Users")] public class UserClaims : BaseRoleClaimGroup { public UserClaims() { - this.Actions = new UserActionsClaims(); + Actions = new UserActionsClaims(); } [ClaimDetails("Search Users", "Can search users")] diff --git a/Disco.Services/Authorization/Roles/RoleCache.cs b/Disco.Services/Authorization/Roles/RoleCache.cs index 7378bdcc..edd177b4 100644 --- a/Disco.Services/Authorization/Roles/RoleCache.cs +++ b/Disco.Services/Authorization/Roles/RoleCache.cs @@ -2,11 +2,8 @@ using Disco.Models.Services.Authorization; using Disco.Models.Repository; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Disco.Services.Interop.ActiveDirectory; using Newtonsoft.Json; diff --git a/Disco.Services/Authorization/Roles/RoleClaims.cs b/Disco.Services/Authorization/Roles/RoleClaims.cs index 0add33a9..2bd02d29 100644 --- a/Disco.Services/Authorization/Roles/RoleClaims.cs +++ b/Disco.Services/Authorization/Roles/RoleClaims.cs @@ -1,13 +1,7 @@ -using Disco.Services.Authorization.Roles.ClaimGroups; -using Disco.Services.Authorization.Roles.ClaimGroups.Configuration; +using Disco.Services.Authorization.Roles.ClaimGroups.Configuration; using Disco.Services.Authorization.Roles.ClaimGroups.Device; using Disco.Services.Authorization.Roles.ClaimGroups.Job; using Disco.Services.Authorization.Roles.ClaimGroups.User; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Authorization.Roles { @@ -15,11 +9,11 @@ namespace Disco.Services.Authorization.Roles { public RoleClaims() { - this.Config = new ConfigClaims(); + Config = new ConfigClaims(); - this.Job = new JobClaims(); - this.Device = new DeviceClaims(); - this.User = new UserClaims(); + Job = new JobClaims(); + Device = new DeviceClaims(); + User = new UserClaims(); } [ClaimDetails("Computer Account", "Represents a computer account", true)] diff --git a/Disco.Services/Authorization/Roles/RoleToken.cs b/Disco.Services/Authorization/Roles/RoleToken.cs index 5a4ce6fc..1b697409 100644 --- a/Disco.Services/Authorization/Roles/RoleToken.cs +++ b/Disco.Services/Authorization/Roles/RoleToken.cs @@ -4,8 +4,6 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Authorization.Roles { diff --git a/Disco.Services/Devices/DeviceExtensions.cs b/Disco.Services/Devices/DeviceExtensions.cs index d330f5f7..60555b9d 100644 --- a/Disco.Services/Devices/DeviceExtensions.cs +++ b/Disco.Services/Devices/DeviceExtensions.cs @@ -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 { diff --git a/Disco.Services/Devices/Enrolment/DeviceEnrolment.cs b/Disco.Services/Devices/Enrolment/DeviceEnrolment.cs index aca13ae8..c9d04cbb 100644 --- a/Disco.Services/Devices/Enrolment/DeviceEnrolment.cs +++ b/Disco.Services/Devices/Enrolment/DeviceEnrolment.cs @@ -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)); } } diff --git a/Disco.Services/Devices/Enrolment/EnrolmentTypes.cs b/Disco.Services/Devices/Enrolment/EnrolmentTypes.cs index 1849fb28..03a80b64 100644 --- a/Disco.Services/Devices/Enrolment/EnrolmentTypes.cs +++ b/Disco.Services/Devices/Enrolment/EnrolmentTypes.cs @@ -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 { diff --git a/Disco.Services/Devices/Enrolment/LogMacAddressImportingTask.cs b/Disco.Services/Devices/Enrolment/LogMacAddressImportingTask.cs index 2574c8dc..ba26f7a0 100644 --- a/Disco.Services/Devices/Enrolment/LogMacAddressImportingTask.cs +++ b/Disco.Services/Devices/Enrolment/LogMacAddressImportingTask.cs @@ -54,7 +54,7 @@ namespace Disco.Services.Devices.Enrolment var trigger = TriggerBuilder.Create() .StartAt(DateTimeOffset.Now.AddMinutes(5)); - this.ScheduleTask(trigger); + ScheduleTask(trigger); } } diff --git a/Disco.Services/Devices/Exporting/DeviceExportTask.cs b/Disco.Services/Devices/Exporting/DeviceExportTask.cs index d5f11f49..dc48dfe8 100644 --- a/Disco.Services/Devices/Exporting/DeviceExportTask.cs +++ b/Disco.Services/Devices/Exporting/DeviceExportTask.cs @@ -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); } } } diff --git a/Disco.Services/Devices/Exporting/DeviceExportTaskContext.cs b/Disco.Services/Devices/Exporting/DeviceExportTaskContext.cs index 1e940e80..531d60d3 100644 --- a/Disco.Services/Devices/Exporting/DeviceExportTaskContext.cs +++ b/Disco.Services/Devices/Exporting/DeviceExportTaskContext.cs @@ -1,6 +1,5 @@ using Disco.Models.Services.Devices.Exporting; using Disco.Services.Tasks; -using System.IO; namespace Disco.Services.Devices.Exporting { diff --git a/Disco.Services/Devices/Importing/DeviceImportApplyTask.cs b/Disco.Services/Devices/Importing/DeviceImportApplyTask.cs index 6c5af90f..614a622c 100644 --- a/Disco.Services/Devices/Importing/DeviceImportApplyTask.cs +++ b/Disco.Services/Devices/Importing/DeviceImportApplyTask.cs @@ -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")}"); } } } diff --git a/Disco.Services/Devices/Importing/DeviceImportColumn.cs b/Disco.Services/Devices/Importing/DeviceImportColumn.cs new file mode 100644 index 00000000..a1f5c6d8 --- /dev/null +++ b/Disco.Services/Devices/Importing/DeviceImportColumn.cs @@ -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); + } + } +} diff --git a/Disco.Services/Devices/Importing/DeviceImportInMemoryCache.cs b/Disco.Services/Devices/Importing/DeviceImportInMemoryCache.cs index 8c292dd6..64aac9ee 100644 --- a/Disco.Services/Devices/Importing/DeviceImportInMemoryCache.cs +++ b/Disco.Services/Devices/Importing/DeviceImportInMemoryCache.cs @@ -19,10 +19,10 @@ namespace Disco.Services.Devices.Importing { this.Database = Database; - this.devices = new Lazy>(() => Database.Devices.Include("DeviceDetails").ToList()); - this.deviceModels = new Lazy>(() => Database.DeviceModels.ToList()); - this.deviceProfiles = new Lazy>(() => Database.DeviceProfiles.ToList()); - this.deviceBatches = new Lazy>(() => Database.DeviceBatches.ToList()); + devices = new Lazy>(() => Database.Devices.Include("DeviceDetails").ToList()); + deviceModels = new Lazy>(() => Database.DeviceModels.ToList()); + deviceProfiles = new Lazy>(() => Database.DeviceProfiles.ToList()); + deviceBatches = new Lazy>(() => Database.DeviceBatches.ToList()); } public Device FindDevice(string DeviceSerialNumber) diff --git a/Disco.Services/Devices/ManagedGroups/DeviceBatchAssignedUsersManagedGroup.cs b/Disco.Services/Devices/ManagedGroups/DeviceBatchAssignedUsersManagedGroup.cs index aedd9648..0141b035 100644 --- a/Disco.Services/Devices/ManagedGroups/DeviceBatchAssignedUsersManagedGroup.cs +++ b/Disco.Services/Devices/ManagedGroups/DeviceBatchAssignedUsersManagedGroup.cs @@ -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 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; diff --git a/Disco.Services/Devices/ManagedGroups/DeviceBatchDevicesManagedGroup.cs b/Disco.Services/Devices/ManagedGroups/DeviceBatchDevicesManagedGroup.cs index 71e9f961..abf91e13 100644 --- a/Disco.Services/Devices/ManagedGroups/DeviceBatchDevicesManagedGroup.cs +++ b/Disco.Services/Devices/ManagedGroups/DeviceBatchDevicesManagedGroup.cs @@ -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 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 + "$"); diff --git a/Disco.Services/Devices/ManagedGroups/DeviceProfileAssignedUsersManagedGroup.cs b/Disco.Services/Devices/ManagedGroups/DeviceProfileAssignedUsersManagedGroup.cs index 71ebb916..ed3403b4 100644 --- a/Disco.Services/Devices/ManagedGroups/DeviceProfileAssignedUsersManagedGroup.cs +++ b/Disco.Services/Devices/ManagedGroups/DeviceProfileAssignedUsersManagedGroup.cs @@ -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 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; diff --git a/Disco.Services/Devices/ManagedGroups/DeviceProfileDevicesManagedGroup.cs b/Disco.Services/Devices/ManagedGroups/DeviceProfileDevicesManagedGroup.cs index acb01180..ec5b2502 100644 --- a/Disco.Services/Devices/ManagedGroups/DeviceProfileDevicesManagedGroup.cs +++ b/Disco.Services/Devices/ManagedGroups/DeviceProfileDevicesManagedGroup.cs @@ -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 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 + "$"); diff --git a/Disco.Services/Documents/AttachmentImport/ImportDirectoryMonitor.cs b/Disco.Services/Documents/AttachmentImport/ImportDirectoryMonitor.cs index 320bf79b..f711a032 100644 --- a/Disco.Services/Documents/AttachmentImport/ImportDirectoryMonitor.cs +++ b/Disco.Services/Documents/AttachmentImport/ImportDirectoryMonitor.cs @@ -73,7 +73,7 @@ namespace Disco.Services.Documents.AttachmentImport public void ScheduleCurrentFiles(int ImportDelay) { - foreach (var filename in Directory.GetFiles(this.MonitorLocation, "*.pdf")) + foreach (var filename in Directory.GetFiles(MonitorLocation, "*.pdf")) { ScheduleImport(filename, ImportDelay); } diff --git a/Disco.Services/Documents/AttachmentImport/ImporterCleanCacheJob.cs b/Disco.Services/Documents/AttachmentImport/ImporterCleanCacheJob.cs index 1cc220f8..c78892ad 100644 --- a/Disco.Services/Documents/AttachmentImport/ImporterCleanCacheJob.cs +++ b/Disco.Services/Documents/AttachmentImport/ImporterCleanCacheJob.cs @@ -1,5 +1,4 @@ using Disco.Data.Repository; -using Disco.Services.Logging; using Disco.Services.Tasks; using Quartz; using System; @@ -20,7 +19,7 @@ namespace Disco.Services.Documents.AttachmentImport // Trigger Daily @ 12:30am TriggerBuilder triggerBuilder = TriggerBuilder.Create().WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 30)); - this.ScheduleTask(triggerBuilder); + ScheduleTask(triggerBuilder); } protected override void ExecuteTask() diff --git a/Disco.Services/Documents/AttachmentImport/ThumbnailUpdateTask.cs b/Disco.Services/Documents/AttachmentImport/ThumbnailUpdateTask.cs index a29fc35e..207952c1 100644 --- a/Disco.Services/Documents/AttachmentImport/ThumbnailUpdateTask.cs +++ b/Disco.Services/Documents/AttachmentImport/ThumbnailUpdateTask.cs @@ -55,7 +55,7 @@ namespace Disco.Services.Documents.AttachmentImport var trigger = TriggerBuilder.Create() .StartAt(DateTimeOffset.Now.AddMinutes(5)); - this.ScheduleTask(trigger); + ScheduleTask(trigger); } } diff --git a/Disco.Services/Documents/DocumentUniqueIdentifier.cs b/Disco.Services/Documents/DocumentUniqueIdentifier.cs index 8bc70d39..4956ba1a 100644 --- a/Disco.Services/Documents/DocumentUniqueIdentifier.cs +++ b/Disco.Services/Documents/DocumentUniqueIdentifier.cs @@ -137,11 +137,11 @@ namespace Disco.Services.Documents private DocumentUniqueIdentifier(DiscoDataContext Database, int Version, short DeploymentChecksum, string DocumentTemplateId, string TargetId, string CreatorId, DateTime TimeStamp, int PageIndex, AttachmentTypes? AttachmentType) { - this.database = Database; + database = Database; this.Version = Version; this.DeploymentChecksum = DeploymentChecksum; this.DocumentTemplateId = DocumentTemplateId; - this.attachmentType = AttachmentType; + attachmentType = AttachmentType; this.TargetId = TargetId; this.CreatorId = ActiveDirectory.ParseDomainAccountId(CreatorId); this.TimeStamp = TimeStamp; @@ -440,7 +440,7 @@ namespace Disco.Services.Documents public static bool IsDocumentUniqueIdentifier(string Identifier) { - return Identifier != null && Identifier.StartsWith("Disco|", System.StringComparison.OrdinalIgnoreCase); + return Identifier != null && Identifier.StartsWith("Disco|", StringComparison.OrdinalIgnoreCase); } public static bool IsDocumentUniqueIdentifier(byte[] Identifier) diff --git a/Disco.Services/Documents/DocumentUniqueIdentifierExtensions.cs b/Disco.Services/Documents/DocumentUniqueIdentifierExtensions.cs index 9fcee845..8adf7efb 100644 --- a/Disco.Services/Documents/DocumentUniqueIdentifierExtensions.cs +++ b/Disco.Services/Documents/DocumentUniqueIdentifierExtensions.cs @@ -2,10 +2,7 @@ using Disco.Models.Repository; using Disco.Services.Documents; using System; -using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; namespace Disco.Services { diff --git a/Disco.Services/Documents/ManagedGroups/DocumentTemplateDevicesManagedGroup.cs b/Disco.Services/Documents/ManagedGroups/DocumentTemplateDevicesManagedGroup.cs index 7b0eac99..5360eea6 100644 --- a/Disco.Services/Documents/ManagedGroups/DocumentTemplateDevicesManagedGroup.cs +++ b/Disco.Services/Documents/ManagedGroups/DocumentTemplateDevicesManagedGroup.cs @@ -34,9 +34,9 @@ namespace Disco.Services.Documents.ManagedGroups private DocumentTemplateDevicesManagedGroup(string Key, ADManagedGroupConfiguration Configuration, DocumentTemplate DocumentTemplate) : base(Key, Configuration) { - this.DocumentTemplateId = DocumentTemplate.Id; - this.DocumentTemplateDescription = DocumentTemplate.Description; - this.DocumentTemplateScope = DocumentTemplate.Scope; + DocumentTemplateId = DocumentTemplate.Id; + DocumentTemplateDescription = DocumentTemplate.Description; + DocumentTemplateScope = DocumentTemplate.Scope; } public override void Initialize() @@ -160,7 +160,7 @@ namespace Disco.Services.Documents.ManagedGroups if (Configuration.FilterBeginDate.HasValue) { return Database.Devices - .Where(d => d.DeviceDomainId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) + .Where(d => d.DeviceDomainId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) .Select(d => d.DeviceDomainId) .ToList() .Where(ActiveDirectory.IsValidDomainAccountId) @@ -169,7 +169,7 @@ namespace Disco.Services.Documents.ManagedGroups else { return Database.Devices - .Where(d => d.DeviceDomainId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)) + .Where(d => d.DeviceDomainId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)) .Select(d => d.DeviceDomainId) .ToList() .Where(ActiveDirectory.IsValidDomainAccountId) @@ -179,7 +179,7 @@ namespace Disco.Services.Documents.ManagedGroups if (Configuration.FilterBeginDate.HasValue) { return Database.Jobs - .Where(j => j.Device.DeviceDomainId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) + .Where(j => j.Device.DeviceDomainId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) .Select(j => j.Device.DeviceDomainId) .Distinct() .ToList() @@ -189,7 +189,7 @@ namespace Disco.Services.Documents.ManagedGroups else { return Database.Jobs - .Where(j => j.Device.DeviceDomainId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)) + .Where(j => j.Device.DeviceDomainId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)) .Select(j => j.Device.DeviceDomainId) .Distinct() .ToList() @@ -200,7 +200,7 @@ namespace Disco.Services.Documents.ManagedGroups if (Configuration.FilterBeginDate.HasValue) { return Database.Users - .Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) + .Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) .SelectMany(u => u.DeviceUserAssignments.Where(dua => !dua.UnassignedDate.HasValue && dua.Device.DeviceDomainId != null), (u, dua) => dua.Device.DeviceDomainId) .ToList() .Where(ActiveDirectory.IsValidDomainAccountId) @@ -209,7 +209,7 @@ namespace Disco.Services.Documents.ManagedGroups else { return Database.Users - .Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)) + .Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)) .SelectMany(u => u.DeviceUserAssignments.Where(dua => !dua.UnassignedDate.HasValue && dua.Device.DeviceDomainId != null), (u, dua) => dua.Device.DeviceDomainId) .ToList() .Where(ActiveDirectory.IsValidDomainAccountId) @@ -229,14 +229,14 @@ namespace Disco.Services.Documents.ManagedGroups { result = Database.Devices .Where(d => d.SerialNumber == DeviceSerialNumber && d.DeviceDomainId != null) - .Select(d => Tuple.Create(d.DeviceDomainId, d.DeviceAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))) + .Select(d => Tuple.Create(d.DeviceDomainId, d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))) .FirstOrDefault(); } else { result = Database.Devices .Where(d => d.SerialNumber == DeviceSerialNumber && d.DeviceDomainId != null) - .Select(d => Tuple.Create(d.DeviceDomainId, d.DeviceAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId))) + .Select(d => Tuple.Create(d.DeviceDomainId, d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))) .FirstOrDefault(); } @@ -295,7 +295,7 @@ namespace Disco.Services.Documents.ManagedGroups .Select(j => new Tuple( j.Device.DeviceDomainId, j.Device.SerialNumber, - j.Device.Jobs.Any(dj => dj.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)))) + j.Device.Jobs.Any(dj => dj.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)))) .FirstOrDefault(); } else @@ -305,7 +305,7 @@ namespace Disco.Services.Documents.ManagedGroups .Select(j => new Tuple( j.Device.DeviceDomainId, j.Device.SerialNumber, - j.Device.Jobs.Any(dj => dj.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)))) + j.Device.Jobs.Any(dj => dj.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)))) .FirstOrDefault(); } @@ -372,7 +372,7 @@ namespace Disco.Services.Documents.ManagedGroups result = Database.Users .Where(u => u.UserId == UserId) .Select(u => Tuple.Create( - u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate), + u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate), u.DeviceUserAssignments .Where(dua => !dua.UnassignedDate.HasValue && dua.Device.DeviceDomainId != null) .Select(dua => new Tuple(dua.Device.DeviceDomainId, dua.Device.SerialNumber)))) @@ -383,7 +383,7 @@ namespace Disco.Services.Documents.ManagedGroups result = Database.Users .Where(u => u.UserId == UserId) .Select(u => Tuple.Create( - u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId), + u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId), u.DeviceUserAssignments .Where(dua => !dua.UnassignedDate.HasValue && dua.Device.DeviceDomainId != null) .Select(dua => new Tuple(dua.Device.DeviceDomainId, dua.Device.SerialNumber)))) @@ -458,13 +458,13 @@ namespace Disco.Services.Documents.ManagedGroups { jobsHaveTemplate = e.Database.Jobs .Where(j => j.DeviceSerialNumber == deviceSerialNumber) - .Any(j => j.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)); + .Any(j => j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)); } else { jobsHaveTemplate = e.Database.Jobs .Where(j => j.DeviceSerialNumber == deviceSerialNumber) - .Any(j => j.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)); + .Any(j => j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)); } if (jobsHaveTemplate) @@ -482,14 +482,14 @@ namespace Disco.Services.Documents.ManagedGroups userHasTemplate = e.Database.Devices .Where(d => d.SerialNumber == deviceSerialNumber) .Select(d => d.AssignedUser) - .Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)); + .Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)); } else { userHasTemplate = e.Database.Devices .Where(d => d.SerialNumber == deviceSerialNumber) .Select(d => d.AssignedUser) - .Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)); + .Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)); } if (userHasTemplate) @@ -526,13 +526,13 @@ namespace Disco.Services.Documents.ManagedGroups if (Configuration.FilterBeginDate.HasValue) { previousUserHasTemplate = e.Database.Users - .Where(u => u.UserId == devicePreviousAssignedUserId && u.UserAttachments.Any(ua => ua.DocumentTemplateId == this.DocumentTemplateId && ua.Timestamp >= Configuration.FilterBeginDate)) + .Where(u => u.UserId == devicePreviousAssignedUserId && u.UserAttachments.Any(ua => ua.DocumentTemplateId == DocumentTemplateId && ua.Timestamp >= Configuration.FilterBeginDate)) .Any(); } else { previousUserHasTemplate = e.Database.Users - .Where(u => u.UserId == devicePreviousAssignedUserId && u.UserAttachments.Any(ua => ua.DocumentTemplateId == this.DocumentTemplateId)) + .Where(u => u.UserId == devicePreviousAssignedUserId && u.UserAttachments.Any(ua => ua.DocumentTemplateId == DocumentTemplateId)) .Any(); } } @@ -542,13 +542,13 @@ namespace Disco.Services.Documents.ManagedGroups if (Configuration.FilterBeginDate.HasValue) { currentUserHasTemplate = e.Database.Users - .Where(u => u.UserId == deviceCurrentAssignedUserId && u.UserAttachments.Any(ua => ua.DocumentTemplateId == this.DocumentTemplateId && ua.Timestamp >= Configuration.FilterBeginDate)) + .Where(u => u.UserId == deviceCurrentAssignedUserId && u.UserAttachments.Any(ua => ua.DocumentTemplateId == DocumentTemplateId && ua.Timestamp >= Configuration.FilterBeginDate)) .Any(); } else { currentUserHasTemplate = e.Database.Users - .Where(u => u.UserId == deviceCurrentAssignedUserId && u.UserAttachments.Any(ua => ua.DocumentTemplateId == this.DocumentTemplateId)) + .Where(u => u.UserId == deviceCurrentAssignedUserId && u.UserAttachments.Any(ua => ua.DocumentTemplateId == DocumentTemplateId)) .Any(); } } diff --git a/Disco.Services/Documents/ManagedGroups/DocumentTemplateUsersManagedGroup.cs b/Disco.Services/Documents/ManagedGroups/DocumentTemplateUsersManagedGroup.cs index f4257c35..b7316b1d 100644 --- a/Disco.Services/Documents/ManagedGroups/DocumentTemplateUsersManagedGroup.cs +++ b/Disco.Services/Documents/ManagedGroups/DocumentTemplateUsersManagedGroup.cs @@ -33,9 +33,9 @@ namespace Disco.Services.Documents.ManagedGroups private DocumentTemplateUsersManagedGroup(string Key, ADManagedGroupConfiguration Configuration, DocumentTemplate DocumentTemplate) : base(Key, Configuration) { - this.DocumentTemplateId = DocumentTemplate.Id; - this.DocumentTemplateDescription = DocumentTemplate.Description; - this.DocumentTemplateScope = DocumentTemplate.Scope; + DocumentTemplateId = DocumentTemplate.Id; + DocumentTemplateDescription = DocumentTemplate.Description; + DocumentTemplateScope = DocumentTemplate.Scope; } public override void Initialize() @@ -155,27 +155,27 @@ namespace Disco.Services.Documents.ManagedGroups if (Configuration.FilterBeginDate.HasValue) { return Database.Devices - .Where(d => d.AssignedUserId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) + .Where(d => d.AssignedUserId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) .Select(d => d.AssignedUserId); } else { return Database.Devices - .Where(d => d.AssignedUserId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)) + .Where(d => d.AssignedUserId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)) .Select(d => d.AssignedUserId); } case DocumentTemplate.DocumentTemplateScopes.Job: if (Configuration.FilterBeginDate.HasValue) { return Database.Jobs - .Where(j => j.UserId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) + .Where(j => j.UserId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) .Select(j => j.UserId) .Distinct(); } else { return Database.Jobs - .Where(j => j.UserId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)) + .Where(j => j.UserId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)) .Select(j => j.UserId) .Distinct(); } @@ -183,13 +183,13 @@ namespace Disco.Services.Documents.ManagedGroups if (Configuration.FilterBeginDate.HasValue) { return Database.Users - .Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) + .Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)) .Select(u => u.UserId); } else { return Database.Users - .Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)) + .Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)) .Select(u => u.UserId); } default: @@ -208,7 +208,7 @@ namespace Disco.Services.Documents.ManagedGroups .Where(d => d.SerialNumber == DeviceSerialNumber && d.AssignedUser != null) .Select(d => Tuple.Create( d.AssignedUserId, - d.DeviceAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))) + d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))) .FirstOrDefault(); } else @@ -217,7 +217,7 @@ namespace Disco.Services.Documents.ManagedGroups .Where(d => d.SerialNumber == DeviceSerialNumber && d.AssignedUser != null) .Select(d => Tuple.Create( d.AssignedUserId, - d.DeviceAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId))) + d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))) .FirstOrDefault(); } @@ -270,7 +270,7 @@ namespace Disco.Services.Documents.ManagedGroups .Where(j => j.Id == JobId && j.UserId != null) .Select(j => Tuple.Create( j.UserId, - j.User.Jobs.Any(uj => uj.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)))) + j.User.Jobs.Any(uj => uj.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)))) .FirstOrDefault(); } else @@ -279,7 +279,7 @@ namespace Disco.Services.Documents.ManagedGroups .Where(j => j.Id == JobId && j.UserId != null) .Select(j => Tuple.Create( j.UserId, - j.User.Jobs.Any(uj => uj.JobAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)))) + j.User.Jobs.Any(uj => uj.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)))) .FirstOrDefault(); } @@ -328,13 +328,13 @@ namespace Disco.Services.Documents.ManagedGroups { return Database.Users .Where(u => u.UserId == UserId) - .Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)); + .Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)); } else { return Database.Users .Where(u => u.UserId == UserId) - .Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == this.DocumentTemplateId)); + .Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)); } } @@ -369,13 +369,13 @@ namespace Disco.Services.Documents.ManagedGroups if (Configuration.FilterBeginDate.HasValue) { relevantDevice = Event.Database.Devices - .Where(d => d.SerialNumber == deviceSerialNumber && d.DeviceAttachments.Any(ja => ja.DocumentTemplateId == this.DocumentTemplateId && ja.Timestamp >= Configuration.FilterBeginDate)) + .Where(d => d.SerialNumber == deviceSerialNumber && d.DeviceAttachments.Any(ja => ja.DocumentTemplateId == DocumentTemplateId && ja.Timestamp >= Configuration.FilterBeginDate)) .Any(); } else { relevantDevice = Event.Database.Devices - .Where(d => d.SerialNumber == deviceSerialNumber && d.DeviceAttachments.Any(ja => ja.DocumentTemplateId == this.DocumentTemplateId)) + .Where(d => d.SerialNumber == deviceSerialNumber && d.DeviceAttachments.Any(ja => ja.DocumentTemplateId == DocumentTemplateId)) .Any(); } diff --git a/Disco.Services/Expressions/EvaluateExpressionPart.cs b/Disco.Services/Expressions/EvaluateExpressionPart.cs index f71a1570..3300b1f6 100644 --- a/Disco.Services/Expressions/EvaluateExpressionPart.cs +++ b/Disco.Services/Expressions/EvaluateExpressionPart.cs @@ -22,7 +22,7 @@ namespace Disco.Services.Expressions return null; else if (_EvaluateParseException == null) - _EvaluateParseException = EvaluateExpressionParseException.FromRecognitionException(_ExpressionParseException, this.Source); + _EvaluateParseException = EvaluateExpressionParseException.FromRecognitionException(_ExpressionParseException, Source); return _EvaluateParseException; } } @@ -44,38 +44,38 @@ namespace Disco.Services.Expressions public EvaluateExpressionPart(string Source) { - this.RawSource = Source; + RawSource = Source; if (Source.StartsWith("{") && Source.EndsWith("}")) Source = Source.Substring(1, Source.Length - 2); if (Source[0] == '~') { - this.ErrorsAllowed = true; + ErrorsAllowed = true; this.Source = Source.Substring(1); } else { - this.ErrorsAllowed = false; + ErrorsAllowed = false; this.Source = Source; } try { - this._Expression = Spring.Expressions.Expression.Parse(this.Source); + _Expression = Spring.Expressions.Expression.Parse(this.Source); } catch (RecognitionException ex) { - this._ExpressionParseException = ex; + _ExpressionParseException = ex; } } object IExpressionPart.Evaluate(object ExpressionContext, IDictionary Variables) { - if (this._ExpressionParseException == null) + if (_ExpressionParseException == null) { - return this._Expression.GetValue(ExpressionContext, Variables); + return _Expression.GetValue(ExpressionContext, Variables); } - throw this._ExpressionParseException; + throw _ExpressionParseException; } } diff --git a/Disco.Services/Expressions/Expression.cs b/Disco.Services/Expressions/Expression.cs index e948735c..cb4cfcb3 100644 --- a/Disco.Services/Expressions/Expression.cs +++ b/Disco.Services/Expressions/Expression.cs @@ -36,7 +36,7 @@ namespace Disco.Services.Expressions public T EvaluateFirst(object ExpressionContext, IDictionary Variables) { T result = default(T); - if (this.Count > 0) + if (Count > 0) { try { diff --git a/Disco.Services/Expressions/ExpressionCachePreloadTask.cs b/Disco.Services/Expressions/ExpressionCachePreloadTask.cs index 85d7cea6..ce21463e 100644 --- a/Disco.Services/Expressions/ExpressionCachePreloadTask.cs +++ b/Disco.Services/Expressions/ExpressionCachePreloadTask.cs @@ -19,7 +19,7 @@ namespace Disco.Services.Expressions // Run in Background 5 Second after Scheduled (on App Startup) TriggerBuilder triggerBuilder = TriggerBuilder.Create().StartAt(new DateTimeOffset(DateTime.Now).AddSeconds(5)); - this.ScheduleTask(triggerBuilder); + ScheduleTask(triggerBuilder); } protected override void ExecuteTask() diff --git a/Disco.Services/Expressions/Extensions/ImageResultImplementations/BaseImageExpressionResult.cs b/Disco.Services/Expressions/Extensions/ImageResultImplementations/BaseImageExpressionResult.cs index 8ee3b40e..0aeb6587 100644 --- a/Disco.Services/Expressions/Extensions/ImageResultImplementations/BaseImageExpressionResult.cs +++ b/Disco.Services/Expressions/Extensions/ImageResultImplementations/BaseImageExpressionResult.cs @@ -15,10 +15,10 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations public BaseImageExpressionResult() { - this.LosslessFormat = false; - this.Quality = 90; - this.ShowField = false; - this.BackgroundPreferTransparent = true; + LosslessFormat = false; + Quality = 90; + ShowField = false; + BackgroundPreferTransparent = true; } public abstract Stream GetImage(int Width, int Height); @@ -35,10 +35,10 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations Brush backgroundBrush = null; if (!LosslessFormat || !BackgroundPreferTransparent) { - if (string.IsNullOrEmpty(this.BackgroundColour)) + if (string.IsNullOrEmpty(BackgroundColour)) backgroundBrush = Brushes.White; else - backgroundBrush = new SolidBrush(ColorTranslator.FromHtml(this.BackgroundColour)); + backgroundBrush = new SolidBrush(ColorTranslator.FromHtml(BackgroundColour)); } using (Image resizedImage = SourceImage.ResizeImage(Width, Height, backgroundBrush)) @@ -56,7 +56,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations } else { // Lossy Format - JPG - byte quality = Math.Min((byte)100, Math.Max((byte)1, this.Quality)); + byte quality = Math.Min((byte)100, Math.Max((byte)1, Quality)); SourceImage.SaveJpg(quality, imageStream); } imageStream.Position = 0; diff --git a/Disco.Services/Expressions/Extensions/ImageResultImplementations/BitmapImageExpressionResult.cs b/Disco.Services/Expressions/Extensions/ImageResultImplementations/BitmapImageExpressionResult.cs index f7852cc8..31509d3d 100644 --- a/Disco.Services/Expressions/Extensions/ImageResultImplementations/BitmapImageExpressionResult.cs +++ b/Disco.Services/Expressions/Extensions/ImageResultImplementations/BitmapImageExpressionResult.cs @@ -18,7 +18,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations public override Stream GetImage(int Width, int Height) { - return this.RenderImage(this.Image, Width, Height); + return RenderImage(Image, Width, Height); } } } diff --git a/Disco.Services/Expressions/Extensions/ImageResultImplementations/FileImageExpressionResult.cs b/Disco.Services/Expressions/Extensions/ImageResultImplementations/FileImageExpressionResult.cs index c9a1c14a..9da1fa85 100644 --- a/Disco.Services/Expressions/Extensions/ImageResultImplementations/FileImageExpressionResult.cs +++ b/Disco.Services/Expressions/Extensions/ImageResultImplementations/FileImageExpressionResult.cs @@ -20,9 +20,9 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations public override Stream GetImage(int Width, int Height) { - using (Image SourceImage = Bitmap.FromFile(this.AbsoluteFilePath)) + using (Image SourceImage = Bitmap.FromFile(AbsoluteFilePath)) { - return this.RenderImage(SourceImage, Width, Height); + return RenderImage(SourceImage, Width, Height); } } } diff --git a/Disco.Services/Expressions/Extensions/ImageResultImplementations/FileMontageImageExpressionResult.cs b/Disco.Services/Expressions/Extensions/ImageResultImplementations/FileMontageImageExpressionResult.cs index 1a40a6df..06849772 100644 --- a/Disco.Services/Expressions/Extensions/ImageResultImplementations/FileMontageImageExpressionResult.cs +++ b/Disco.Services/Expressions/Extensions/ImageResultImplementations/FileMontageImageExpressionResult.cs @@ -23,8 +23,8 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations throw new ArgumentException("AbsoluteFilePaths is empty", "AbsoluteFilePaths"); this.AbsoluteFilePaths = AbsoluteFilePaths; - this.MontageTableLayout = true; - this.Padding = 4; + MontageTableLayout = true; + Padding = 4; } public override Stream GetImage(int Width, int Height) @@ -33,7 +33,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations try { // Load Images - foreach (string imageFilePath in this.AbsoluteFilePaths) + foreach (string imageFilePath in AbsoluteFilePaths) Images.Add(Bitmap.FromFile(imageFilePath)); // Build Montage @@ -49,21 +49,21 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations if (!LosslessFormat || !BackgroundPreferTransparent) { Brush backgroundBrush = Brushes.White; - if (!string.IsNullOrEmpty(this.BackgroundColour)) - backgroundBrush = new SolidBrush(ColorTranslator.FromHtml(this.BackgroundColour)); + if (!string.IsNullOrEmpty(BackgroundColour)) + backgroundBrush = new SolidBrush(ColorTranslator.FromHtml(BackgroundColour)); montageGraphics.FillRectangle(backgroundBrush, montageGraphics.VisibleClipBounds); } - if (this.MontageHorizontalLayout) + if (MontageHorizontalLayout) DoHorizontalLayout(Images, montageGraphics); else - if (this.MontageVerticalLayout) + if (MontageVerticalLayout) DoVirticalLayout(Images, montageGraphics); else DoTableLayout(Images, montageGraphics); } - return this.OutputImage(montageImage); + return OutputImage(montageImage); } } catch (Exception) { throw; } @@ -83,7 +83,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations float imagePosition = 0; int imagesWidthTotal = Images.Sum(i => i.Width); int imagesHeightMax = Images.Max(i => i.Height); - int imagesPadding = ((Images.Count - 1) * this.Padding); + int imagesPadding = ((Images.Count - 1) * Padding); imageScale = (float)(MontageGraphics.VisibleClipBounds.Width - imagesPadding) / (float)imagesWidthTotal; if ((MontageGraphics.VisibleClipBounds.Height / (float)imagesHeightMax) < imageScale) @@ -91,7 +91,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations foreach (Image image in Images) { MontageGraphics.DrawImageResized(image, imageScale, imagePosition, 0); - imagePosition += (imageScale * image.Width) + this.Padding; + imagePosition += (imageScale * image.Width) + Padding; } } private void DoVirticalLayout(List Images, Graphics MontageGraphics) @@ -100,7 +100,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations float imagePosition = 0; int imagesWidthMax = Images.Max(i => i.Width); int imagesHeightTotal = Images.Sum(i => i.Height); - int imagesPadding = ((Images.Count - 1) * this.Padding); + int imagesPadding = ((Images.Count - 1) * Padding); imageScale = (float)(MontageGraphics.VisibleClipBounds.Height - imagesPadding) / (float)imagesHeightTotal; if ((MontageGraphics.VisibleClipBounds.Width / (float)imagesWidthMax) < imageScale) @@ -108,7 +108,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations foreach (Image image in Images) { MontageGraphics.DrawImageResized(image, imageScale, 0, imagePosition); - imagePosition += (imageScale * image.Height) + this.Padding; + imagePosition += (imageScale * image.Height) + Padding; } } private void DoTableLayout(List Images, Graphics MontageGraphics) @@ -118,8 +118,8 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations var calculatedLayout = CalculateColumnCount(stageSize, itemAverageSize, Images.Count); - SizeF cellSize = new SizeF((MontageGraphics.VisibleClipBounds.Width - ((calculatedLayout.Item1 - 1) * this.Padding)) / calculatedLayout.Item1, - (MontageGraphics.VisibleClipBounds.Height - ((calculatedLayout.Item2 - 1) * this.Padding)) / calculatedLayout.Item2); + SizeF cellSize = new SizeF((MontageGraphics.VisibleClipBounds.Width - ((calculatedLayout.Item1 - 1) * Padding)) / calculatedLayout.Item1, + (MontageGraphics.VisibleClipBounds.Height - ((calculatedLayout.Item2 - 1) * Padding)) / calculatedLayout.Item2); int imageIndex = 0; for (int rowIndex = 0; rowIndex < calculatedLayout.Item2; rowIndex++) @@ -129,7 +129,7 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations if (imageIndex < Images.Count) { var image = Images[imageIndex]; - var cellPoint = new PointF((cellSize.Width * columnIndex) + (this.Padding * columnIndex), (cellSize.Height * rowIndex) + (this.Padding * rowIndex)); + var cellPoint = new PointF((cellSize.Width * columnIndex) + (Padding * columnIndex), (cellSize.Height * rowIndex) + (Padding * rowIndex)); MontageGraphics.Clip = new Region(new RectangleF(cellPoint, cellSize)); MontageGraphics.DrawImageResized(image); imageIndex++; @@ -151,8 +151,8 @@ namespace Disco.Services.Expressions.Extensions.ImageResultImplementations { int rowCount = (int)Math.Ceiling((double)ItemCount / (double)columnCount); - int requiredWidthPadding = (columnCount - 1) * this.Padding; - int requiredHeightPadding = (rowCount - 1) * this.Padding; + int requiredWidthPadding = (columnCount - 1) * Padding; + int requiredHeightPadding = (rowCount - 1) * Padding; Size usableStageSize = new Size(StageSize.Width - requiredWidthPadding, StageSize.Height - requiredHeightPadding); double stageWidthRatio = (float)usableStageSize.Width / (float)usableStageSize.Height; double stageHeightRatio = (float)usableStageSize.Height / (float)usableStageSize.Width; diff --git a/Disco.Services/Expressions/TextExpressionPart.cs b/Disco.Services/Expressions/TextExpressionPart.cs index 893fa4c8..b114cae1 100644 --- a/Disco.Services/Expressions/TextExpressionPart.cs +++ b/Disco.Services/Expressions/TextExpressionPart.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections; - namespace Disco.Services.Expressions { public class TextExpressionPart : IExpressionPart @@ -22,7 +19,7 @@ namespace Disco.Services.Expressions { get { - return this._Source; + return _Source; } set { @@ -33,7 +30,7 @@ namespace Disco.Services.Expressions { get { - return this._Source; + return _Source; } set { @@ -63,11 +60,11 @@ namespace Disco.Services.Expressions public TextExpressionPart(string Source) { - this._Source = Source; + _Source = Source; } object IExpressionPart.Evaluate(object ExpressionContext, System.Collections.IDictionary Variables) { - return this._Source; + return _Source; } } diff --git a/Disco.Services/Extensions/DateTimeExtensions.cs b/Disco.Services/Extensions/DateTimeExtensions.cs index 485e9d2c..74a722e1 100644 --- a/Disco.Services/Extensions/DateTimeExtensions.cs +++ b/Disco.Services/Extensions/DateTimeExtensions.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco { diff --git a/Disco.Services/Extensions/EnumerableExtensions.cs b/Disco.Services/Extensions/EnumerableExtensions.cs index 4bd07917..066c1eb4 100644 --- a/Disco.Services/Extensions/EnumerableExtensions.cs +++ b/Disco.Services/Extensions/EnumerableExtensions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Disco { diff --git a/Disco.Services/Extensions/StringExtensions.cs b/Disco.Services/Extensions/StringExtensions.cs index 98ea1b5a..3ac777bc 100644 --- a/Disco.Services/Extensions/StringExtensions.cs +++ b/Disco.Services/Extensions/StringExtensions.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco { diff --git a/Disco.Services/Extensions/UIHelpers.cs b/Disco.Services/Extensions/UIHelpers.cs index 89636001..7ea18b2e 100644 --- a/Disco.Services/Extensions/UIHelpers.cs +++ b/Disco.Services/Extensions/UIHelpers.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Extensions { diff --git a/Disco.Services/Interop/ActiveDirectory/ADDeviceDescriptionUpdateTask.cs b/Disco.Services/Interop/ActiveDirectory/ADDeviceDescriptionUpdateTask.cs index 59fd1a39..82554f62 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADDeviceDescriptionUpdateTask.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADDeviceDescriptionUpdateTask.cs @@ -52,7 +52,7 @@ namespace Disco.Services.Interop.ActiveDirectory var trigger = TriggerBuilder.Create() .StartAt(DateTimeOffset.Now.AddMinutes(3)); - this.ScheduleTask(trigger); + ScheduleTask(trigger); } } diff --git a/Disco.Services/Interop/ActiveDirectory/ADDirectoryEntry.cs b/Disco.Services/Interop/ActiveDirectory/ADDirectoryEntry.cs index b93f3202..b38bc3b3 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADDirectoryEntry.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADDirectoryEntry.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.DirectoryServices; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Interop.ActiveDirectory { @@ -38,8 +34,8 @@ namespace Disco.Services.Interop.ActiveDirectory public override string ToString() { - if (this.Entry != null) - return this.Entry.Path; + if (Entry != null) + return Entry.Path; else return base.ToString(); } diff --git a/Disco.Services/Interop/ActiveDirectory/ADDiscoverForestServers.cs b/Disco.Services/Interop/ActiveDirectory/ADDiscoverForestServers.cs index e1a5207e..2aa26eb6 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADDiscoverForestServers.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADDiscoverForestServers.cs @@ -1,10 +1,8 @@ using Disco.Data.Repository; using Disco.Services.Tasks; -using System; using System.Collections.Generic; using System.DirectoryServices.ActiveDirectory; using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Disco.Services.Interop.ActiveDirectory diff --git a/Disco.Services/Interop/ActiveDirectory/ADDomain.cs b/Disco.Services/Interop/ActiveDirectory/ADDomain.cs index 9773d256..0c36d65b 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADDomain.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADDomain.cs @@ -43,19 +43,19 @@ namespace Disco.Services.Interop.ActiveDirectory public ADDomain(ActiveDirectoryContext Context, Domain Domain) { - this.context = Context; + context = Context; this.Domain = Domain; - this.SearchContainers = null; - this.domainControllers = null; - this.domainMaintenanceNext = DateTime.Now.AddMinutes(DomainMaintanceIntervalMinutes); + SearchContainers = null; + domainControllers = null; + domainMaintenanceNext = DateTime.Now.AddMinutes(DomainMaintanceIntervalMinutes); - this.Initialize(); + Initialize(); } private void Initialize() { - this.Name = Domain.Name; + Name = Domain.Name; var dc = Domain.FindDomainController(); @@ -63,26 +63,26 @@ namespace Disco.Services.Interop.ActiveDirectory using (var adRootDSE = new DirectoryEntry(ldapPath + "RootDSE")) { - this.DistinguishedName = adRootDSE.Properties["defaultNamingContext"][0].ToString(); - this.ConfigurationNamingContext = adRootDSE.Properties["configurationNamingContext"][0].ToString(); + DistinguishedName = adRootDSE.Properties["defaultNamingContext"][0].ToString(); + ConfigurationNamingContext = adRootDSE.Properties["configurationNamingContext"][0].ToString(); } - using (var adDomainRoot = new DirectoryEntry(ldapPath + this.DistinguishedName)) + using (var adDomainRoot = new DirectoryEntry(ldapPath + DistinguishedName)) { - this.SecurityIdentifier = new SecurityIdentifier((byte[])(adDomainRoot.Properties["objectSid"][0]), 0); + SecurityIdentifier = new SecurityIdentifier((byte[])(adDomainRoot.Properties["objectSid"][0]), 0); } - using (var configSearchRoot = new DirectoryEntry(ldapPath + "CN=Partitions," + this.ConfigurationNamingContext)) + using (var configSearchRoot = new DirectoryEntry(ldapPath + "CN=Partitions," + ConfigurationNamingContext)) { - var configSearchFilter = string.Format("(&(objectcategory=Crossref)(dnsRoot={0})(netBIOSName=*))", this.Name); + var configSearchFilter = string.Format("(&(objectcategory=Crossref)(dnsRoot={0})(netBIOSName=*))", Name); using (var configSearcher = new DirectorySearcher(configSearchRoot, configSearchFilter, new string[] { "NetBIOSName" }, System.DirectoryServices.SearchScope.OneLevel)) { SearchResult configResult = configSearcher.FindOne(); if (configResult != null) - this.NetBiosName = configResult.Properties["NetBIOSName"][0].ToString(); + NetBiosName = configResult.Properties["NetBIOSName"][0].ToString(); else - this.NetBiosName = null; + NetBiosName = null; } } } @@ -91,17 +91,17 @@ namespace Disco.Services.Interop.ActiveDirectory public IEnumerable GetAllReachableDomainControllers() { - return this.Domain.FindAllDomainControllers().WhereReachable().Select(dc => new ADDomainController(this.context, dc, this, dc.SiteName == this.context.Site.Name, false)); + return Domain.FindAllDomainControllers().WhereReachable().Select(dc => new ADDomainController(context, dc, this, dc.SiteName == context.Site.Name, false)); } public IEnumerable GetReachableSiteDomainControllers() { - return this.DomainControllers.Where(dc => dc.IsSiteServer && dc.DomainController.IsReachable()); + return DomainControllers.Where(dc => dc.IsSiteServer && dc.DomainController.IsReachable()); } public ADDomainController GetAvailableDomainController(bool RequireWritable = false) { - if (this.domainMaintenanceNext < DateTime.Now) + if (domainMaintenanceNext < DateTime.Now) MaintainDomainControllers(); IEnumerable availableServers; @@ -144,7 +144,7 @@ namespace Disco.Services.Interop.ActiveDirectory } private IEnumerable AvailableDomainControllers(bool RequireSiteServer, bool RequireWritable) { - IEnumerable query = this.DomainControllers.Where(dc => dc.IsAvailable); + IEnumerable query = DomainControllers.Where(dc => dc.IsAvailable); if (RequireSiteServer) query = query.Where(dc => dc.IsSiteServer); if (RequireWritable) @@ -160,11 +160,11 @@ namespace Disco.Services.Interop.ActiveDirectory else locatorOptions = LocatorOptions.ForceRediscovery; - var dc = this.Domain.FindDomainController(locatorOptions); + var dc = Domain.FindDomainController(locatorOptions); var dcName = dc.Name; - var existingDC = this.DomainControllers.FirstOrDefault(edc => edc.Name == dcName); + var existingDC = DomainControllers.FirstOrDefault(edc => edc.Name == dcName); if (existingDC != null) { @@ -183,10 +183,10 @@ namespace Disco.Services.Interop.ActiveDirectory { // New DC discovered - var adDC = new ADDomainController(this.context, dc, this, dc.SiteName == this.context.Site.Name, RequireWritable); + var adDC = new ADDomainController(context, dc, this, dc.SiteName == context.Site.Name, RequireWritable); // Add DC to Available Servers - this.domainControllers.Push(adDC); + domainControllers.Push(adDC); return adDC; } @@ -196,7 +196,7 @@ namespace Disco.Services.Interop.ActiveDirectory { lock (domainMaintainLock) { - var servers = this.domainControllers.ToList(); + var servers = domainControllers.ToList(); var nonSiteServersPresent = servers.Any(s => !s.IsSiteServer); @@ -216,13 +216,13 @@ namespace Disco.Services.Interop.ActiveDirectory UpdateDomainControllers(servers.Where(s => s.IsSiteServer || s.IsAvailable)); } } - this.domainMaintenanceNext = DateTime.Now.AddMinutes(DomainMaintanceIntervalMinutes); + domainMaintenanceNext = DateTime.Now.AddMinutes(DomainMaintanceIntervalMinutes); } } internal void UpdateDomainControllers(IEnumerable DomainControllers) { - this.domainControllers = new ConcurrentStack(DomainControllers); + domainControllers = new ConcurrentStack(DomainControllers); } #endregion @@ -233,7 +233,7 @@ namespace Disco.Services.Interop.ActiveDirectory throw new ArgumentNullException("DistinguishedName"); if (!DistinguishedName.EndsWith(this.DistinguishedName, StringComparison.OrdinalIgnoreCase)) - throw new ArgumentException(string.Format("The Distinguished Name ({0}) isn't a member of this domain [{1}]", DistinguishedName, this.Name), "DistinguishedName"); + throw new ArgumentException(string.Format("The Distinguished Name ({0}) isn't a member of this domain [{1}]", DistinguishedName, Name), "DistinguishedName"); var dc = GetAvailableDomainController(); @@ -244,12 +244,12 @@ namespace Disco.Services.Interop.ActiveDirectory public IEnumerable SearchEntireDomain(string LdapFilter, string[] LoadProperties, int? ResultLimit = null) { - return SearchInternal(this.DistinguishedName, LdapFilter, LoadProperties, ResultLimit); + return SearchInternal(DistinguishedName, LdapFilter, LoadProperties, ResultLimit); } public IEnumerable SearchScope(string LdapFilter, string[] LoadProperties, int? ResultLimit = null) { - var searchScope = this.SearchContainers; + var searchScope = SearchContainers; // No scope set, search entire domain if (searchScope == null) @@ -322,11 +322,11 @@ namespace Disco.Services.Interop.ActiveDirectory internal void UpdateSearchContainers(List Containers) { - this.SearchContainers = Containers ?? new List(); + SearchContainers = Containers ?? new List(); } internal void UpdateSearchEntireDomain() { - this.SearchContainers = null; + SearchContainers = null; } #region Helpers @@ -335,7 +335,7 @@ namespace Disco.Services.Interop.ActiveDirectory { get { - return string.Format("CN=Computers,{0}", this.DistinguishedName); + return string.Format("CN=Computers,{0}", DistinguishedName); } } @@ -346,7 +346,7 @@ namespace Disco.Services.Interop.ActiveDirectory StringBuilder name = new StringBuilder(); - name.Append('[').Append(this.NetBiosName).Append(']'); + name.Append('[').Append(NetBiosName).Append(']'); var subDN = DistinguishedName.Substring(0, DistinguishedName.Length - this.DistinguishedName.Length); var subDNComponents = subDN.Split(','); @@ -365,7 +365,7 @@ namespace Disco.Services.Interop.ActiveDirectory public override string ToString() { - return string.Format("{0} [{1}]", this.Name, this.NetBiosName); + return string.Format("{0} [{1}]", Name, NetBiosName); } public override bool Equals(object obj) @@ -373,11 +373,11 @@ namespace Disco.Services.Interop.ActiveDirectory if (obj == null || !(obj is ADDomain)) return false; else - return this.DistinguishedName == ((ADDomain)obj).DistinguishedName; + return DistinguishedName == ((ADDomain)obj).DistinguishedName; } public override int GetHashCode() { - return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(this.DistinguishedName); + return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(DistinguishedName); } } } \ No newline at end of file diff --git a/Disco.Services/Interop/ActiveDirectory/ADDomainController.cs b/Disco.Services/Interop/ActiveDirectory/ADDomainController.cs index d505bca3..a939373b 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADDomainController.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADDomainController.cs @@ -45,18 +45,18 @@ namespace Disco.Services.Interop.ActiveDirectory public ADDomainController(ActiveDirectoryContext Context, DomainController DomainController, ADDomain Domain, bool IsSiteServer, bool IsWritable) { - this.context = Context; + context = Context; this.Domain = Domain; this.DomainController = DomainController; - this.Name = DomainController.Name; - this.SiteName = DomainController.SiteName; + Name = DomainController.Name; + SiteName = DomainController.SiteName; this.IsSiteServer = IsSiteServer; this.IsWritable = IsWritable; - this.AvailableWhen = null; + AvailableWhen = null; } public ADDirectoryEntry RetrieveDirectoryEntry(string DistinguishedName, string[] LoadProperties = null) @@ -64,15 +64,15 @@ namespace Disco.Services.Interop.ActiveDirectory if (string.IsNullOrWhiteSpace(DistinguishedName)) throw new ArgumentNullException("DistinguishedName"); - if (!DistinguishedName.EndsWith(this.Domain.DistinguishedName, StringComparison.OrdinalIgnoreCase)) - throw new ArgumentException(string.Format("The Distinguished Name ({0}) isn't a member of this domain [{1}]", DistinguishedName, this.Domain.Name), "DistinguishedName"); + if (!DistinguishedName.EndsWith(Domain.DistinguishedName, StringComparison.OrdinalIgnoreCase)) + throw new ArgumentException(string.Format("The Distinguished Name ({0}) isn't a member of this domain [{1}]", DistinguishedName, Domain.Name), "DistinguishedName"); - var entry = new DirectoryEntry(string.Format(LdapPathTemplate, this.Name, ADHelpers.EscapeDistinguishedName(DistinguishedName))); + var entry = new DirectoryEntry(string.Format(LdapPathTemplate, Name, ADHelpers.EscapeDistinguishedName(DistinguishedName))); if (LoadProperties != null) entry.RefreshCache(LoadProperties); - return new ADDirectoryEntry(this.Domain, this, entry); + return new ADDirectoryEntry(Domain, this, entry); } #region Searching @@ -83,7 +83,7 @@ namespace Disco.Services.Interop.ActiveDirectory public IEnumerable SearchScope(string LdapFilter, string[] LoadProperties, int? ResultLimit = null) { - var searchScope = this.Domain.SearchContainers; + var searchScope = Domain.SearchContainers; // No scope set, search entire domain if (searchScope == null) @@ -109,7 +109,7 @@ namespace Disco.Services.Interop.ActiveDirectory if (ResultLimit.HasValue && ResultLimit.Value < 1) throw new ArgumentOutOfRangeException("ResultLimit", "The ResultLimit must be 1 or greater"); - using (ADDirectoryEntry rootEntry = this.RetrieveDirectoryEntry(SearchRoot)) + using (ADDirectoryEntry rootEntry = RetrieveDirectoryEntry(SearchRoot)) { using (DirectorySearcher searcher = new DirectorySearcher(rootEntry.Entry, LdapFilter, LoadProperties, System.DirectoryServices.SearchScope.Subtree)) { @@ -174,7 +174,7 @@ namespace Disco.Services.Interop.ActiveDirectory { ldapFilter = string.Format(ADMachineAccount.LdapNetbootGuidSingleFilterTemplate, MacAddressNetbootGUID.Value.ToLdapQueryFormat()); } - adResult = this.SearchEntireDomain(ldapFilter, loadProperites, ActiveDirectory.SingleSearchResult).FirstOrDefault(); + adResult = SearchEntireDomain(ldapFilter, loadProperites, ActiveDirectory.SingleSearchResult).FirstOrDefault(); } if (adResult != null) @@ -212,7 +212,7 @@ namespace Disco.Services.Interop.ActiveDirectory ? ADGroup.LoadProperties.Concat(AdditionalProperties).ToArray() : ADGroup.LoadProperties; - using (var groupEntry = this.RetrieveDirectoryEntry(DistinguishedName, loadProperites)) + using (var groupEntry = RetrieveDirectoryEntry(DistinguishedName, loadProperites)) { if (groupEntry == null) return null; @@ -224,8 +224,8 @@ namespace Disco.Services.Interop.ActiveDirectory { if (SecurityIdentifier == null) throw new ArgumentNullException("SecurityIdentifier"); - if (!SecurityIdentifier.IsEqualDomainSid(this.Domain.SecurityIdentifier)) - throw new ArgumentException(string.Format("The specified Security Identifier [{0}] does not belong to this domain [{1}]", SecurityIdentifier.ToString(), this.Domain.Name), "SecurityIdentifier"); + if (!SecurityIdentifier.IsEqualDomainSid(Domain.SecurityIdentifier)) + throw new ArgumentException(string.Format("The specified Security Identifier [{0}] does not belong to this domain [{1}]", SecurityIdentifier.ToString(), Domain.Name), "SecurityIdentifier"); var sidBinaryString = SecurityIdentifier.ToBinaryString(); @@ -234,7 +234,7 @@ namespace Disco.Services.Interop.ActiveDirectory ? ADGroup.LoadProperties.Concat(AdditionalProperties).ToArray() : ADGroup.LoadProperties; - var result = this.SearchEntireDomain(ldapFilter, loadProperites, ActiveDirectory.SingleSearchResult).FirstOrDefault(); + var result = SearchEntireDomain(ldapFilter, loadProperites, ActiveDirectory.SingleSearchResult).FirstOrDefault(); if (result == null) return null; else @@ -280,7 +280,7 @@ namespace Disco.Services.Interop.ActiveDirectory { Dictionary> resultTree = new Dictionary>(); - var unsortedOrganisationalUnits = this.SearchEntireDomain(OrganisationalUnitsLdapFilter, OrganisationalUnitsLoadProperties) + var unsortedOrganisationalUnits = SearchEntireDomain(OrganisationalUnitsLdapFilter, OrganisationalUnitsLoadProperties) .Select(r => r.AsADOrganisationalUnit()).ToList(); var indexedOrganisationalUnits = unsortedOrganisationalUnits.ToDictionary(k => k.DistinguishedName); @@ -307,12 +307,12 @@ namespace Disco.Services.Interop.ActiveDirectory { var slashIndex = Id.IndexOf('\\'); - if (!this.Domain.NetBiosName.Equals(Id.Substring(0, slashIndex), StringComparison.OrdinalIgnoreCase)) - throw new ArgumentException(string.Format("The Id [{0}] is invalid for this domain [{1}]", Id, this.Domain.Name), "Id"); + if (!Domain.NetBiosName.Equals(Id.Substring(0, slashIndex), StringComparison.OrdinalIgnoreCase)) + throw new ArgumentException(string.Format("The Id [{0}] is invalid for this domain [{1}]", Id, Domain.Name), "Id"); var ldapFilter = string.Format(LdapFilterTemplate, Id.Substring(slashIndex + 1)); - return this.SearchEntireDomain(ldapFilter, LoadProperties, ActiveDirectory.SingleSearchResult).FirstOrDefault(); + return SearchEntireDomain(ldapFilter, LoadProperties, ActiveDirectory.SingleSearchResult).FirstOrDefault(); } #endregion @@ -321,7 +321,7 @@ namespace Disco.Services.Interop.ActiveDirectory { using (Ping p = new Ping()) { - var pr = p.Send(this.Name, 1000); + var pr = p.Send(Name, 1000); return (pr.Status == IPStatus.Success); } } @@ -331,8 +331,8 @@ namespace Disco.Services.Interop.ActiveDirectory if (MachineAccount != null && MachineAccount.IsCriticalSystemObject) throw new InvalidOperationException(string.Format("This account {0} is a Critical System Active Directory Object and Disco refuses to modify it", MachineAccount.DistinguishedName)); - if (!this.IsWritable) - throw new InvalidOperationException(string.Format("The domain controller [{0}] is not writable. This action (Offline Domain Join Provision) requires a writable domain controller.", this.Name)); + if (!IsWritable) + throw new InvalidOperationException(string.Format("The domain controller [{0}] is not writable. This action (Offline Domain Join Provision) requires a writable domain controller.", Name)); StringBuilder diagnosticInfo = new StringBuilder(); string DJoinResult = null; @@ -349,7 +349,7 @@ namespace Disco.Services.Interop.ActiveDirectory { try { - using (var deOU = this.RetrieveDirectoryEntry(OrganisationalUnit, new string[] { "distinguishedName" })) + using (var deOU = RetrieveDirectoryEntry(OrganisationalUnit, new string[] { "distinguishedName" })) { if (deOU == null) throw new Exception(string.Format("OU's Directory Entry couldn't be found at [{0}]", OrganisationalUnit)); @@ -367,8 +367,8 @@ namespace Disco.Services.Interop.ActiveDirectory string tempFileName = System.IO.Path.GetTempFileName(); string argumentOU = (!string.IsNullOrWhiteSpace(OrganisationalUnit)) ? string.Format(" /MACHINEOU \"{0}\"", OrganisationalUnit) : string.Empty; string arguments = string.Format("/PROVISION /DOMAIN \"{0}\" /DCNAME \"{1}\" /MACHINE \"{2}\"{3} /REUSE /SAVEFILE \"{4}\"", - this.Domain.Name, - this.Name, + Domain.Name, + Name, ComputerSamAccountName, argumentOU, tempFileName @@ -409,7 +409,7 @@ namespace Disco.Services.Interop.ActiveDirectory DiagnosticInformation = diagnosticInfo.ToString(); // Reload Machine Account - MachineAccount = this.RetrieveADMachineAccount(string.Format(@"{0}\{1}", this.Domain.NetBiosName, ComputerSamAccountName), (MachineAccount == null ? null : MachineAccount.LoadedProperties.Keys.ToArray())); + MachineAccount = RetrieveADMachineAccount(string.Format(@"{0}\{1}", Domain.NetBiosName, ComputerSamAccountName), (MachineAccount == null ? null : MachineAccount.LoadedProperties.Keys.ToArray())); return DJoinResult; } @@ -417,7 +417,7 @@ namespace Disco.Services.Interop.ActiveDirectory public override string ToString() { - return this.Name; + return Name; } public override bool Equals(object obj) @@ -425,11 +425,11 @@ namespace Disco.Services.Interop.ActiveDirectory if (obj == null || !(obj is ADDomainController)) return false; else - return this.Name == ((ADDomainController)obj).Name; + return Name == ((ADDomainController)obj).Name; } public override int GetHashCode() { - return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(this.Name); + return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Name); } } } diff --git a/Disco.Services/Interop/ActiveDirectory/ADGroup.cs b/Disco.Services/Interop/ActiveDirectory/ADGroup.cs index dc7c0fc0..fb637a9c 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADGroup.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADGroup.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.DirectoryServices; using System.Linq; using System.Security.Principal; @@ -22,7 +21,7 @@ namespace Disco.Services.Interop.ActiveDirectory public string SamAccountName { get; private set; } public string Name { get; private set; } - public string DisplayName { get { return this.Name; } } + public string DisplayName { get { return Name; } } public List MemberOf { get; private set; } @@ -105,18 +104,18 @@ namespace Disco.Services.Interop.ActiveDirectory switch (PropertyName.ToLower()) { case "name": - return new string[] { this.Name }.OfType(); + return new string[] { Name }.OfType(); case "samaccountname": - return new string[] { this.SamAccountName }.OfType(); + return new string[] { SamAccountName }.OfType(); case "distinguishedname": - return new string[] { this.DistinguishedName }.OfType(); + return new string[] { DistinguishedName }.OfType(); case "objectsid": - return new SecurityIdentifier[] { this.SecurityIdentifier }.OfType(); + return new SecurityIdentifier[] { SecurityIdentifier }.OfType(); case "memberof": - return this.MemberOf.OfType(); + return MemberOf.OfType(); default: object[] adProperty; - if (this.LoadedProperties.TryGetValue(PropertyName, out adProperty)) + if (LoadedProperties.TryGetValue(PropertyName, out adProperty)) return adProperty.OfType(); else return Enumerable.Empty(); @@ -125,7 +124,7 @@ namespace Disco.Services.Interop.ActiveDirectory public override string ToString() { - return this.Id; + return Id; } public override bool Equals(object obj) @@ -133,11 +132,11 @@ namespace Disco.Services.Interop.ActiveDirectory if (obj == null || !(obj is ADGroup)) return false; else - return this.DistinguishedName == ((ADGroup)obj).DistinguishedName; + return DistinguishedName == ((ADGroup)obj).DistinguishedName; } public override int GetHashCode() { - return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(this.DistinguishedName); + return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(DistinguishedName); } } } \ No newline at end of file diff --git a/Disco.Services/Interop/ActiveDirectory/ADManagedGroup.cs b/Disco.Services/Interop/ActiveDirectory/ADManagedGroup.cs index 0ae325b7..0f908c58 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADManagedGroup.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADManagedGroup.cs @@ -36,7 +36,7 @@ namespace Disco.Services.Interop.ActiveDirectory public ADGroup GetGroup() { - return ActiveDirectory.RetrieveADGroup(this.Configuration.GroupId, "member"); + return ActiveDirectory.RetrieveADGroup(Configuration.GroupId, "member"); } protected void AddMember(string Id) diff --git a/Disco.Services/Interop/ActiveDirectory/ADManagedGroupsSyncTask.cs b/Disco.Services/Interop/ActiveDirectory/ADManagedGroupsSyncTask.cs index e973255f..f2ead91f 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADManagedGroupsSyncTask.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADManagedGroupsSyncTask.cs @@ -1,5 +1,4 @@ using Disco.Data.Repository; -using Disco.Services.Logging; using Disco.Services.Tasks; using Quartz; using System; @@ -20,23 +19,23 @@ namespace Disco.Services.Interop.ActiveDirectory TriggerBuilder triggerBuilder = TriggerBuilder.Create(). WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(23, 0)); - this.ScheduleTask(triggerBuilder); + ScheduleTask(triggerBuilder); } protected override void ExecuteTask() { int changeCount; - List managedGroups = this.ExecutionContext.JobDetail.JobDataMap["ManagedGroups"] as List; + List managedGroups = ExecutionContext.JobDetail.JobDataMap["ManagedGroups"] as List; if (managedGroups == null) managedGroups = ActiveDirectory.Context.ManagedGroups.Values; - this.Status.UpdateStatus(0, "Synchronising Active Directory Managed Groups", "Starting"); + Status.UpdateStatus(0, "Synchronising Active Directory Managed Groups", "Starting"); - changeCount = ActiveDirectory.Context.ManagedGroups.SyncManagedGroups(managedGroups, this.Status); + changeCount = ActiveDirectory.Context.ManagedGroups.SyncManagedGroups(managedGroups, Status); Status.LogInformation($"Synchronised Active Directory Managed Groups, {changeCount:N0} changes made"); - this.Status.SetFinishedMessage(string.Format("Made {0} Changes to Active Directory Groups", changeCount)); + Status.SetFinishedMessage(string.Format("Made {0} Changes to Active Directory Groups", changeCount)); } public static ScheduledTaskStatus ScheduleSync(ADManagedGroup ManagedGroup) diff --git a/Disco.Services/Interop/ActiveDirectory/ADNetworkLogonDatesUpdateTask.cs b/Disco.Services/Interop/ActiveDirectory/ADNetworkLogonDatesUpdateTask.cs index c0f10ef9..fe302aa9 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADNetworkLogonDatesUpdateTask.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADNetworkLogonDatesUpdateTask.cs @@ -27,10 +27,10 @@ namespace Disco.Services.Interop.ActiveDirectory { int changeCount; - this.Status.UpdateStatus(1, "Starting", "Connecting to the Database and initializing the environment"); + Status.UpdateStatus(1, "Starting", "Connecting to the Database and initializing the environment"); using (DiscoDataContext database = new DiscoDataContext()) { - UpdateLastNetworkLogonDates(database, this.Status); + UpdateLastNetworkLogonDates(database, Status); Status.UpdateStatus(95, "Updating Database", "Writing last network logon dates to the Database"); changeCount = database.SaveChanges(); Status.Finished(string.Format("{0} Device last network logon dates updated", changeCount), "/Config/SystemConfig"); diff --git a/Disco.Services/Interop/ActiveDirectory/ADOrganisationalUnit.cs b/Disco.Services/Interop/ActiveDirectory/ADOrganisationalUnit.cs index a4ec4c67..5235b737 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADOrganisationalUnit.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADOrganisationalUnit.cs @@ -28,7 +28,7 @@ namespace Disco.Services.Interop.ActiveDirectory public override string ToString() { - return this.Name; + return Name; } public override bool Equals(object obj) @@ -36,11 +36,11 @@ namespace Disco.Services.Interop.ActiveDirectory if (obj == null || !(obj is ADOrganisationalUnit)) return false; else - return this.DistinguishedName == ((ADOrganisationalUnit)obj).DistinguishedName; + return DistinguishedName == ((ADOrganisationalUnit)obj).DistinguishedName; } public override int GetHashCode() { - return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(this.DistinguishedName); + return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(DistinguishedName); } } } diff --git a/Disco.Services/Interop/ActiveDirectory/ADSearchResult.cs b/Disco.Services/Interop/ActiveDirectory/ADSearchResult.cs index f7b53823..1cfca980 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADSearchResult.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADSearchResult.cs @@ -18,14 +18,14 @@ namespace Disco.Services.Interop.ActiveDirectory public ADSearchResult(ADDomain Domain, ADDomainController DomainController, string SearchPath, string LdapFilter, SearchResult Result) { - this._result = Result; + _result = Result; this.Domain = Domain; this.DomainController = DomainController; this.SearchPath = SearchPath; this.LdapFilter = LdapFilter; - this.LdapPath = _result.Path; - this.DistinguishedName = Value("dn"); + LdapPath = _result.Path; + DistinguishedName = Value("dn"); } public bool Contains(string PropertyName) @@ -47,7 +47,7 @@ namespace Disco.Services.Interop.ActiveDirectory public override string ToString() { - return this.LdapPath; + return LdapPath; } } } diff --git a/Disco.Services/Interop/ActiveDirectory/ADSite.cs b/Disco.Services/Interop/ActiveDirectory/ADSite.cs index 96216232..1cb98880 100644 --- a/Disco.Services/Interop/ActiveDirectory/ADSite.cs +++ b/Disco.Services/Interop/ActiveDirectory/ADSite.cs @@ -16,12 +16,12 @@ namespace Disco.Services.Interop.ActiveDirectory public ADSite(ActiveDirectoryContext Context, ActiveDirectorySite Site) { - this.context = Context; + context = Context; this.Site = Site; - this.Name = Site.Name; - this.DomainControllers = null; + Name = Site.Name; + DomainControllers = null; } internal void UpdateDomainControllers(IEnumerable DomainControllers) @@ -31,7 +31,7 @@ namespace Disco.Services.Interop.ActiveDirectory public override string ToString() { - return this.Name; + return Name; } public override bool Equals(object obj) @@ -39,11 +39,11 @@ namespace Disco.Services.Interop.ActiveDirectory if (obj == null || !(obj is ADSite)) return false; else - return this.Name == ((ADSite)obj).Name; + return Name == ((ADSite)obj).Name; } public override int GetHashCode() { - return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(this.Name); + return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(Name); } } } diff --git a/Disco.Services/Interop/ActiveDirectory/ActiveDirectory.cs b/Disco.Services/Interop/ActiveDirectory/ActiveDirectory.cs index fb27581b..5617e27d 100644 --- a/Disco.Services/Interop/ActiveDirectory/ActiveDirectory.cs +++ b/Disco.Services/Interop/ActiveDirectory/ActiveDirectory.cs @@ -2,11 +2,8 @@ using Disco.Models.Repository; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Security.Principal; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Interop.ActiveDirectory { diff --git a/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryContext.cs b/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryContext.cs index 7d9606de..675bd5c0 100644 --- a/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryContext.cs +++ b/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryContext.cs @@ -1,11 +1,9 @@ using Disco.Data.Repository; using System; using System.Collections.Generic; -using System.DirectoryServices; using System.DirectoryServices.ActiveDirectory; using System.Linq; using System.Security.Principal; -using System.Text; using System.Threading.Tasks; namespace Disco.Services.Interop.ActiveDirectory @@ -53,22 +51,22 @@ namespace Disco.Services.Interop.ActiveDirectory private void Initialize(DiscoDataContext Database) { // Search Entire Forest (default: true) - this._SearchAllForestServers = Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers ?? true; + _SearchAllForestServers = Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers ?? true; // Set Search LDAP Filters InitializeWildcardSearchSufixOnly(Database.DiscoConfiguration.ActiveDirectory.SearchWildcardSuffixOnly); // Determine Site var computerSite = ActiveDirectorySite.GetComputerSite(); - this.Site = new ADSite(this, computerSite); + Site = new ADSite(this, computerSite); // Determine Domains var computerDomain = Domain.GetComputerDomain(); - this.Domains = computerDomain.Forest.Domains + Domains = computerDomain.Forest.Domains .Cast() .Select(d => new ADDomain(this, d)) .ToList(); - this.PrimaryDomain = this.Domains.Where(d => d.Name == computerDomain.Name).First(); + PrimaryDomain = Domains.Where(d => d.Name == computerDomain.Name).First(); // Determine Search Scope Containers ReinitializeSearchContainers(Database.DiscoConfiguration.ActiveDirectory.SearchContainers); @@ -80,7 +78,7 @@ namespace Disco.Services.Interop.ActiveDirectory .Select(dc => new ADDomainController(this, dc, GetDomainByName(dc.Domain.Name), IsSiteServer: true, IsWritable: false)); Site.UpdateDomainControllers(siteDomainControllers); - this.Domains.ForEach(domain => domain.UpdateDomainControllers(siteDomainControllers.Where(dc => dc.Domain == domain))); + Domains.ForEach(domain => domain.UpdateDomainControllers(siteDomainControllers.Where(dc => dc.Domain == domain))); } #endregion @@ -90,7 +88,7 @@ namespace Disco.Services.Interop.ActiveDirectory public bool TryGetDomainFromDistinguishedName(string DistinguishedName, out ADDomain Domain) { // Find closest match - Domain = this.Domains.Where(d => DistinguishedName.EndsWith(d.DistinguishedName, StringComparison.OrdinalIgnoreCase)) + Domain = Domains.Where(d => DistinguishedName.EndsWith(d.DistinguishedName, StringComparison.OrdinalIgnoreCase)) .OrderByDescending(d => d.DistinguishedName.Length).FirstOrDefault(); return (Domain != null); @@ -105,7 +103,7 @@ namespace Disco.Services.Interop.ActiveDirectory public bool TryGetDomainByNetBiosName(string NetBiosName, out ADDomain Domain) { - Domain = this.Domains.FirstOrDefault(d => d.NetBiosName.Equals(NetBiosName, StringComparison.OrdinalIgnoreCase)); + Domain = Domains.FirstOrDefault(d => d.NetBiosName.Equals(NetBiosName, StringComparison.OrdinalIgnoreCase)); return (Domain != null); } public ADDomain GetDomainByNetBiosName(string NetBiosName) @@ -118,7 +116,7 @@ namespace Disco.Services.Interop.ActiveDirectory public bool TryGetDomainByName(string Name, out ADDomain Domain) { - Domain = this.Domains.FirstOrDefault(d => d.Name.Equals(Name, StringComparison.OrdinalIgnoreCase)); + Domain = Domains.FirstOrDefault(d => d.Name.Equals(Name, StringComparison.OrdinalIgnoreCase)); return (Domain != null); } public ADDomain GetDomainByName(string Name) @@ -131,7 +129,7 @@ namespace Disco.Services.Interop.ActiveDirectory public bool TryGetDomainFromSecurityIdentifier(SecurityIdentifier SecurityIdentifier, out ADDomain Domain) { - Domain = this.Domains.FirstOrDefault(d => d.SecurityIdentifier.IsEqualDomainSid(SecurityIdentifier)); + Domain = Domains.FirstOrDefault(d => d.SecurityIdentifier.IsEqualDomainSid(SecurityIdentifier)); return (Domain != null); } public ADDomain GetDomainFromSecurityIdentifier(SecurityIdentifier SecurityIdentifier) @@ -184,14 +182,14 @@ namespace Disco.Services.Interop.ActiveDirectory public IEnumerable SearchEntireForest(string LdapFilter, string[] LoadProperties, int? ResultLimit = null) { - var queries = this.Domains.Select(d => Tuple.Create(d, d.DistinguishedName)); + var queries = Domains.Select(d => Tuple.Create(d, d.DistinguishedName)); return SearchInternal(queries, LdapFilter, LoadProperties, ResultLimit); } public IEnumerable SearchScope(string LdapFilter, string[] LoadProperties, int? ResultLimit = null) { - var queries = this.Domains.SelectMany( + var queries = Domains.SelectMany( d => d.SearchContainers ?? new List() { d.DistinguishedName }, (d, scope) => Tuple.Create(d, scope)); @@ -256,7 +254,7 @@ namespace Disco.Services.Interop.ActiveDirectory if (SearchAllForestServers == false) { Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers = false; - this._SearchAllForestServers = false; + _SearchAllForestServers = false; return true; } else @@ -265,13 +263,13 @@ namespace Disco.Services.Interop.ActiveDirectory if (forestServers.Count <= ActiveDirectory.MaxForestServerSearch) { Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers = true; - this._SearchAllForestServers = true; + _SearchAllForestServers = true; return true; } else { Database.DiscoConfiguration.ActiveDirectory.SearchAllForestServers = false; - this._SearchAllForestServers = false; + _SearchAllForestServers = false; return false; } } @@ -315,18 +313,18 @@ namespace Disco.Services.Interop.ActiveDirectory if (Containers == null) { // No search restrictions (search entire domain) - foreach (var domain in this.Domains) + foreach (var domain in Domains) domain.UpdateSearchEntireDomain(); } else { // Restrict search containers - var searchContainerDomains = Containers.Join(this.Domains, ok => ok.Key, ik => ik.Name, (o, i) => Tuple.Create(o, i), StringComparer.OrdinalIgnoreCase); + var searchContainerDomains = Containers.Join(Domains, ok => ok.Key, ik => ik.Name, (o, i) => Tuple.Create(o, i), StringComparer.OrdinalIgnoreCase); foreach (var domainContainers in searchContainerDomains) domainContainers.Item2.UpdateSearchContainers(domainContainers.Item1.Value); // Ignore domains without configured containers - var unconfiguredContainers = this.Domains.Except(searchContainerDomains.Select(sc => sc.Item2)); + var unconfiguredContainers = Domains.Except(searchContainerDomains.Select(sc => sc.Item2)); foreach (var domain in unconfiguredContainers) domain.UpdateSearchContainers(new List()); } diff --git a/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryGroupCache.cs b/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryGroupCache.cs index bc5688d4..05267f65 100644 --- a/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryGroupCache.cs +++ b/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryGroupCache.cs @@ -3,7 +3,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Security.Principal; -using System.Text; using System.Threading.Tasks; namespace Disco.Services.Interop.ActiveDirectory @@ -21,8 +20,8 @@ namespace Disco.Services.Interop.ActiveDirectory public ActiveDirectoryGroupCache() { - this.securityIdentifierCache = new ConcurrentDictionary>(); - this.distinguishedNameCache = new ConcurrentDictionary>(StringComparer.OrdinalIgnoreCase); + securityIdentifierCache = new ConcurrentDictionary>(); + distinguishedNameCache = new ConcurrentDictionary>(StringComparer.OrdinalIgnoreCase); cacheCleanNext = DateTime.Now.AddMinutes(CacheCleanIntervalMinutes); } diff --git a/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryManagedGroups.cs b/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryManagedGroups.cs index 379f8cbb..cd3db466 100644 --- a/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryManagedGroups.cs +++ b/Disco.Services/Interop/ActiveDirectory/ActiveDirectoryManagedGroups.cs @@ -3,8 +3,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Reactive.Subjects; -using System.Text; -using System.Threading.Tasks; using Disco.Data.Repository; namespace Disco.Services.Interop.ActiveDirectory @@ -436,7 +434,7 @@ namespace Disco.Services.Interop.ActiveDirectory this.ManagedGroup = ManagedGroup; this.ActionType = ActionType; this.InvokingIdentifier = InvokingIdentifier; - this.memberResolver = MemberResolver; + memberResolver = MemberResolver; } public IEnumerable ResolveMembers(DiscoDataContext Database) @@ -448,14 +446,14 @@ namespace Disco.Services.Interop.ActiveDirectory return Enumerable.Empty(); else return members.Select(m => - new ADManagedGroupScheduledActionItem(this.ManagedGroup, this.ActionType, m) + new ADManagedGroupScheduledActionItem(ManagedGroup, ActionType, m) ); } else { return new ADManagedGroupScheduledActionItem[] { - new ADManagedGroupScheduledActionItem(this.ManagedGroup, this.ActionType, this.InvokingIdentifier) + new ADManagedGroupScheduledActionItem(ManagedGroup, ActionType, InvokingIdentifier) }; } } diff --git a/Disco.Services/Interop/DiscoServices/PluginLibraryUpdateTask.cs b/Disco.Services/Interop/DiscoServices/PluginLibraryUpdateTask.cs index 8178f05b..76a6cd4d 100644 --- a/Disco.Services/Interop/DiscoServices/PluginLibraryUpdateTask.cs +++ b/Disco.Services/Interop/DiscoServices/PluginLibraryUpdateTask.cs @@ -1,9 +1,7 @@ using Disco.Data.Repository; using Disco.Services.Tasks; -using Newtonsoft.Json; using Quartz; using System; -using System.IO; using System.Linq; namespace Disco.Services.Interop.DiscoServices @@ -25,7 +23,7 @@ namespace Disco.Services.Interop.DiscoServices TriggerBuilder triggerBuilder = TriggerBuilder.Create(). WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(rndHour, rndMinute)); - this.ScheduleTask(triggerBuilder); + ScheduleTask(triggerBuilder); } protected override void ExecuteTask() @@ -34,7 +32,7 @@ namespace Disco.Services.Interop.DiscoServices { Status.UpdateStatus(1, "Updating Plugin Library Manifest", "Initializing"); - var manifest = PluginLibrary.UpdateManifest(database, this.Status); + var manifest = PluginLibrary.UpdateManifest(database, Status); Status.SetFinishedMessage("The Plugin Library Manifest was updated successfully"); } diff --git a/Disco.Services/Interop/DiscoServices/UpdateQueryTask.cs b/Disco.Services/Interop/DiscoServices/UpdateQueryTask.cs index a2aa418e..682c9f07 100644 --- a/Disco.Services/Interop/DiscoServices/UpdateQueryTask.cs +++ b/Disco.Services/Interop/DiscoServices/UpdateQueryTask.cs @@ -23,7 +23,7 @@ namespace Disco.Services.Interop.DiscoServices TriggerBuilder triggerBuilder = TriggerBuilder.Create(). WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(rndHour, rndMinute)); - this.ScheduleTask(triggerBuilder); + ScheduleTask(triggerBuilder); } protected override void ExecuteTask() diff --git a/Disco.Services/Jobs/JobLists/JobTableExtensions.cs b/Disco.Services/Jobs/JobLists/JobTableExtensions.cs index 6fd99df2..0c1561d8 100644 --- a/Disco.Services/Jobs/JobLists/JobTableExtensions.cs +++ b/Disco.Services/Jobs/JobLists/JobTableExtensions.cs @@ -7,8 +7,6 @@ using Disco.Services.Users; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services { diff --git a/Disco.Services/Jobs/JobLists/ManagedJobList.cs b/Disco.Services/Jobs/JobLists/ManagedJobList.cs index 3a659cbf..3490adb1 100644 --- a/Disco.Services/Jobs/JobLists/ManagedJobList.cs +++ b/Disco.Services/Jobs/JobLists/ManagedJobList.cs @@ -146,7 +146,7 @@ using Disco.Services.Authorization; .Subscribe(JobNotification, NotificationError); // Initially fill table - base.Items = this.SortFunction(this.DetermineItems(Database, this.FilterFunction(Database.Jobs), FilterAuthorization)).ToList(); + base.Items = SortFunction(this.DetermineItems(Database, FilterFunction(Database.Jobs), FilterAuthorization)).ToList(); } return this; } @@ -178,7 +178,7 @@ using Disco.Services.Authorization; private void NotificationError(Exception ex) { - SystemLog.LogException(string.Format("Disco.Services.Jobs.JobLists.ManagedJobList: [{0}]", this.Name), ex); + SystemLog.LogException(string.Format("Disco.Services.Jobs.JobLists.ManagedJobList: [{0}]", Name), ex); } private void JobNotification(RepositoryMonitorEvent e) @@ -262,7 +262,7 @@ using Disco.Services.Authorization; if (existingItems == null) existingItems = base.Items.Where(i => jobIds.Contains(i.JobId)).ToArray(); - var updatedItems = this.DetermineItems(Database, this.FilterFunction(Database.Jobs.Where(j => jobIds.Contains(j.Id))), false); + var updatedItems = this.DetermineItems(Database, FilterFunction(Database.Jobs.Where(j => jobIds.Contains(j.Id))), false); var refreshedList = base.Items.ToList(); @@ -277,7 +277,7 @@ using Disco.Services.Authorization; refreshedList.Add(updatedItem); // Reorder - base.Items = this.SortFunction(refreshedList).ToList(); + base.Items = SortFunction(refreshedList).ToList(); } } diff --git a/Disco.Services/Jobs/JobUpdatesHub.cs b/Disco.Services/Jobs/JobUpdatesHub.cs index 76dfccba..63fd3a6a 100644 --- a/Disco.Services/Jobs/JobUpdatesHub.cs +++ b/Disco.Services/Jobs/JobUpdatesHub.cs @@ -6,9 +6,7 @@ using Disco.Services.Web.Signalling; using Microsoft.AspNet.SignalR; using Microsoft.AspNet.SignalR.Hubs; using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Reactive.Linq; using System.Threading.Tasks; using Disco.Services.Users; diff --git a/Disco.Services/Jobs/Jobs.cs b/Disco.Services/Jobs/Jobs.cs index 7268e201..558ab40f 100644 --- a/Disco.Services/Jobs/Jobs.cs +++ b/Disco.Services/Jobs/Jobs.cs @@ -2,7 +2,6 @@ using Disco.Models.Repository; using Disco.Services.Expressions; using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/Disco.Services/Jobs/Noticeboards/HeldDeviceItem.cs b/Disco.Services/Jobs/Noticeboards/HeldDeviceItem.cs index e9489e93..4cc2e22d 100644 --- a/Disco.Services/Jobs/Noticeboards/HeldDeviceItem.cs +++ b/Disco.Services/Jobs/Noticeboards/HeldDeviceItem.cs @@ -29,15 +29,15 @@ namespace Disco.Services.Jobs.Noticeboards { get { - StringBuilder sb = new StringBuilder(this.DeviceComputerNameFriendly); + StringBuilder sb = new StringBuilder(DeviceComputerNameFriendly); if (UserId != null) - sb.Append(" - ").Append(this.UserDisplayName).Append(" (").Append(this.UserIdFriendly).Append(")"); + sb.Append(" - ").Append(UserDisplayName).Append(" (").Append(UserIdFriendly).Append(")"); - if (!string.IsNullOrWhiteSpace(this.DeviceLocation)) - sb.Append(" - ").Append(this.DeviceLocation); + if (!string.IsNullOrWhiteSpace(DeviceLocation)) + sb.Append(" - ").Append(DeviceLocation); else if (UserId == null) - sb.Append(" - ").Append(this.DeviceSerialNumber); + sb.Append(" - ").Append(DeviceSerialNumber); return sb.ToString(); } @@ -108,10 +108,10 @@ namespace Disco.Services.Jobs.Noticeboards { get { - if (this.ReadyForReturn && (this.ReadyForReturnSince.Value < DateTime.Now.AddDays(-3))) + if (ReadyForReturn && (ReadyForReturnSince.Value < DateTime.Now.AddDays(-3))) return true; - if (this.WaitingForUserAction && (this.WaitingForUserActionSince.Value < DateTime.Now.AddDays(-6))) + if (WaitingForUserAction && (WaitingForUserActionSince.Value < DateTime.Now.AddDays(-6))) return true; return false; diff --git a/Disco.Services/Jobs/Statistics/DailyOpenedClosed.cs b/Disco.Services/Jobs/Statistics/DailyOpenedClosed.cs index 402a3c80..2e8b10b2 100644 --- a/Disco.Services/Jobs/Statistics/DailyOpenedClosed.cs +++ b/Disco.Services/Jobs/Statistics/DailyOpenedClosed.cs @@ -29,7 +29,7 @@ namespace Disco.Services.Jobs.Statistics // Trigger Daily @ 12:29am TriggerBuilder triggerBuilder = TriggerBuilder.Create().WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(0, 29)); - this.ScheduleTask(triggerBuilder); + ScheduleTask(triggerBuilder); } protected override void ExecuteTask() { diff --git a/Disco.Services/Logging/LogBase.cs b/Disco.Services/Logging/LogBase.cs index 6c5fa36a..70bb5354 100644 --- a/Disco.Services/Logging/LogBase.cs +++ b/Disco.Services/Logging/LogBase.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; namespace Disco.Services.Logging { @@ -12,7 +10,7 @@ namespace Disco.Services.Logging public LogBase() { // Cache Event Types - _EventTypes = this.LoadEventTypes().ToDictionary(et => et.Id); + _EventTypes = LoadEventTypes().ToDictionary(et => et.Id); } public abstract int ModuleId { get; } @@ -29,13 +27,13 @@ namespace Disco.Services.Logging } protected void Log(int EventTypeId, params object[] Args) { - LogContext.Current.Log(this.ModuleId, EventTypeId, Args); + LogContext.Current.Log(ModuleId, EventTypeId, Args); } public string LiveLogGroupName { get { - return this.ModuleName; + return ModuleName; } } diff --git a/Disco.Services/Logging/LogContext.cs b/Disco.Services/Logging/LogContext.cs index def2a567..98dfa34c 100644 --- a/Disco.Services/Logging/LogContext.cs +++ b/Disco.Services/Logging/LogContext.cs @@ -1,17 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Disco.Data.Repository; using System.IO; -using System.Management; -using System.Diagnostics; using System.Data.SqlServerCe; -using System.Data.EntityClient; -using System.Data.Entity; using Quartz; using Quartz.Impl; -using Quartz.Impl.Triggers; using Newtonsoft.Json; namespace Disco.Services.Logging diff --git a/Disco.Services/Logging/LogReInitalizeJob.cs b/Disco.Services/Logging/LogReInitalizeJob.cs index 176a501a..afa51485 100644 --- a/Disco.Services/Logging/LogReInitalizeJob.cs +++ b/Disco.Services/Logging/LogReInitalizeJob.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Quartz; +using Quartz; using Disco.Data.Repository; namespace Disco.Services.Logging diff --git a/Disco.Services/Logging/Models/LogEvent.cs b/Disco.Services/Logging/Models/LogEvent.cs index eb8b3894..33fa3267 100644 --- a/Disco.Services/Logging/Models/LogEvent.cs +++ b/Disco.Services/Logging/Models/LogEvent.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/Disco.Services/Logging/Models/LogEventType.cs b/Disco.Services/Logging/Models/LogEventType.cs index 58f8df23..7e65bade 100644 --- a/Disco.Services/Logging/Models/LogEventType.cs +++ b/Disco.Services/Logging/Models/LogEventType.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/Disco.Services/Logging/Models/LogLiveEvent.cs b/Disco.Services/Logging/Models/LogLiveEvent.cs index 578fc4ea..79a26d48 100644 --- a/Disco.Services/Logging/Models/LogLiveEvent.cs +++ b/Disco.Services/Logging/Models/LogLiveEvent.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Collections; using Newtonsoft.Json; namespace Disco.Services.Logging.Models diff --git a/Disco.Services/Logging/Models/LogModule.cs b/Disco.Services/Logging/Models/LogModule.cs index c2110410..5eea9f1f 100644 --- a/Disco.Services/Logging/Models/LogModule.cs +++ b/Disco.Services/Logging/Models/LogModule.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/Disco.Services/Logging/Persistance/LogPersistContext.cs b/Disco.Services/Logging/Persistance/LogPersistContext.cs index dae65db3..304c1589 100644 --- a/Disco.Services/Logging/Persistance/LogPersistContext.cs +++ b/Disco.Services/Logging/Persistance/LogPersistContext.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Data.Entity; -using System.Data.Entity.Infrastructure; +using System.Data.Entity; namespace Disco.Services.Logging.Persistance { diff --git a/Disco.Services/Logging/Persistance/LogPersistContextInitializer.cs b/Disco.Services/Logging/Persistance/LogPersistContextInitializer.cs index 5dc12cc5..e1458bc3 100644 --- a/Disco.Services/Logging/Persistance/LogPersistContextInitializer.cs +++ b/Disco.Services/Logging/Persistance/LogPersistContextInitializer.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Data.Entity; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Data.Entity; namespace Disco.Services.Logging.Persistance { diff --git a/Disco.Services/Logging/ReadLogContext.cs b/Disco.Services/Logging/ReadLogContext.cs index ea6dcbc5..f5481b51 100644 --- a/Disco.Services/Logging/ReadLogContext.cs +++ b/Disco.Services/Logging/ReadLogContext.cs @@ -20,9 +20,9 @@ namespace Disco.Services.Logging public bool Validate() { - if (this.Start.HasValue && this.End.HasValue && this.End.Value < this.Start.Value) + if (Start.HasValue && End.HasValue && End.Value < Start.Value) throw new ArgumentOutOfRangeException("End", "End must be greater than Start"); - if (this.Start.HasValue && !this.End.HasValue && this.Start > DateTime.Now) + if (Start.HasValue && !End.HasValue && Start > DateTime.Now) throw new ArgumentOutOfRangeException("Start", "Start must be less than current time"); return true; @@ -33,7 +33,7 @@ namespace Disco.Services.Logging List results = new List(); // Validate Options - this.Validate(); + Validate(); var relevantLogFiles = RelevantLogFiles(Database); relevantLogFiles.Reverse(); @@ -46,11 +46,11 @@ namespace Disco.Services.Logging using (var context = new LogPersistContext(sqlCeCSB.ToString())) { - var query = this.BuildQuery(context, logFile.Item2, results.Count); + var query = BuildQuery(context, logFile.Item2, results.Count); IEnumerable queryResults = query; // Run the Query results.AddRange(queryResults.Select(le => Models.LogLiveEvent.Create(logModules[le.ModuleId], logModules[le.ModuleId].EventTypes[le.EventTypeId], le.Timestamp, le.Arguments))); } - if (this.Take.HasValue && this.Take.Value < results.Count) + if (Take.HasValue && Take.Value < results.Count) break; } return results; @@ -77,17 +77,17 @@ namespace Disco.Services.Logging List> relevantFiles = new List>(); var logDirectoryBase = LogContext.LogFileBasePath(Database); var logDirectoryBaseInfo = new DirectoryInfo(logDirectoryBase); - var endDate = this.End.HasValue ? this.End.Value : DateTime.Now; + var endDate = End.HasValue ? End.Value : DateTime.Now; var endDateYear = endDate.Year.ToString(); // Try Shortcut ( < 31 Days in Query) - if (this.Start.HasValue) + if (Start.HasValue) { - if ((this.End.HasValue && this.End.Value.Subtract(this.Start.Value).Days < 31) || - (!this.End.HasValue && DateTime.Now.Subtract(this.Start.Value).Days < 31)) + if ((End.HasValue && End.Value.Subtract(Start.Value).Days < 31) || + (!End.HasValue && DateTime.Now.Subtract(Start.Value).Days < 31)) { // Less than 31 Days in Query - Just evaluate each Path - var queryDate = this.Start.Value.Date; + var queryDate = Start.Value.Date; while (queryDate <= endDate) { var fileName = LogContext.LogFilePath(Database, queryDate, false); @@ -148,27 +148,27 @@ namespace Disco.Services.Logging private IQueryable BuildQuery(LogPersistContext LogContext, DateTime LogDate, int Taken) { IQueryable query = LogContext.Events.OrderByDescending(le => le.Timestamp); - if (this.Module.HasValue) + if (Module.HasValue) { - query = query.Where(le => le.ModuleId == this.Module.Value); + query = query.Where(le => le.ModuleId == Module.Value); } - if (this.EventTypes != null && this.EventTypes.Count > 0) + if (EventTypes != null && EventTypes.Count > 0) { - query = query.Where(le => this.EventTypes.Contains(le.EventTypeId)); + query = query.Where(le => EventTypes.Contains(le.EventTypeId)); } - if (this.Start.HasValue && this.Start.Value > LogDate) + if (Start.HasValue && Start.Value > LogDate) { - var startValue = DateTime.SpecifyKind(this.Start.Value, DateTimeKind.Local); + var startValue = DateTime.SpecifyKind(Start.Value, DateTimeKind.Local); query = query.Where(le => le.Timestamp > startValue); } - if (this.End.HasValue && this.End.Value <= LogDate.AddDays(1)) + if (End.HasValue && End.Value <= LogDate.AddDays(1)) { - var endValue = DateTime.SpecifyKind(this.End.Value, DateTimeKind.Local); + var endValue = DateTime.SpecifyKind(End.Value, DateTimeKind.Local); query = query.Where(le => le.Timestamp < endValue); } - if (this.Take.HasValue && this.Take.Value > 0) + if (Take.HasValue && Take.Value > 0) { - var take = this.Take.Value - Taken; + var take = Take.Value - Taken; query = query.Take(take); } return query; diff --git a/Disco.Services/Logging/Utilities.cs b/Disco.Services/Logging/Utilities.cs index 4f51ae2f..0afe226e 100644 --- a/Disco.Services/Logging/Utilities.cs +++ b/Disco.Services/Logging/Utilities.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; using System.IO; diff --git a/Disco.Services/Plugins/Features/InteroperabilityProvider/InteroperabilityProviderFeature.cs b/Disco.Services/Plugins/Features/InteroperabilityProvider/InteroperabilityProviderFeature.cs index e6d978da..ceed72ad 100644 --- a/Disco.Services/Plugins/Features/InteroperabilityProvider/InteroperabilityProviderFeature.cs +++ b/Disco.Services/Plugins/Features/InteroperabilityProvider/InteroperabilityProviderFeature.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Plugins.Features.InteroperabilityProvider +namespace Disco.Services.Plugins.Features.InteroperabilityProvider { [PluginFeatureCategory(DisplayName = "Interoperability Providers")] public abstract class InteroperabilityProviderFeature : PluginFeature diff --git a/Disco.Services/Plugins/Features/Other/OtherFeature.cs b/Disco.Services/Plugins/Features/Other/OtherFeature.cs index 2f6ad6a0..55e09eba 100644 --- a/Disco.Services/Plugins/Features/Other/OtherFeature.cs +++ b/Disco.Services/Plugins/Features/Other/OtherFeature.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Plugins.Features.Other +namespace Disco.Services.Plugins.Features.Other { [PluginFeatureCategory(DisplayName = "Other")] public abstract class OtherFeature : PluginFeature diff --git a/Disco.Services/Plugins/Features/RepairProvider/RepairProviderFeature.cs b/Disco.Services/Plugins/Features/RepairProvider/RepairProviderFeature.cs index cb802d16..57baeb20 100644 --- a/Disco.Services/Plugins/Features/RepairProvider/RepairProviderFeature.cs +++ b/Disco.Services/Plugins/Features/RepairProvider/RepairProviderFeature.cs @@ -4,8 +4,6 @@ using Disco.Models.Repository; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web.Mvc; namespace Disco.Services.Plugins.Features.RepairProvider diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/LiteralResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/LiteralResult.cs index 624794cf..9ef62c7d 100644 --- a/Disco.Services/Plugins/Features/UIExtension/Results/LiteralResult.cs +++ b/Disco.Services/Plugins/Features/UIExtension/Results/LiteralResult.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; +using System.Web; using System.Web.Mvc; namespace Disco.Services.Plugins.Features.UIExtension.Results @@ -15,7 +10,7 @@ namespace Disco.Services.Plugins.Features.UIExtension.Results public LiteralResult(PluginFeatureManifest Source, string Content) : base(Source) { - this._content = Content; + _content = Content; } public override void ExecuteResult(WebViewPage page) diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/MultipleResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/MultipleResult.cs index 1663f5d3..04e08705 100644 --- a/Disco.Services/Plugins/Features/UIExtension/Results/MultipleResult.cs +++ b/Disco.Services/Plugins/Features/UIExtension/Results/MultipleResult.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web.Mvc; namespace Disco.Services.Plugins.Features.UIExtension.Results @@ -16,12 +13,12 @@ namespace Disco.Services.Plugins.Features.UIExtension.Results if (Results == null || Results.Length == 0) throw new ArgumentException("At least one result is required", "Results"); - this.results = Results; + results = Results; } public override void ExecuteResult(WebViewPage page) { - foreach (var result in this.results) + foreach (var result in results) { result.ExecuteResult(page); page.WriteLiteral("\n"); diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceCssResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceCssResult.cs index 7aadd20d..e97ff324 100644 --- a/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceCssResult.cs +++ b/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceCssResult.cs @@ -1,12 +1,6 @@ using Disco.Services.Web.Bundles; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web; -using System.Web.Mvc; -using System.Web.Routing; namespace Disco.Services.Plugins.Features.UIExtension.Results { @@ -18,8 +12,8 @@ namespace Disco.Services.Plugins.Features.UIExtension.Results public PluginResourceCssResult(PluginFeatureManifest Source, string Resource) : base(Source) { - this._resource = Resource; - this._resourceUrl = Source.PluginManifest.WebResourceUrl(Resource); + _resource = Resource; + _resourceUrl = Source.PluginManifest.WebResourceUrl(Resource); var deferredBundles = HttpContext.Current.Items[BundleTable.UIExtensionCssKey] as List; if (deferredBundles == null) @@ -27,8 +21,8 @@ namespace Disco.Services.Plugins.Features.UIExtension.Results deferredBundles = new List(); HttpContext.Current.Items[BundleTable.UIExtensionCssKey] = deferredBundles; } - if (!deferredBundles.Contains(this._resourceUrl)) - deferredBundles.Add(this._resourceUrl); + if (!deferredBundles.Contains(_resourceUrl)) + deferredBundles.Add(_resourceUrl); } public override void ExecuteResult(System.Web.Mvc.WebViewPage page) diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceScriptResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceScriptResult.cs index a7c18269..25c4cfb7 100644 --- a/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceScriptResult.cs +++ b/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceScriptResult.cs @@ -1,9 +1,5 @@ using Disco.Services.Web.Bundles; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web; namespace Disco.Services.Plugins.Features.UIExtension.Results @@ -17,11 +13,11 @@ namespace Disco.Services.Plugins.Features.UIExtension.Results public PluginResourceScriptResult(PluginFeatureManifest Source, string Resource, bool PlaceInPageHead) : base(Source) { - this._resource = Resource; - this._resourceUrl = Source.PluginManifest.WebResourceUrl(Resource); - this._placeInPageHead = PlaceInPageHead; + _resource = Resource; + _resourceUrl = Source.PluginManifest.WebResourceUrl(Resource); + _placeInPageHead = PlaceInPageHead; - if (this._placeInPageHead) + if (_placeInPageHead) { var deferredBundles = HttpContext.Current.Items[BundleTable.UIExtensionScriptsKey] as List; if (deferredBundles == null) @@ -29,14 +25,14 @@ namespace Disco.Services.Plugins.Features.UIExtension.Results deferredBundles = new List(); HttpContext.Current.Items[BundleTable.UIExtensionScriptsKey] = deferredBundles; } - if (!deferredBundles.Contains(this._resourceUrl)) - deferredBundles.Add(this._resourceUrl); + if (!deferredBundles.Contains(_resourceUrl)) + deferredBundles.Add(_resourceUrl); } } public override void ExecuteResult(System.Web.Mvc.WebViewPage page) { - if (!this._placeInPageHead) + if (!_placeInPageHead) { page.WriteLiteral("")); + return new LiteralResult(Manifest, string.Concat("")); } protected PluginResourceScriptResult ScriptResource(string Resource, bool PlaceInPageHead) { - return new PluginResourceScriptResult(this.Manifest, Resource, PlaceInPageHead); + return new PluginResourceScriptResult(Manifest, Resource, PlaceInPageHead); } protected PluginResourceCssResult CssResource(string Resource) { - return new PluginResourceCssResult(this.Manifest, Resource); + return new PluginResourceCssResult(Manifest, Resource); } protected MultipleResult Multiple(params UIExtensionResult[] Results) { - return new MultipleResult(this.Manifest, Results); + return new MultipleResult(Manifest, Results); } [Obsolete("Use: PartialCompiled(dynamic Model)")] protected PrecompiledPartialViewResult Partial(Type PartialViewType, object Model = null) { - return new PrecompiledPartialViewResult(this.Manifest, PartialViewType, Model); + return new PrecompiledPartialViewResult(Manifest, PartialViewType, Model); } protected PrecompiledPartialViewResult PartialCompiled(dynamic Model = null) where ViewType : WebViewPage { - return new PrecompiledPartialViewResult(this.Manifest, typeof(ViewType), Model); + return new PrecompiledPartialViewResult(Manifest, typeof(ViewType), Model); } #endregion diff --git a/Disco.Services/Plugins/Features/UIExtension/UIExtensionResult.cs b/Disco.Services/Plugins/Features/UIExtension/UIExtensionResult.cs index 92bb25c5..05c5018e 100644 --- a/Disco.Services/Plugins/Features/UIExtension/UIExtensionResult.cs +++ b/Disco.Services/Plugins/Features/UIExtension/UIExtensionResult.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; -using System.Web.Mvc; +using System.Web.Mvc; namespace Disco.Services.Plugins.Features.UIExtension { diff --git a/Disco.Services/Plugins/Features/UIExtension/UIExtensions.cs b/Disco.Services/Plugins/Features/UIExtension/UIExtensions.cs index b4c3e400..b8dd198d 100644 --- a/Disco.Services/Plugins/Features/UIExtension/UIExtensions.cs +++ b/Disco.Services/Plugins/Features/UIExtension/UIExtensions.cs @@ -1,15 +1,9 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web; using System.Web.Mvc; using Disco.Models.UI; -using Disco.Services.Plugins; -using Disco.Services.Plugins.Features.UIExtension; namespace Disco.Services.Plugins.Features.UIExtension { diff --git a/Disco.Services/Plugins/Features/WarrantyProvider/WarrantyProviderFeature.cs b/Disco.Services/Plugins/Features/WarrantyProvider/WarrantyProviderFeature.cs index b6077d51..7350b69d 100644 --- a/Disco.Services/Plugins/Features/WarrantyProvider/WarrantyProviderFeature.cs +++ b/Disco.Services/Plugins/Features/WarrantyProvider/WarrantyProviderFeature.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web.Mvc; using Disco.Data.Repository; using Disco.Models.BI.Config; @@ -22,7 +20,7 @@ namespace Disco.Services.Plugins.Features.WarrantyProvider public abstract string SubmitJob(DiscoDataContext Database, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription, Dictionary WarrantyProviderProperties); public abstract Type JobDetailsViewType { get; } - public bool JobDetailsSupported { get { return this.JobDetailsViewType != null; } } + public bool JobDetailsSupported { get { return JobDetailsViewType != null; } } public abstract dynamic JobDetailsViewModel(DiscoDataContext Database, Controller controller, Job Job); public static PluginFeatureManifest FindPluginFeature(string PluginIdOrWarrantyProviderId) diff --git a/Disco.Services/Plugins/InstallPluginTask.cs b/Disco.Services/Plugins/InstallPluginTask.cs index 7f73b05b..16e2ea63 100644 --- a/Disco.Services/Plugins/InstallPluginTask.cs +++ b/Disco.Services/Plugins/InstallPluginTask.cs @@ -17,9 +17,9 @@ namespace Disco.Services.Plugins protected override void ExecuteTask() { - string packageUrlPath = (string)this.ExecutionContext.JobDetail.JobDataMap["PackageUrl"]; - string packageFilePath = (string)this.ExecutionContext.JobDetail.JobDataMap["PackageFilePath"]; - bool DeletePackageAfterInstall = (bool)this.ExecutionContext.JobDetail.JobDataMap["DeletePackageAfterInstall"]; + string packageUrlPath = (string)ExecutionContext.JobDetail.JobDataMap["PackageUrl"]; + string packageFilePath = (string)ExecutionContext.JobDetail.JobDataMap["PackageFilePath"]; + bool DeletePackageAfterInstall = (bool)ExecutionContext.JobDetail.JobDataMap["DeletePackageAfterInstall"]; if (!Plugins.PluginsLoaded) throw new InvalidOperationException("Plugins have not been initialized"); diff --git a/Disco.Services/Plugins/InvalidFeatureCategoryTypeException.cs b/Disco.Services/Plugins/InvalidFeatureCategoryTypeException.cs index 8860a20d..b5c94767 100644 --- a/Disco.Services/Plugins/InvalidFeatureCategoryTypeException.cs +++ b/Disco.Services/Plugins/InvalidFeatureCategoryTypeException.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Disco.Services.Plugins { @@ -31,8 +28,8 @@ namespace Disco.Services.Plugins } public InvalidFeatureCategoryTypeException(Type CategoryType, string PluginRequested) { - this._categoryType = CategoryType; - this._pluginRequested = PluginRequested; + _categoryType = CategoryType; + _pluginRequested = PluginRequested; } public override string Message diff --git a/Disco.Services/Plugins/Plugin.cs b/Disco.Services/Plugins/Plugin.cs index 68ad7ac3..6fd14706 100644 --- a/Disco.Services/Plugins/Plugin.cs +++ b/Disco.Services/Plugins/Plugin.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Disco.Data.Repository; using Disco.Services.Tasks; @@ -27,7 +23,7 @@ namespace Disco.Services.Plugins public override sealed string ToString() { - return string.Format("{0} ({1}) - v{2}", this.Manifest.Name, this.Manifest.Id, this.Manifest.Version.ToString(4)); + return string.Format("{0} ({1}) - v{2}", Manifest.Name, Manifest.Id, Manifest.Version.ToString(4)); } } } diff --git a/Disco.Services/Plugins/PluginAttribute.cs b/Disco.Services/Plugins/PluginAttribute.cs index 70c87bdb..54d51ade 100644 --- a/Disco.Services/Plugins/PluginAttribute.cs +++ b/Disco.Services/Plugins/PluginAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Plugins { diff --git a/Disco.Services/Plugins/PluginConfigurationHandler.cs b/Disco.Services/Plugins/PluginConfigurationHandler.cs index 2a003f9a..09e252ec 100644 --- a/Disco.Services/Plugins/PluginConfigurationHandler.cs +++ b/Disco.Services/Plugins/PluginConfigurationHandler.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web.Mvc; using Disco.Data.Repository; @@ -23,12 +19,12 @@ namespace Disco.Services.Plugins [Obsolete("Use: Response(dynamic ViewModel)")] protected PluginConfigurationHandlerGetResponse GetResponse(Type ViewType, dynamic ViewModel = null) { - return new PluginConfigurationHandlerGetResponse(this.Manifest, ViewType, ViewModel); + return new PluginConfigurationHandlerGetResponse(Manifest, ViewType, ViewModel); } protected PluginConfigurationHandlerGetResponse Response(dynamic Model = null) where ViewType : WebViewPage { - return new PluginConfigurationHandlerGetResponse(this.Manifest, typeof(ViewType), Model); + return new PluginConfigurationHandlerGetResponse(Manifest, typeof(ViewType), Model); } public class PluginConfigurationHandlerGetResponse diff --git a/Disco.Services/Plugins/PluginExtensions.cs b/Disco.Services/Plugins/PluginExtensions.cs index 8d5b8294..7b409f12 100644 --- a/Disco.Services/Plugins/PluginExtensions.cs +++ b/Disco.Services/Plugins/PluginExtensions.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Data.Repository; using System.IO; using System.Web.Mvc; using System.Web.WebPages; diff --git a/Disco.Services/Plugins/PluginFeature.cs b/Disco.Services/Plugins/PluginFeature.cs index 35cc8508..1ff8d78b 100644 --- a/Disco.Services/Plugins/PluginFeature.cs +++ b/Disco.Services/Plugins/PluginFeature.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Disco.Data.Repository; namespace Disco.Services.Plugins diff --git a/Disco.Services/Plugins/PluginFeatureAttribute.cs b/Disco.Services/Plugins/PluginFeatureAttribute.cs index 77b90994..b92ec805 100644 --- a/Disco.Services/Plugins/PluginFeatureAttribute.cs +++ b/Disco.Services/Plugins/PluginFeatureAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Plugins { diff --git a/Disco.Services/Plugins/PluginFeatureCategoryAttribute.cs b/Disco.Services/Plugins/PluginFeatureCategoryAttribute.cs index fce13b0d..220bc30c 100644 --- a/Disco.Services/Plugins/PluginFeatureCategoryAttribute.cs +++ b/Disco.Services/Plugins/PluginFeatureCategoryAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Plugins { diff --git a/Disco.Services/Plugins/PluginFeatureManifest.cs b/Disco.Services/Plugins/PluginFeatureManifest.cs index 1f6c7b0d..b954d658 100644 --- a/Disco.Services/Plugins/PluginFeatureManifest.cs +++ b/Disco.Services/Plugins/PluginFeatureManifest.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Disco.Data.Repository; using Newtonsoft.Json; -using System.Reflection; namespace Disco.Services.Plugins { @@ -28,20 +24,20 @@ namespace Disco.Services.Plugins internal bool Initialize(DiscoDataContext Database, PluginManifest pluginManifest) { - this.PluginManifest = pluginManifest; + PluginManifest = pluginManifest; - if (this.Type == null) - this.Type = this.PluginManifest.PluginAssembly.GetType(this.TypeName, true, true); + if (Type == null) + Type = PluginManifest.PluginAssembly.GetType(TypeName, true, true); - if (this.CategoryType == null) - this.CategoryType = Type.GetType(this.CategoryTypeName, true, true); + if (CategoryType == null) + CategoryType = Type.GetType(CategoryTypeName, true, true); - using (var instance = this.CreateInstance()) + using (var instance = CreateInstance()) { instance.Initialize(Database); } - PluginsLog.LogInitializedPluginFeature(this.PluginManifest, this); + PluginsLog.LogInitializedPluginFeature(PluginManifest, this); return true; } @@ -54,14 +50,14 @@ namespace Disco.Services.Plugins } public CategoryType CreateInstance() where CategoryType : PluginFeature { - if (typeof(CategoryType).IsAssignableFrom(this.Type)) + if (typeof(CategoryType).IsAssignableFrom(Type)) { var i = (CategoryType)Activator.CreateInstance(Type); i.Manifest = this; return i; } else - throw new InvalidOperationException(string.Format("The feature [{0}] cannot be cast into type [{1}]", this.Type.Name, typeof(CategoryType).Name)); + throw new InvalidOperationException(string.Format("The feature [{0}] cannot be cast into type [{1}]", Type.Name, typeof(CategoryType).Name)); } /// diff --git a/Disco.Services/Plugins/PluginWebHandler.cs b/Disco.Services/Plugins/PluginWebHandler.cs index 199d5bbb..0db0146a 100644 --- a/Disco.Services/Plugins/PluginWebHandler.cs +++ b/Disco.Services/Plugins/PluginWebHandler.cs @@ -28,23 +28,23 @@ namespace Disco.Services.Plugins public PluginWebHandler() { - this.plugin = new Lazy(new Func(() => new WebHelper(this.HostController.HttpContext, this.Manifest))); + plugin = new Lazy(new Func(() => new WebHelper(HostController.HttpContext, Manifest))); } public void OnActionExecuting() { - this.Database = new DiscoDataContext(); - this.Database.Configuration.LazyLoadingEnabled = false; + Database = new DiscoDataContext(); + Database.Configuration.LazyLoadingEnabled = false; } public abstract ActionResult ExecuteAction(string ActionName); public virtual void Dispose() { - if (this.Database != null) + if (Database != null) { - this.Database.Dispose(); - this.Database = null; + Database.Dispose(); + Database = null; } } @@ -68,7 +68,7 @@ namespace Disco.Services.Plugins public void SetCacheability(TimeSpan CacheDuration) { - var cache = this.HostController.Response.Cache; + var cache = HostController.Response.Cache; cache.SetOmitVaryStar(true); cache.SetExpires(DateTime.Now.Add(CacheDuration)); cache.SetValidUntilExpires(true); @@ -76,7 +76,7 @@ namespace Disco.Services.Plugins } public void SetCacheabilityOff() { - var cache = this.HostController.Response.Cache; + var cache = HostController.Response.Cache; cache.SetExpires(DateTime.Now.AddDays(-1)); cache.SetCacheability(HttpCacheability.NoCache); } @@ -92,37 +92,37 @@ namespace Disco.Services.Plugins { string layoutPath = UseDiscoLayout ? "~/Views/Shared/_Layout.cshtml" : null; - IView v = new PrecompiledMvcView(this.HostController.Request.Path, layoutPath, typeof(ViewType), false, _viewFileNames); + IView v = new PrecompiledMvcView(HostController.Request.Path, layoutPath, typeof(ViewType), false, _viewFileNames); if (Model != null) - this.HostController.ViewData.Model = Model; + HostController.ViewData.Model = Model; - return new ViewResult { View = v, ViewData = this.HostController.ViewData, TempData = this.HostController.TempData }; + return new ViewResult { View = v, ViewData = HostController.ViewData, TempData = HostController.TempData }; } public ActionResult CompiledView(bool UseDiscoLayout) where ViewType : WebViewPage { - return this.CompiledView(null, UseDiscoLayout); + return CompiledView(null, UseDiscoLayout); } public ActionResult CompiledView(object Model) where ViewType : WebViewPage { - return this.CompiledView(Model, true); + return CompiledView(Model, true); } public ActionResult CompiledView() where ViewType : WebViewPage { - return this.CompiledView(false, true); + return CompiledView(false, true); } public ActionResult CompiledPartialView(object Model) where ViewType : WebViewPage { - IView v = new PrecompiledMvcView(this.HostController.Request.Path, typeof(ViewType), false, _viewFileNames); + IView v = new PrecompiledMvcView(HostController.Request.Path, typeof(ViewType), false, _viewFileNames); if (Model != null) - this.HostController.ViewData.Model = Model; + HostController.ViewData.Model = Model; - return new PartialViewResult { View = v, ViewData = this.HostController.ViewData, TempData = this.HostController.TempData }; + return new PartialViewResult { View = v, ViewData = HostController.ViewData, TempData = HostController.TempData }; } public ActionResult CompiledPartialView() where ViewType : WebViewPage { - return this.CompiledView(); + return CompiledView(); } [Obsolete("Use Generic Methods")] @@ -130,42 +130,42 @@ namespace Disco.Services.Plugins { string layoutPath = UseDiscoLayout ? "~/Views/Shared/_Layout.cshtml" : null; - IView v = new PrecompiledMvcView(this.HostController.Request.Path, layoutPath, CompiledViewType, false, _viewFileNames); + IView v = new PrecompiledMvcView(HostController.Request.Path, layoutPath, CompiledViewType, false, _viewFileNames); if (Model != null) - this.HostController.ViewData.Model = Model; + HostController.ViewData.Model = Model; - return new ViewResult { View = v, ViewData = this.HostController.ViewData, TempData = this.HostController.TempData }; + return new ViewResult { View = v, ViewData = HostController.ViewData, TempData = HostController.TempData }; } [Obsolete("Use Generic Methods")] public ActionResult CompiledView(Type CompiledViewType, bool UseDiscoLayout) { - return this.CompiledView(CompiledViewType, null, UseDiscoLayout); + return CompiledView(CompiledViewType, null, UseDiscoLayout); } [Obsolete("Use Generic Methods")] public ActionResult CompiledView(Type CompiledViewType, object Model) { - return this.CompiledView(CompiledViewType, Model, true); + return CompiledView(CompiledViewType, Model, true); } [Obsolete("Use Generic Methods")] public ActionResult CompiledView(Type CompiledViewType) { - return this.CompiledView(CompiledViewType, false, true); + return CompiledView(CompiledViewType, false, true); } [Obsolete("Use Generic Methods")] public ActionResult CompiledPartialView(Type PartialCompiledViewType, object Model) { - IView v = new PrecompiledMvcView(this.HostController.Request.Path, PartialCompiledViewType, false, _viewFileNames); + IView v = new PrecompiledMvcView(HostController.Request.Path, PartialCompiledViewType, false, _viewFileNames); if (Model != null) - this.HostController.ViewData.Model = Model; + HostController.ViewData.Model = Model; - return new PartialViewResult { View = v, ViewData = this.HostController.ViewData, TempData = this.HostController.TempData }; + return new PartialViewResult { View = v, ViewData = HostController.ViewData, TempData = HostController.TempData }; } [Obsolete("Use Generic Methods")] public ActionResult CompiledPartialView(Type PartialCompiledViewType) { - return this.CompiledView(PartialCompiledViewType, null); + return CompiledView(PartialCompiledViewType, null); } #endregion @@ -176,11 +176,11 @@ namespace Disco.Services.Plugins } public ActionResult Content(string content, string contentType) { - return this.Content(content, null, null); + return Content(content, null, null); } public ActionResult Content(string content) { - return this.Content(content, null); + return Content(content, null); } #endregion @@ -194,7 +194,7 @@ namespace Disco.Services.Plugins #region File public ActionResult File(Stream fileStream, string contentType) { - return this.File(fileStream, contentType, null); + return File(fileStream, contentType, null); } public ActionResult File(Stream fileStream, string contentType, string fileDownloadName) { @@ -202,7 +202,7 @@ namespace Disco.Services.Plugins } public ActionResult File(byte[] fileContents, string contentType) { - return this.File(fileContents, contentType, null); + return File(fileContents, contentType, null); } public ActionResult File(byte[] fileContents, string contentType, string fileDownloadName) { @@ -217,7 +217,7 @@ namespace Disco.Services.Plugins } public ActionResult HttpNotFound() { - return this.HttpNotFound(null); + return HttpNotFound(null); } #endregion @@ -227,7 +227,7 @@ namespace Disco.Services.Plugins if (string.IsNullOrEmpty(SessionId)) throw new ArgumentNullException(SessionId); - return this.RedirectToAction("TaskStatus", "Logging", "Config", new { id = SessionId }); + return RedirectToAction("TaskStatus", "Logging", "Config", new { id = SessionId }); } public ActionResult Redirect(string url) { @@ -245,7 +245,7 @@ namespace Disco.Services.Plugins } public ActionResult RedirectToPluginConfiguration() { - var routeValues = new RouteValueDictionary(new { PluginId = this.Manifest.Id }); + var routeValues = new RouteValueDictionary(new { PluginId = Manifest.Id }); return new RedirectToRouteResult("Config_Plugins_Configure", routeValues); } public ActionResult RedirectToPluginAction(string PluginAction) @@ -253,17 +253,17 @@ namespace Disco.Services.Plugins if (string.IsNullOrEmpty(PluginAction)) throw new ArgumentNullException("PluginAction"); - var routeValues = new RouteValueDictionary(new { PluginId = this.Manifest.Id, PluginAction = PluginAction }); - string pluginActionUrl = UrlHelper.GenerateUrl("Plugin", null, null, routeValues, RouteTable.Routes, this.HostController.Request.RequestContext, false); + var routeValues = new RouteValueDictionary(new { PluginId = Manifest.Id, PluginAction = PluginAction }); + string pluginActionUrl = UrlHelper.GenerateUrl("Plugin", null, null, routeValues, RouteTable.Routes, HostController.Request.RequestContext, false); return new RedirectResult(pluginActionUrl, false); } public ActionResult RedirectToPluginResource(string Resource, bool? Download) { - var resourcePath = this.Manifest.WebResourcePath(Resource); + var resourcePath = Manifest.WebResourcePath(Resource); - var routeValues = new RouteValueDictionary(new { PluginId = this.Manifest.Id, res = Resource }); - string pluginActionUrl = UrlHelper.GenerateUrl("Plugin_Resources", null, null, routeValues, RouteTable.Routes, this.HostController.Request.RequestContext, false); + var routeValues = new RouteValueDictionary(new { PluginId = Manifest.Id, res = Resource }); + string pluginActionUrl = UrlHelper.GenerateUrl("Plugin_Resources", null, null, routeValues, RouteTable.Routes, HostController.Request.RequestContext, false); pluginActionUrl += string.Format("?v={0}", resourcePath.Item2); @@ -276,7 +276,7 @@ namespace Disco.Services.Plugins } public ActionResult RedirectToPluginResource(string Resource) { - return this.RedirectToPluginResource(Resource, null); + return RedirectToPluginResource(Resource, null); } public ActionResult RedirectToRoute(string routeName, object routeValues) { @@ -290,7 +290,7 @@ namespace Disco.Services.Plugins } public ActionResult RedirectToRoute(string routeName) { - return this.RedirectToRoute(routeName, null); + return RedirectToRoute(routeName, null); } public ActionResult RedirectToAction(string actionName, string controller, string areaName, object routeValues) { @@ -309,27 +309,27 @@ namespace Disco.Services.Plugins } public ActionResult RedirectToAction(string actionName, string controller, string areaName) { - return this.RedirectToAction(actionName, controller, areaName, null); + return RedirectToAction(actionName, controller, areaName, null); } public ActionResult RedirectToAction(string actionName, string controller, object routeValues) { - return this.RedirectToAction(actionName, controller, null, routeValues); + return RedirectToAction(actionName, controller, null, routeValues); } public ActionResult RedirectToAction(string actionName, string controller) { - return this.RedirectToAction(actionName, controller, null, null); + return RedirectToAction(actionName, controller, null, null); } public ActionResult RedirectToDiscoJob(int jobId) { - return this.RedirectToAction("Show", "Job", null, new { id = jobId.ToString() }); + return RedirectToAction("Show", "Job", null, new { id = jobId.ToString() }); } public ActionResult RedirectToDiscoDevice(string DeviceSerialNumber) { - return this.RedirectToAction("Show", "Device", null, new { id = DeviceSerialNumber }); + return RedirectToAction("Show", "Device", null, new { id = DeviceSerialNumber }); } public ActionResult RedirectToDiscoUser(string UserId) { - return this.RedirectToAction("Show", "User", null, new { id = UserId }); + return RedirectToAction("Show", "User", null, new { id = UserId }); } #endregion diff --git a/Disco.Services/Plugins/PluginWebHandlerController.cs b/Disco.Services/Plugins/PluginWebHandlerController.cs index be797df1..e06d7fd3 100644 --- a/Disco.Services/Plugins/PluginWebHandlerController.cs +++ b/Disco.Services/Plugins/PluginWebHandlerController.cs @@ -3,8 +3,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Web.Mvc; namespace Disco.Services.Plugins @@ -14,11 +12,11 @@ namespace Disco.Services.Plugins public override ActionResult ExecuteAction(string ActionName) { - var handlerType = this.GetType(); + var handlerType = GetType(); var methodDescriptor = FindControllerMethod(Manifest, handlerType, ActionName); if (methodDescriptor == null) - return this.HttpNotFound("Unknown Plugin Method"); + return HttpNotFound("Unknown Plugin Method"); // Authorize Method if (methodDescriptor.Authorizers.Length > 0) @@ -36,7 +34,7 @@ namespace Disco.Services.Plugins } } - var methodParams = BuildMethodParameters(Manifest, handlerType, methodDescriptor.MethodInfo, ActionName, this.HostController); + var methodParams = BuildMethodParameters(Manifest, handlerType, methodDescriptor.MethodInfo, ActionName, HostController); return (ActionResult)methodDescriptor.MethodInfo.Invoke(this, methodParams); } diff --git a/Disco.Services/Plugins/PluginWebViewPage.cs b/Disco.Services/Plugins/PluginWebViewPage.cs index 57671dc7..837fcce8 100644 --- a/Disco.Services/Plugins/PluginWebViewPage.cs +++ b/Disco.Services/Plugins/PluginWebViewPage.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Plugins { @@ -21,14 +17,14 @@ namespace Disco.Services.Plugins public PluginWebViewPage() { - var self = this.GetType(); - this.Manifest = Plugins.GetPlugin(self.Assembly); + var self = GetType(); + Manifest = Plugins.GetPlugin(self.Assembly); - this._plugin = new Lazy>(() => { - if (this.Context == null) + _plugin = new Lazy>(() => { + if (Context == null) throw new InvalidOperationException("The WebViewPage Context property is not initialized"); - return new WebPageHelper(this, this.Manifest); + return new WebPageHelper(this, Manifest); }); } } diff --git a/Disco.Services/Plugins/PluginsLog.cs b/Disco.Services/Plugins/PluginsLog.cs index 3a986085..aa615ac0 100644 --- a/Disco.Services/Plugins/PluginsLog.cs +++ b/Disco.Services/Plugins/PluginsLog.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using Disco.Services.Logging; using Disco.Services.Logging.Models; using System.Reflection; diff --git a/Disco.Services/Plugins/UnknownPluginException.cs b/Disco.Services/Plugins/UnknownPluginException.cs index 746cf9f3..65ee23ac 100644 --- a/Disco.Services/Plugins/UnknownPluginException.cs +++ b/Disco.Services/Plugins/UnknownPluginException.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Disco.Services.Plugins { @@ -19,11 +16,11 @@ namespace Disco.Services.Plugins public UnknownPluginException(string PluginRequested) { - this._pluginRequested = PluginRequested; + _pluginRequested = PluginRequested; } public UnknownPluginException(string PluginRequested, string Message) : base(Message) { - this._pluginRequested = PluginRequested; + _pluginRequested = PluginRequested; } public override string Message diff --git a/Disco.Services/Plugins/UpdatePluginTask.cs b/Disco.Services/Plugins/UpdatePluginTask.cs index cb7020f2..2954dd72 100644 --- a/Disco.Services/Plugins/UpdatePluginTask.cs +++ b/Disco.Services/Plugins/UpdatePluginTask.cs @@ -18,8 +18,8 @@ namespace Disco.Services.Plugins protected override void ExecuteTask() { - string pluginId = (string)this.ExecutionContext.JobDetail.JobDataMap["PluginId"]; - string packageFilePath = (string)this.ExecutionContext.JobDetail.JobDataMap["PackageFilePath"]; + string pluginId = (string)ExecutionContext.JobDetail.JobDataMap["PluginId"]; + string packageFilePath = (string)ExecutionContext.JobDetail.JobDataMap["PackageFilePath"]; PluginLibraryManifestV2 libraryManifest; PluginLibraryIncompatibility libraryIncompatibility; @@ -82,13 +82,13 @@ namespace Disco.Services.Plugins if (updatePlugins == null || updatePlugins.Count == 0) { - this.Status.Finished("No plugins to update...", "/Config/Plugins"); + Status.Finished("No plugins to update...", "/Config/Plugins"); return; } - ExecuteTaskInternal(this.Status, pluginPackagesLocation, updatePlugins); + ExecuteTaskInternal(Status, pluginPackagesLocation, updatePlugins); - this.Status.Finished("Restarting Disco, please wait...", "/Config/Plugins"); + Status.Finished("Restarting Disco, please wait...", "/Config/Plugins"); Plugins.RestartApp(2500); } diff --git a/Disco.Services/Plugins/UpdatePluginsAfterDiscoUpdateTask.cs b/Disco.Services/Plugins/UpdatePluginsAfterDiscoUpdateTask.cs index 1b6b01e2..d6074d70 100644 --- a/Disco.Services/Plugins/UpdatePluginsAfterDiscoUpdateTask.cs +++ b/Disco.Services/Plugins/UpdatePluginsAfterDiscoUpdateTask.cs @@ -14,26 +14,26 @@ namespace Disco.Services.Plugins protected override void ExecuteTask() { - this.Status.UpdateStatus(0, "Updating plugins after Disco update", "Starting, please wait..."); + Status.UpdateStatus(0, "Updating plugins after Disco update", "Starting, please wait..."); // Wait for App to Load (10 Seconds) for (int i = 0; i < 10; i++) { - this.Status.UpdateStatus(10 * i); + Status.UpdateStatus(10 * i); System.Threading.Thread.Sleep(1000); } // Update Catalogue using (DiscoDataContext database = new DiscoDataContext()) { - PluginLibrary.UpdateManifest(database, this.Status); + PluginLibrary.UpdateManifest(database, Status); } // Update all Plugins - UpdatePluginTask.UpdateOffline(this.Status); + UpdatePluginTask.UpdateOffline(Status); // Restart - this.Status.Finished("Restarting Disco, please wait...", "/"); + Status.Finished("Restarting Disco, please wait...", "/"); Plugins.RestartApp(2500); } diff --git a/Disco.Services/Plugins/WebHelper.cs b/Disco.Services/Plugins/WebHelper.cs index fe10301c..e8ec5c7c 100644 --- a/Disco.Services/Plugins/WebHelper.cs +++ b/Disco.Services/Plugins/WebHelper.cs @@ -1,11 +1,4 @@ -using Disco.Services.Web.Bundles; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using System.Web; using System.Web.Mvc; using System.Web.Routing; @@ -25,11 +18,11 @@ namespace Disco.Services.Plugins public void IncludeStyleSheet(string Resource) { - Context.IncludeStyleSheetResource(Resource, this.Manifest); + Context.IncludeStyleSheetResource(Resource, Manifest); } public void IncludeJavaScript(string Resource) { - Context.IncludeScriptResource(Resource, this.Manifest); + Context.IncludeScriptResource(Resource, Manifest); } #region Urls diff --git a/Disco.Services/Plugins/WebPageHelper.cs b/Disco.Services/Plugins/WebPageHelper.cs index 25a22cb8..444fbb41 100644 --- a/Disco.Services/Plugins/WebPageHelper.cs +++ b/Disco.Services/Plugins/WebPageHelper.cs @@ -2,9 +2,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Html; diff --git a/Disco.Services/Properties/AssemblyInfo.cs b/Disco.Services/Properties/AssemblyInfo.cs index e5723d4e..f8c1e4b1 100644 --- a/Disco.Services/Properties/AssemblyInfo.cs +++ b/Disco.Services/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.2.16326.0500")] -[assembly: AssemblyFileVersion("2.2.16326.0500")] \ No newline at end of file +[assembly: AssemblyVersion("2.2.17084.0414")] +[assembly: AssemblyFileVersion("2.2.17084.0414")] \ No newline at end of file diff --git a/Disco.Services/Searching/Search.cs b/Disco.Services/Searching/Search.cs index 77c4b9e7..8e10e4f5 100644 --- a/Disco.Services/Searching/Search.cs +++ b/Disco.Services/Searching/Search.cs @@ -7,8 +7,6 @@ using Disco.Services.Users; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Searching { diff --git a/Disco.Services/Tasks/IScheduledTaskStatus.cs b/Disco.Services/Tasks/IScheduledTaskStatus.cs index 6a01899f..eca25517 100644 --- a/Disco.Services/Tasks/IScheduledTaskStatus.cs +++ b/Disco.Services/Tasks/IScheduledTaskStatus.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Tasks { diff --git a/Disco.Services/Tasks/ScheduledTask.cs b/Disco.Services/Tasks/ScheduledTask.cs index 7ab4f83b..6762273d 100644 --- a/Disco.Services/Tasks/ScheduledTask.cs +++ b/Disco.Services/Tasks/ScheduledTask.cs @@ -64,43 +64,43 @@ namespace Disco.Services.Tasks public void Execute(IJobExecutionContext context) { // Task Status - this.ExecutionContext = context; - this.Status = context.GetDiscoScheduledTaskStatus(); - if (this.Status == null) - this.Status = ScheduledTasks.RegisterTask(this); + ExecutionContext = context; + Status = context.GetDiscoScheduledTaskStatus(); + if (Status == null) + Status = ScheduledTasks.RegisterTask(this); try { - if (!this.LogExceptionsOnly) - ScheduledTasksLog.LogScheduledTaskExecuted(this.Status.TaskName, this.Status.SessionId); + if (!LogExceptionsOnly) + ScheduledTasksLog.LogScheduledTaskExecuted(Status.TaskName, Status.SessionId); - this.Status.Started(); - this.ExecuteTask(); + Status.Started(); + ExecuteTask(); } catch (Exception ex) { - ScheduledTasksLog.LogScheduledTaskException(this.Status.TaskName, this.Status.SessionId, this.GetType(), ex); - this.Status.SetTaskException(ex); + ScheduledTasksLog.LogScheduledTaskException(Status.TaskName, Status.SessionId, GetType(), ex); + Status.SetTaskException(ex); } finally { - if (!this.Status.FinishedTimestamp.HasValue) // Scheduled Task Didn't Trigger 'Finished' - this.Status.Finished(); + if (!Status.FinishedTimestamp.HasValue) // Scheduled Task Didn't Trigger 'Finished' + Status.Finished(); - this.Status.Finally(); + Status.Finally(); var nextTriggerTime = context.NextFireTimeUtc; if (nextTriggerTime.HasValue) { // Continuous Task - this.Status.Reset(nextTriggerTime.Value.LocalDateTime); + Status.Reset(nextTriggerTime.Value.LocalDateTime); } else { this.UnregisterTask(); } - if (!this.LogExceptionsOnly) - ScheduledTasksLog.LogScheduledTaskFinished(this.Status.TaskName, this.Status.SessionId); + if (!LogExceptionsOnly) + ScheduledTasksLog.LogScheduledTaskFinished(Status.TaskName, Status.SessionId); } } } diff --git a/Disco.Services/Tasks/ScheduledTaskMockStatus.cs b/Disco.Services/Tasks/ScheduledTaskMockStatus.cs index a55812f6..3d7f2492 100644 --- a/Disco.Services/Tasks/ScheduledTaskMockStatus.cs +++ b/Disco.Services/Tasks/ScheduledTaskMockStatus.cs @@ -31,7 +31,7 @@ namespace Disco.Services.Tasks private byte CalculateProgressValue(byte Progress) { - return (byte)((Progress * this.ProgressMultiplier) + this.ProgressOffset); + return (byte)((Progress * ProgressMultiplier) + ProgressOffset); } public void UpdateStatus(byte Progress) @@ -80,11 +80,11 @@ namespace Disco.Services.Tasks } public void Finished() { - Finished(this.FinishedMessage, this.FinishedUrl); + Finished(FinishedMessage, FinishedUrl); } public void Finished(string FinishedMessage) { - Finished(FinishedMessage, this.FinishedUrl); + Finished(FinishedMessage, FinishedUrl); } public void Finished(string FinishedMessage, string FinishedUrl) { diff --git a/Disco.Services/Tasks/ScheduledTaskStatus.cs b/Disco.Services/Tasks/ScheduledTaskStatus.cs index 39645fc8..b08bcd6f 100644 --- a/Disco.Services/Tasks/ScheduledTaskStatus.cs +++ b/Disco.Services/Tasks/ScheduledTaskStatus.cs @@ -1,10 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Quartz; -using System.Web.Script.Serialization; -using System.Threading; using System.Threading.Tasks; namespace Disco.Services.Tasks @@ -44,33 +39,33 @@ namespace Disco.Services.Tasks #region Properties - public string SessionId { get { return this._sessionId; } } - public string TriggerKey { get { return this._triggerKey; } } - public string TaskName { get { return this._taskName; } } - public Type TaskType { get { return this._taskType; } } - public bool IsSilent { get { return this._isSilent; } } + public string SessionId { get { return _sessionId; } } + public string TriggerKey { get { return _triggerKey; } } + public string TaskName { get { return _taskName; } } + public Type TaskType { get { return _taskType; } } + public bool IsSilent { get { return _isSilent; } } - public byte Progress { get { return this._progress; } } - public string CurrentProcess { get { return this._currentProcess; } } - public string CurrentDescription { get { return this._currentDescription; } } + public byte Progress { get { return _progress; } } + public string CurrentProcess { get { return _currentProcess; } } + public string CurrentDescription { get { return _currentDescription; } } public bool IgnoreCurrentProcessChanges { get; set; } public bool IgnoreCurrentDescription { get; set; } public double ProgressMultiplier { get; set; } public byte ProgressOffset { get; set; } - public Exception TaskException { get { return this._taskException; } } - public bool CancelSupported { get { return this._cancelSupported; } } - public bool IsCanceling { get { return this._isCanceling; } } + public Exception TaskException { get { return _taskException; } } + public bool CancelSupported { get { return _cancelSupported; } } + public bool IsCanceling { get { return _isCanceling; } } - public DateTime? StartedTimestamp { get { return this._startedTimestamp; } } - public DateTime? FinishedTimestamp { get { return this._finishedTimestamp; } } - public DateTime? NextScheduledTimestamp { get { return this._nextScheduledTimestamp; } } + public DateTime? StartedTimestamp { get { return _startedTimestamp; } } + public DateTime? FinishedTimestamp { get { return _finishedTimestamp; } } + public DateTime? NextScheduledTimestamp { get { return _nextScheduledTimestamp; } } - public string FinishedMessage { get { return this._finishedMessage; } } - public string FinishedUrl { get { return this._finishedUrl; } } + public string FinishedMessage { get { return _finishedMessage; } } + public string FinishedUrl { get { return _finishedUrl; } } - public int StatusVersion { get { return this._statusVersion; } } + public int StatusVersion { get { return _statusVersion; } } public bool IsRunning { @@ -93,22 +88,22 @@ namespace Disco.Services.Tasks public ScheduledTaskStatus(ScheduledTask Task, string SessionId, string TriggerKey, string FinishedUrl = null) { - this._taskName = Task.TaskName; - this._taskType = Task.GetType(); - this._tcs = new TaskCompletionSource(); + _taskName = Task.TaskName; + _taskType = Task.GetType(); + _tcs = new TaskCompletionSource(); - this._sessionId = SessionId; - this._triggerKey = TriggerKey; - this._cancelInitiallySupported = Task.CancelInitiallySupported; - this._cancelSupported = this._cancelInitiallySupported; + _sessionId = SessionId; + _triggerKey = TriggerKey; + _cancelInitiallySupported = Task.CancelInitiallySupported; + _cancelSupported = _cancelInitiallySupported; - this._finishedUrl = FinishedUrl; + _finishedUrl = FinishedUrl; - this._currentProcess = "Scheduled"; - this._currentDescription = "Scheduled Task for Execution"; + _currentProcess = "Scheduled"; + _currentDescription = "Scheduled Task for Execution"; - this.ProgressMultiplier = 1; - this._progress = 0; + ProgressMultiplier = 1; + _progress = 0; } public void LogWarning(string Message) @@ -124,13 +119,13 @@ namespace Disco.Services.Tasks #region Progress Actions private byte CalculateProgressValue(byte Progress) { - return (byte)((Progress * this.ProgressMultiplier) + this.ProgressOffset); + return (byte)((Progress * ProgressMultiplier) + ProgressOffset); } public void UpdateStatus(byte Progress) { - this._progress = CalculateProgressValue(Progress); - UpdateTriggered("Progress", this._progress); + _progress = CalculateProgressValue(Progress); + UpdateTriggered("Progress", _progress); } public void UpdateStatus(double Progress) { @@ -140,13 +135,13 @@ namespace Disco.Services.Tasks { if (!IgnoreCurrentDescription) { - this._currentDescription = CurrentDescription; - UpdateTriggered("CurrentDescription", this._currentDescription); + _currentDescription = CurrentDescription; + UpdateTriggered("CurrentDescription", _currentDescription); } } public void UpdateStatus(byte Progress, string CurrentDescription) { - this._progress = CalculateProgressValue(Progress); + _progress = CalculateProgressValue(Progress); var changedProperties = new List() { new ChangedItem("Progress", Progress) @@ -154,7 +149,7 @@ namespace Disco.Services.Tasks if (!IgnoreCurrentDescription) { - this._currentDescription = CurrentDescription; + _currentDescription = CurrentDescription; changedProperties.Add(new ChangedItem("CurrentDescription", CurrentDescription)); } @@ -166,7 +161,7 @@ namespace Disco.Services.Tasks } public void UpdateStatus(byte Progress, string CurrentProcess, string CurrentDescription) { - this._progress = CalculateProgressValue(Progress); + _progress = CalculateProgressValue(Progress); var changedProperties = new List() { new ChangedItem("Progress", Progress) @@ -174,12 +169,12 @@ namespace Disco.Services.Tasks if (!IgnoreCurrentProcessChanges) { - this._currentProcess = CurrentProcess; + _currentProcess = CurrentProcess; changedProperties.Add(new ChangedItem("CurrentProcess", CurrentProcess)); } if (!IgnoreCurrentDescription) { - this._currentDescription = CurrentDescription; + _currentDescription = CurrentDescription; changedProperties.Add(new ChangedItem("CurrentDescription", CurrentDescription)); } @@ -194,13 +189,13 @@ namespace Disco.Services.Tasks #region State Actions public bool Canceled() { - if (!this._isCanceling) + if (!_isCanceling) { if (_cancelSupported) { // Cancelling - this._isCanceling = true; + _isCanceling = true; UpdateTriggered("IsCancelling", true); - if (this.Canceling != null) + if (Canceling != null) Canceling(this); return true; } @@ -216,46 +211,46 @@ namespace Disco.Services.Tasks } public void SetCancelSupported(bool CancelSupported) { - if (this._cancelSupported != CancelSupported) + if (_cancelSupported != CancelSupported) { - this._cancelSupported = CancelSupported; + _cancelSupported = CancelSupported; UpdateTriggered("CancelSupported", CancelSupported); } } public void SetTaskException(Exception TaskException) { - if (this._taskException != TaskException) + if (_taskException != TaskException) { - this._taskException = TaskException; - UpdateTriggered("TaskExceptionMessage", (this._taskException == null ? null : this._taskException.Message)); + _taskException = TaskException; + UpdateTriggered("TaskExceptionMessage", (_taskException == null ? null : _taskException.Message)); } } public void SetIsSilent(bool IsSilent) { - if (this._isSilent != IsSilent) - this._isSilent = IsSilent; + if (_isSilent != IsSilent) + _isSilent = IsSilent; } public void SetFinishedUrl(string FinishedUrl) { - if (this._finishedUrl != FinishedUrl) + if (_finishedUrl != FinishedUrl) { - this._finishedUrl = FinishedUrl; + _finishedUrl = FinishedUrl; UpdateTriggered("FinishedUrl", FinishedUrl); } } public void SetFinishedMessage(string FinishedMessage) { - if (this._finishedMessage != FinishedMessage) + if (_finishedMessage != FinishedMessage) { - this._finishedMessage = FinishedMessage; + _finishedMessage = FinishedMessage; UpdateTriggered("FinishedMessage", FinishedMessage); } } public void SetNextScheduledTimestamp(DateTime? NextScheduledTimestamp) { - if (this._nextScheduledTimestamp != NextScheduledTimestamp) + if (_nextScheduledTimestamp != NextScheduledTimestamp) { - this._nextScheduledTimestamp = NextScheduledTimestamp; + _nextScheduledTimestamp = NextScheduledTimestamp; UpdateTriggered("NextScheduledTimestamp", NextScheduledTimestamp); } } @@ -264,163 +259,163 @@ namespace Disco.Services.Tasks var changedProperties = new List(); // Change StartedTimestamp - this._startedTimestamp = DateTime.Now; - changedProperties.Add(new ChangedItem("StartedTimestamp", this.StartedTimestamp)); + _startedTimestamp = DateTime.Now; + changedProperties.Add(new ChangedItem("StartedTimestamp", StartedTimestamp)); - if (this._finishedTimestamp != null) + if (_finishedTimestamp != null) { - this._finishedTimestamp = null; - changedProperties.Add(new ChangedItem("FinishedTimestamp", this._finishedTimestamp)); + _finishedTimestamp = null; + changedProperties.Add(new ChangedItem("FinishedTimestamp", _finishedTimestamp)); } - if (this._nextScheduledTimestamp != null) + if (_nextScheduledTimestamp != null) { - this._nextScheduledTimestamp = null; - changedProperties.Add(new ChangedItem("NextScheduledTimestamp", this._nextScheduledTimestamp)); + _nextScheduledTimestamp = null; + changedProperties.Add(new ChangedItem("NextScheduledTimestamp", _nextScheduledTimestamp)); } - changedProperties.Add(new ChangedItem("IsRunning", this.IsRunning)); + changedProperties.Add(new ChangedItem("IsRunning", IsRunning)); - if (this._progress != 0) + if (_progress != 0) { - this._progress = 0; - changedProperties.Add(new ChangedItem("Progress", this._progress)); + _progress = 0; + changedProperties.Add(new ChangedItem("Progress", _progress)); } - if (this._currentProcess != "Starting") + if (_currentProcess != "Starting") { - this._currentProcess = "Starting"; - changedProperties.Add(new ChangedItem("CurrentProcess", this._currentProcess)); + _currentProcess = "Starting"; + changedProperties.Add(new ChangedItem("CurrentProcess", _currentProcess)); } - if (this._currentDescription != "Initializing Task for Execution") + if (_currentDescription != "Initializing Task for Execution") { - this._currentDescription = "Initializing Task for Execution"; - changedProperties.Add(new ChangedItem("CurrentDescription", this._currentDescription)); + _currentDescription = "Initializing Task for Execution"; + changedProperties.Add(new ChangedItem("CurrentDescription", _currentDescription)); } - if (this._taskException != null) + if (_taskException != null) { - this._taskException = null; - changedProperties.Add(new ChangedItem("TaskExceptionMessage", (this._taskException == null ? null : this._taskException.Message))); + _taskException = null; + changedProperties.Add(new ChangedItem("TaskExceptionMessage", (_taskException == null ? null : _taskException.Message))); } - if (this._cancelSupported != this._cancelInitiallySupported) + if (_cancelSupported != _cancelInitiallySupported) { - this._cancelSupported = this._cancelInitiallySupported; - changedProperties.Add(new ChangedItem("CancelSupported", this._cancelSupported)); + _cancelSupported = _cancelInitiallySupported; + changedProperties.Add(new ChangedItem("CancelSupported", _cancelSupported)); } - if (this._isCanceling) + if (_isCanceling) { - this._isCanceling = false; - changedProperties.Add(new ChangedItem("IsCanceling", this._isCanceling)); + _isCanceling = false; + changedProperties.Add(new ChangedItem("IsCanceling", _isCanceling)); } UpdateTriggered(changedProperties.ToArray()); } public void Finished() { - Finished(this._finishedMessage, this._finishedUrl); + Finished(_finishedMessage, _finishedUrl); } public void Finished(string FinishedMessage) { - Finished(FinishedMessage, this._finishedUrl); + Finished(FinishedMessage, _finishedUrl); } public void Finished(string FinishedMessage, string FinishedUrl) { var changedProperties = new List(); - this._finishedTimestamp = DateTime.Now; - changedProperties.Add(new ChangedItem("FinishedTimestamp", this._finishedTimestamp)); - changedProperties.Add(new ChangedItem("IsRunning", this.IsRunning)); + _finishedTimestamp = DateTime.Now; + changedProperties.Add(new ChangedItem("FinishedTimestamp", _finishedTimestamp)); + changedProperties.Add(new ChangedItem("IsRunning", IsRunning)); - if (FinishedMessage != this._finishedMessage) + if (FinishedMessage != _finishedMessage) { - this._finishedMessage = FinishedMessage; - changedProperties.Add(new ChangedItem("FinishedMessage", this._finishedMessage)); + _finishedMessage = FinishedMessage; + changedProperties.Add(new ChangedItem("FinishedMessage", _finishedMessage)); } - if (FinishedUrl != this._finishedUrl) + if (FinishedUrl != _finishedUrl) { - this._finishedUrl = FinishedUrl; - changedProperties.Add(new ChangedItem("FinishedUrl", this._finishedUrl)); + _finishedUrl = FinishedUrl; + changedProperties.Add(new ChangedItem("FinishedUrl", _finishedUrl)); } - if (this._isCanceling) + if (_isCanceling) { - this._isCanceling = false; - changedProperties.Add(new ChangedItem("IsCanceling", this._isCanceling)); + _isCanceling = false; + changedProperties.Add(new ChangedItem("IsCanceling", _isCanceling)); } UpdateTriggered(changedProperties.ToArray()); } internal void Finally() { - this._tcs.SetResult(this); + _tcs.SetResult(this); } public void Reset(DateTime? NextScheduledTimestamp) { - if (this._tcs != null) - this._tcs.Task.Dispose(); - this._tcs = new TaskCompletionSource(); + if (_tcs != null) + _tcs.Task.Dispose(); + _tcs = new TaskCompletionSource(); var changedProperties = new List(); - if (this._nextScheduledTimestamp != NextScheduledTimestamp) + if (_nextScheduledTimestamp != NextScheduledTimestamp) { - this._nextScheduledTimestamp = NextScheduledTimestamp; - changedProperties.Add(new ChangedItem("NextScheduledTimestamp", this._nextScheduledTimestamp)); + _nextScheduledTimestamp = NextScheduledTimestamp; + changedProperties.Add(new ChangedItem("NextScheduledTimestamp", _nextScheduledTimestamp)); } - if (this._startedTimestamp != null) + if (_startedTimestamp != null) { - this._startedTimestamp = null; - changedProperties.Add(new ChangedItem("StartedTimestamp", this._startedTimestamp)); + _startedTimestamp = null; + changedProperties.Add(new ChangedItem("StartedTimestamp", _startedTimestamp)); } - if (this._finishedTimestamp != null) + if (_finishedTimestamp != null) { - this._finishedTimestamp = null; - changedProperties.Add(new ChangedItem("FinishedTimestamp", this._finishedTimestamp)); + _finishedTimestamp = null; + changedProperties.Add(new ChangedItem("FinishedTimestamp", _finishedTimestamp)); } - if (this._finishedMessage != null) + if (_finishedMessage != null) { - this._finishedMessage = null; - changedProperties.Add(new ChangedItem("FinishedMessage", this._finishedMessage)); + _finishedMessage = null; + changedProperties.Add(new ChangedItem("FinishedMessage", _finishedMessage)); } - if (this._finishedUrl != null) + if (_finishedUrl != null) { - this._finishedUrl = null; - changedProperties.Add(new ChangedItem("FinishedUrl", this._finishedUrl)); + _finishedUrl = null; + changedProperties.Add(new ChangedItem("FinishedUrl", _finishedUrl)); } - if (this._progress != 0) + if (_progress != 0) { - this._progress = 0; - changedProperties.Add(new ChangedItem("Progress", this._progress)); + _progress = 0; + changedProperties.Add(new ChangedItem("Progress", _progress)); } - this.ProgressMultiplier = 1; - this.ProgressOffset = 0; - this.IgnoreCurrentDescription = false; - this.IgnoreCurrentProcessChanges = false; + ProgressMultiplier = 1; + ProgressOffset = 0; + IgnoreCurrentDescription = false; + IgnoreCurrentProcessChanges = false; - if (this._currentProcess != "Scheduled") + if (_currentProcess != "Scheduled") { - this._currentProcess = "Scheduled"; - changedProperties.Add(new ChangedItem("CurrentProcess", this._currentProcess)); + _currentProcess = "Scheduled"; + changedProperties.Add(new ChangedItem("CurrentProcess", _currentProcess)); } - if (this._currentDescription != "Scheduled Task for Execution") + if (_currentDescription != "Scheduled Task for Execution") { - this._currentDescription = "Scheduled Task for Execution"; - changedProperties.Add(new ChangedItem("CurrentDescription", this._currentDescription)); + _currentDescription = "Scheduled Task for Execution"; + changedProperties.Add(new ChangedItem("CurrentDescription", _currentDescription)); } - if (this._isCanceling) + if (_isCanceling) { - this._isCanceling = false; - changedProperties.Add(new ChangedItem("IsCanceling", this._isCanceling)); + _isCanceling = false; + changedProperties.Add(new ChangedItem("IsCanceling", _isCanceling)); } UpdateTriggered(changedProperties.ToArray()); } public bool WaitUntilFinished(TimeSpan Timeout) { - var finished = this._tcs.Task.Wait(Timeout); + var finished = _tcs.Task.Wait(Timeout); // Return false if task completed, but with an error if (finished) - return this.TaskException == null; + return TaskException == null; else return false; } @@ -433,13 +428,13 @@ namespace Disco.Services.Tasks private void UpdateTriggered(params ChangedItem[] ChangedProperties) { - this._statusVersion++; + _statusVersion++; if (Updated != null) Updated(this, ChangedProperties); if (!_isSilent) - ScheduledTaskNotificationsHub.PublishEvent(this.SessionId, ChangedProperties); + ScheduledTaskNotificationsHub.PublishEvent(SessionId, ChangedProperties); } } } diff --git a/Disco.Services/Tasks/ScheduledTaskStatusLive.cs b/Disco.Services/Tasks/ScheduledTaskStatusLive.cs index 41d826da..316a5f98 100644 --- a/Disco.Services/Tasks/ScheduledTaskStatusLive.cs +++ b/Disco.Services/Tasks/ScheduledTaskStatusLive.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Disco.Services.Tasks { diff --git a/Disco.Services/Tasks/ScheduledTasks.cs b/Disco.Services/Tasks/ScheduledTasks.cs index 62d152f0..c13b702b 100644 --- a/Disco.Services/Tasks/ScheduledTasks.cs +++ b/Disco.Services/Tasks/ScheduledTasks.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using Quartz; using Quartz.Impl; using Disco.Data.Repository; diff --git a/Disco.Services/Tasks/ScheduledTasksLog.cs b/Disco.Services/Tasks/ScheduledTasksLog.cs index 312f86f7..1a3f7543 100644 --- a/Disco.Services/Tasks/ScheduledTasksLog.cs +++ b/Disco.Services/Tasks/ScheduledTasksLog.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using Disco.Services.Logging; using Disco.Services.Logging.Models; using Exceptionless; diff --git a/Disco.Services/Users/UserFlags/Cache.cs b/Disco.Services/Users/UserFlags/Cache.cs index 4fd3957e..69864273 100644 --- a/Disco.Services/Users/UserFlags/Cache.cs +++ b/Disco.Services/Users/UserFlags/Cache.cs @@ -26,7 +26,7 @@ namespace Disco.Services.Users.UserFlags var flags = Database.UserFlags.ToList(); // Add Queues to In-Memory Cache - this._Cache = new ConcurrentDictionary(flags.Select(f => new KeyValuePair(f.Id, f))); + _Cache = new ConcurrentDictionary(flags.Select(f => new KeyValuePair(f.Id, f))); } public UserFlag GetUserFlag(int UserFlagId) diff --git a/Disco.Services/Users/UserFlags/UserFlagService.cs b/Disco.Services/Users/UserFlags/UserFlagService.cs index 432321d7..17488c4c 100644 --- a/Disco.Services/Users/UserFlags/UserFlagService.cs +++ b/Disco.Services/Users/UserFlags/UserFlagService.cs @@ -4,12 +4,8 @@ using Disco.Models.Repository; using Disco.Services.Extensions; using Disco.Services.Tasks; using System; -using System.Collections; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Reactive.Linq; namespace Disco.Services.Users.UserFlags diff --git a/Disco.Services/Users/UserFlags/UserFlagUserDevicesManagedGroup.cs b/Disco.Services/Users/UserFlags/UserFlagUserDevicesManagedGroup.cs index 35c67a65..0bb85d34 100644 --- a/Disco.Services/Users/UserFlags/UserFlagUserDevicesManagedGroup.cs +++ b/Disco.Services/Users/UserFlags/UserFlagUserDevicesManagedGroup.cs @@ -29,8 +29,8 @@ namespace Disco.Services.Users.UserFlags private UserFlagUserDevicesManagedGroup(string Key, ADManagedGroupConfiguration Configuration, UserFlag UserFlag) : base(Key, Configuration) { - this.UserFlagId = UserFlag.Id; - this.UserFlagName = UserFlag.Name; + UserFlagId = UserFlag.Id; + UserFlagName = UserFlag.Name; } public override void Initialize() diff --git a/Disco.Services/Users/UserFlags/UserFlagUsersManagedGroup.cs b/Disco.Services/Users/UserFlags/UserFlagUsersManagedGroup.cs index faf0c916..397c1553 100644 --- a/Disco.Services/Users/UserFlags/UserFlagUsersManagedGroup.cs +++ b/Disco.Services/Users/UserFlags/UserFlagUsersManagedGroup.cs @@ -29,8 +29,8 @@ namespace Disco.Services.Users.UserFlags private UserFlagUsersManagedGroup(string Key, ADManagedGroupConfiguration Configuration, UserFlag UserFlag) : base(Key, Configuration) { - this.UserFlagId = UserFlag.Id; - this.UserFlagName = UserFlag.Name; + UserFlagId = UserFlag.Id; + UserFlagName = UserFlag.Name; } public override void Initialize() diff --git a/Disco.Services/Users/UserFlags/UserFlagsDeleteTask.cs b/Disco.Services/Users/UserFlags/UserFlagsDeleteTask.cs index b1e71447..3c1a7026 100644 --- a/Disco.Services/Users/UserFlags/UserFlagsDeleteTask.cs +++ b/Disco.Services/Users/UserFlags/UserFlagsDeleteTask.cs @@ -18,7 +18,7 @@ namespace Disco.Services.Users.UserFlags using (DiscoDataContext Database = new DiscoDataContext()) { - UserFlagService.DeleteUserFlag(Database, UserFlagId, this.Status); + UserFlagService.DeleteUserFlag(Database, UserFlagId, Status); } } diff --git a/Disco.Services/Users/UserService.cs b/Disco.Services/Users/UserService.cs index 9cacad0f..85f815cc 100644 --- a/Disco.Services/Users/UserService.cs +++ b/Disco.Services/Users/UserService.cs @@ -7,12 +7,9 @@ using Disco.Services.Logging; using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Data.Entity.Infrastructure; using System.DirectoryServices.ActiveDirectory; using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.Web; namespace Disco.Services.Users diff --git a/Disco.Services/Users/UserUpdatesHub.cs b/Disco.Services/Users/UserUpdatesHub.cs index 9b6e2928..b6cb563f 100644 --- a/Disco.Services/Users/UserUpdatesHub.cs +++ b/Disco.Services/Users/UserUpdatesHub.cs @@ -4,9 +4,7 @@ using Disco.Services.Web.Signalling; using Microsoft.AspNet.SignalR; using Microsoft.AspNet.SignalR.Hubs; using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Reactive.Linq; using Disco.Models.Repository; diff --git a/Disco.Services/Web/AuthorizedController.cs b/Disco.Services/Web/AuthorizedController.cs index 2ca2b7e5..1356a8a8 100644 --- a/Disco.Services/Web/AuthorizedController.cs +++ b/Disco.Services/Web/AuthorizedController.cs @@ -1,12 +1,6 @@ using Disco.Models.Repository; using Disco.Services.Authorization; using Disco.Services.Users; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Mvc; namespace Disco.Services.Web { diff --git a/Disco.Services/Web/AuthorizedDatabaseController.cs b/Disco.Services/Web/AuthorizedDatabaseController.cs index 3133912c..a9405126 100644 --- a/Disco.Services/Web/AuthorizedDatabaseController.cs +++ b/Disco.Services/Web/AuthorizedDatabaseController.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Disco.Services.Authorization; +using Disco.Services.Authorization; using Disco.Models.Repository; using Disco.Services.Users; diff --git a/Disco.Services/Web/BaseController.cs b/Disco.Services/Web/BaseController.cs index cd5afef3..9429124f 100644 --- a/Disco.Services/Web/BaseController.cs +++ b/Disco.Services/Web/BaseController.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web.Mvc; +using System.Web.Mvc; namespace Disco.Services.Web { diff --git a/Disco.Services/Web/Bundles/BundleExtensions.cs b/Disco.Services/Web/Bundles/BundleExtensions.cs index 303f5bb6..3044a642 100644 --- a/Disco.Services/Web/Bundles/BundleExtensions.cs +++ b/Disco.Services/Web/Bundles/BundleExtensions.cs @@ -1,9 +1,6 @@ using Disco.Services.Web.Bundles; -using System; using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; using System.Web; using System.Web.Mvc; diff --git a/Disco.Services/Web/Bundles/BundleHandler.cs b/Disco.Services/Web/Bundles/BundleHandler.cs index c6b81d14..b98a68eb 100644 --- a/Disco.Services/Web/Bundles/BundleHandler.cs +++ b/Disco.Services/Web/Bundles/BundleHandler.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; +using System.Web; namespace Disco.Services.Web.Bundles { @@ -14,8 +9,8 @@ namespace Disco.Services.Web.Bundles public BundleHandler(IBundle requestBundle, string bundleVirtualPath) { - this.RequestBundle = requestBundle; - this.BundleVirtualPath = bundleVirtualPath; + RequestBundle = requestBundle; + BundleVirtualPath = bundleVirtualPath; } public bool IsReusable @@ -30,7 +25,7 @@ namespace Disco.Services.Web.Bundles if (!string.IsNullOrEmpty(context.Request.Headers["If-Modified-Since"])) context.Response.StatusCode = 304; else - this.RequestBundle.ProcessRequest(context); + RequestBundle.ProcessRequest(context); } internal static bool RemapHandlerForBundleRequests(HttpApplication app) diff --git a/Disco.Services/Web/Bundles/BundleModule.cs b/Disco.Services/Web/Bundles/BundleModule.cs index 0bfcf4be..9d479f9f 100644 --- a/Disco.Services/Web/Bundles/BundleModule.cs +++ b/Disco.Services/Web/Bundles/BundleModule.cs @@ -1,9 +1,5 @@ using Microsoft.Web.Infrastructure.DynamicModuleHelper; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web; [assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Disco.Services.Web.Bundles.BundleModule), "PreApplicationStart")] @@ -14,7 +10,7 @@ namespace Disco.Services.Web.Bundles { public void Init(HttpApplication context) { - context.PostResolveRequestCache += new EventHandler(this.OnApplicationPostResolveRequestCache); + context.PostResolveRequestCache += new EventHandler(OnApplicationPostResolveRequestCache); } private void OnApplicationPostResolveRequestCache(object sender, EventArgs e) diff --git a/Disco.Services/Web/Bundles/BundleTable.cs b/Disco.Services/Web/Bundles/BundleTable.cs index 8b76234a..0eedf45a 100644 --- a/Disco.Services/Web/Bundles/BundleTable.cs +++ b/Disco.Services/Web/Bundles/BundleTable.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web; namespace Disco.Services.Web.Bundles diff --git a/Disco.Services/Web/Bundles/FileBundle.cs b/Disco.Services/Web/Bundles/FileBundle.cs index 8ab65d98..6bd59804 100644 --- a/Disco.Services/Web/Bundles/FileBundle.cs +++ b/Disco.Services/Web/Bundles/FileBundle.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using System.Web; namespace Disco.Services.Web.Bundles @@ -34,7 +30,7 @@ namespace Disco.Services.Web.Bundles get { #if DEBUG - return string.Format("{0}?v={1}", this.Url, this.FileHash); + return string.Format("{0}?v={1}", Url, FileHash); #else return _VersionUrl; #endif @@ -65,10 +61,10 @@ namespace Disco.Services.Web.Bundles switch (fileInfo.Extension.ToLower()) { case ".css": - this.ContentType = "text/css"; + ContentType = "text/css"; break; case ".js": - this.ContentType = "text/javascript"; + ContentType = "text/javascript"; break; default: throw new ArgumentException("Unsupported Bundle File Extension"); @@ -78,28 +74,28 @@ namespace Disco.Services.Web.Bundles if (fileInfo.Length > 0) UpdateFileHash(); else - this._FileHash = string.Empty; + _FileHash = string.Empty; //this.Version = fileInfo.LastWriteTimeUtc.Ticks; - this._VersionUrl = string.Format("{0}?v={1}", this.Url, this.FileHash); + _VersionUrl = string.Format("{0}?v={1}", this.Url, FileHash); } private void UpdateFileHash() { - if (System.IO.File.Exists(this.File)) + if (System.IO.File.Exists(File)) { - var fileLastModified = System.IO.File.GetLastWriteTimeUtc(this.File); - if (!this._FileLastModified.HasValue || this._FileLastModified.Value != fileLastModified) + var fileLastModified = System.IO.File.GetLastWriteTimeUtc(File); + if (!_FileLastModified.HasValue || _FileLastModified.Value != fileLastModified) { - this._FileLastModified = fileLastModified; - var fileBytes = System.IO.File.ReadAllBytes(this.File); + _FileLastModified = fileLastModified; + var fileBytes = System.IO.File.ReadAllBytes(File); if (fileBytes.Length > 0) { using (SHA256 sha = SHA256.Create()) { byte[] hash = sha.ComputeHash(fileBytes); - this._FileHash = HttpServerUtility.UrlTokenEncode(hash); + _FileHash = HttpServerUtility.UrlTokenEncode(hash); return; } } @@ -111,13 +107,13 @@ namespace Disco.Services.Web.Bundles } } - this._FileHash = string.Empty; + _FileHash = string.Empty; } public void ProcessRequest(HttpContext context) { // Write Content Type - context.Response.ContentType = this.ContentType; + context.Response.ContentType = ContentType; // Write Headers var cache = context.Response.Cache; @@ -128,7 +124,7 @@ namespace Disco.Services.Web.Bundles cache.SetCacheability(HttpCacheability.Public); // Write File - context.Response.WriteFile(this.File); + context.Response.WriteFile(File); } } } diff --git a/Disco.Services/Web/Bundles/IBundle.cs b/Disco.Services/Web/Bundles/IBundle.cs index 87ecf75d..f3172d62 100644 --- a/Disco.Services/Web/Bundles/IBundle.cs +++ b/Disco.Services/Web/Bundles/IBundle.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; -using System.Web; +using System.Web; namespace Disco.Services.Web.Bundles { diff --git a/Disco.Services/Web/Bundles/UrlBundle.cs b/Disco.Services/Web/Bundles/UrlBundle.cs index 16174e2d..f5c39a39 100644 --- a/Disco.Services/Web/Bundles/UrlBundle.cs +++ b/Disco.Services/Web/Bundles/UrlBundle.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Web.Bundles { @@ -24,7 +20,7 @@ namespace Disco.Services.Web.Bundles public UrlBundle(string Url, string ContentType) { this.Url = Url; - this.VersionUrl = Url; + VersionUrl = Url; this.ContentType = ContentType; } diff --git a/Disco.Services/Web/DatabaseController.cs b/Disco.Services/Web/DatabaseController.cs index c6e30da7..7170b596 100644 --- a/Disco.Services/Web/DatabaseController.cs +++ b/Disco.Services/Web/DatabaseController.cs @@ -1,9 +1,4 @@ using Disco.Data.Repository; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web.Mvc; namespace Disco.Services.Web @@ -15,18 +10,18 @@ namespace Disco.Services.Web protected override void OnActionExecuting(ActionExecutingContext filterContext) { - this.Database = new DiscoDataContext(); - this.Database.Configuration.LazyLoadingEnabled = false; + Database = new DiscoDataContext(); + Database.Configuration.LazyLoadingEnabled = false; base.OnActionExecuting(filterContext); } protected override void Dispose(bool disposing) { - if (this.Database != null) + if (Database != null) { - this.Database.Dispose(); - this.Database = null; + Database.Dispose(); + Database = null; } base.Dispose(disposing); diff --git a/Disco.Services/Web/HandleErrorAttribute.cs b/Disco.Services/Web/HandleErrorAttribute.cs index 4cc3232e..a6edec83 100644 --- a/Disco.Services/Web/HandleErrorAttribute.cs +++ b/Disco.Services/Web/HandleErrorAttribute.cs @@ -1,12 +1,5 @@ -using Disco.Services.Authorization; -using Disco.Services.Users; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; +using System; using System.Net; -using System.Text; -using System.Threading.Tasks; using System.Web; using System.Web.Mvc; @@ -48,7 +41,7 @@ namespace Disco.Services.Web { get { - return this._typeId; + return _typeId; } } } diff --git a/Disco.Services/Web/HelperExtensions.cs b/Disco.Services/Web/HelperExtensions.cs index 4981bbd4..4d67a334 100644 --- a/Disco.Services/Web/HelperExtensions.cs +++ b/Disco.Services/Web/HelperExtensions.cs @@ -1,11 +1,6 @@ using Disco.Services.Authorization; using Disco.Services.Users; using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Web; using System.Web.Mvc; diff --git a/Disco.Services/Web/Signalling/DiscoHubAuthorizeAllAttribute.cs b/Disco.Services/Web/Signalling/DiscoHubAuthorizeAllAttribute.cs index 72f3073d..cf8293af 100644 --- a/Disco.Services/Web/Signalling/DiscoHubAuthorizeAllAttribute.cs +++ b/Disco.Services/Web/Signalling/DiscoHubAuthorizeAllAttribute.cs @@ -15,7 +15,7 @@ namespace Disco.Services.Web.Signalling if (AuthorisedClaims == null || AuthorisedClaims.Length == 0) throw new ArgumentNullException("AuthorisedClaims"); - this.authorizedClaims = AuthorisedClaims; + authorizedClaims = AuthorisedClaims; } protected override bool UserAuthorized(IPrincipal user) diff --git a/Disco.Services/Web/Signalling/DiscoHubAuthorizeAnyAttribute.cs b/Disco.Services/Web/Signalling/DiscoHubAuthorizeAnyAttribute.cs index c4f831c8..b16af3c5 100644 --- a/Disco.Services/Web/Signalling/DiscoHubAuthorizeAnyAttribute.cs +++ b/Disco.Services/Web/Signalling/DiscoHubAuthorizeAnyAttribute.cs @@ -15,7 +15,7 @@ namespace Disco.Services.Web.Signalling if (AuthorisedClaims == null || AuthorisedClaims.Length == 0) throw new ArgumentNullException("AuthorisedClaims"); - this.authorizedClaims = AuthorisedClaims; + authorizedClaims = AuthorisedClaims; } protected override bool UserAuthorized(IPrincipal user) diff --git a/Disco.Services/Web/Signalling/DiscoHubAuthorizeAttribute.cs b/Disco.Services/Web/Signalling/DiscoHubAuthorizeAttribute.cs index c2a9d05d..de26e889 100644 --- a/Disco.Services/Web/Signalling/DiscoHubAuthorizeAttribute.cs +++ b/Disco.Services/Web/Signalling/DiscoHubAuthorizeAttribute.cs @@ -14,7 +14,7 @@ namespace Disco.Services.Web.Signalling public DiscoHubAuthorizeAttribute(string AuthorisedClaim) { - this.authorizedClaim = AuthorisedClaim; + authorizedClaim = AuthorisedClaim; } protected override bool UserAuthorized(IPrincipal user) diff --git a/Disco.Services/Web/WebViewPage.cs b/Disco.Services/Web/WebViewPage.cs index 2fbada25..631dded4 100644 --- a/Disco.Services/Web/WebViewPage.cs +++ b/Disco.Services/Web/WebViewPage.cs @@ -1,11 +1,6 @@ using Disco.Models.Repository; using Disco.Services.Authorization; using Disco.Services.Users; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Disco.Services.Web {