JiShe.CollectBus/services/JiShe.CollectBus.Migration.Application/CollectBusMigrationApplicationModule.cs
2025-05-18 14:10:39 +08:00

70 lines
2.6 KiB
C#

using JiShe.CollectBus.FreeRedis;
using JiShe.CollectBus.FreeSql;
using JiShe.CollectBus.IoTDB;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
namespace JiShe.CollectBus.Migration;
[DependsOn(
typeof(CollectBusDomainModule),
typeof(CollectBusMigrationApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule),
typeof(CollectBusFreeRedisModule),
typeof(CollectBusFreeSqlModule),
typeof(CollectBusIoTDbModule)
)]
public class CollectBusMigrationApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
context.Services.AddAutoMapperObjectMapper<CollectBusMigrationApplicationModule>();
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<CollectBusMigrationApplicationModule>(true); });
}
public override async Task OnApplicationInitializationAsync(
ApplicationInitializationContext context)
{
//var assembly = Assembly.GetExecutingAssembly();
//var types = assembly.GetTypes().Where(t => typeof(ICollectWorker).IsAssignableFrom(t) && !t.IsInterface)
// .ToList();
//foreach (var type in types) await context.AddBackgroundWorkerAsync(type);
//Task.Run(() =>
//{
// //默认初始化表计信息
// var dbContext = context.ServiceProvider.GetRequiredService<EnergySystemScheduledMeterReadingService>();
// dbContext.InitAmmeterCacheData();
// //await dbContext.InitWatermeterCacheData();
//}).ConfigureAwait(false);
////下发任务通道构建
//DataChannelManage.TaskDataChannel = Channel.CreateUnbounded<ValueTuple<string, List<MeterReadingTelemetryPacketInfo>>>();
//// 日志存储通道构建
//DataChannelManage.LogSaveChannel = Channel.CreateUnbounded<object>();
//// 日志刷新通道构建
//DataChannelManage.LogRefreshChannel = Channel.CreateUnbounded<object>();
//// 启动通道任务
//var _dataChannelManage = context.ServiceProvider.GetRequiredService<DataChannelManageService>();
//_ = _dataChannelManage.LogSaveAsync(DataChannelManage.LogSaveChannel.Reader);
////默认初始化表计信息
//var dbContext = context.ServiceProvider.GetRequiredService<EnergySystemScheduledMeterReadingService>();
//await dbContext.InitAmmeterCacheData();
}
}