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 JiShe.CollectBus.Common.Extensions; using Volo.Abp.AspNetCore.Mvc.AntiForgery; using JiShe.CollectBus.FreeRedisProvider; using JiShe.CollectBus.Workers; using Volo.Abp.BackgroundWorkers.Hangfire; using JiShe.CollectBus.MongoDB; using JiShe.CollectBus.ScheduledMeterReading; using AutoMapper.Configuration.Annotations; using JiShe.CollectBus.Common.Attributes; namespace JiShe.CollectBus; [DependsOn( typeof(CollectBusDomainModule), typeof(CollectBusApplicationContractsModule), typeof(AbpDddApplicationModule), typeof(AbpAutoMapperModule), typeof(AbpBackgroundWorkersHangfireModule), typeof(CollectBusFreeRedisModule), typeof(CollectBusFreeSqlModule) )] public class CollectBusApplicationModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAutoMapperObjectMapper(); Configure(options => { options.AddMaps(validate: true); }); //Configure(options => //{ // options.TokenCookie.Expiration = TimeSpan.FromDays(365); // options.AutoValidateIgnoredHttpMethods.Add("POST"); //}); } public override void OnApplicationInitialization( ApplicationInitializationContext context) { var assembly = Assembly.GetExecutingAssembly(); var types = assembly.GetTypes().Where(t => typeof(ICollectWorker).IsAssignableFrom(t) && !t.IsInterface).ToList(); foreach (var type in types) { context.AddBackgroundWorkerAsync(type); } var dbContext = context.ServiceProvider.GetRequiredService(); //默认初始化表计信息 dbContext.InitAmmeterCacheData().ConfigureAwait(false).GetAwaiter().GetResult(); } }