2026-07-02 18:13:56 +08:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2026-08-13 15:00:39 +08:00
|
|
|
|
using Gpulse.WCT.DataAnalyzer.Core.Infrastructure.LocalData;
|
|
|
|
|
|
using Gpulse.WCT.DataAnalyzer.Core.Application.Parsing;
|
2026-08-14 15:36:29 +08:00
|
|
|
|
using Gpulse.WCT.DataAnalyzer.Core.Application.Analysis;
|
2026-08-13 15:00:39 +08:00
|
|
|
|
using Gpulse.WCT.DataAnalyzer.Core.Application;
|
2026-08-25 11:29:30 +08:00
|
|
|
|
using Gpulse.WCT.DataAnalyzer.Core.Application.Exporting;
|
2026-07-02 18:13:56 +08:00
|
|
|
|
|
2026-08-13 15:00:39 +08:00
|
|
|
|
namespace Gpulse.WCT.DataAnalyzer.Core.Infrastructure.Extensions;
|
2026-07-02 18:13:56 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 服务注册扩展
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static class ServiceCollectionExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 注册数据库服务
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static IServiceCollection AddDatabaseServices(
|
|
|
|
|
|
this IServiceCollection services,
|
|
|
|
|
|
IConfiguration configuration)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 注册 DbContext 工厂
|
|
|
|
|
|
services.AddScoped<IDbContextFactory, DbContextFactory>();
|
|
|
|
|
|
|
|
|
|
|
|
// 注册 DbContext(通过工厂创建)
|
|
|
|
|
|
services.AddScoped<WctMinerDbContext>(sp =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var factory = sp.GetRequiredService<IDbContextFactory>();
|
|
|
|
|
|
return factory.CreateDbContext();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-08-13 15:00:39 +08:00
|
|
|
|
services.AddScoped<IReleaseDbContextFactory, ReleaseDbContextFactory>();
|
|
|
|
|
|
|
|
|
|
|
|
// 注册正式发布数据库上下文(与本地解析数据库完全独立)
|
|
|
|
|
|
services.AddScoped<ReleaseDbContext>(sp =>
|
|
|
|
|
|
{
|
|
|
|
|
|
var factory = sp.GetRequiredService<IReleaseDbContextFactory>();
|
|
|
|
|
|
return factory.CreateDbContext();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-07-02 18:13:56 +08:00
|
|
|
|
return services;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 注册应用服务
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static IServiceCollection AddApplicationServices(this IServiceCollection services)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Parsers
|
|
|
|
|
|
services.AddScoped<QfodParser>();
|
|
|
|
|
|
services.AddScoped<PlossParser>();
|
|
|
|
|
|
services.AddSingleton<FileNameParser>();
|
|
|
|
|
|
|
|
|
|
|
|
// Services
|
|
|
|
|
|
services.AddScoped<DimensionService>();
|
|
|
|
|
|
services.AddScoped<ScenarioService>();
|
|
|
|
|
|
services.AddScoped<ParseService>();
|
|
|
|
|
|
services.AddScoped<ExportService>();
|
|
|
|
|
|
services.AddScoped<CleanService>();
|
2026-08-13 15:00:39 +08:00
|
|
|
|
services.AddScoped<AggregationService>();
|
2026-07-02 18:13:56 +08:00
|
|
|
|
|
2026-08-14 15:36:29 +08:00
|
|
|
|
// Analysis
|
|
|
|
|
|
services.AddScoped<PlossAnalysisService>();
|
|
|
|
|
|
services.AddScoped<QfodCalibrationService>();
|
|
|
|
|
|
|
2026-08-25 11:29:30 +08:00
|
|
|
|
// Excel Export
|
|
|
|
|
|
services.AddScoped<AnalyzeExcelExporter>();
|
|
|
|
|
|
|
2026-07-02 18:13:56 +08:00
|
|
|
|
return services;
|
|
|
|
|
|
}
|
2026-07-03 10:47:27 +08:00
|
|
|
|
}
|