public async Task DeleteAllStudyRelatedResourcesAsync(Study study, CancellationToken cancellationToken = default)
        {
            _logger.LogInformation($"DeleteAllStudyRelatedResourcesAsync - Study Id: {study.Id}");

            try
            {
                var resourceGroupEntry = await GetResourceGroupEntryForStudySpecificDatasetDeletionAsync(study);

                if (resourceGroupEntry != null)
                {
                    var currentUser = await _userService.GetCurrentUserAsync();

                    SoftDeleteUtil.MarkAsDeleted(resourceGroupEntry, currentUser);

                    foreach (var curResource in resourceGroupEntry.ChildResources)
                    {
                        SoftDeleteUtil.MarkAsDeleted(curResource, currentUser);
                    }

                    var deleteOperation = await _cloudResourceOperationCreateService.CreateDeleteOperationAsync(resourceGroupEntry.Id, $"Delete study related resurces for Study {study.Id}");

                    await _provisioningQueueService.CreateItemAndEnqueue(deleteOperation);
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Failed to delete resources for study specific dataset", ex);
            }
        }
示例#2
0
        public void MarkAsDeleted_ShouldMarkAsDeletedWithCorrectName5()
        {
            var deletedBy       = new UserDto {
            };
            var itemToBeDeleted = new CloudResource {
            };
            var ex = Assert.Throws <ArgumentNullException>(() => SoftDeleteUtil.MarkAsDeleted(null, ""));

            Assert.Contains("Item to delete was null", ex.Message);
            Assert.False(SoftDeleteUtil.IsMarkedAsDeleted(itemToBeDeleted));
        }
示例#3
0
        public void MarkAsDeleted_ShouldMarkAsDeletedWithCorrectName()
        {
            var deletedBy       = "John";
            var itemToBeDeleted = new CloudResource {
            };

            SoftDeleteUtil.MarkAsDeleted(itemToBeDeleted, deletedBy);

            Assert.Equal(itemToBeDeleted.DeletedBy, deletedBy);
            Assert.True(SoftDeleteUtil.IsMarkedAsDeleted(itemToBeDeleted));
        }
示例#4
0
        public async Task SoftDeleteAsync(int sandboxId)
        {
            var sandbox = await GetByIdAsync(sandboxId, UserOperation.Study_Crud_Sandbox, false);

            if (sandbox != null)
            {
                var user = await _userService.GetCurrentUserAsync();

                SoftDeleteUtil.MarkAsDeleted(sandbox, user);
                await _db.SaveChangesAsync();
            }
        }
        public async Task DeleteResourcesForStudySpecificDatasetAsync(Study study, Dataset dataset, CancellationToken cancellationToken = default)
        {
            _logger.LogInformation($"DeleteResourcesForStudySpecificDatasetAsync - Dataset Id: {dataset.Id}. Resources will be marked ");

            try
            {
                var datasetResourceEntry = DatasetUtils.GetStudySpecificStorageAccountResourceEntry(dataset);

                if (datasetResourceEntry != null)
                {
                    await SoftDeleteUtil.MarkAsDeleted(datasetResourceEntry, _userService);

                    var deleteOperation = await _cloudResourceOperationCreateService.CreateDeleteOperationAsync(datasetResourceEntry.Id, $"Delete dataset related resurces for dataset {dataset.Id}");

                    await _provisioningQueueService.CreateItemAndEnqueue(deleteOperation);
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Failed to delete resources for study specific dataset", ex);
            }
        }
示例#6
0
 void MarkAsDeletedInternal(CloudResource resource, string deletedBy)
 {
     SoftDeleteUtil.MarkAsDeleted(resource, deletedBy);
 }
示例#7
0
        protected async Task SoftDeleteAsync(Dataset dataset)
        {
            await SoftDeleteUtil.MarkAsDeleted(dataset, _userService);

            await _db.SaveChangesAsync();
        }