diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs index 403bbac7b1..3b5ccb38c9 100644 --- a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebApplicationBuilderExtensions.cs @@ -9,15 +9,16 @@ namespace Volo.Abp.AspNetCore.TestBase; public static class WebApplicationBuilderExtensions { - public async static Task RunAbpModuleAsync(this WebApplicationBuilder builder, Action? optionsAction = null) + public async static Task RunAbpModuleAsync(this WebApplicationBuilder builder, Action? optionsAction = null, string? applicationName = null) where TModule : IAbpModule { - var assemblyName = typeof(TModule).Assembly.GetName()?.Name; - if (!assemblyName.IsNullOrWhiteSpace()) + applicationName = applicationName ?? typeof(TModule).Assembly.GetName()?.Name; + if (!applicationName.IsNullOrWhiteSpace()) { // Set the application name as the assembly name of the module will automatically add assembly to the ApplicationParts of MVC application. - builder.Environment.ApplicationName = assemblyName!; + builder.Environment.ApplicationName = applicationName; } + builder.Host.UseAutofac(); await builder.AddApplicationAsync(optionsAction); var app = builder.Build(); diff --git a/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebProjectPatchHelper.cs b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebProjectPatchHelper.cs new file mode 100644 index 0000000000..96d8d2383c --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/WebProjectPatchHelper.cs @@ -0,0 +1,28 @@ +using System.IO; + +namespace Volo.Abp.AspNetCore.TestBase; + +public static class GetWebProjectContentRootPathHelper +{ + public static string Get(string webProjectName) + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (currentDirectory != null && Directory.GetParent(currentDirectory.FullName) != null) + { + currentDirectory = Directory.GetParent(currentDirectory.FullName); + if (currentDirectory == null) + { + continue; + } + + var files = currentDirectory.GetFiles(webProjectName, SearchOption.AllDirectories); + if (files.Length > 0) + { + return files[0].DirectoryName!; + } + } + + throw new AbpException($"Web project({webProjectName}) not found!"); + } +} diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs index cbc16e10a7..0c066a0904 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/EfCoreAuditLogRepository.cs @@ -149,12 +149,13 @@ public class EfCoreAuditLogRepository : EfCoreRepository a.ExecutionTime < endDate.AddDays(1) && a.ExecutionTime > startDate) .OrderBy(t => t.ExecutionTime) .GroupBy(t => new { t.ExecutionTime.Date }) + .ToListAsync(cancellationToken: cancellationToken)) .Select(g => new { Day = g.Min(t => t.ExecutionTime), avgExecutionTime = g.Average(t => t.ExecutionDuration) }) - .ToListAsync(GetCancellationToken(cancellationToken)); + .ToList(); return result.ToDictionary(element => element.Day.ClearTime(), element => element.avgExecutionTime); } diff --git a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore.cs b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore.cs index c8d1f0895c..7e2bf3dff3 100644 --- a/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore.cs +++ b/modules/openiddict/src/Volo.Abp.OpenIddict.Domain/Volo/Abp/OpenIddict/Tokens/AbpOpenIddictTokenStore.cs @@ -63,7 +63,7 @@ public class AbpOpenIddictTokenStore : AbpOpenIddictStoreBase(); -public partial class Program -{ +builder.Environment.ContentRootPath = GetWebProjectContentRootPathHelper.Get("MyCompanyName.MyProjectName.Web.csproj"); +await builder.RunAbpModuleAsync(applicationName: "MyCompanyName.MyProjectName.Web" ); -} \ No newline at end of file +public partial class Program +{ +}