mirror of https://github.com/abpframework/abp.git
95 changed files with 1274 additions and 191 deletions
@ -0,0 +1,18 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Components.WebAssembly.BasicTheme.Themes.Basic |
|||
{ |
|||
public partial class LoginDisplay |
|||
{ |
|||
[Inject] protected IMenuManager MenuManager { get; set; } |
|||
|
|||
protected ApplicationMenu Menu { get; set; } |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
Menu = await MenuManager.GetAsync(StandardMenus.User); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using Volo.Abp.Cli.ProjectBuilding.Building; |
|||
|
|||
namespace Volo.Abp.Cli.ProjectBuilding.Templates.App |
|||
{ |
|||
public class BlazorAppsettingsFilePortChangeForSeparatedIdentityServersStep : ProjectBuildPipelineStep |
|||
{ |
|||
public override void Execute(ProjectBuildContext context) |
|||
{ |
|||
var appsettingsFile = context.Files.FirstOrDefault(x => |
|||
!x.IsDirectory && |
|||
x.Name.EndsWith("aspnet-core/src/MyCompanyName.MyProjectName.Blazor/wwwroot/appsettings.json", |
|||
StringComparison.InvariantCultureIgnoreCase) |
|||
); |
|||
|
|||
appsettingsFile.NormalizeLineEndings(); |
|||
var lines = appsettingsFile.GetLines(); |
|||
|
|||
for (var i = 0; i < lines.Length; i++) |
|||
{ |
|||
var line = lines[i]; |
|||
|
|||
if (line.Contains("Authority") && line.Contains("localhost")) |
|||
{ |
|||
line = line.Replace("44305", "44301"); |
|||
} |
|||
else if (line.Contains("BaseUrl") && line.Contains("localhost")) |
|||
{ |
|||
line = line.Replace("44305", "44300"); |
|||
} |
|||
|
|||
lines[i] = line; |
|||
} |
|||
|
|||
appsettingsFile.SetLines(lines); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using System; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.MongoDB.DependencyInjection |
|||
{ |
|||
public class AbpMongoDbConventionalRegistrar : DefaultConventionalRegistrar |
|||
{ |
|||
public override void AddType(IServiceCollection services, Type type) |
|||
{ |
|||
if (!typeof(IAbpMongoDbContext).IsAssignableFrom(type) || type == typeof(AbpMongoDbContext)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var dependencyAttribute = GetDependencyAttributeOrNull(type); |
|||
var lifeTime = GetLifeTimeOrNull(type, dependencyAttribute); |
|||
|
|||
if (lifeTime == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
services.Add(ServiceDescriptor.Describe(typeof(IAbpMongoDbContext), type, ServiceLifetime.Transient)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using MongoDB.Driver; |
|||
|
|||
namespace Volo.Abp.Uow.MongoDB |
|||
{ |
|||
public class MongoDbTransactionApi : ITransactionApi, ISupportsRollback |
|||
{ |
|||
public IClientSessionHandle SessionHandle { get; } |
|||
|
|||
public MongoDbTransactionApi(IClientSessionHandle sessionHandle) |
|||
{ |
|||
SessionHandle = sessionHandle; |
|||
} |
|||
|
|||
public async Task CommitAsync() |
|||
{ |
|||
await SessionHandle.CommitTransactionAsync(); |
|||
} |
|||
|
|||
protected void Commit() |
|||
{ |
|||
SessionHandle.CommitTransaction(); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
SessionHandle.Dispose(); |
|||
} |
|||
|
|||
public void Rollback() |
|||
{ |
|||
SessionHandle.AbortTransaction(); |
|||
} |
|||
|
|||
public async Task RollbackAsync(CancellationToken cancellationToken) |
|||
{ |
|||
await SessionHandle.AbortTransactionAsync(cancellationToken); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using AutoMapper; |
|||
using Volo.Abp.Account.Blazor.Pages.Account; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace Volo.Abp.Account.Blazor |
|||
{ |
|||
public class AbpAccountBlazorAutoMapperProfile : Profile |
|||
{ |
|||
public AbpAccountBlazorAutoMapperProfile() |
|||
{ |
|||
CreateMap<ProfileDto, PersonalInfoModel>() |
|||
.Ignore(x => x.PhoneNumberConfirmed) |
|||
.Ignore(x => x.EmailConfirmed); |
|||
|
|||
CreateMap<PersonalInfoModel, UpdateProfileDto>() |
|||
.Ignore(x => x.ExtraProperties); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming; |
|||
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming.Routing; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Volo.Abp.Account.Blazor |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule), |
|||
typeof(AbpAutoMapperModule), |
|||
typeof(AbpAccountHttpApiClientModule) |
|||
)] |
|||
public class AbpAccountBlazorModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAutoMapperObjectMapper<AbpAccountBlazorModule>(); |
|||
|
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddProfile<AbpAccountBlazorAutoMapperProfile>(validate: true); |
|||
}); |
|||
|
|||
Configure<AbpNavigationOptions>(options => |
|||
{ |
|||
options.MenuContributors.Add(new AbpAccountBlazorUserMenuContributor()); |
|||
}); |
|||
|
|||
Configure<AbpRouterOptions>(options => |
|||
{ |
|||
options.AdditionalAssemblies.Add(typeof(AbpAccountBlazorModule).Assembly); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Account.Localization; |
|||
using Volo.Abp.UI.Navigation; |
|||
|
|||
namespace Volo.Abp.Account.Blazor |
|||
{ |
|||
public class AbpAccountBlazorUserMenuContributor : IMenuContributor |
|||
{ |
|||
public Task ConfigureMenuAsync(MenuConfigurationContext context) |
|||
{ |
|||
if (context.Menu.Name != StandardMenus.User) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
var accountResource = context.GetLocalizer<AccountResource>(); |
|||
|
|||
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountResource["ManageYourProfile"], url: "account/manage-profile", icon: "fa fa-cog")); |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,64 @@ |
|||
@page "/account/manage-profile" |
|||
@inherits AccountManageBase |
|||
<Row> |
|||
<Column ColumnSize="ColumnSize.Is12"> |
|||
<Tabs @bind-SelectedTab="@SelectedTab" TabPosition="TabPosition.Left" Pills="true"> |
|||
<Items> |
|||
<Tab Name="Password">@L["ProfileTab:Password"]</Tab> |
|||
<Tab Name="PersonalInfo">@L["ProfileTab:PersonalInfo"]</Tab> |
|||
</Items> |
|||
<Content> |
|||
@if (ChangePasswordModel != null) |
|||
{ |
|||
<TabPanel Name="Password"> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName:CurrentPassword"]</FieldLabel> |
|||
<TextEdit Role="TextRole.Password" @bind-text="@ChangePasswordModel.CurrentPassword" /> |
|||
</Field> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName:NewPassword"]</FieldLabel> |
|||
<TextEdit Role="TextRole.Password" @bind-text="@ChangePasswordModel.NewPassword" /> |
|||
</Field> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName:NewPasswordConfirm"]</FieldLabel> |
|||
<TextEdit Role="TextRole.Password" @bind-text="@ChangePasswordModel.NewPasswordConfirm" /> |
|||
</Field> |
|||
<Field> |
|||
<Button Color="Color.Primary" Clicked="@ChangePasswordAsync">@L["Save"]</Button> |
|||
</Field> |
|||
</TabPanel> |
|||
} |
|||
@if (PersonalInfoModel != null) |
|||
{ |
|||
<TabPanel Name="PersonalInfo"> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName:UserName"]</FieldLabel> |
|||
<TextEdit @bind-text="@PersonalInfoModel.UserName" /> |
|||
</Field> |
|||
<Fields> |
|||
<Field ColumnSize="ColumnSize.Is6"> |
|||
<FieldLabel>@L["DisplayName:Name"]</FieldLabel> |
|||
<TextEdit @bind-text="@PersonalInfoModel.Name" /> |
|||
</Field> |
|||
<Field ColumnSize="ColumnSize.Is6"> |
|||
<FieldLabel>@L["DisplayName:Surname"]</FieldLabel> |
|||
<TextEdit @bind-text="@PersonalInfoModel.Surname" /> |
|||
</Field> |
|||
</Fields> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName:Email"]</FieldLabel> |
|||
<TextEdit @bind-text="@PersonalInfoModel.Email" /> |
|||
</Field> |
|||
<Field> |
|||
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel> |
|||
<TextEdit @bind-text="@PersonalInfoModel.PhoneNumber" /> |
|||
</Field> |
|||
<Field> |
|||
<Button Color="Color.Primary" Clicked="@UpdatePersonalInfoAsync">@L["Save"]</Button> |
|||
</Field> |
|||
</TabPanel> |
|||
} |
|||
</Content> |
|||
</Tabs> |
|||
</Column> |
|||
</Row> |
|||
@ -0,0 +1,117 @@ |
|||
using System.Threading.Tasks; |
|||
using Localization.Resources.AbpUi; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.Extensions.Localization; |
|||
using Volo.Abp.Account.Localization; |
|||
using Volo.Abp.AspNetCore.Components.WebAssembly; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.ObjectMapping; |
|||
|
|||
namespace Volo.Abp.Account.Blazor.Pages.Account |
|||
{ |
|||
public class AccountManageBase : OwningComponentBase |
|||
{ |
|||
[Inject] protected IAccountAppService AccountAppService { get; set; } |
|||
[Inject] protected IProfileAppService ProfileAppService { get; set; } |
|||
|
|||
[Inject] protected IObjectMapper<AbpAccountBlazorModule> ObjectMapper { get; set; } |
|||
|
|||
[Inject] protected IUiMessageService UiMessageService { get; set; } |
|||
|
|||
[Inject] protected IStringLocalizer<AbpUiResource> UiLocalizer { get; set; } |
|||
|
|||
[Inject] protected IStringLocalizer<AccountResource> L { get; set; } |
|||
|
|||
protected string SelectedTab = "Password"; |
|||
|
|||
protected ChangePasswordModel ChangePasswordModel; |
|||
|
|||
protected PersonalInfoModel PersonalInfoModel; |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
await GetUserInformations(); |
|||
} |
|||
|
|||
protected async Task GetUserInformations() |
|||
{ |
|||
var user = await ProfileAppService.GetAsync(); |
|||
|
|||
ChangePasswordModel = new ChangePasswordModel |
|||
{ |
|||
HideOldPasswordInput = !user.HasPassword |
|||
}; |
|||
|
|||
PersonalInfoModel = ObjectMapper.Map<ProfileDto, PersonalInfoModel>(user); |
|||
} |
|||
|
|||
protected async Task ChangePasswordAsync() |
|||
{ |
|||
if (string.IsNullOrWhiteSpace(ChangePasswordModel.CurrentPassword)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
if (ChangePasswordModel.NewPassword != ChangePasswordModel.NewPasswordConfirm) |
|||
{ |
|||
await UiMessageService.WarnAsync(L["NewPasswordConfirmFailed"]); |
|||
return; |
|||
} |
|||
|
|||
if (!await UiMessageService.ConfirmAsync(UiLocalizer["AreYouSure"])) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
await ProfileAppService.ChangePasswordAsync(new ChangePasswordInput |
|||
{ |
|||
CurrentPassword = ChangePasswordModel.CurrentPassword, |
|||
NewPassword = ChangePasswordModel.NewPassword |
|||
}); |
|||
|
|||
await UiMessageService.SuccessAsync(L["PasswordChanged"]); |
|||
} |
|||
|
|||
protected async Task UpdatePersonalInfoAsync() |
|||
{ |
|||
if (!await UiMessageService.ConfirmAsync(UiLocalizer["AreYouSure"])) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
await ProfileAppService.UpdateAsync( |
|||
ObjectMapper.Map<PersonalInfoModel, UpdateProfileDto>(PersonalInfoModel) |
|||
); |
|||
|
|||
await UiMessageService.SuccessAsync(L["PersonalSettingsSaved"]); |
|||
} |
|||
} |
|||
|
|||
public class ChangePasswordModel |
|||
{ |
|||
public string CurrentPassword { get; set; } |
|||
|
|||
public string NewPassword { get; set; } |
|||
|
|||
public string NewPasswordConfirm { get; set; } |
|||
|
|||
public bool HideOldPasswordInput { get; set; } |
|||
} |
|||
|
|||
public class PersonalInfoModel |
|||
{ |
|||
public string UserName { get; set; } |
|||
|
|||
public string Email { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public string Surname { get; set; } |
|||
|
|||
public string PhoneNumber { get; set; } |
|||
|
|||
public bool PhoneNumberConfirmed { get; set; } |
|||
|
|||
public bool EmailConfirmed { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<Import Project="..\..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RazorLangVersion>3.0</RazorLangVersion> |
|||
<RootNamespace>Volo.Abp.Account.Blazor</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.WebAssembly.Theming\Volo.Abp.AspNetCore.Components.WebAssembly.Theming.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Account.HttpApi.Client\Volo.Abp.Account.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Content Update="Pages\Account\Manage.razor"> |
|||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using Volo.Abp.AspNetCore.Components.WebAssembly |
|||
@using Volo.Abp.BlazoriseUI |
|||
@using Blazorise |
|||
@using Blazorise.DataGrid |
|||
@ -1,25 +1,31 @@ |
|||
using System; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace Volo.Abp.BlobStoring.Database.MongoDB |
|||
{ |
|||
[DependsOn( |
|||
typeof(BlobStoringDatabaseTestBaseModule), |
|||
typeof(BlobStoringDatabaseMongoDbModule) |
|||
)] |
|||
)] |
|||
public class BlobStoringDatabaseMongoDbTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var connectionString = MongoDbFixture.ConnectionString.EnsureEndsWith('/') + |
|||
var connectionString = MongoDbFixture.ConnectionString.EnsureEndsWith('/') + |
|||
"Db_" + |
|||
Guid.NewGuid().ToString("N"); |
|||
Guid.NewGuid().ToString("N"); |
|||
|
|||
Configure<AbpDbConnectionOptions>(options => |
|||
{ |
|||
options.ConnectionStrings.Default = connectionString; |
|||
}); |
|||
|
|||
Configure<AbpUnitOfWorkDefaultOptions>(options => |
|||
{ |
|||
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,25 +1,31 @@ |
|||
using System; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace Volo.CmsKit.MongoDB |
|||
{ |
|||
[DependsOn( |
|||
typeof(CmsKitTestBaseModule), |
|||
typeof(CmsKitMongoDbModule) |
|||
)] |
|||
)] |
|||
public class CmsKitMongoDbTestModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var connectionString = MongoDbFixture.ConnectionString.EnsureEndsWith('/') + |
|||
var connectionString = MongoDbFixture.ConnectionString.EnsureEndsWith('/') + |
|||
"Db_" + |
|||
Guid.NewGuid().ToString("N"); |
|||
Guid.NewGuid().ToString("N"); |
|||
|
|||
Configure<AbpDbConnectionOptions>(options => |
|||
{ |
|||
options.ConnectionStrings.Default = connectionString; |
|||
}); |
|||
|
|||
Configure<AbpUnitOfWorkDefaultOptions>(options => |
|||
{ |
|||
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,7 +1,9 @@ |
|||
namespace Volo.Abp.FeatureManagement |
|||
using System; |
|||
|
|||
namespace Volo.Abp.FeatureManagement |
|||
{ |
|||
public static class FeatureManagementDomainErrorCodes |
|||
{ |
|||
|
|||
public const string FeatureValueInvalid = "Volo.Abp.FeatureManagement:InvalidFeatureValue"; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.FeatureManagement |
|||
{ |
|||
[Serializable] |
|||
public class FeatureValueInvalidException : BusinessException |
|||
{ |
|||
public FeatureValueInvalidException(string name) : |
|||
base(FeatureManagementDomainErrorCodes.FeatureValueInvalid) |
|||
{ |
|||
WithData("0", name); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using MongoDB.Driver; |
|||
using MyCompanyName.MyProjectName.Data; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.MongoDB; |
|||
|
|||
namespace MyCompanyName.MyProjectName.MongoDB |
|||
{ |
|||
public class MongoDbMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator , ITransientDependency |
|||
{ |
|||
private readonly IServiceProvider _serviceProvider; |
|||
|
|||
public MongoDbMyProjectNameDbSchemaMigrator(IServiceProvider serviceProvider) |
|||
{ |
|||
_serviceProvider = serviceProvider; |
|||
} |
|||
|
|||
public Task MigrateAsync() |
|||
{ |
|||
var dbContexts = _serviceProvider.GetServices<IAbpMongoDbContext>(); |
|||
var connectionStringResolver = _serviceProvider.GetService<IConnectionStringResolver>(); |
|||
|
|||
foreach (var dbContext in dbContexts) |
|||
{ |
|||
var connectionString = |
|||
connectionStringResolver.Resolve( |
|||
ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType())); |
|||
var mongoUrl = new MongoUrl(connectionString); |
|||
var databaseName = mongoUrl.DatabaseName; |
|||
var client = new MongoClient(mongoUrl); |
|||
|
|||
if (databaseName.IsNullOrWhiteSpace()) |
|||
{ |
|||
databaseName = ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType()); |
|||
} |
|||
|
|||
(dbContext as AbpMongoDbContext)?.InitializeCollections(client.GetDatabase(databaseName)); |
|||
} |
|||
|
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue