public bool Execute(IEmailUserTaskMessageProvider messageProvider, ProcessExecutingContext context) { EmailTemplateUserTask userTask = messageProvider.EmailUserTask; EmailMessage message = messageProvider.GetEmailMessage(); if (message.To.IsNullOrEmpty()) { return(true); } if (message.From.IsEmpty()) { SendEmailWithDefaultSender(message, userTask.IgnoreErrors); return(true); } var constructorArguments = new ConstructorArgument("userConnection", UserConnection); var emailClientFactory = ClassFactory.Get <EmailClientFactory>(constructorArguments); var emailSender = new HtmlEmailMessageSender(emailClientFactory, UserConnection); try { bool ignoreRights = (SendEmailType)userTask.SendEmailType == SendEmailType.Auto; emailSender.Send(message, ignoreRights); } catch (Exception e) { _log.Error(e); if (!userTask.IgnoreErrors) { throw; } } return(true); }
private void InternalExecute(IEmailUserTaskMessageProvider messageProvider) { EmailTemplateUserTask userTask = messageProvider.EmailUserTask; EmailMessage message = messageProvider.GetEmailMessage(); Activity activity = CreateActivity(message, userTask); userTask.ExecuteAfterActivitySaveScript(activity); }
public bool Execute(IEmailUserTaskMessageProvider messageProvider, ProcessExecutingContext context) { var userTask = messageProvider.EmailUserTask; Guid activityId = userTask.ActivityId; bool showExecutionPage = userTask.ShowExecutionPage; bool isActivityCompleted = userTask.IsActivityCompleted; bool isRunning = activityId.IsNotEmpty() && !isActivityCompleted; if (userTask.Status == ProcessStatus.Error) { bool isActivityCreated = ProcessUserTaskUtilities.GetIsActivityCreated(UserConnection, userTask.UId); if (activityId.IsEmpty() && !isActivityCreated) { InternalExecute(messageProvider); } } if (!isRunning) { InternalExecute(messageProvider); } userTask.InteractWithUser(context, isRunning, showExecutionPage); return(false); }