You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

  1. using Microsoft.Extensions.DependencyInjection;
  2. using Volo.Abp;
  3. using Volo.Abp.Authorization;
  4. using Volo.Abp.Autofac;
  5. using Volo.Abp.BackgroundJobs;
  6. using Volo.Abp.Data;
  7. using Volo.Abp.Modularity;
  8. using Volo.Abp.Threading;
  9. namespace Shentun.Sms;
  10. [DependsOn(
  11. typeof(AbpAutofacModule),
  12. typeof(AbpTestBaseModule),
  13. typeof(AbpAuthorizationModule),
  14. typeof(SmsDomainModule)
  15. )]
  16. public class SmsTestBaseModule : AbpModule
  17. {
  18. public override void PreConfigureServices(ServiceConfigurationContext context)
  19. {
  20. }
  21. public override void ConfigureServices(ServiceConfigurationContext context)
  22. {
  23. Configure<AbpBackgroundJobOptions>(options =>
  24. {
  25. options.IsJobExecutionEnabled = false;
  26. });
  27. context.Services.AddAlwaysAllowAuthorization();
  28. }
  29. public override void OnApplicationInitialization(ApplicationInitializationContext context)
  30. {
  31. SeedTestData(context);
  32. }
  33. private static void SeedTestData(ApplicationInitializationContext context)
  34. {
  35. AsyncHelper.RunSync(async () =>
  36. {
  37. using (var scope = context.ServiceProvider.CreateScope())
  38. {
  39. await scope.ServiceProvider
  40. .GetRequiredService<IDataSeeder>()
  41. .SeedAsync();
  42. }
  43. });
  44. }
  45. }