2025-03-20 16:40:27 +08:00
|
|
|
|
using JiShe.CollectBus.IotSystems.MeterReadingRecords;
|
|
|
|
|
|
using JiShe.CollectBus.Repository;
|
|
|
|
|
|
using JiShe.CollectBus.Repository.MeterReadingRecord;
|
|
|
|
|
|
using JiShe.CollectBus.ShardingStrategy;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using Volo.Abp;
|
2024-12-19 16:07:07 +08:00
|
|
|
|
using Volo.Abp.AuditLogging.MongoDB;
|
|
|
|
|
|
using Volo.Abp.BackgroundJobs.MongoDB;
|
2025-03-20 16:40:27 +08:00
|
|
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
|
|
|
using Volo.Abp.Domain.Repositories.MongoDB;
|
2024-12-19 16:07:07 +08:00
|
|
|
|
using Volo.Abp.Modularity;
|
|
|
|
|
|
using Volo.Abp.MongoDB;
|
|
|
|
|
|
using Volo.Abp.Uow;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.MongoDB;
|
|
|
|
|
|
|
|
|
|
|
|
[DependsOn(
|
|
|
|
|
|
typeof(CollectBusDomainModule),
|
|
|
|
|
|
typeof(AbpMongoDbModule),
|
|
|
|
|
|
typeof(AbpBackgroundJobsMongoDbModule),
|
|
|
|
|
|
typeof(AbpAuditLoggingMongoDbModule)
|
|
|
|
|
|
)]
|
|
|
|
|
|
public class CollectBusMongoDbModule : AbpModule
|
|
|
|
|
|
{
|
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
context.Services.AddMongoDbContext<CollectBusMongoDbContext>(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.AddDefaultRepositories();
|
2025-03-20 16:40:27 +08:00
|
|
|
|
|
|
|
|
|
|
// 注册分表策略
|
|
|
|
|
|
context.Services.AddTransient(
|
|
|
|
|
|
typeof(IShardingStrategy<>),
|
|
|
|
|
|
typeof(DayShardingStrategy<>));
|
|
|
|
|
|
|
2025-03-21 11:48:31 +08:00
|
|
|
|
//// 分表策略仓储 替换默认仓储
|
|
|
|
|
|
//options.AddRepository<MeterReadingRecords, MeterReadingRecordRepository>();
|
2024-12-19 16:07:07 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
context.Services.AddAlwaysDisableUnitOfWorkTransaction();
|
|
|
|
|
|
Configure<AbpUnitOfWorkDefaultOptions>(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|