Пример #1
0
        public static void Delete(this DeviceBatch db, DiscoDataContext Database)
        {
            if (!db.CanDelete(Database))
                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
            Database.DeviceBatches.Remove(db);
        }
Пример #2
0
        public static void OnDelete(this UserAttachment ua, DiscoDataContext Database)
        {
            if (!ua.CanDelete())
                throw new InvalidOperationException("Deletion of Attachment is Denied");

            var attachmentId = ua.Id;
            var documentTemplateId = ua.DocumentTemplateId;
            var userId = ua.UserId;

            ua.RepositoryDelete(Database);
            Database.UserAttachments.Remove(ua);

            DocumentTemplateManagedGroups.TriggerUserAttachmentDeleted(Database, attachmentId, documentTemplateId, userId);
        }
Пример #3
0
        public static void OnDelete(this JobAttachment ja, DiscoDataContext Database)
        {
            if (!ja.CanDelete())
                throw new InvalidOperationException("Deletion of Attachment is Denied");

            var attachmentId = ja.Id;
            var documentTemplateId = ja.DocumentTemplateId;
            var jobId = ja.JobId;

            ja.RepositoryDelete(Database);
            Database.JobAttachments.Remove(ja);

            DocumentTemplateManagedGroups.TriggerJobAttachmentDeleted(Database, attachmentId, documentTemplateId, jobId);
        }
Пример #4
0
        public static void OnDelete(this DeviceAttachment da, DiscoDataContext Database)
        {
            if (!da.CanDelete())
                throw new InvalidOperationException("Deletion of Attachment is Denied");

            var attachmentId = da.Id;
            var documentTemplateId = da.DocumentTemplateId;
            var deviceSerialNumber = da.DeviceSerialNumber;

            da.RepositoryDelete(Database);
            Database.DeviceAttachments.Remove(da);

            DocumentTemplateManagedGroups.TriggerDeviceAttachmentDeleted(Database, attachmentId, documentTemplateId, deviceSerialNumber);
        }
Пример #5
0
        public static void Delete(this DeviceProfile dp, DiscoDataContext Database)
        {
            if (!dp.CanDelete(Database))
                throw new InvalidOperationException("The state of this Device Profile doesn't allow it to be deleted");

            // Update Defaults
            if (Database.DiscoConfiguration.DeviceProfiles.DefaultDeviceProfileId == dp.Id)
                Database.DiscoConfiguration.DeviceProfiles.DefaultDeviceProfileId = 1;
            if (Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId == dp.Id)
                Database.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId = 1;

            // Remove Linked Group
            ActiveDirectory.Context.ManagedGroups.Remove(DeviceProfileDevicesManagedGroup.GetKey(dp));
            ActiveDirectory.Context.ManagedGroups.Remove(DeviceProfileAssignedUsersManagedGroup.GetKey(dp));

            // Delete Profile
            Database.DeviceProfiles.Remove(dp);
        }
Пример #6
0
        public static void Delete(this DeviceModel dm, DiscoDataContext Database)
        {
            if (!dm.CanDelete(Database))
                throw new InvalidOperationException("The state of this Device Model doesn't allow it to be deleted");

            // Delete Image
            var deviceModelImagePath = dm.ImageFilePath();
            if (File.Exists(deviceModelImagePath))
                File.Delete(deviceModelImagePath);

            // Delete any Device Model Components
            foreach (var deviceModelComponent in Database.DeviceComponents.Where(dc => dc.DeviceModelId == dm.Id).ToList())
            {
                Database.DeviceComponents.Remove(deviceModelComponent);
            }

            // Delete Model
            Database.DeviceModels.Remove(dm);
        }