From ea1d2bfb3bccf22d53fa2001cbdd019d2264f34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=87=E9=98=B3=20=E9=82=B9?= Date: Tue, 24 Oct 2023 00:35:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8E=BB=E7=A1=AE=E5=AE=9A=E6=98=AF=E5=90=A6=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E5=BC=80=E5=90=AF=E5=AE=9A=E6=97=B6=E4=BB=8E=E6=9E=81?= =?UTF-8?q?=E5=85=89=E7=9A=84api=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 24Hour/appsettings.json | 6 ++++++ Elight.Logic/Job/QuartzHostedService.cs | 21 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/24Hour/appsettings.json b/24Hour/appsettings.json index 120c84b..ecad3e6 100644 --- a/24Hour/appsettings.json +++ b/24Hour/appsettings.json @@ -50,5 +50,11 @@ "secret": "e752e4fba67526eca21313a18c96a58f", "secid": "e752e4fba67526eca21313a18c96a58f", "miniprogram_state": "trial" + }, + "CaseTwenty": { + "SysAddress": "http://127.0.0.1" + }, + "SyncDataFromJiguang": { + "enable": "false" } } diff --git a/Elight.Logic/Job/QuartzHostedService.cs b/Elight.Logic/Job/QuartzHostedService.cs index ee9a9fc..3895dfd 100644 --- a/Elight.Logic/Job/QuartzHostedService.cs +++ b/Elight.Logic/Job/QuartzHostedService.cs @@ -2,6 +2,7 @@ using Elight.Utility.logs; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using Quartz; using Quartz.Spi; using SqlSugar; @@ -19,16 +20,30 @@ namespace Elight.Logic.Job private readonly ISchedulerFactory _schedulerFactory; private readonly IJobFactory _jobFactory; private readonly WsJob _myJob; + private readonly IConfiguration configuration; + private readonly ILogger logger; - public QuartzHostedService(ISchedulerFactory schedulerFactory, IJobFactory jobFactory, WsJob myJob, IConfiguration configuration) + public QuartzHostedService(ISchedulerFactory schedulerFactory, IJobFactory jobFactory, WsJob myJob, IConfiguration _configuration, ILogger _logger) { _schedulerFactory = schedulerFactory; _jobFactory = jobFactory; _myJob = myJob; + this.configuration = _configuration; + this.logger = _logger; } public async Task StartAsync(CancellationToken cancellationToken) - { + { + if (configuration.GetSection("SyncDataFromJiguang:enable").Value == "false") + { + logger.LogInformation("disabled data sync from jiguang api"); + return; + } + else + { + logger.LogInformation("enable data sync from jiguang api "); + } + try { IScheduler scheduler = await _schedulerFactory.GetScheduler(cancellationToken); @@ -63,7 +78,7 @@ namespace Elight.Logic.Job } catch (Exception ex) { - LogService.WriteLog(ex.Message+"___"+ex.InnerException, "同步程序错误"); + LogService.WriteLog(ex.Message + "___" + ex.InnerException, "同步程序错误"); } #endregion }