Bug Fix #82: Dereference managed groups on delete
Managed Group references (and subscriptions) continued to exist after Device Profiles, Device Batches and Document Templates were deleted. This prevented assigning the same group to another Profile/Batch/Template without first recycling the IIS App Pool.
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
using Disco.Data.Repository;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Data.Repository;
|
|
||||||
using Disco.Services.Users;
|
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
|
using Disco.Services.Devices.ManagedGroups;
|
||||||
|
using Disco.Services.Interop.ActiveDirectory;
|
||||||
|
using Disco.Services.Users;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Disco.BI.Extensions
|
namespace Disco.BI.Extensions
|
||||||
{
|
{
|
||||||
@@ -29,6 +29,10 @@ namespace Disco.BI.Extensions
|
|||||||
if (!db.CanDelete(Database))
|
if (!db.CanDelete(Database))
|
||||||
throw new InvalidOperationException("The state of this Device Batch doesn't allow it to be deleted");
|
throw new InvalidOperationException("The state of this Device Batch doesn't allow it to be deleted");
|
||||||
|
|
||||||
|
// Remove Linked Group
|
||||||
|
ActiveDirectory.Context.ManagedGroups.Remove(DeviceBatchDevicesManagedGroup.GetKey(db));
|
||||||
|
ActiveDirectory.Context.ManagedGroups.Remove(DeviceBatchAssignedUsersManagedGroup.GetKey(db));
|
||||||
|
|
||||||
// Delete Batch
|
// Delete Batch
|
||||||
Database.DeviceBatches.Remove(db);
|
Database.DeviceBatches.Remove(db);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
using System;
|
using Disco.Data.Repository;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Disco.Models.Repository;
|
|
||||||
using Disco.Data.Repository;
|
|
||||||
using Disco.Data.Configuration.Modules;
|
|
||||||
using Disco.Models.BI.Config;
|
using Disco.Models.BI.Config;
|
||||||
using Disco.Services.Users;
|
using Disco.Models.Repository;
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
|
using Disco.Services.Devices.ManagedGroups;
|
||||||
|
using Disco.Services.Interop.ActiveDirectory;
|
||||||
|
using Disco.Services.Users;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Disco.BI.Extensions
|
namespace Disco.BI.Extensions
|
||||||
{
|
{
|
||||||
@@ -58,6 +57,10 @@ namespace Disco.BI.Extensions
|
|||||||
if (Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId == dp.Id)
|
if (Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId == dp.Id)
|
||||||
Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId = 1;
|
Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId = 1;
|
||||||
|
|
||||||
|
// Remove Linked Group
|
||||||
|
ActiveDirectory.Context.ManagedGroups.Remove(DeviceProfileDevicesManagedGroup.GetKey(dp));
|
||||||
|
ActiveDirectory.Context.ManagedGroups.Remove(DeviceProfileAssignedUsersManagedGroup.GetKey(dp));
|
||||||
|
|
||||||
// Delete Profile
|
// Delete Profile
|
||||||
Database.DeviceProfiles.Remove(dp);
|
Database.DeviceProfiles.Remove(dp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
using System;
|
using Disco.BI.DocumentTemplateBI;
|
||||||
using System.Collections.Concurrent;
|
using Disco.BI.DocumentTemplateBI.ManagedGroups;
|
||||||
using System.Linq;
|
using Disco.BI.Expressions;
|
||||||
using System.Web;
|
|
||||||
using Disco.Data.Repository;
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.BI.DocumentTemplates;
|
using Disco.Models.BI.DocumentTemplates;
|
||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using System.Collections;
|
using Disco.Services.Interop.ActiveDirectory;
|
||||||
using System.Collections.Generic;
|
|
||||||
using iTextSharp.text.pdf;
|
using iTextSharp.text.pdf;
|
||||||
using Disco.BI.Expressions;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Disco.BI.DocumentTemplateBI;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Disco.BI.Extensions
|
namespace Disco.BI.Extensions
|
||||||
{
|
{
|
||||||
@@ -273,6 +273,10 @@ namespace Disco.BI.Extensions
|
|||||||
a.DocumentTemplate = null;
|
a.DocumentTemplate = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove Linked Group
|
||||||
|
ActiveDirectory.Context.ManagedGroups.Remove(DocumentTemplateDevicesManagedGroup.GetKey(dt));
|
||||||
|
ActiveDirectory.Context.ManagedGroups.Remove(DocumentTemplateUsersManagedGroup.GetKey(dt));
|
||||||
|
|
||||||
// Delete SubTypes
|
// Delete SubTypes
|
||||||
dt.JobSubTypes.Clear();
|
dt.JobSubTypes.Clear();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user