-
Notifications
You must be signed in to change notification settings - Fork 8
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 #408 from bcgov/1.2
Version 1.2
- Loading branch information
Showing
9 changed files
with
144 additions
and
19 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Hangfire; | ||
using Hmcr.Data.Repositories; | ||
using Hmcr.Domain.Services; | ||
using Hmcr.Model; | ||
using Hmcr.Model.Dtos.User; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Hmcr.Domain.Hangfire | ||
{ | ||
public interface IEmailJobService | ||
{ | ||
Task ResendEmails(); | ||
} | ||
|
||
public class EmailJobService : IEmailJobService | ||
{ | ||
private IFeebackMessageRepository _feedbackRepo; | ||
private IEmailService _emailService; | ||
private HmcrCurrentUser _user; | ||
private ILogger<EmailJobService> _logger; | ||
|
||
public EmailJobService(IFeebackMessageRepository feedbackRepo, IEmailService emailService, HmcrCurrentUser user, ILogger<EmailJobService> logger) | ||
{ | ||
_feedbackRepo = feedbackRepo; | ||
_emailService = emailService; | ||
_user = user; | ||
_logger = logger; | ||
} | ||
|
||
[SkipSameJob] | ||
[AutomaticRetry(Attempts = 0)] | ||
public async Task ResendEmails() | ||
{ | ||
_user.AuthDirName = UserTypeDto.IDIR; | ||
_user.UniversalId = "hangfire"; | ||
_user.UserGuid = new Guid(); | ||
|
||
var feedbackMessages = await _feedbackRepo.GetFailedFeedbackMessagesAsync(); | ||
var count = feedbackMessages.Count(); | ||
|
||
if (count == 0) | ||
return; | ||
|
||
_logger.LogInformation($"[Hangfire] The job for resending emails is starting - {count} emails to send"); | ||
|
||
foreach (var feedbackMessage in feedbackMessages) | ||
{ | ||
await _emailService.SendStatusEmailAsync(feedbackMessage.SubmissionObjectId, feedbackMessage); | ||
} | ||
} | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
api/Hmcr.Model/Dtos/FeedbackMessage/FeedbackMessageUpdateDto.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,16 @@ | ||
using System; | ||
|
||
namespace Hmcr.Model.Dtos.FeedbackMessage | ||
{ | ||
public class FeedbackMessageUpdateDto | ||
{ | ||
public decimal FeedbackMessageId { get; set; } | ||
public decimal SubmissionObjectId { get; set; } | ||
public string CommunicationSubject { get; set; } | ||
public string CommunicationText { get; set; } | ||
public DateTime? CommunicationDate { get; set; } | ||
public bool? IsSent { get; set; } | ||
public bool? IsError { get; set; } | ||
public string SendErrorText { get; set; } | ||
} | ||
} |