-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #336 from DFE-Digital/122999-sharepoint-path-for-s…
…chool-financial-docs Added quartz.net scheduler for running a one time job to fix sharepoi…
- Loading branch information
Showing
8 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
Dfe.Academies.External.Web/Dtos/ApplicationSchoolSharepointServiceModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Dfe.Academies.External.Web.Dtos; | ||
|
||
public record ApplicationSchoolSharepointServiceModel( | ||
int Id, | ||
string ApplicationReference, | ||
List<SchoolSharepointServiceModel> SchoolSharepointServiceModels); |
3 changes: 3 additions & 0 deletions
3
Dfe.Academies.External.Web/Dtos/SchoolSharepointServiceModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Dfe.Academies.External.Web.Dtos; | ||
|
||
public record SchoolSharepointServiceModel(int Id, string Name, Guid EntityId); |
40 changes: 40 additions & 0 deletions
40
Dfe.Academies.External.Web/Jobs/FixSharepointFoldersJob.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Dfe.Academies.External.Web.Exceptions; | ||
using Dfe.Academies.External.Web.Services; | ||
using Quartz; | ||
|
||
namespace Dfe.Academies.External.Web.Jobs; | ||
|
||
public class FixSharepointFoldersJob : IJob | ||
{ | ||
private readonly IConversionApplicationRetrievalService _conversionApplicationRetrievalService; | ||
private readonly IFileUploadService _fileUploadService; | ||
private readonly ILogger<FixSharepointFoldersJob> _logger; | ||
public FixSharepointFoldersJob(IConversionApplicationRetrievalService conversionApplicationRetrievalService, IFileUploadService fileUploadService, ILogger<FixSharepointFoldersJob> logger) | ||
{ | ||
_conversionApplicationRetrievalService = conversionApplicationRetrievalService; | ||
_fileUploadService = fileUploadService; | ||
_logger = logger; | ||
} | ||
|
||
public async Task Execute(IJobExecutionContext context) | ||
{ | ||
var sharepointApplicationServiceModels = await _conversionApplicationRetrievalService.GetAllApplications(); | ||
foreach (var applicationSchoolSharepointServiceModel in sharepointApplicationServiceModels) | ||
{ | ||
_logger.LogInformation($"Application sharepoint model: {applicationSchoolSharepointServiceModel.ApplicationReference}"); | ||
foreach (var schoolSharepointServiceModel in applicationSchoolSharepointServiceModel.SchoolSharepointServiceModels) | ||
{ | ||
_logger.LogInformation($"Fixing folder structure for application: {applicationSchoolSharepointServiceModel.ApplicationReference} with school: {schoolSharepointServiceModel.Name} :: ${schoolSharepointServiceModel.EntityId}"); | ||
try | ||
{ | ||
await _fileUploadService.FixApplyingSchool(applicationSchoolSharepointServiceModel.ApplicationReference, schoolSharepointServiceModel.EntityId.ToString()); | ||
} | ||
catch (FileUploadException ex) | ||
{ | ||
_logger.LogError($"Could not fix folder structure for application: {applicationSchoolSharepointServiceModel.ApplicationReference} with school: {schoolSharepointServiceModel.Name} :: ${schoolSharepointServiceModel.EntityId}"); | ||
_logger.LogDebug($"{ex.StackTrace}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters