mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-24 18:25:04 +08:00
Add outcome for when email failed (#7825)
This commit is contained in:
committed by
Sébastien Ros
parent
5ea4a7a397
commit
70adb1833f
@@ -3,6 +3,7 @@ using Orchard.Email.Services;
|
|||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Events;
|
using Orchard.Events;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
using Orchard.Logging;
|
||||||
using Orchard.Messaging.Services;
|
using Orchard.Messaging.Services;
|
||||||
using Orchard.Workflows.Models;
|
using Orchard.Workflows.Models;
|
||||||
using Orchard.Workflows.Services;
|
using Orchard.Workflows.Services;
|
||||||
@@ -16,6 +17,7 @@ namespace Orchard.Email.Activities {
|
|||||||
public class EmailActivity : Task {
|
public class EmailActivity : Task {
|
||||||
private readonly IMessageService _messageService;
|
private readonly IMessageService _messageService;
|
||||||
private readonly IJobsQueueService _jobsQueueService;
|
private readonly IJobsQueueService _jobsQueueService;
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
public EmailActivity(
|
public EmailActivity(
|
||||||
IMessageService messageService,
|
IMessageService messageService,
|
||||||
@@ -23,13 +25,14 @@ namespace Orchard.Email.Activities {
|
|||||||
) {
|
) {
|
||||||
_messageService = messageService;
|
_messageService = messageService;
|
||||||
_jobsQueueService = jobsQueueService;
|
_jobsQueueService = jobsQueueService;
|
||||||
|
Logger = NullLogger.Instance;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public override IEnumerable<LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) {
|
public override IEnumerable<LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) {
|
||||||
return new[] { T("Done") };
|
return new[] { T("Done"), T("Failed") };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Form {
|
public override string Form {
|
||||||
@@ -69,6 +72,11 @@ namespace Orchard.Email.Activities {
|
|||||||
{"NotifyReadEmail",notifyReadEmail }
|
{"NotifyReadEmail",notifyReadEmail }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(recipients)) {
|
||||||
|
Logger.Error("Email message doesn't have any recipient for Workflow {0}", workflowContext.Record.WorkflowDefinitionRecord.Name);
|
||||||
|
yield return T("Failed");
|
||||||
|
}
|
||||||
|
else {
|
||||||
var queued = activityContext.GetState<bool>("Queued");
|
var queued = activityContext.GetState<bool>("Queued");
|
||||||
|
|
||||||
if (!queued) {
|
if (!queued) {
|
||||||
@@ -82,4 +90,5 @@ namespace Orchard.Email.Activities {
|
|||||||
yield return T("Done");
|
yield return T("Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user