JiShe.CollectBus/src/JiShe.CollectBus.Application/CollectBusApplicationModule.cs

67 lines
2.1 KiB
C#
Raw Normal View History

2024-12-19 16:07:07 +08:00
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
using Volo.Abp.BackgroundWorkers;
using System.Threading.Tasks;
using Volo.Abp;
using System.Reflection;
using JiShe.CollectBus.FreeSql;
using System;
using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using JiShe.CollectBus.FreeRedisProvider;
2025-03-14 13:45:29 +08:00
using JiShe.CollectBus.Workers;
using Volo.Abp.BackgroundWorkers.Hangfire;
2025-03-20 16:40:27 +08:00
using JiShe.CollectBus.MongoDB;
2025-03-21 11:48:31 +08:00
using JiShe.CollectBus.ScheduledMeterReading;
2025-04-02 17:46:33 +08:00
using JiShe.CollectBus.IoTDBProvider;
2024-12-19 16:07:07 +08:00
namespace JiShe.CollectBus;
[DependsOn(
typeof(CollectBusDomainModule),
typeof(CollectBusApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule),
2025-03-14 13:45:29 +08:00
typeof(AbpBackgroundWorkersHangfireModule),
2025-03-17 08:35:19 +08:00
typeof(CollectBusFreeRedisModule),
2025-04-02 17:46:33 +08:00
typeof(CollectBusIoTDBModule),
2024-12-19 16:07:07 +08:00
typeof(CollectBusFreeSqlModule)
)]
public class CollectBusApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<CollectBusApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<CollectBusApplicationModule>(validate: true);
});
Configure<AbpAntiForgeryOptions>(options =>
{
options.TokenCookie.Expiration = TimeSpan.FromDays(365);
options.AutoValidateIgnoredHttpMethods.Add("POST");
});
}
2025-03-14 13:45:29 +08:00
public override void OnApplicationInitialization(
2024-12-19 16:07:07 +08:00
ApplicationInitializationContext context)
{
var assembly = Assembly.GetExecutingAssembly();
var types = assembly.GetTypes().Where(t => typeof(ICollectWorker).IsAssignableFrom(t) && !t.IsInterface).ToList();
foreach (var type in types)
{
2025-03-14 13:45:29 +08:00
context.AddBackgroundWorkerAsync(type);
2024-12-19 16:07:07 +08:00
}
2025-03-21 11:48:31 +08:00
var dbContext = context.ServiceProvider.GetRequiredService<EnergySystemScheduledMeterReadingService>();
//默认初始化表计信息
dbContext.InitAmmeterCacheData().ConfigureAwait(false).GetAwaiter().GetResult();
2024-12-19 16:07:07 +08:00
}
}