Skip to content

Commit b97668b

Browse files
authored
Merge pull request #424 from TechnologyEnhancedLearning/Develop/Fixes/TD-4054
TD-4054 archive extracted content folders for html and scorm resource.
2 parents ac656aa + 66b0601 commit b97668b

File tree

5 files changed

+427
-120
lines changed

5 files changed

+427
-120
lines changed

AdminUI/LearningHub.Nhs.AdminUI/Configuration/WebSettings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ public class WebSettings
7777
/// </summary>
7878
public string AzureFileStorageConnectionString { get; set; }
7979

80+
/// <summary>
81+
/// Gets or sets the AzureSourceFileStorageConnectionString.
82+
/// </summary>
83+
public string AzureSourceArchiveStorageConnectionString { get; set; }
84+
85+
/// <summary>
86+
/// Gets or sets the AzurePurgedFileStorageConnectionString.
87+
/// </summary>
88+
public string AzureContentArchiveStorageConnectionString { get; set; }
89+
8090
/// <summary>
8191
/// Gets or sets the azure file storage resource share name.
8292
/// </summary>

AdminUI/LearningHub.Nhs.AdminUI/Controllers/ResourceController.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,27 @@ public class ResourceController : BaseController
5454
/// </summary>
5555
private IResourceService resourceService;
5656

57+
/// <summary>
58+
/// Defines the _fileService.
59+
/// </summary>
60+
private IFileService fileService;
61+
5762
/// <summary>
5863
/// Initializes a new instance of the <see cref="ResourceController"/> class.
5964
/// </summary>
6065
/// <param name="hostingEnvironment">The hostingEnvironment<see cref="IWebHostEnvironment"/>.</param>
6166
/// <param name="config">The config<see cref="IOptions{WebSettings}"/>.</param>
6267
/// <param name="logger">The logger<see cref="ILogger{HomeController}"/>.</param>
6368
/// <param name="resourceService">The resourceService<see cref="IResourceService"/>.</param>
69+
/// <param name="fileService">The fileService<see cref="IResourceService"/>.</param>
6470
/// /// <param name="websettings">The websettings<see cref="IOptions{WebSettings}"/>.</param>
6571
/// <param name="featureManager">The featureManager<see cref="IFeatureManager"/>.</param>
6672
public ResourceController(
6773
IWebHostEnvironment hostingEnvironment,
6874
IOptions<WebSettings> config,
6975
ILogger<HomeController> logger,
7076
IResourceService resourceService,
77+
IFileService fileService,
7178
IOptions<WebSettings> websettings,
7279
IFeatureManager featureManager)
7380
: base(hostingEnvironment)
@@ -76,6 +83,7 @@ public ResourceController(
7683
this.websettings = websettings;
7784
this.config = config.Value;
7885
this.resourceService = resourceService;
86+
this.fileService = fileService;
7987
this.featureManager = featureManager;
8088
}
8189

@@ -298,11 +306,17 @@ public async Task<IActionResult> TransferResourceOwnership(int resourceId, strin
298306
[HttpPost]
299307
public async Task<IActionResult> Unpublish(int resourceVersionId, string details)
300308
{
309+
var associatedFile = await this.resourceService.GetResourceVersionExtendedViewModelAsync(resourceVersionId);
301310
var vr = await this.resourceService.UnpublishResourceVersionAsync(resourceVersionId, details);
302311
await this.resourceService.CreateResourceVersionEvent(resourceVersionId, Nhs.Models.Enums.ResourceVersionEventTypeEnum.UnpublishedByAdmin, "Unpublish using Admin UI", 0);
303312

304313
if (vr.IsValid)
305314
{
315+
if (associatedFile.ScormDetails != null || associatedFile.HtmlDetails != null)
316+
{
317+
_ = Task.Run(async () => { await this.fileService.PurgeResourceFile(associatedFile, null); });
318+
}
319+
306320
return this.Json(new
307321
{
308322
success = true,
Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,48 @@
11
namespace LearningHub.Nhs.AdminUI.Interfaces
22
{
3-
using System.IO;
4-
using System.Threading.Tasks;
5-
using Azure.Storage.Files.Shares.Models;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Threading.Tasks;
6+
using Azure.Storage.Files.Shares.Models;
7+
using LearningHub.Nhs.Models.Resource;
68

7-
/// <summary>
8-
/// Defines the <see cref="IFileService" />.
9-
/// </summary>
10-
public interface IFileService
11-
{
129
/// <summary>
13-
/// The DeleteChunkDirectory.
10+
/// Defines the <see cref="IFileService" />.
1411
/// </summary>
15-
/// <param name="directoryRef">Directory ref.</param>
16-
/// <param name="chunks">Chunks.</param>
17-
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
18-
Task DeleteChunkDirectory(string directoryRef, int chunks);
12+
public interface IFileService
13+
{
14+
/// <summary>
15+
/// The DeleteChunkDirectory.
16+
/// </summary>
17+
/// <param name="directoryRef">Directory ref.</param>
18+
/// <param name="chunks">Chunks.</param>
19+
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
20+
Task DeleteChunkDirectory(string directoryRef, int chunks);
1921

20-
/// <summary>
21-
/// The DownloadFileAsync.
22-
/// </summary>
23-
/// <param name="filePath">File path.</param>
24-
/// <param name="fileName">File name.</param>
25-
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
26-
Task<ShareFileDownloadInfo> DownloadFileAsync(string filePath, string fileName);
22+
/// <summary>
23+
/// The DownloadFileAsync.
24+
/// </summary>
25+
/// <param name="filePath">File path.</param>
26+
/// <param name="fileName">File name.</param>
27+
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
28+
Task<ShareFileDownloadInfo> DownloadFileAsync(string filePath, string fileName);
2729

28-
/// <summary>
29-
/// The ProcessFile.
30-
/// </summary>
31-
/// <param name="fileBytes">The fileBytes<see cref="Stream"/>.</param>
32-
/// <param name="fileName">The fileName<see cref="string"/>.</param>
33-
/// <param name="directoryRef">The directoryRef<see cref="string"/>.</param>
34-
/// <param name="originalFileName">The originalFileName<see cref="string"/>.</param>
35-
/// <returns>The <see cref="string"/>.</returns>
36-
Task<string> ProcessFile(Stream fileBytes, string fileName, string directoryRef = "", string originalFileName = null);
37-
}
30+
/// <summary>
31+
/// The ProcessFile.
32+
/// </summary>
33+
/// <param name="fileBytes">The fileBytes<see cref="Stream"/>.</param>
34+
/// <param name="fileName">The fileName<see cref="string"/>.</param>
35+
/// <param name="directoryRef">The directoryRef<see cref="string"/>.</param>
36+
/// <param name="originalFileName">The originalFileName<see cref="string"/>.</param>
37+
/// <returns>The <see cref="string"/>.</returns>
38+
Task<string> ProcessFile(Stream fileBytes, string fileName, string directoryRef = "", string originalFileName = null);
39+
40+
/// <summary>
41+
/// The PurgeResourceFile.
42+
/// </summary>
43+
/// <param name="vm">The vm.<see cref="ResourceVersionExtendedViewModel"/>.</param>
44+
/// <param name="filePaths">.</param>
45+
/// <returns>The <see cref="Task"/>.</returns>
46+
Task PurgeResourceFile(ResourceVersionExtendedViewModel vm = null, List<string> filePaths = null);
47+
}
3848
}

0 commit comments

Comments
 (0)