From fa59527cf386cd9c282a76a636f21f6591582d80 Mon Sep 17 00:00:00 2001 From: df123 Date: Fri, 20 Mar 2026 09:55:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(background):=20=E6=B7=BB=E5=8A=A0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=8D=95=E8=8E=B7=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E5=BD=A9=E7=A5=A8=E5=A4=84=E7=90=86=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E4=B8=8D=E5=BD=B1=E5=93=8D=E5=85=B6=E4=BB=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 LotteryResultTimer 的 Execute 方法中为双色球(SSQ)和快乐8(KL8) 的处理逻辑分别添加 try-catch 异常捕获块。当某种彩票类型处理 发生异常时,仅记录错误日志而不中断整个任务,从而保证其他彩票 类型能继续正常处理。 --- .../Background/LotteryResultTimer.cs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/DFApp.Application/Background/LotteryResultTimer.cs b/src/DFApp.Application/Background/LotteryResultTimer.cs index 32dfb2f6..95e1baab 100644 --- a/src/DFApp.Application/Background/LotteryResultTimer.cs +++ b/src/DFApp.Application/Background/LotteryResultTimer.cs @@ -57,8 +57,25 @@ public LotteryResultTimer(IRepository lotteryResultReposito public override async Task Execute(IJobExecutionContext context) { - await StartWork(LotteryConst.SSQ, LotteryConst.SSQ_ENG, LotteryConst.SSQ_START_CODE); - await StartWork(LotteryConst.KL8, LotteryConst.KL8_ENG, LotteryConst.KL8_STRAT_CODE); + // 处理双色球(SSQ),失败不影响其他彩票类型 + try + { + await StartWork(LotteryConst.SSQ, LotteryConst.SSQ_ENG, LotteryConst.SSQ_START_CODE); + } + catch (Exception ex) + { + Logger.LogError(ex, $"处理双色球(SSQ)时发生异常,将继续处理其他彩票类型"); + } + + // 处理快乐8(KL8),失败不影响其他彩票类型 + try + { + await StartWork(LotteryConst.KL8, LotteryConst.KL8_ENG, LotteryConst.KL8_STRAT_CODE); + } + catch (Exception ex) + { + Logger.LogError(ex, $"处理快乐8(KL8)时发生异常,将继续处理其他彩票类型"); + } } private async Task StartWork(string lotteryType, string lotteryTypeEng, string code)