From 2aef482fa7431fb47eef94081ff23ec220f89820 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期五, 24 一月 2025 09:10:31 +0800 Subject: [PATCH] 1 --- WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/JobFactory.cs | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/JobFactory.cs b/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/JobFactory.cs index 96adb62..224be01 100644 --- a/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/JobFactory.cs +++ b/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzNet/JobFactory.cs @@ -23,19 +23,29 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using WIDESEAWCS_Core; namespace WIDESEAWCS_QuartzJob { + /// <summary> + /// Job娉ㄥ叆 + /// </summary> public class JobFactory : IJobFactory { /// <summary> /// 娉ㄥ叆鍙嶅皠鑾峰彇渚濊禆瀵硅薄 /// </summary> private readonly IServiceProvider _serviceProvider; + + /// <summary> + /// Job娉ㄥ叆 + /// </summary> + /// <param name="serviceProvider"></param> public JobFactory(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; } + /// <summary> /// 瀹炵幇鎺ュ彛Job /// </summary> @@ -46,17 +56,26 @@ { try { - Console.Out.WriteLine(1); + if (App.ExpDateTime != null && (DateTime.Now - App.ExpDateTime.GetValueOrDefault()).Seconds > 0) + { + throw new InvalidOperationException($"楠岃瘉閿欒"); + } + IServiceScope serviceScope = _serviceProvider.CreateScope(); IJob? job = serviceScope.ServiceProvider.GetService(bundle.JobDetail.JobType) as IJob; return job; } - catch (Exception) + catch (Exception ex) { - throw; + Console.Out.WriteLine(ex.ToString()); + throw new Exception(ex.Message); } } + /// <summary> + /// Job娉ㄥ叆 + /// </summary> + /// <param name="job"></param> public void ReturnJob(IJob job) { IDisposable? disposable = job as IDisposable; -- Gitblit v1.9.3