修复 注入仓储仓时导致数据库连接被占用问题
This commit is contained in:
parent
d25fa4bcff
commit
7c0e39a43e
|
|
@ -19,6 +19,7 @@ namespace Learn.VideoAnalysis.Expand
|
||||||
Console.WriteLine($"{DateTime.Now}=>初始化 Coravel");
|
Console.WriteLine($"{DateTime.Now}=>初始化 Coravel");
|
||||||
service.AddScheduler();
|
service.AddScheduler();
|
||||||
service.AddTransient<NodeSubscriptionJob>();
|
service.AddTransient<NodeSubscriptionJob>();
|
||||||
|
service.AddTransient<TaskFileClearJob>();
|
||||||
}
|
}
|
||||||
public static void UseCoravelExpand(this IServiceProvider provider)
|
public static void UseCoravelExpand(this IServiceProvider provider)
|
||||||
{
|
{
|
||||||
|
|
@ -27,7 +28,7 @@ namespace Learn.VideoAnalysis.Expand
|
||||||
//每5分钟执行一次 未处理视频扫描
|
//每5分钟执行一次 未处理视频扫描
|
||||||
scheduler.Schedule<NodeSubscriptionJob>().EveryFiveMinutes();
|
scheduler.Schedule<NodeSubscriptionJob>().EveryFiveMinutes();
|
||||||
//每天两点
|
//每天两点
|
||||||
scheduler.Schedule<TaskFileClearJob>().DailyAtHour(2);
|
scheduler.Schedule<TaskFileClearJob>().HourlyAt(10);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ namespace Learn.VideoAnalysis.Expand
|
||||||
public static void AddSqlSugarExpand(this IServiceCollection services)
|
public static void AddSqlSugarExpand(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
services.AddHttpContextAccessor();
|
||||||
Console.WriteLine($"{DateTime.Now}=>初始化 YitId雪花ID");
|
Console.WriteLine($"{DateTime.Now}=>初始化 YitId雪花ID");
|
||||||
var options = new IdGeneratorOptions(ushort.Parse(AppCommon.Config.ID));
|
var options = new IdGeneratorOptions(ushort.Parse(AppCommon.Config.ID));
|
||||||
YitIdHelper.SetIdGenerator(options);
|
YitIdHelper.SetIdGenerator(options);
|
||||||
|
|
@ -42,7 +43,7 @@ namespace Learn.VideoAnalysis.Expand
|
||||||
DbType = s.SqlType,
|
DbType = s.SqlType,
|
||||||
IsAutoCloseConnection = true
|
IsAutoCloseConnection = true
|
||||||
}));
|
}));
|
||||||
services.AddSingleton(typeof(Repository<>));
|
services.AddTransient(typeof(Repository<>));
|
||||||
|
|
||||||
//注入SqlSugar 主库
|
//注入SqlSugar 主库
|
||||||
services.AddSqlSugar(dbList);
|
services.AddSqlSugar(dbList);
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ namespace Learn.VideoAnalysis
|
||||||
.AddInteractiveServerComponents();
|
.AddInteractiveServerComponents();
|
||||||
//.AddInteractiveWebAssemblyComponents();
|
//.AddInteractiveWebAssemblyComponents();
|
||||||
|
|
||||||
builder.Services.AddHttpContextAccessor();
|
|
||||||
|
|
||||||
builder.Services.AddLogging(loggingBuilder =>
|
builder.Services.AddLogging(loggingBuilder =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@ namespace VideoAnalysisCore.Common
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var c = t.GetCustomAttribute<TenantAttribute>();
|
var c = t.GetCustomAttribute<TenantAttribute>();
|
||||||
if (!CID.ContainsKey(typeof(T)))
|
if (!CID.ContainsKey(t))
|
||||||
CID.Add(typeof(T), c?.configId);
|
CID.Add(t, c?.configId);
|
||||||
base.Context = c != null
|
base.Context = c != null
|
||||||
? DbScoped.Sugar.GetConnectionScope(c.configId)
|
? DbScoped.Sugar.GetConnectionScope(c.configId)
|
||||||
: DbScoped.Sugar;
|
: DbScoped.Sugar;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue