quartz.net - quartz.net 将 trigger_state 设置为 ERROR,不知道为什么
问题描述
我有石英坚持到 SQL 服务器。我的测试环境中没有这个,但现在我转移到生产环境中并且它正在发生。现在作业运行一次并导致触发器设置为 ERROR。我看不出有什么理由。我的工作看起来像这样......没有任何记录。知道为什么吗?
public class SendEmailsJob : IJob
{
public Task Execute(IJobExecutionContext context)
{
IEmailRepo _emailService = new EmailRepo();
IContactHistory _contactHistoryService = new ContactHistoryRepo();
IPolicyRepo _policyService = new PolicyRepo();
NLog.Logger _logger = Log.Instance;
IUtility _utilityService = new UtilityRepo();
const string DIRECT_WELCOME = "DirectWelcome";
const string DIRECT_POST_WELCOME = "DirectPostWelcome";
const string DIRECT_SIGN_NOPAY = "DirectSignNoPay";
const string DIRECT_NOSIGN_NOPAY = "DirectNoSignNoPay";
try
{
var templates = _utilityService.GetEmailTemplates();
foreach (var template in templates)
{
if (template.Value.isActive)
{
var queueItems = _emailService.GetQueueItemsForTemplate(template.Value.name);
foreach (var queueItem in queueItems)
{
var previousEmails = _contactHistoryService.GetAllForPolicy(queueItem.policyNo);
var emailLookup = previousEmails.ToLookup(x => x.contactReference);
bool skip = (queueItem.name == DIRECT_POST_WELCOME && emailLookup.Contains(DIRECT_POST_WELCOME)) || emailLookup.Contains(queueItem.name);
if (skip)
_emailService.DeleteQueueItem(queueItem);
else
{
var policy = _policyService.GetPolicyByPolicyNo(queueItem.policyNo);
var status = SendGridService.Send(queueItem.email, $"{policy.firstName} {policy.lastName}", queueItem.policyNo,
queueItem.name);
if (status == HttpStatusCode.Accepted)
{
_contactHistoryService.Insert(new ContactHistoryModel()
{
contactType = "email",
description = $"{queueItem.name} email sent to {queueItem.email} and was {status}",
contactReference = queueItem.name,
policyId = queueItem.policyId,
policyNo = queueItem.policyNo,
quoteId = queueItem.quoteId,
quoteNumber = queueItem.quoteNumber,
email = queueItem.email
});
_emailService.DeleteQueueItem(queueItem);
}
else
_logger.Error(
$"Error sending email {queueItem.name} for policy {queueItem.policyNo} to {queueItem.email} ending in status {status}");
}
}
}
}
return Task.CompletedTask;
}
catch (JobExecutionException e)
{
_logger.Error($"Error sending emails {e.StackTrace}");
return Task.CompletedTask;
}
catch (Exception e)
{
_logger.Error($"Error sending emails {e.StackTrace}");
return Task.CompletedTask;
}
return Task.CompletedTask;
}
}
解决方案
推荐阅读
- php - CakePHP 3.7 - 干预 ImageUpload 错误“无法从路径读取图像”
- python - 来自数据框的带有 Matplotlib 的日期时间堆积条形图
- linux - Windows 10 上拒绝 Clion 和 cmd ssh WSL
- javascript - 从 ajax 调用中获取 ERR_EMPTY_RESPONSE
- angular - 无法读取未定义的 HighCharts 的属性“系列”
- reactjs - 如何在reactjs中将令牌添加到标头
- java - Android MotionLayout 不在真实设备上显示动画
- salt-stack - 如何定义 cmd.run 以在状态文件中的指定 minion 上执行
- cucumber-jvm - 基于 Cucumber JVM 的测试套件作为 Spring Boot 应用程序
- javascript - 迭代对象数组并仅获取特定键以在 React js 中形成新的对象数组