From 7c0e39a43ebb765db5846191704f043c2a44e0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Thu, 13 Mar 2025 15:48:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E4=BB=93=E5=82=A8=E4=BB=93=E6=97=B6=E5=AF=BC=E8=87=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=BF=9E=E6=8E=A5=E8=A2=AB=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VideoAnalysis/Expand/CoravelExpand.cs | 3 ++- VideoAnalysis/Expand/SqlSugarExpand.cs | 3 ++- VideoAnalysis/Program.cs | 1 - VideoAnalysisCore/Common/Repository.cs | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/VideoAnalysis/Expand/CoravelExpand.cs b/VideoAnalysis/Expand/CoravelExpand.cs index df884ec..3e43beb 100644 --- a/VideoAnalysis/Expand/CoravelExpand.cs +++ b/VideoAnalysis/Expand/CoravelExpand.cs @@ -19,6 +19,7 @@ namespace Learn.VideoAnalysis.Expand Console.WriteLine($"{DateTime.Now}=>初始化 Coravel"); service.AddScheduler(); service.AddTransient(); + service.AddTransient(); } public static void UseCoravelExpand(this IServiceProvider provider) { @@ -27,7 +28,7 @@ namespace Learn.VideoAnalysis.Expand //每5分钟执行一次 未处理视频扫描 scheduler.Schedule().EveryFiveMinutes(); //每天两点 - scheduler.Schedule().DailyAtHour(2); + scheduler.Schedule().HourlyAt(10); }); } } diff --git a/VideoAnalysis/Expand/SqlSugarExpand.cs b/VideoAnalysis/Expand/SqlSugarExpand.cs index 41a6fe5..3761d20 100644 --- a/VideoAnalysis/Expand/SqlSugarExpand.cs +++ b/VideoAnalysis/Expand/SqlSugarExpand.cs @@ -21,6 +21,7 @@ namespace Learn.VideoAnalysis.Expand public static void AddSqlSugarExpand(this IServiceCollection services) { + services.AddHttpContextAccessor(); Console.WriteLine($"{DateTime.Now}=>初始化 YitId雪花ID"); var options = new IdGeneratorOptions(ushort.Parse(AppCommon.Config.ID)); YitIdHelper.SetIdGenerator(options); @@ -42,7 +43,7 @@ namespace Learn.VideoAnalysis.Expand DbType = s.SqlType, IsAutoCloseConnection = true })); - services.AddSingleton(typeof(Repository<>)); + services.AddTransient(typeof(Repository<>)); //注入SqlSugar 主库 services.AddSqlSugar(dbList); diff --git a/VideoAnalysis/Program.cs b/VideoAnalysis/Program.cs index 27bdfd7..b8b558f 100644 --- a/VideoAnalysis/Program.cs +++ b/VideoAnalysis/Program.cs @@ -28,7 +28,6 @@ namespace Learn.VideoAnalysis .AddInteractiveServerComponents(); //.AddInteractiveWebAssemblyComponents(); - builder.Services.AddHttpContextAccessor(); builder.Services.AddLogging(loggingBuilder => { diff --git a/VideoAnalysisCore/Common/Repository.cs b/VideoAnalysisCore/Common/Repository.cs index 332ea87..37f0cc6 100644 --- a/VideoAnalysisCore/Common/Repository.cs +++ b/VideoAnalysisCore/Common/Repository.cs @@ -29,8 +29,8 @@ namespace VideoAnalysisCore.Common return; } var c = t.GetCustomAttribute(); - if (!CID.ContainsKey(typeof(T))) - CID.Add(typeof(T), c?.configId); + if (!CID.ContainsKey(t)) + CID.Add(t, c?.configId); base.Context = c != null ? DbScoped.Sugar.GetConnectionScope(c.configId) : DbScoped.Sugar;