From 76deaf8d6fe108cdd8e1e4c32997b084b319d3b7 Mon Sep 17 00:00:00 2001 From: nongzhsh Date: Fri, 15 Mar 2019 03:37:38 +0800 Subject: [PATCH 01/44] Fixed the bug that add new tag was not valid for the first time --- .../Volo/Blogging/Posts/PostAppService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs index 34488f77a1..916455bc47 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Posts/PostAppService.cs @@ -228,8 +228,9 @@ namespace Volo.Blogging.Posts { tag.IncreaseUsageCount(); tag = await _tagRepository.UpdateAsync(tag); - post.AddTag(tag.Id); } + + post.AddTag(tag.Id); } } From f875706c2b605872cf3059bdf54a3d94f100efa8 Mon Sep 17 00:00:00 2001 From: Bruno Bertechini Date: Sat, 16 Mar 2019 09:01:22 -0300 Subject: [PATCH 02/44] #881 msdemo: added default value for input.Sorting in ProductAppService GetListPagedAsync --- .../ProductManagement/ProductAppService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductAppService.cs b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductAppService.cs index 25a596b24e..6cdf82f22a 100644 --- a/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductAppService.cs +++ b/samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductAppService.cs @@ -28,7 +28,7 @@ namespace ProductManagement await NormalizeMaxResultCountAsync(input); var products = await _productRepository - .OrderBy(input.Sorting) + .OrderBy(input.Sorting ?? "Name") .Skip(input.SkipCount) .Take(input.MaxResultCount) .ToListAsync(); From be76678c74adaa8fed279212ee0b9c1045511966 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Mon, 18 Mar 2019 17:21:23 +0300 Subject: [PATCH 03/44] Resolved #885: Add default "Administration" menu --- .../AbpAspNetCoreMvcUiBootstrapModule.cs | 3 +- .../AbpAspNetCoreMvcUiThemeSharedModule.cs | 3 +- .../{ILayoutManager.cs => IPageLayout.cs} | 0 .../Volo.Abp.UI.Navigation.csproj | 7 +++- .../Ui/Navigation/AbpUiNavigationModule.cs | 24 ++++++++++++- .../Navigation/ApplicationMenuExtensions.cs | 35 +++++++++++++++++++ .../Ui/Navigation/DefaultMenuContributor.cs | 34 ++++++++++++++++++ .../Abp/Ui/Navigation/DefaultMenuNames.cs | 13 +++++++ .../Resource/AbpUiNavigationResource.cs | 10 ++++++ .../Navigation/Localization/Resource/en.json | 6 ++++ .../Navigation/Localization/Resource/tr.json | 6 ++++ .../Volo/Abp/Ui/Navigation/MenuManager.cs | 16 ++++----- .../Volo/Abp/Ui/Navigation/StandardMenus.cs | 6 ++++ .../Resources/AbpUi/AbpUiResource.cs | 1 + framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj | 3 +- .../Volo.Abp.UI/Volo/Abp/Ui/AbpUiModule.cs | 4 ++- .../Abp/Ui/Navigation/MenuManager_Tests.cs | 14 +++----- 17 files changed, 159 insertions(+), 26 deletions(-) rename framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Layout/{ILayoutManager.cs => IPageLayout.cs} (100%) create mode 100644 framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs create mode 100644 framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/DefaultMenuContributor.cs create mode 100644 framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/DefaultMenuNames.cs create mode 100644 framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/AbpUiNavigationResource.cs create mode 100644 framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/en.json create mode 100644 framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/tr.json diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs index 44a00808f8..d038d64789 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/AbpAspNetCoreMvcUiBootstrapModule.cs @@ -1,5 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Modularity; +using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs index 57a03d0d75..fb8619b60a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpAspNetCoreMvcUiThemeSharedModule.cs @@ -1,5 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Layout/ILayoutManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Layout/IPageLayout.cs similarity index 100% rename from framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Layout/ILayoutManager.cs rename to framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Layout/IPageLayout.cs diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo.Abp.UI.Navigation.csproj b/framework/src/Volo.Abp.UI.Navigation/Volo.Abp.UI.Navigation.csproj index 79955d3241..c218698017 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo.Abp.UI.Navigation.csproj +++ b/framework/src/Volo.Abp.UI.Navigation/Volo.Abp.UI.Navigation.csproj @@ -1,4 +1,4 @@ - + @@ -13,6 +13,11 @@ + + + + + diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/AbpUiNavigationModule.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/AbpUiNavigationModule.cs index c0934e0a4a..8f4be85af2 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/AbpUiNavigationModule.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/AbpUiNavigationModule.cs @@ -1,10 +1,32 @@ -using Volo.Abp.Modularity; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.Ui.Navigation; +using Volo.Abp.Ui.Navigation.Localization.Resource; +using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.UI.Navigation { [DependsOn(typeof(AbpUiModule))] public class AbpUiNavigationModule : AbpModule { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + Configure(options => + { + options.Resources + .Add("en") + .AddVirtualJson("/Volo/Abp/Ui/Navigation/Localization/Resource"); + }); + + Configure(options => + { + options.MenuContributors.Add(new DefaultMenuContributor()); + }); + } } } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs new file mode 100644 index 0000000000..4c24027a1e --- /dev/null +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs @@ -0,0 +1,35 @@ +using System.Linq; +using JetBrains.Annotations; +using Volo.Abp.Ui.Navigation; + +namespace Volo.Abp.UI.Navigation +{ + public static class ApplicationMenuExtensions + { + [NotNull] + public static ApplicationMenuItem GetAdministration(this ApplicationMenu applicationMenu) + { + return applicationMenu.GetMenuItem(DefaultMenuNames.Application.Main.Administration); + } + + [NotNull] + public static ApplicationMenuItem GetMenuItem(this IHasMenuItems menuWithItems, string menuItemName) + { + var menuItem = menuWithItems.GetMenuItemOrNull(menuItemName); + if (menuItem == null) + { + throw new AbpException($"Could not find a menu item with given name: {menuItemName}"); + } + + return menuItem; + } + + [CanBeNull] + public static ApplicationMenuItem GetMenuItemOrNull( + this IHasMenuItems menuWithItems, + string menuItemName) + { + return menuWithItems.Items.FirstOrDefault(mi => mi.Name == menuItemName); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/DefaultMenuContributor.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/DefaultMenuContributor.cs new file mode 100644 index 0000000000..c1f035e292 --- /dev/null +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/DefaultMenuContributor.cs @@ -0,0 +1,34 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; +using System.Threading.Tasks; +using Volo.Abp.Ui.Navigation.Localization.Resource; +using Volo.Abp.UI.Navigation; + +namespace Volo.Abp.Ui.Navigation +{ + public class DefaultMenuContributor : IMenuContributor + { + public virtual Task ConfigureMenuAsync(MenuConfigurationContext context) + { + Configure(context); + return Task.CompletedTask; + } + + protected virtual void Configure(MenuConfigurationContext context) + { + var l = context.ServiceProvider + .GetRequiredService>(); + + if (context.Menu.Name == StandardMenus.Main) + { + context.Menu.AddItem( + new ApplicationMenuItem( + DefaultMenuNames.Application.Main.Administration, + l["Menu:Administration"], + icon: "fa fa-wrench" + ) + ); + } + } + } +} diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/DefaultMenuNames.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/DefaultMenuNames.cs new file mode 100644 index 0000000000..96032f48fa --- /dev/null +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/DefaultMenuNames.cs @@ -0,0 +1,13 @@ +namespace Volo.Abp.Ui.Navigation +{ + public static class DefaultMenuNames + { + public static class Application + { + public static class Main + { + public const string Administration = "Abp.Application.Main.Administration"; + } + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/AbpUiNavigationResource.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/AbpUiNavigationResource.cs new file mode 100644 index 0000000000..96d09e9507 --- /dev/null +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/AbpUiNavigationResource.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Localization; + +namespace Volo.Abp.Ui.Navigation.Localization.Resource +{ + [LocalizationResourceName("AbpUiNavigation")] + public class AbpUiNavigationResource + { + + } +} diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/en.json b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/en.json new file mode 100644 index 0000000000..96ca0c5603 --- /dev/null +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/en.json @@ -0,0 +1,6 @@ +{ + "culture": "en", + "texts": { + "Menu:Administration": "Administration" + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/tr.json b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/tr.json new file mode 100644 index 0000000000..67c6da0197 --- /dev/null +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/Localization/Resource/tr.json @@ -0,0 +1,6 @@ +{ + "culture": "tr", + "texts": { + "Menu:Administration": "Yönetim" + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs index 93b206a2b4..ada287ff87 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; @@ -9,26 +8,26 @@ namespace Volo.Abp.UI.Navigation { public class MenuManager : IMenuManager, ITransientDependency { - private readonly NavigationOptions _options; - private readonly IServiceProvider _serviceProvider; + protected NavigationOptions Options { get; } + protected IHybridServiceScopeFactory ServiceScopeFactory { get; } public MenuManager( IOptions options, - IServiceProvider serviceProvider) + IHybridServiceScopeFactory serviceScopeFactory) { - _serviceProvider = serviceProvider; - _options = options.Value; + ServiceScopeFactory = serviceScopeFactory; + Options = options.Value; } public async Task GetAsync(string name) { var menu = new ApplicationMenu(name); - using (var scope = _serviceProvider.CreateScope()) + using (var scope = ServiceScopeFactory.CreateScope()) { var context = new MenuConfigurationContext(menu, scope.ServiceProvider); - foreach (var contributor in _options.MenuContributors) + foreach (var contributor in Options.MenuContributors) { await contributor.ConfigureMenuAsync(context); } @@ -41,6 +40,7 @@ namespace Volo.Abp.UI.Navigation protected virtual void NormalizeMenu(ApplicationMenu menu) { + //TODO: Should also consider sub menus, recursively, bottom to top! menu.Items.RemoveAll(item => item.IsLeaf && item.Url.IsNullOrEmpty()); } } diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/StandardMenus.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/StandardMenus.cs index b8d63a104d..57a8d7ee41 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/StandardMenus.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/StandardMenus.cs @@ -2,6 +2,12 @@ namespace Volo.Abp.UI.Navigation { public static class StandardMenus { + /* TODO: Consider to create nested class like + * StandardMenus.Application.Main + * StandardMenus.Application.User + * StandardMenus.Application.Shortcut + */ + public const string Main = "Main"; public const string User = "User"; public const string Shortcut = "Shortcut"; diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/AbpUiResource.cs b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/AbpUiResource.cs index 9eb90832e5..fb4600be6e 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/AbpUiResource.cs +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/AbpUiResource.cs @@ -2,6 +2,7 @@ namespace Localization.Resources.AbpUi { + //TODO: Move to the Volo.Abp.UI.Localization.Resource folder [LocalizationResourceName("AbpUi")] public class AbpUiResource { diff --git a/framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj b/framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj index 1a7ab915c9..8716d7a210 100644 --- a/framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj +++ b/framework/src/Volo.Abp.UI/Volo.Abp.UI.csproj @@ -1,4 +1,4 @@ - + @@ -15,6 +15,7 @@ + diff --git a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/AbpUiModule.cs b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/AbpUiModule.cs index fb173ee882..0a9206c309 100644 --- a/framework/src/Volo.Abp.UI/Volo/Abp/Ui/AbpUiModule.cs +++ b/framework/src/Volo.Abp.UI/Volo/Abp/Ui/AbpUiModule.cs @@ -20,7 +20,9 @@ namespace Volo.Abp.UI Configure(options => { - options.Resources.Add("en").AddVirtualJson("/Localization/Resources/AbpUi"); + options.Resources + .Add("en") + .AddVirtualJson("/Localization/Resources/AbpUi"); }); } } diff --git a/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs b/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs index c7f2093e83..0b2d5db4a0 100644 --- a/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs +++ b/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Shouldly; using Volo.Abp.Modularity; -using System.Collections.Generic; +using Volo.Abp.Ui.Navigation; using Xunit; namespace Volo.Abp.UI.Navigation @@ -25,7 +25,7 @@ namespace Volo.Abp.UI.Navigation mainMenu.DisplayName.ShouldBe("Main Menu"); mainMenu.Items.Count.ShouldBe(2); mainMenu.Items[0].Name.ShouldBe("Dashboard"); - mainMenu.Items[1].Name.ShouldBe("Administration"); + mainMenu.Items[1].Name.ShouldBe(DefaultMenuNames.Application.Main.Administration); mainMenu.Items[1].Items[0].Name.ShouldBe("Administration.UserManagement"); mainMenu.Items[1].Items[1].Name.ShouldBe("Administration.RoleManagement"); mainMenu.Items[1].Items[2].Name.ShouldBe("Administration.DashboardSettings"); @@ -60,10 +60,7 @@ namespace Volo.Abp.UI.Navigation context.Menu.DisplayName = "Main Menu"; - var administration = context.Menu.Items.GetOrAdd( - m => m.Name == "Administration", - () => new ApplicationMenuItem("Administration", "Administration") - ); + var administration = context.Menu.GetAdministration(); administration.AddItem(new ApplicationMenuItem("Administration.UserManagement", "User Management", url: "/admin/users")); administration.AddItem(new ApplicationMenuItem("Administration.RoleManagement", "Role Management", url: "/admin/roles")); @@ -88,10 +85,7 @@ namespace Volo.Abp.UI.Navigation context.Menu.Items.Insert(0, new ApplicationMenuItem("Dashboard", "Dashboard", url: "/dashboard")); - var administration = context.Menu.Items.GetOrAdd( - m => m.Name == "Administration", - () => new ApplicationMenuItem("Administration", "Administration") - ); + var administration = context.Menu.GetAdministration(); administration.AddItem(new ApplicationMenuItem("Administration.DashboardSettings", "Dashboard Settings", url: "/admin/settings/dashboard")); From 03246e0791c472847c924d3c935f1c7960de4fbe Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Mon, 18 Mar 2019 19:10:31 +0300 Subject: [PATCH 04/44] Move menu items under the new administration menu --- .../Volo/Abp/Ui/Navigation/ApplicationMenu.cs | 13 ++++-- .../Navigation/ApplicationMenuExtensions.cs | 34 ++++++++++++-- .../Abp/Ui/Navigation/ApplicationMenuItem.cs | 10 +++- .../Ui/Navigation/ApplicationMenuItemList.cs | 46 +++++++++++++++++++ .../Volo/Abp/Ui/Navigation/IHasMenuItems.cs | 4 +- .../Volo/Abp/Ui/Navigation/MenuManager.cs | 11 +++-- .../Abp/Ui/Navigation/MenuManager_Tests.cs | 9 ++++ .../SettingManagementMainMenuContributor.cs | 11 ++++- .../Navigation/SettingManagementMenuNames.cs | 9 +--- 9 files changed, 122 insertions(+), 25 deletions(-) create mode 100644 framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItemList.cs diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenu.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenu.cs index fce412c22f..a40c67cdf6 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenu.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenu.cs @@ -1,5 +1,5 @@ -using System.Collections.Generic; using JetBrains.Annotations; +using Volo.Abp.Ui.Navigation; namespace Volo.Abp.UI.Navigation { @@ -29,11 +29,11 @@ namespace Volo.Abp.UI.Navigation /// [NotNull] - public IList Items { get; } //TODO: Create a specialized collection (that can contain AddAfter for example) + public ApplicationMenuItemList Items { get; } /// /// Can be used to store a custom object related to this menu. - /// TODO: Conver to dictionary! + /// TODO: Convert to dictionary! /// [CanBeNull] public object CustomData { get; set; } @@ -47,7 +47,7 @@ namespace Volo.Abp.UI.Navigation Name = name; DisplayName = displayName ?? Name; - Items = new List(); + Items = new ApplicationMenuItemList(); } /// @@ -60,5 +60,10 @@ namespace Volo.Abp.UI.Navigation Items.Add(menuItem); return this; } + + public override string ToString() + { + return $"[ApplicationMenu] Name = {Name}"; + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs index 4c24027a1e..e69471e15d 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuExtensions.cs @@ -1,5 +1,5 @@ -using System.Linq; using JetBrains.Annotations; +using System.Linq; using Volo.Abp.Ui.Navigation; namespace Volo.Abp.UI.Navigation @@ -7,13 +7,18 @@ namespace Volo.Abp.UI.Navigation public static class ApplicationMenuExtensions { [NotNull] - public static ApplicationMenuItem GetAdministration(this ApplicationMenu applicationMenu) + public static ApplicationMenuItem GetAdministration( + [NotNull] this ApplicationMenu applicationMenu) { - return applicationMenu.GetMenuItem(DefaultMenuNames.Application.Main.Administration); + return applicationMenu.GetMenuItem( + DefaultMenuNames.Application.Main.Administration + ); } [NotNull] - public static ApplicationMenuItem GetMenuItem(this IHasMenuItems menuWithItems, string menuItemName) + public static ApplicationMenuItem GetMenuItem( + [NotNull] this IHasMenuItems menuWithItems, + string menuItemName) { var menuItem = menuWithItems.GetMenuItemOrNull(menuItemName); if (menuItem == null) @@ -26,10 +31,29 @@ namespace Volo.Abp.UI.Navigation [CanBeNull] public static ApplicationMenuItem GetMenuItemOrNull( - this IHasMenuItems menuWithItems, + [NotNull] this IHasMenuItems menuWithItems, string menuItemName) { + Check.NotNull(menuWithItems, nameof(menuWithItems)); + return menuWithItems.Items.FirstOrDefault(mi => mi.Name == menuItemName); } + + [NotNull] + public static IHasMenuItems SetSubItemOrder( + [NotNull] this IHasMenuItems menuWithItems, + string menuItemName, + int order) + { + Check.NotNull(menuWithItems, nameof(menuWithItems)); + + var menuItem = menuWithItems.GetMenuItemOrNull(menuItemName); + if (menuItem != null) + { + menuItem.Order = order; + } + + return menuWithItems; + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs index de19f6db7b..e09c065b00 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItem.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using JetBrains.Annotations; +using Volo.Abp.Ui.Navigation; namespace Volo.Abp.UI.Navigation { @@ -68,7 +69,7 @@ namespace Volo.Abp.UI.Navigation /// [NotNull] - public IList Items { get; } + public ApplicationMenuItemList Items { get; } /// /// Can be used to store a custom object related to this menu item. Optional. @@ -109,7 +110,7 @@ namespace Volo.Abp.UI.Navigation ElementId = elementId ?? GetDefaultElementId(); CssClass = cssClass; - Items = new List(); + Items = new ApplicationMenuItemList(); } /// @@ -127,5 +128,10 @@ namespace Volo.Abp.UI.Navigation { return "MenuItem_" + Name; } + + public override string ToString() + { + return $"[ApplicationMenuItem] Name = {Name}"; + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItemList.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItemList.cs new file mode 100644 index 0000000000..0e9c845664 --- /dev/null +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/ApplicationMenuItemList.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Volo.Abp.UI.Navigation; + +namespace Volo.Abp.Ui.Navigation +{ + public class ApplicationMenuItemList : List + { + public ApplicationMenuItemList() + { + + } + + public ApplicationMenuItemList(int capacity) + : base(capacity) + { + + } + + public ApplicationMenuItemList(IEnumerable collection) + : base(collection) + { + + } + + public void Normalize() + { + RemoveEmptyItems(); + Order(); + } + + private void RemoveEmptyItems() + { + RemoveAll(item => item.IsLeaf && item.Url.IsNullOrEmpty()); + } + + private void Order() + { + //TODO: Is there any way that is more performant? + var orderedItems = this.OrderBy(item => item.Order).ToArray(); + Clear(); + AddRange(orderedItems); + } + } +} diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/IHasMenuItems.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/IHasMenuItems.cs index adfa8f2f40..f33ddcd4c2 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/IHasMenuItems.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/IHasMenuItems.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using Volo.Abp.Ui.Navigation; namespace Volo.Abp.UI.Navigation { @@ -7,6 +7,6 @@ namespace Volo.Abp.UI.Navigation /// /// Menu items. /// - IList Items { get; } + ApplicationMenuItemList Items { get; } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs index ada287ff87..9c96006b02 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; @@ -38,10 +39,14 @@ namespace Volo.Abp.UI.Navigation return menu; } - protected virtual void NormalizeMenu(ApplicationMenu menu) + protected virtual void NormalizeMenu(IHasMenuItems menuWithItems) { - //TODO: Should also consider sub menus, recursively, bottom to top! - menu.Items.RemoveAll(item => item.IsLeaf && item.Url.IsNullOrEmpty()); + foreach (var menuItem in menuWithItems.Items) + { + NormalizeMenu(menuItem); + } + + menuWithItems.Items.Normalize(); } } } \ No newline at end of file diff --git a/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs b/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs index 0b2d5db4a0..77203962ae 100644 --- a/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs +++ b/framework/test/Volo.Abp.UI.Navigation.Tests/Volo/Abp/Ui/Navigation/MenuManager_Tests.cs @@ -29,6 +29,9 @@ namespace Volo.Abp.UI.Navigation mainMenu.Items[1].Items[0].Name.ShouldBe("Administration.UserManagement"); mainMenu.Items[1].Items[1].Name.ShouldBe("Administration.RoleManagement"); mainMenu.Items[1].Items[2].Name.ShouldBe("Administration.DashboardSettings"); + mainMenu.Items[1].Items[3].Name.ShouldBe("Administration.SubMenu1"); + mainMenu.Items[1].Items[3].Items[0].Name.ShouldBe("Administration.SubMenu1.1"); + mainMenu.Items[1].Items[3].Items[1].Name.ShouldBe("Administration.SubMenu1.2"); } [DependsOn(typeof(AbpUiNavigationModule))] @@ -89,6 +92,12 @@ namespace Volo.Abp.UI.Navigation administration.AddItem(new ApplicationMenuItem("Administration.DashboardSettings", "Dashboard Settings", url: "/admin/settings/dashboard")); + administration.AddItem( + new ApplicationMenuItem("Administration.SubMenu1", "Sub menu 1") + .AddItem(new ApplicationMenuItem("Administration.SubMenu1.1", "Sub menu 1.1", url: "/submenu1/submenu1_1")) + .AddItem(new ApplicationMenuItem("Administration.SubMenu1.2", "Sub menu 1.2", url: "/submenu1/submenu1_2")) + ); + return Task.CompletedTask; } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs index c6ff751d57..1fbd519bfd 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs @@ -25,7 +25,16 @@ namespace Volo.Abp.SettingManagement.Web.Navigation //TODO: Localize //var l = context.ServiceProvider.GetRequiredService>(); - context.Menu.AddItem(new ApplicationMenuItem(SettingManagementMenuNames.GroupName, "Settings", "/SettingManagement", icon: "fa fa-cog", order: int.MaxValue - 1000)); + context.Menu + .GetAdministration() + .AddItem( + new ApplicationMenuItem( + SettingManagementMenuNames.GroupName, + "Settings", + "/SettingManagement", + icon: "fa fa-cog" + ) + ); return Task.CompletedTask; } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMenuNames.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMenuNames.cs index 67678f5b9e..4c5af73abe 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMenuNames.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMenuNames.cs @@ -1,14 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Volo.Abp.SettingManagement.Web.Navigation +namespace Volo.Abp.SettingManagement.Web.Navigation { public class SettingManagementMenuNames { public const string GroupName = "SettingManagement"; - - public const string Settings = GroupName + ".Settings"; } } From 89dbb912560025ef60d1b3a10568821b7ee9edd8 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 19 Mar 2019 10:22:38 +0300 Subject: [PATCH 05/44] Cleanup --- .../Volo.Abp.Identity.Domain.csproj | 10 ++++++---- .../Volo/Abp/Identity/IdentityDataSeeder.cs | 18 +++--------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj b/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj index 2d7948e20d..b0cff474c1 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj @@ -17,6 +17,12 @@ + + + + + + @@ -29,8 +35,4 @@ - - - - diff --git a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs index 0ff080cfad..09718049de 100644 --- a/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs +++ b/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Volo.Abp.DependencyInjection; @@ -53,7 +52,7 @@ namespace Volo.Abp.Identity adminUser = new IdentityUser(_guidGenerator.Create(), adminUserName, "admin@abp.io", tenantId); adminUser.Name = adminUserName; - CheckIdentityErrors(await _userManager.CreateAsync(adminUser, adminUserPassword)); + (await _userManager.CreateAsync(adminUser, adminUserPassword)).CheckErrors(); result.CreatedAdminUser = true; //"admin" role @@ -65,24 +64,13 @@ namespace Volo.Abp.Identity adminRole.IsStatic = true; adminRole.IsPublic = true; - CheckIdentityErrors(await _roleManager.CreateAsync(adminRole)); + (await _roleManager.CreateAsync(adminRole)).CheckErrors(); result.CreatedAdminRole = true; } - CheckIdentityErrors(await _userManager.AddToRoleAsync(adminUser, adminRoleName)); + (await _userManager.AddToRoleAsync(adminUser, adminRoleName)).CheckErrors(); return result; } - - protected void CheckIdentityErrors(IdentityResult identityResult) //TODO: This is temporary and duplicate code! - { - if (!identityResult.Succeeded) - { - //TODO: A better exception that can be shown on UI as localized? - throw new AbpException("Operation failed: " + identityResult.Errors.Select(e => $"[{e.Code}] {e.Description}").JoinAsString(", ")); - } - - //identityResult.CheckErrors(LocalizationManager); //TODO: Get from old Abp - } } } From 0b5dd0ceab0159c0a22c2bae43b8f5b31dfb86be Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 19 Mar 2019 10:41:55 +0300 Subject: [PATCH 06/44] audit logging exceptionn filter --- .../Volo/Abp/AuditLogging/IAuditLogRepository.cs | 2 ++ .../EntityFrameworkCore/EfCoreAuditLogRepository.cs | 9 +++++++-- .../AuditLogging/MongoDB/MongoAuditLogRepository.cs | 11 ++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs index 513861bf11..489a07a0ce 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/IAuditLogRepository.cs @@ -20,6 +20,7 @@ namespace Volo.Abp.AuditLogging string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false, CancellationToken cancellationToken = default); @@ -32,6 +33,7 @@ namespace Volo.Abp.AuditLogging string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, CancellationToken cancellationToken = default); } 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 e1f720e8cd..043c3d8988 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 @@ -30,11 +30,12 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, httpStatusCode, includeDetails); + var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, hasException, httpStatusCode, includeDetails); var auditLogs = await query.OrderBy(sorting ?? "executionTime desc") .PageBy(skipCount, maxResultCount) @@ -51,10 +52,11 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, httpStatusCode); + var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxExecutionDuration, minExecutionDuration, hasException, httpStatusCode); var totalCount = await query.LongCountAsync(); @@ -69,11 +71,14 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore string correlationId = null, int? maxExecutionDuration = null, int? minExecutionDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false) { return DbSet.AsNoTracking() .IncludeDetails(includeDetails) + .WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null && auditLog.Exceptions.Length > 0) + .WhereIf(hasException.HasValue && !hasException.Value, auditLog => auditLog.Exceptions == null || auditLog.Exceptions.Length == 0) .WhereIf(httpMethod != null, auditLog => auditLog.HttpMethod != null && auditLog.HttpMethod.ToLowerInvariant() == httpMethod.ToLowerInvariant()) .WhereIf(url != null, auditLog => auditLog.Url != null && auditLog.Url.ToLowerInvariant().Contains(url.ToLowerInvariant())) .WhereIf(userName != null, auditLog => auditLog.UserName != null && auditLog.UserName.ToLowerInvariant() == userName.ToLowerInvariant()) diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs index 09988682af..f70bd1deaf 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.MongoDB/Volo/Abp/AuditLogging/MongoDB/MongoAuditLogRepository.cs @@ -31,11 +31,12 @@ namespace Volo.Abp.AuditLogging.MongoDB string correlationId = null, int? maxDuration = null, int? minDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, httpStatusCode, includeDetails); + var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, hasException, httpStatusCode, includeDetails); return await query.OrderBy(sorting ?? "executionTime desc").As>() .PageBy>(skipCount, maxResultCount) @@ -50,10 +51,11 @@ namespace Volo.Abp.AuditLogging.MongoDB string correlationId = null, int? maxDuration = null, int? minDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, CancellationToken cancellationToken = default) { - var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, httpStatusCode); + var query = GetListQuery(httpMethod, url, userName, applicationName, correlationId, maxDuration, minDuration, hasException, httpStatusCode); var count = await query.As>().LongCountAsync(); @@ -68,10 +70,13 @@ namespace Volo.Abp.AuditLogging.MongoDB string correlationId = null, int? maxDuration = null, int? minDuration = null, + bool? hasException = null, HttpStatusCode? httpStatusCode = null, bool includeDetails = false) { return GetMongoQueryable() + .WhereIf(hasException.HasValue && hasException.Value, auditLog => auditLog.Exceptions != null && auditLog.Exceptions.Length > 0) + .WhereIf(hasException.HasValue && !hasException.Value, auditLog => auditLog.Exceptions == null || auditLog.Exceptions.Length == 0) .WhereIf(httpMethod != null, auditLog => auditLog.HttpMethod != null && auditLog.HttpMethod.ToLowerInvariant() == httpMethod.ToLowerInvariant()) .WhereIf(url != null, auditLog => auditLog.Url != null && auditLog.Url.ToLowerInvariant().Contains(url.ToLowerInvariant())) .WhereIf(userName != null, auditLog => auditLog.UserName != null && auditLog.UserName.ToLowerInvariant() == userName.ToLowerInvariant()) @@ -79,7 +84,7 @@ namespace Volo.Abp.AuditLogging.MongoDB .WhereIf(correlationId != null, auditLog => auditLog.CorrelationId != null && auditLog.CorrelationId.ToLowerInvariant() == correlationId.ToLowerInvariant()) .WhereIf(httpStatusCode != null && httpStatusCode > 0, auditLog => auditLog.HttpStatusCode == (int?)httpStatusCode) .WhereIf(maxDuration != null && maxDuration > 0, auditLog => auditLog.ExecutionDuration <= maxDuration) - .WhereIf(minDuration != null && minDuration > 0, auditLog => auditLog.ExecutionDuration >= minDuration); ; + .WhereIf(minDuration != null && minDuration > 0, auditLog => auditLog.ExecutionDuration >= minDuration); } } } From 671d10867d72912e8ccea8d197655737886ba849 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 19 Mar 2019 11:02:28 +0300 Subject: [PATCH 07/44] Added tests for localization --- .../AbpDictionaryBasedStringLocalizer.cs | 9 ++- .../Abp/Localization/AbpLocalization_Tests.cs | 60 +++++++++++++++++-- .../Source/LocalizationTestResource.cs | 6 +- .../Localization/TestResources/Source/en.json | 3 +- 4 files changed, 69 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs index c9428626a8..18fa853ecf 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs @@ -26,7 +26,10 @@ namespace Volo.Abp.Localization public IEnumerable GetAllStrings(bool includeParentCultures) { - return GetAllStrings(CultureInfo.CurrentUICulture.Name, includeParentCultures); + return GetAllStrings( + CultureInfo.CurrentUICulture.Name, + includeParentCultures + ); } public IStringLocalizer WithCulture(CultureInfo culture) @@ -109,7 +112,9 @@ namespace Volo.Abp.Localization return null; } - protected virtual IReadOnlyList GetAllStrings(string cultureName, bool includeParentCultures = true) + protected virtual IReadOnlyList GetAllStrings( + string cultureName, + bool includeParentCultures = true) { //TODO: Can be optimized (example: if it's already default dictionary, skip overriding) diff --git a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs index ea6ce3e242..8c5a9f5702 100644 --- a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs +++ b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs @@ -1,4 +1,5 @@ using System.Globalization; +using System.Linq; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Shouldly; @@ -104,6 +105,46 @@ namespace Volo.Abp.Localization _localizer.WithCulture(CultureInfo.GetCultureInfo("tr"))["CarPlural"].Value.ShouldBe("Araba"); } + [Fact] + public void GetAllStrings_With_Parents() + { + using (AbpCultureHelper.Use("tr")) + { + var localizedStrings = _localizer.GetAllStrings(true).ToList(); + + localizedStrings.ShouldContain( + ls => ls.Name == "FortyTwo" && + ls.Value == "Forty Two" && + ls.ResourceNotFound == false + ); + + localizedStrings.ShouldContain( + ls => ls.Name == "Universe" && + ls.Value == "Evren" && + ls.ResourceNotFound == false + ); + } + } + + [Fact] + public void GetAllStrings_Without_Parents() + { + using (AbpCultureHelper.Use("tr")) + { + var localizedStrings = _localizer.GetAllStrings(false).ToList(); + + localizedStrings.ShouldNotContain( + ls => ls.Name == "FortyTwo" + ); + + localizedStrings.ShouldContain( + ls => ls.Name == "Universe" && + ls.Value == "Evren" && + ls.ResourceNotFound == false + ); + } + } + [DependsOn(typeof(AbpTestBaseModule))] [DependsOn(typeof(AbpLocalizationModule))] public class TestModule : AbpModule @@ -117,10 +158,21 @@ namespace Volo.Abp.Localization Configure(options => { - options.Resources.Add("en").AddVirtualJson("/Volo/Abp/Localization/TestResources/Base/Validation"); - options.Resources.Add("en").AddVirtualJson("/Volo/Abp/Localization/TestResources/Base/CountryNames"); - options.Resources.Add("en").AddVirtualJson("/Volo/Abp/Localization/TestResources/Source"); - options.Resources.Get().AddVirtualJson("/Volo/Abp/Localization/TestResources/SourceExt"); + options.Resources + .Add("en") + .AddVirtualJson("/Volo/Abp/Localization/TestResources/Base/Validation"); + + options.Resources + .Add("en") + .AddVirtualJson("/Volo/Abp/Localization/TestResources/Base/CountryNames"); + + options.Resources + .Add("en") + .AddVirtualJson("/Volo/Abp/Localization/TestResources/Source"); + + options.Resources + .Get() + .AddVirtualJson("/Volo/Abp/Localization/TestResources/SourceExt"); }); } } diff --git a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/Source/LocalizationTestResource.cs b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/Source/LocalizationTestResource.cs index 04cacc6b20..9344085adf 100644 --- a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/Source/LocalizationTestResource.cs +++ b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/Source/LocalizationTestResource.cs @@ -3,8 +3,10 @@ using Volo.Abp.Localization.TestResources.Base.Validation; namespace Volo.Abp.Localization.TestResources.Source { - [InheritResource(typeof(LocalizationTestValidationResource))] - [InheritResource(typeof(LocalizationTestCountryNamesResource))] + [InheritResource( + typeof(LocalizationTestValidationResource), + typeof(LocalizationTestCountryNamesResource) + )] public sealed class LocalizationTestResource { diff --git a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/Source/en.json b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/Source/en.json index 0388b6efe2..098b3655ee 100644 --- a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/Source/en.json +++ b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/TestResources/Source/en.json @@ -5,6 +5,7 @@ "Car": "Car", "CarPlural": "Cars", "MaxLenghtErrorMessage": "This field's length can be maximum of '{0}' chars", - "Universe": "Universe" + "Universe": "Universe", + "FortyTwo": "Forty Two" } } \ No newline at end of file From 2f0aa53cad75ce4c6e5237ffdf7bfe89708d4a4e Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 19 Mar 2019 11:40:55 +0300 Subject: [PATCH 08/44] Support to get all strings without inheritance --- .../AbpDictionaryBasedStringLocalizer.cs | 36 +++++++++---- .../Abp/Localization/AbpLocalizationModule.cs | 3 +- .../AbpStringLocalizerExtensions.cs | 46 ++++++++++++++++ .../IStringLocalizerSupportsInheritance.cs | 10 ++++ .../Abp/Localization/AbpLocalization_Tests.cs | 52 +++++++++++++++++++ 5 files changed, 135 insertions(+), 12 deletions(-) create mode 100644 framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs create mode 100644 framework/src/Volo.Abp.Localization/Volo/Abp/Localization/IStringLocalizerSupportsInheritance.cs diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs index 18fa853ecf..56625f5ac4 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.Localization; namespace Volo.Abp.Localization { - public class AbpDictionaryBasedStringLocalizer : IStringLocalizer + public class AbpDictionaryBasedStringLocalizer : IStringLocalizer, IStringLocalizerSupportsInheritance { public LocalizationResource Resource { get; } @@ -32,6 +32,16 @@ namespace Volo.Abp.Localization ); } + + public IEnumerable GetAllStrings(bool includeParentCultures, bool includeBaseLocalizers) + { + return GetAllStrings( + CultureInfo.CurrentUICulture.Name, + includeParentCultures, + includeBaseLocalizers + ); + } + public IStringLocalizer WithCulture(CultureInfo culture) { return new CultureWrapperStringLocalizer(culture.Name, this); @@ -114,26 +124,30 @@ namespace Volo.Abp.Localization protected virtual IReadOnlyList GetAllStrings( string cultureName, - bool includeParentCultures = true) + bool includeParentCultures = true, + bool includeBaseLocalizers = true) { //TODO: Can be optimized (example: if it's already default dictionary, skip overriding) var allStrings = new Dictionary(); - foreach (var baseLocalizer in BaseLocalizers.Select(l => l.WithCulture(CultureInfo.GetCultureInfo(cultureName)))) + if (includeBaseLocalizers) { - //TODO: Try/catch is a workaround here! - try + foreach (var baseLocalizer in BaseLocalizers.Select(l => l.WithCulture(CultureInfo.GetCultureInfo(cultureName)))) { - var baseLocalizedString = baseLocalizer.GetAllStrings(includeParentCultures); - foreach (var localizedString in baseLocalizedString) + //TODO: Try/catch is a workaround here! + try { - allStrings[localizedString.Name] = localizedString; + var baseLocalizedString = baseLocalizer.GetAllStrings(includeParentCultures); + foreach (var localizedString in baseLocalizedString) + { + allStrings[localizedString.Name] = localizedString; + } } - } - catch (MissingManifestResourceException) - { + catch (MissingManifestResourceException) + { + } } } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationModule.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationModule.cs index a65e6863a8..23e61e417f 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationModule.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Localization.Resources.AbpValidation; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Localization.Resources.AbpValidation; using Volo.Abp.Modularity; using Volo.Abp.Settings; using Volo.Abp.VirtualFileSystem; diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs new file mode 100644 index 0000000000..3e4a42603f --- /dev/null +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using System.Reflection; +using Microsoft.Extensions.Localization; +using Volo.Abp.DynamicProxy; + +namespace Volo.Abp.Localization +{ + public static class AbpStringLocalizerExtensions + { + public static IStringLocalizer GetInternalLocalizer(this IStringLocalizer stringLocalizer) + { + var localizerField = stringLocalizer.GetType() + .GetField( + "_localizer", + BindingFlags.Instance | + BindingFlags.NonPublic + ); + + if (localizerField == null) + { + return stringLocalizer; + } + + return localizerField.GetValue(stringLocalizer) as IStringLocalizer; + } + + public static IEnumerable GetAllStrings( + this IStringLocalizer stringLocalizer, + bool includeParentCultures, + bool includeBaseLocalizers) + { + var internalLocalizer = (ProxyHelper.UnProxy(stringLocalizer) as IStringLocalizer).GetInternalLocalizer(); + if (internalLocalizer is IStringLocalizerSupportsInheritance stringLocalizerSupportsInheritance) + { + return stringLocalizerSupportsInheritance.GetAllStrings( + includeParentCultures, + includeBaseLocalizers + ); + } + + return stringLocalizer.GetAllStrings( + includeParentCultures + ); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/IStringLocalizerSupportsInheritance.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/IStringLocalizerSupportsInheritance.cs new file mode 100644 index 0000000000..ccd1616a06 --- /dev/null +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/IStringLocalizerSupportsInheritance.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using Microsoft.Extensions.Localization; + +namespace Volo.Abp.Localization +{ + public interface IStringLocalizerSupportsInheritance + { + IEnumerable GetAllStrings(bool includeParentCultures, bool includeBaseLocalizers); + } +} \ No newline at end of file diff --git a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs index 8c5a9f5702..6f141e56f0 100644 --- a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs +++ b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs @@ -21,6 +21,14 @@ namespace Volo.Abp.Localization _localizer = GetRequiredService>(); } + [Fact] + public void AbpStringLocalizerExtensions_GetInternalLocalizer() + { + var internalLocalizer = _localizer.GetInternalLocalizer(); + internalLocalizer.ShouldNotBeNull(); + internalLocalizer.ShouldBeOfType(); + } + [Fact] public void Should_Get_Same_Text_If_Not_Defined_Anywhere() { @@ -145,6 +153,50 @@ namespace Volo.Abp.Localization } } + [Fact] + public void GetAllStrings_With_Inheritance() + { + using (AbpCultureHelper.Use("tr")) + { + var localizedStrings = _localizer + .GetAllStrings(true, includeBaseLocalizers: true) + .ToList(); + + localizedStrings.ShouldContain( + ls => ls.Name == "USA" && + ls.Value == "Amerika Birleşik Devletleri" && + ls.ResourceNotFound == false + ); + + localizedStrings.ShouldContain( + ls => ls.Name == "Universe" && + ls.Value == "Evren" && + ls.ResourceNotFound == false + ); + } + } + + [Fact] + public void GetAllStrings_Without_Inheritance() + { + using (AbpCultureHelper.Use("tr")) + { + var localizedStrings = _localizer + .GetAllStrings(true, includeBaseLocalizers: false) + .ToList(); + + localizedStrings.ShouldNotContain( + ls => ls.Name == "USA" + ); + + localizedStrings.ShouldContain( + ls => ls.Name == "Universe" && + ls.Value == "Evren" && + ls.ResourceNotFound == false + ); + } + } + [DependsOn(typeof(AbpTestBaseModule))] [DependsOn(typeof(AbpLocalizationModule))] public class TestModule : AbpModule From b8fa84d69057ea2974204e8a09efa19b82cbc606 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 19 Mar 2019 12:00:21 +0300 Subject: [PATCH 09/44] Implement IStringLocalizerSupportsInheritance for also CultureWrapperStringLocalizer --- .../AbpDictionaryBasedStringLocalizer.cs | 7 +++++- .../AbpStringLocalizerExtensions.cs | 18 ++++++++++++--- .../Abp/Localization/AbpLocalization_Tests.cs | 22 +++++++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs index 56625f5ac4..0cfe90d9ef 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs @@ -179,7 +179,7 @@ namespace Volo.Abp.Localization : cultureName; } - public class CultureWrapperStringLocalizer : IStringLocalizer + public class CultureWrapperStringLocalizer : IStringLocalizer, IStringLocalizerSupportsInheritance { private readonly string _cultureName; private readonly AbpDictionaryBasedStringLocalizer _innerLocalizer; @@ -203,6 +203,11 @@ namespace Volo.Abp.Localization { return new CultureWrapperStringLocalizer(culture.Name, _innerLocalizer); } + + public IEnumerable GetAllStrings(bool includeParentCultures, bool includeBaseLocalizers) + { + return _innerLocalizer.GetAllStrings(includeParentCultures, includeBaseLocalizers); + } } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs index 3e4a42603f..218f9c4164 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpStringLocalizerExtensions.cs @@ -1,15 +1,27 @@ using System.Collections.Generic; using System.Reflection; +using JetBrains.Annotations; using Microsoft.Extensions.Localization; using Volo.Abp.DynamicProxy; +using Volo.Abp.Reflection; namespace Volo.Abp.Localization { public static class AbpStringLocalizerExtensions { - public static IStringLocalizer GetInternalLocalizer(this IStringLocalizer stringLocalizer) + [NotNull] + public static IStringLocalizer GetInternalLocalizer( + [NotNull] this IStringLocalizer stringLocalizer) { - var localizerField = stringLocalizer.GetType() + Check.NotNull(stringLocalizer, nameof(stringLocalizer)); + + var localizerType = stringLocalizer.GetType(); + if (!ReflectionHelper.IsAssignableToGenericType(localizerType, typeof(StringLocalizer<>))) + { + return stringLocalizer; + } + + var localizerField = localizerType .GetField( "_localizer", BindingFlags.Instance | @@ -18,7 +30,7 @@ namespace Volo.Abp.Localization if (localizerField == null) { - return stringLocalizer; + throw new AbpException($"Could not find the _localizer field inside the {typeof(StringLocalizer<>).FullName} class. Probably its name has changed. Please report this issue to the ABP framework."); } return localizerField.GetValue(stringLocalizer) as IStringLocalizer; diff --git a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs index 6f141e56f0..309e317997 100644 --- a/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs +++ b/framework/test/Volo.Abp.Localization.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs @@ -15,10 +15,12 @@ namespace Volo.Abp.Localization public class AbpLocalization_Tests : AbpIntegratedTest { private readonly IStringLocalizer _localizer; + private readonly IStringLocalizerFactory _localizerFactory; public AbpLocalization_Tests() { _localizer = GetRequiredService>(); + _localizerFactory = GetRequiredService(); } [Fact] @@ -29,6 +31,14 @@ namespace Volo.Abp.Localization internalLocalizer.ShouldBeOfType(); } + [Fact] + public void AbpStringLocalizerExtensions_GetInternalLocalizer_Using_LocalizerFactory() + { + var internalLocalizer = _localizerFactory.Create(typeof(LocalizationTestResource)).GetInternalLocalizer(); + internalLocalizer.ShouldNotBeNull(); + internalLocalizer.ShouldBeOfType(); + } + [Fact] public void Should_Get_Same_Text_If_Not_Defined_Anywhere() { @@ -173,6 +183,12 @@ namespace Volo.Abp.Localization ls.Value == "Evren" && ls.ResourceNotFound == false ); + + localizedStrings.ShouldContain( + ls => ls.Name == "SeeYou" && + ls.Value == "See you" && + ls.ResourceNotFound == false + ); } } @@ -194,6 +210,12 @@ namespace Volo.Abp.Localization ls.Value == "Evren" && ls.ResourceNotFound == false ); + + localizedStrings.ShouldContain( + ls => ls.Name == "SeeYou" && + ls.Value == "See you" && + ls.ResourceNotFound == false + ); } } From 96f4bc188a1f44b2c886dd3ac3c5152e418ecdb5 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 19 Mar 2019 13:30:25 +0300 Subject: [PATCH 10/44] EditionFeatureValueProvider should handle null principal --- .../Volo/Abp/Features/EditionFeatureValueProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs index 8ce1332ecb..ef22197f8a 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/EditionFeatureValueProvider.cs @@ -20,7 +20,7 @@ namespace Volo.Abp.Features public override async Task GetOrNullAsync(FeatureDefinition feature) { - var editionId = PrincipalAccessor.Principal.FindEditionId(); + var editionId = PrincipalAccessor.Principal?.FindEditionId(); if (editionId == null) { return null; From 231c24a386bb9e5c26457475d732677b5c3ba941 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 19 Mar 2019 13:30:33 +0300 Subject: [PATCH 11/44] Fix TestFeatureStore --- .../Volo/Abp/Features/TestFeatureStore.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/test/Volo.Abp.Features.Tests/Volo/Abp/Features/TestFeatureStore.cs b/framework/test/Volo.Abp.Features.Tests/Volo/Abp/Features/TestFeatureStore.cs index 87fef33a8d..4592a18365 100644 --- a/framework/test/Volo.Abp.Features.Tests/Volo/Abp/Features/TestFeatureStore.cs +++ b/framework/test/Volo.Abp.Features.Tests/Volo/Abp/Features/TestFeatureStore.cs @@ -20,9 +20,9 @@ namespace Volo.Abp.Features { _settingRecords = new List { - new SettingRecord("BooleanTestFeature1", TenantFeatureValueProvider.ProviderName, Tenant1Id.ToString(), "true"), - new SettingRecord("BooleanTestFeature2", TenantFeatureValueProvider.ProviderName, Tenant1Id.ToString(), "true"), - new SettingRecord("IntegerTestFeature1", TenantFeatureValueProvider.ProviderName, Tenant2Id.ToString(), "34") + new SettingRecord("BooleanTestFeature1", TenantFeatureValueProvider.ProviderName, Tenant1Id.ToString("N"), "true"), + new SettingRecord("BooleanTestFeature2", TenantFeatureValueProvider.ProviderName, Tenant1Id.ToString("N"), "true"), + new SettingRecord("IntegerTestFeature1", TenantFeatureValueProvider.ProviderName, Tenant2Id.ToString("N"), "34") }; } From cfd2d984dde730abb86c708ceeb2d5aa0972659d Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 19 Mar 2019 14:30:08 +0300 Subject: [PATCH 12/44] Resolved Prevent deleting the current user #889 --- .../Identity/AbpIdentityApplicationContractsModule.cs | 6 ++++++ .../Volo/Abp/Identity/IdentityErrorCodes.cs | 11 +++++++++++ .../Localization/ApplicationContracts/en.json | 1 + .../Localization/ApplicationContracts/tr.json | 1 + .../Volo/Abp/Identity/IdentityUserAppService.cs | 5 +++++ 5 files changed, 24 insertions(+) create mode 100644 modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityErrorCodes.cs diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs index c3d142aefc..821457ac93 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs @@ -7,6 +7,7 @@ using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement; using Volo.Abp.Users; using Volo.Abp.VirtualFileSystem; +using Volo.Abp.Localization.ExceptionHandling; namespace Volo.Abp.Identity { @@ -32,6 +33,11 @@ namespace Volo.Abp.Identity .Get() .AddVirtualJson("/Volo/Abp/Identity/Localization/ApplicationContracts"); }); + + Configure(options => + { + options.MapCodeNamespace("Volo.Abp.Identity", typeof(IdentityResource)); + }); } } } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityErrorCodes.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityErrorCodes.cs new file mode 100644 index 0000000000..4bdfc5d8e9 --- /dev/null +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityErrorCodes.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Volo.Abp.Identity +{ + public static class IdentityErrorCodes + { + public const string UserSelfDeletion = "Volo.Abp.Identity:010001"; + } +} \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/en.json b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/en.json index 4a302c8057..22464dae71 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/en.json +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/en.json @@ -1,6 +1,7 @@ { "culture": "en", "texts": { + "Volo.Abp.Identity:010001": "You can not delete your own account!", "Permission:IdentityManagement": "Identity management", "Permission:RoleManagement": "Role management", "Permission:Create": "Create", diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/tr.json b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/tr.json index 25760c354b..4e0746de1f 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/tr.json +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/tr.json @@ -1,6 +1,7 @@ { "culture": "tr", "texts": { + "Volo.Abp.Identity:010001": "Kendi hesabınızı silemezsiniz!", "Permission:IdentityManagement": "Kimlik yönetimi", "Permission:RoleManagement": "Rol yönetimi", "Permission:Create": "Oluşturma", diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index e1fb6ba8e5..814d32fd19 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -80,6 +80,11 @@ namespace Volo.Abp.Identity [Authorize(IdentityPermissions.Users.Delete)] public async Task DeleteAsync(Guid id) { + if (CurrentUser.Id.Value == id) + { + throw new BusinessException(code: IdentityErrorCodes.UserSelfDeletion); + } + var user = await _userManager.FindByIdAsync(id.ToString()); if (user == null) { From 4398498b88a7090960d639b523eec9d47981fb5b Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 19 Mar 2019 14:42:27 +0300 Subject: [PATCH 13/44] Resolved #886 Move Identity & Tenant Management menu items under the new Administration menu item --- .../Navigation/AbpIdentityWebMainMenuContributor.cs | 4 +++- .../Navigation/AbpTenantManagementWebMainMenuContributor.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs b/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs index 22581401be..f607e62bd3 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs @@ -16,11 +16,13 @@ namespace Volo.Abp.Identity.Web.Navigation return; } + var administrationMenu = context.Menu.GetAdministration(); + var authorizationService = context.ServiceProvider.GetRequiredService(); var l = context.ServiceProvider.GetRequiredService>(); var identityMenuItem = new ApplicationMenuItem(IdentityMenuNames.GroupName, l["Menu:IdentityManagement"], icon: "fa fa-id-card-o"); - context.Menu.AddItem(identityMenuItem); + administrationMenu.AddItem(identityMenuItem); if (await authorizationService.IsGrantedAsync(IdentityPermissions.Roles.Default)) { diff --git a/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs b/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs index 63dee4f7f7..b7ef9f277e 100644 --- a/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs +++ b/modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Navigation/AbpTenantManagementWebMainMenuContributor.cs @@ -16,11 +16,13 @@ namespace Volo.Abp.TenantManagement.Web.Navigation return; } + var administrationMenu = context.Menu.GetAdministration(); + var authorizationService = context.ServiceProvider.GetRequiredService(); var l = context.ServiceProvider.GetRequiredService>(); var tenantManagementMenuItem = new ApplicationMenuItem(TenantManagementMenuNames.GroupName, l["Menu:TenantManagement"], icon: "fa fa-users"); - context.Menu.AddItem(tenantManagementMenuItem); + administrationMenu.AddItem(tenantManagementMenuItem); if (await authorizationService.IsGrantedAsync(TenantManagementPermissions.Tenants.Default)) { From 287725d4d4d4b7a8580b80931af207aed7bcf3b3 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Tue, 19 Mar 2019 20:57:25 +0300 Subject: [PATCH 14/44] Add Serializable to ApplicationFeatureConfigurationDto --- .../ApplicationFeatureConfigurationDto.cs | 9 ++++++++- .../AbpApplicationConfigurationAppService.cs | 5 +---- .../Abp/BackgroundWorkers/AbpBackgroundWorkersModule.cs | 1 - 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs index 8917e3dcfa..4972d2242d 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationFeatureConfigurationDto.cs @@ -1,9 +1,16 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations { + [Serializable] public class ApplicationFeatureConfigurationDto { public Dictionary Values { get; set; } + + public ApplicationFeatureConfigurationDto() + { + Values = new Dictionary(); + } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index 2ea9282a91..70eb04c707 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -133,10 +133,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations protected virtual async Task GetFeaturesConfigAsync() { - var result = new ApplicationFeatureConfigurationDto - { - Values = new Dictionary() - }; + var result = new ApplicationFeatureConfigurationDto(); foreach (var featureDefinition in _featureDefinitionManager.GetAll()) { diff --git a/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AbpBackgroundWorkersModule.cs b/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AbpBackgroundWorkersModule.cs index cae652ad28..1ed2a7f78a 100644 --- a/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AbpBackgroundWorkersModule.cs +++ b/framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AbpBackgroundWorkersModule.cs @@ -10,7 +10,6 @@ namespace Volo.Abp.BackgroundWorkers )] public class AbpBackgroundWorkersModule : AbpModule { - public override void OnApplicationInitialization(ApplicationInitializationContext context) { var options = context.ServiceProvider.GetRequiredService>().Value; From 69c977256691e0d8dc0239a9c189e87ab0512179 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 09:53:47 +0300 Subject: [PATCH 15/44] Re-generate migration --- ...Initial.Designer.cs => 20190320065023_Initial.Designer.cs} | 4 ++-- .../{20190211104804_Initial.cs => 20190320065023_Initial.cs} | 0 .../Migrations/MyProjectNameDbContextModelSnapshot.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/{20190211104804_Initial.Designer.cs => 20190320065023_Initial.Designer.cs} (99%) rename templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/{20190211104804_Initial.cs => 20190320065023_Initial.cs} (100%) diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.Designer.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.Designer.cs similarity index 99% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.Designer.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.Designer.cs index 2002970aad..2c49b5462c 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.Designer.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.Designer.cs @@ -10,14 +10,14 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.Migrations { [DbContext(typeof(MyProjectNameDbContext))] - [Migration("20190211104804_Initial")] + [Migration("20190320065023_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.1-servicing-10028") + .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.cs similarity index 100% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190211104804_Initial.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.cs diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs index 1d2a225f38..ca7bbe2c8e 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs @@ -15,7 +15,7 @@ namespace MyCompanyName.MyProjectName.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.1-servicing-10028") + .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); From 230d018c4d7be48e0f533e3b2044ed61f15b84c2 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 10:31:35 +0300 Subject: [PATCH 16/44] Add and configure MyProjectName.EntityFrameworkCore.DbMigrations project --- templates/mvc/MyCompanyName.MyProjectName.sln | 9 ++++- templates/mvc/common.props | 7 ++++ ...mpanyName.MyProjectName.Application.csproj | 2 ++ .../MyCompanyName.MyProjectName.Domain.csproj | 2 ++ .../MyProjectNameConsts.cs | 9 +++++ .../MyProjectNameMigrationsDbContext.cs | 32 +++++++++++++++++ ...MyProjectNameMigrationsDbContextFactory.cs | 29 ++++++++++++++++ .../20190320072839_Initial.Designer.cs} | 4 +-- .../Migrations/20190320072839_Initial.cs} | 0 ...ctNameMigrationsDbContextModelSnapshot.cs} | 4 +-- ...me.EntityFrameworkCore.DbMigrations.csproj | 14 ++++++++ .../MyProjectNameDbContext.cs | 15 ++------ ...ectNameDbContextModelCreatingExtensions.cs | 34 +++++++++++++++++++ ...e.MyProjectName.EntityFrameworkCore.csproj | 6 ++-- ...MyCompanyName.MyProjectName.MongoDB.csproj | 2 ++ .../MyCompanyName.MyProjectName.Web.csproj | 5 +-- ...ame.MyProjectName.Application.Tests.csproj | 2 ++ ...CompanyName.MyProjectName.Web.Tests.csproj | 2 ++ 18 files changed, 155 insertions(+), 23 deletions(-) create mode 100644 templates/mvc/common.props create mode 100644 templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs create mode 100644 templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs create mode 100644 templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContextFactory.cs rename templates/mvc/src/{MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.Designer.cs => MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190320072839_Initial.Designer.cs} (99%) rename templates/mvc/src/{MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.cs => MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190320072839_Initial.cs} (100%) rename templates/mvc/src/{MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs => MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs} (99%) create mode 100644 templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj create mode 100644 templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs diff --git a/templates/mvc/MyCompanyName.MyProjectName.sln b/templates/mvc/MyCompanyName.MyProjectName.sln index ed0f5881c3..0c616dbc3b 100644 --- a/templates/mvc/MyCompanyName.MyProjectName.sln +++ b/templates/mvc/MyCompanyName.MyProjectName.sln @@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.Web.Tests", "test\MyCompanyName.MyProjectName.Web.Tests\MyCompanyName.MyProjectName.Web.Tests.csproj", "{5F1B28C6-8D0C-4155-92D0-252F7EA5F674}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCompanyName.MyProjectName.MongoDB", "src\MyCompanyName.MyProjectName.MongoDB\MyCompanyName.MyProjectName.MongoDB.csproj", "{E3444355-D47E-431E-BDD0-DD3A7113B2AE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyCompanyName.MyProjectName.MongoDB", "src\MyCompanyName.MyProjectName.MongoDB\MyCompanyName.MyProjectName.MongoDB.csproj", "{E3444355-D47E-431E-BDD0-DD3A7113B2AE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations", "src\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations\MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj", "{0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -55,6 +57,10 @@ Global {E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {E3444355-D47E-431E-BDD0-DD3A7113B2AE}.Release|Any CPU.Build.0 = Release|Any CPU + {0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -67,6 +73,7 @@ Global {50B2631D-129C-47B3-A587-029CCD6099BC} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {5F1B28C6-8D0C-4155-92D0-252F7EA5F674} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {E3444355-D47E-431E-BDD0-DD3A7113B2AE} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} + {0372FA84-C517-4EB3-9A9F-B9ACAC0CA5E0} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} diff --git a/templates/mvc/common.props b/templates/mvc/common.props new file mode 100644 index 0000000000..7585f303ba --- /dev/null +++ b/templates/mvc/common.props @@ -0,0 +1,7 @@ + + + latest + 1.0.0 + $(NoWarn);CS1591 + + \ No newline at end of file diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Application/MyCompanyName.MyProjectName.Application.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.Application/MyCompanyName.MyProjectName.Application.csproj index 70b63090cc..f774c93818 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Application/MyCompanyName.MyProjectName.Application.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Application/MyCompanyName.MyProjectName.Application.csproj @@ -1,5 +1,7 @@  + + netcoreapp2.2 MyCompanyName.MyProjectName diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyCompanyName.MyProjectName.Domain.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyCompanyName.MyProjectName.Domain.csproj index 258847de37..32d5d55698 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyCompanyName.MyProjectName.Domain.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyCompanyName.MyProjectName.Domain.csproj @@ -1,5 +1,7 @@  + + netcoreapp2.2 MyCompanyName.MyProjectName diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs new file mode 100644 index 0000000000..86a322bb13 --- /dev/null +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs @@ -0,0 +1,9 @@ +namespace MyCompanyName.MyProjectName +{ + public static class MyProjectNameConsts + { + public const string DefaultDbTablePrefix = "App"; + + public const string DefaultDbSchema = null; + } +} diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs new file mode 100644 index 0000000000..4d8e7bd10f --- /dev/null +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs @@ -0,0 +1,32 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.AuditLogging.EntityFrameworkCore; +using Volo.Abp.BackgroundJobs.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; + +namespace MyCompanyName.MyProjectName.EntityFrameworkCore +{ + public class MyProjectNameMigrationsDbContext : AbpDbContext + { + public MyProjectNameMigrationsDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.ConfigurePermissionManagement(); + builder.ConfigureSettingManagement(); + builder.ConfigureBackgroundJobs(); + builder.ConfigureAuditLogging(); + builder.ConfigureIdentity(); + + builder.ConfigureMyProjectName(); + } + } +} \ No newline at end of file diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContextFactory.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContextFactory.cs new file mode 100644 index 0000000000..d760790fc8 --- /dev/null +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContextFactory.cs @@ -0,0 +1,29 @@ +using System.IO; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace MyCompanyName.MyProjectName.EntityFrameworkCore +{ + public class MyProjectNameMigrationsDbContextFactory : IDesignTimeDbContextFactory + { + public MyProjectNameMigrationsDbContext CreateDbContext(string[] args) + { + var configuration = BuildConfiguration(); + + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); + + return new MyProjectNameMigrationsDbContext(builder.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false); + + return builder.Build(); + } + } +} diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.Designer.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190320072839_Initial.Designer.cs similarity index 99% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.Designer.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190320072839_Initial.Designer.cs index 2c49b5462c..b25ddbee04 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.Designer.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190320072839_Initial.Designer.cs @@ -9,8 +9,8 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.Migrations { - [DbContext(typeof(MyProjectNameDbContext))] - [Migration("20190320065023_Initial")] + [DbContext(typeof(MyProjectNameMigrationsDbContext))] + [Migration("20190320072839_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190320072839_Initial.cs similarity index 100% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20190320065023_Initial.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/20190320072839_Initial.cs diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs similarity index 99% rename from templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs rename to templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs index ca7bbe2c8e..43def4fbad 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/MyProjectNameDbContextModelSnapshot.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/Migrations/MyProjectNameMigrationsDbContextModelSnapshot.cs @@ -8,8 +8,8 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.Migrations { - [DbContext(typeof(MyProjectNameDbContext))] - partial class MyProjectNameDbContextModelSnapshot : ModelSnapshot + [DbContext(typeof(MyProjectNameMigrationsDbContext))] + partial class MyProjectNameMigrationsDbContextModelSnapshot : ModelSnapshot { protected override void BuildModel(ModelBuilder modelBuilder) { diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj new file mode 100644 index 0000000000..b38b78dbd2 --- /dev/null +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations.csproj @@ -0,0 +1,14 @@ + + + + + + netcoreapp2.2 + MyCompanyName.MyProjectName + + + + + + + diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs index f26ede167b..fb4008aff4 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs @@ -1,11 +1,6 @@ using Microsoft.EntityFrameworkCore; -using Volo.Abp.AuditLogging.EntityFrameworkCore; -using Volo.Abp.BackgroundJobs.EntityFrameworkCore; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.Identity.EntityFrameworkCore; -using Volo.Abp.PermissionManagement.EntityFrameworkCore; -using Volo.Abp.SettingManagement.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.EntityFrameworkCore { @@ -18,15 +13,11 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore } - protected override void OnModelCreating(ModelBuilder modelBuilder) + protected override void OnModelCreating(ModelBuilder builder) { - base.OnModelCreating(modelBuilder); + base.OnModelCreating(builder); - modelBuilder.ConfigureIdentity(); - modelBuilder.ConfigurePermissionManagement(); - modelBuilder.ConfigureSettingManagement(); - modelBuilder.ConfigureBackgroundJobs(); - modelBuilder.ConfigureAuditLogging(); + builder.ConfigureMyProjectName(); } } } diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs new file mode 100644 index 0000000000..719d8f2c1e --- /dev/null +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp; + +namespace MyCompanyName.MyProjectName.EntityFrameworkCore +{ + public static class MyProjectNameDbContextModelCreatingExtensions + { + public static void ConfigureMyProjectName(this ModelBuilder builder) + { + Check.NotNull(builder, nameof(builder)); + + var tablePrefix = MyProjectNameConsts.DefaultDbTablePrefix; + var schema = MyProjectNameConsts.DefaultDbSchema; + + /* Configure all entities here. Example: + + builder.Entity(b => + { + //Configure table & schema name + //b.ToTable(tablePrefix + "Questions", schema); + + //Properties + //b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); + + //Configure relations + //b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); + + //Configure indexes + //b.HasIndex(q => q.CreationTime); + }); + */ + } + } +} \ No newline at end of file diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj index debec3acbe..30b78df34e 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/MyCompanyName.MyProjectName.EntityFrameworkCore.csproj @@ -1,13 +1,11 @@  + + netcoreapp2.2 MyCompanyName.MyProjectName - - - - diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MyCompanyName.MyProjectName.MongoDB.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MyCompanyName.MyProjectName.MongoDB.csproj index b313a4c24d..ece0fd1b4d 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MyCompanyName.MyProjectName.MongoDB.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MyCompanyName.MyProjectName.MongoDB.csproj @@ -1,5 +1,7 @@  + + netcoreapp2.2 MyCompanyName.MyProjectName diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj b/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj index 846b262f32..f3e67ec343 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj @@ -1,5 +1,7 @@  + + netcoreapp2.2 MyCompanyName.MyProjectName @@ -9,7 +11,6 @@ true true false - @@ -28,7 +29,7 @@ - + diff --git a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyCompanyName.MyProjectName.Application.Tests.csproj b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyCompanyName.MyProjectName.Application.Tests.csproj index 752b62442f..e9b614f5e8 100644 --- a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyCompanyName.MyProjectName.Application.Tests.csproj +++ b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyCompanyName.MyProjectName.Application.Tests.csproj @@ -1,5 +1,7 @@  + + netcoreapp2.2 MyCompanyName.MyProjectName diff --git a/templates/mvc/test/MyCompanyName.MyProjectName.Web.Tests/MyCompanyName.MyProjectName.Web.Tests.csproj b/templates/mvc/test/MyCompanyName.MyProjectName.Web.Tests/MyCompanyName.MyProjectName.Web.Tests.csproj index 2a5c9f7a13..177f2da1ec 100644 --- a/templates/mvc/test/MyCompanyName.MyProjectName.Web.Tests/MyCompanyName.MyProjectName.Web.Tests.csproj +++ b/templates/mvc/test/MyCompanyName.MyProjectName.Web.Tests/MyCompanyName.MyProjectName.Web.Tests.csproj @@ -1,5 +1,7 @@  + + netcoreapp2.2 Exe From 3531cf246f0750e0fd27534a2e5f467e227f8f9b Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 10:43:42 +0300 Subject: [PATCH 17/44] Refactor SolutionTemplating --- .../Building/ProjectBuildContextExtensions.cs | 20 +++++++++++++++++++ .../Building/ProjectBuildPipelineStep.cs | 17 +--------------- .../Steps/RemoveProjectFromSolutionStep.cs | 2 +- .../SwitchEntityFrameworkCoreToMongoDbStep.cs | 8 ++++---- 4 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/ProjectBuildContextExtensions.cs diff --git a/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/ProjectBuildContextExtensions.cs b/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/ProjectBuildContextExtensions.cs new file mode 100644 index 0000000000..2aa568ba20 --- /dev/null +++ b/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/ProjectBuildContextExtensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Linq; +using Volo.Utils.SolutionTemplating.Files; + +namespace Volo.Utils.SolutionTemplating.Building +{ + public static class ProjectBuildContextExtensions + { + public static FileEntry GetFile(this ProjectBuildContext context, string filePath) + { + var file = context.Files.FirstOrDefault(f => f.Name == filePath); + if (file == null) + { + throw new ApplicationException("Could not find file: " + filePath); + } + + return file; + } + } +} \ No newline at end of file diff --git a/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/ProjectBuildPipelineStep.cs b/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/ProjectBuildPipelineStep.cs index 7a94ca6ee1..ed6f613dbf 100644 --- a/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/ProjectBuildPipelineStep.cs +++ b/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/ProjectBuildPipelineStep.cs @@ -1,22 +1,7 @@ -using System; -using System.Linq; -using Volo.Utils.SolutionTemplating.Files; - -namespace Volo.Utils.SolutionTemplating.Building +namespace Volo.Utils.SolutionTemplating.Building { public abstract class ProjectBuildPipelineStep { public abstract void Execute(ProjectBuildContext context); - - protected FileEntry GetFile(ProjectBuildContext context, string filePath) - { - var file = context.Files.FirstOrDefault(f => f.Name == filePath); - if (file == null) - { - throw new ApplicationException("Could not find file: " + filePath); - } - - return file; - } } } \ No newline at end of file diff --git a/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs b/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs index 41e9b2cd26..eb56699547 100644 --- a/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs +++ b/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/Steps/RemoveProjectFromSolutionStep.cs @@ -23,7 +23,7 @@ namespace Volo.Utils.SolutionTemplating.Building.Steps public override void Execute(ProjectBuildContext context) { context.Files.RemoveAll(file => file.Name.StartsWith(_projectFolderPath)); - var solutionFile = GetFile(context, _solutionFilePath); + var solutionFile = context.GetFile(_solutionFilePath); solutionFile.NormalizeLineEndings(); solutionFile.SetLines(RemoveProject(solutionFile.GetLines().ToList())); } diff --git a/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs b/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs index cf7404eccf..0901d0250b 100644 --- a/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs +++ b/abp_io/src/Volo.Utils.SolutionTemplating/Volo/Utils/SolutionTemplating/Building/Steps/SwitchEntityFrameworkCoreToMongoDbStep.cs @@ -14,7 +14,7 @@ namespace Volo.Utils.SolutionTemplating.Building.Steps private void ChangeProjectReference(ProjectBuildContext context) { - var file = GetFile(context, "/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj"); + var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/MyCompanyName.MyProjectName.Web.csproj"); file.NormalizeLineEndings(); @@ -29,12 +29,12 @@ namespace Volo.Utils.SolutionTemplating.Building.Steps } } - throw new ApplicationException("Could not find the 'Default' connection string in appsettings.json file!"); + throw new ApplicationException("Could not find the EntityFrameworkCore reference in the MyCompanyName.MyProjectName.Web.csproj!"); } private void ChangeWebModuleUsage(ProjectBuildContext context) { - var file = GetFile(context, "/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs"); + var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs"); file.NormalizeLineEndings(); @@ -59,7 +59,7 @@ namespace Volo.Utils.SolutionTemplating.Building.Steps private void ChangeConnectionString(ProjectBuildContext context) { - var file = GetFile(context, "/src/MyCompanyName.MyProjectName.Web/appsettings.json"); + var file = context.GetFile("/src/MyCompanyName.MyProjectName.Web/appsettings.json"); file.NormalizeLineEndings(); From b5c9bceebb8138354b26b3c7c2837477228c8ef6 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 10:44:28 +0300 Subject: [PATCH 18/44] Remove MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations --- .../src/Volo.AbpWebSite.Web/Templates/MvcApplicationTemplate.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/abp_io/src/Volo.AbpWebSite.Web/Templates/MvcApplicationTemplate.cs b/abp_io/src/Volo.AbpWebSite.Web/Templates/MvcApplicationTemplate.cs index 6868720b20..63e81a7b25 100644 --- a/abp_io/src/Volo.AbpWebSite.Web/Templates/MvcApplicationTemplate.cs +++ b/abp_io/src/Volo.AbpWebSite.Web/Templates/MvcApplicationTemplate.cs @@ -37,6 +37,7 @@ namespace Volo.AbpWebSite.Templates if (context.Request.DatabaseProvider != DatabaseProvider.EntityFrameworkCore) { steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore")); + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Application.Tests", projectFolderPath: "test/MyCompanyName.MyProjectName.Application.Tests")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Tests", projectFolderPath: "test/MyCompanyName.MyProjectName.Web.Tests")); } From 5a54755ab9b19c6d05b5779fa2b6df83b6dfcfa9 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 13:23:33 +0300 Subject: [PATCH 19/44] No need to ModelBuilderConfigurationOptions parameter --- .../IdentityDbContextModelBuilderExtensions.cs | 2 +- .../AbpUsersDbContextModelCreatingExtensions.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs index ce8e1e47d5..0e3fb21688 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs @@ -25,7 +25,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureFullAudited(); b.ConfigureExtraProperties(); b.ConfigureConcurrencyStamp(); - b.ConfigureAbpUser(options); + b.ConfigureAbpUser(); b.Property(u => u.NormalizedUserName).IsRequired().HasMaxLength(IdentityUserConsts.MaxNormalizedUserNameLength).HasColumnName(nameof(IdentityUser.NormalizedUserName)); b.Property(u => u.NormalizedEmail).HasMaxLength(IdentityUserConsts.MaxNormalizedEmailLength).HasColumnName(nameof(IdentityUser.NormalizedEmail)); diff --git a/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/AbpUsersDbContextModelCreatingExtensions.cs b/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/AbpUsersDbContextModelCreatingExtensions.cs index 108b3f4278..1b95984e4b 100644 --- a/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/AbpUsersDbContextModelCreatingExtensions.cs +++ b/modules/users/src/Volo.Abp.Users.EntityFrameworkCore/Volo/Abp/Users/EntityFrameworkCore/AbpUsersDbContextModelCreatingExtensions.cs @@ -1,12 +1,11 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using Volo.Abp.EntityFrameworkCore.Modeling; namespace Volo.Abp.Users.EntityFrameworkCore { public static class AbpUsersDbContextModelCreatingExtensions { - public static void ConfigureAbpUser(this EntityTypeBuilder b, ModelBuilderConfigurationOptions options) + public static void ConfigureAbpUser(this EntityTypeBuilder b) where TUser : class, IUser { b.Property(u => u.TenantId).HasColumnName(nameof(IUser.TenantId)); From 5ebe61562e0016f5c01e7ac756bd3ef5f20e7ef2 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 13:37:33 +0300 Subject: [PATCH 20/44] Added AppUser to the MVC template --- .../Users/AppUser.cs | 53 +++++++++++++++++ .../MyProjectNameMigrationsDbContext.cs | 12 ++++ .../MyProjectNameDbContext.cs | 21 +++++++ .../MyProjectNameDbContextFactory.cs | 29 --------- ...ectNameDbContextModelCreatingExtensions.cs | 29 +++++---- .../MongoDb/MyProjectNameMongoDbContext.cs | 16 ++++- ...ame.MyProjectName.Application.Tests.csproj | 2 +- .../MyProjectNameApplicationTestModule.cs | 4 +- .../Samples/SampleTest.cs | 26 -------- .../Samples/SampleTests.cs | 59 +++++++++++++++++++ 10 files changed, 176 insertions(+), 75 deletions(-) create mode 100644 templates/mvc/src/MyCompanyName.MyProjectName.Domain/Users/AppUser.cs delete mode 100644 templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs delete mode 100644 templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleTest.cs create mode 100644 templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleTests.cs diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/Users/AppUser.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/Users/AppUser.cs new file mode 100644 index 0000000000..587c9d9440 --- /dev/null +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/Users/AppUser.cs @@ -0,0 +1,53 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.Users; + +namespace MyCompanyName.MyProjectName.Users +{ + /* This entity shares the same table/collection ("AbpUsers" by default) with the + * IdentityUser entity of the Identity module. + * + * - You can define your custom properties into this class. + * - You never create or delete this entity, becase it is Identity module's job. + * - You can query users from database with this entity. + * - You can update values of your custom properties. + */ + public class AppUser : FullAuditedAggregateRoot, IUser + { + #region Base properties + + /* These properties are shared with the IdentityUser entity of the Identity module. + * Do not change these properties through this class. Instead, use Identity module + * services (like IdentityUserManager) to change them. + * So, this properties are designed as read only! + */ + + public virtual Guid? TenantId { get; private set; } + + public virtual string UserName { get; private set; } + + public virtual string Name { get; private set; } + + public virtual string Surname { get; private set; } + + public virtual string Email { get; private set; } + + public virtual bool EmailConfirmed { get; private set; } + + public virtual string PhoneNumber { get; private set; } + + public virtual bool PhoneNumberConfirmed { get; private set; } + + #endregion + + /* Add your own properties here. Example: + * + * public virtual string MyProperty { get; set; } + */ + + private AppUser() + { + + } + } +} diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs index 4d8e7bd10f..5fe35526b0 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore.DbMigrations/EntityFrameworkCore/MyProjectNameMigrationsDbContext.cs @@ -2,6 +2,7 @@ using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.BackgroundJobs.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Identity; using Volo.Abp.Identity.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; @@ -20,12 +21,23 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore { base.OnModelCreating(builder); + /* Include modules to your migration db context */ + builder.ConfigurePermissionManagement(); builder.ConfigureSettingManagement(); builder.ConfigureBackgroundJobs(); builder.ConfigureAuditLogging(); builder.ConfigureIdentity(); + /* Configure customizations for entities from the modules included */ + + builder.Entity(b => + { + b.ConfigureCustomUserProperties(); + }); + + /* Configure your own tables/entities inside the ConfigureMyProjectName method */ + builder.ConfigureMyProjectName(); } } diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs index fb4008aff4..5b40bb037a 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs @@ -1,12 +1,17 @@ using Microsoft.EntityFrameworkCore; +using MyCompanyName.MyProjectName.Users; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Modeling; +using Volo.Abp.Users.EntityFrameworkCore; namespace MyCompanyName.MyProjectName.EntityFrameworkCore { [ConnectionStringName("Default")] public class MyProjectNameDbContext : AbpDbContext { + public DbSet Users { get; set; } + public MyProjectNameDbContext(DbContextOptions options) : base(options) { @@ -17,6 +22,22 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore { base.OnModelCreating(builder); + /* Configure your shared tables (with included modules) here */ + + builder.Entity(b => + { + b.ToTable("AbpUsers"); //Sharing the same table "AbpUsers" with the IdentityUser + + b.ConfigureFullAudited(); + b.ConfigureExtraProperties(); + b.ConfigureConcurrencyStamp(); + b.ConfigureAbpUser(); + + b.ConfigureCustomUserProperties(); + }); + + /* Configure your own tables/entities inside the ConfigureMyProjectName method */ + builder.ConfigureMyProjectName(); } } diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs deleted file mode 100644 index c878f12fd5..0000000000 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.IO; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; - -namespace MyCompanyName.MyProjectName.EntityFrameworkCore -{ - public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory - { - public MyProjectNameDbContext CreateDbContext(string[] args) - { - var configuration = BuildConfiguration(); - - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("Default")); - - return new MyProjectNameDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../MyCompanyName.MyProjectName.Web/")) - .AddJsonFile("appsettings.json", optional: false); - - return builder.Build(); - } - } -} diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs index 719d8f2c1e..f345d756db 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs @@ -1,5 +1,9 @@ using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using MyCompanyName.MyProjectName.Users; using Volo.Abp; +using Volo.Abp.Identity; +using Volo.Abp.Users; namespace MyCompanyName.MyProjectName.EntityFrameworkCore { @@ -12,23 +16,18 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore var tablePrefix = MyProjectNameConsts.DefaultDbTablePrefix; var schema = MyProjectNameConsts.DefaultDbSchema; - /* Configure all entities here. Example: + //builder.Entity(b => + //{ + // b.ToTable(tablePrefix + "YourEntities", schema); - builder.Entity(b => - { - //Configure table & schema name - //b.ToTable(tablePrefix + "Questions", schema); - - //Properties - //b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); - - //Configure relations - //b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); + // //... + //}); + } - //Configure indexes - //b.HasIndex(q => q.CreationTime); - }); - */ + public static void ConfigureCustomUserProperties(this EntityTypeBuilder b) + where TUser: class, IUser + { + //b.Property(nameof(AppUser.MyProperty))... } } } \ No newline at end of file diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs b/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs index 19c21ca038..95a041809f 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs @@ -1,4 +1,6 @@ -using Volo.Abp.Data; +using MongoDB.Driver; +using MyCompanyName.MyProjectName.Users; +using Volo.Abp.Data; using Volo.Abp.MongoDB; namespace MyCompanyName.MyProjectName.MongoDb @@ -6,6 +8,16 @@ namespace MyCompanyName.MyProjectName.MongoDb [ConnectionStringName("Default")] public class MyProjectNameMongoDbContext : AbpMongoDbContext { - + public IMongoCollection Users => Collection(); + + protected override void CreateModel(IMongoModelBuilder modelBuilder) + { + base.CreateModel(modelBuilder); + + modelBuilder.Entity(b => + { + b.CollectionName = "AbpUsers"; //Sharing the same collection "AbpUsers" with the IdentityUser + }); + } } } diff --git a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyCompanyName.MyProjectName.Application.Tests.csproj b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyCompanyName.MyProjectName.Application.Tests.csproj index e9b614f5e8..808ee9f1fe 100644 --- a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyCompanyName.MyProjectName.Application.Tests.csproj +++ b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyCompanyName.MyProjectName.Application.Tests.csproj @@ -9,9 +9,9 @@ - + diff --git a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs index 145710c15b..d44dc0bb5a 100644 --- a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs +++ b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs @@ -53,11 +53,11 @@ namespace MyCompanyName.MyProjectName var connection = new SqliteConnection("Data Source=:memory:"); connection.Open(); - var options = new DbContextOptionsBuilder() + var options = new DbContextOptionsBuilder() .UseSqlite(connection) .Options; - using (var context = new MyProjectNameDbContext(options)) + using (var context = new MyProjectNameMigrationsDbContext(options)) { context.GetService().CreateTables(); } diff --git a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleTest.cs b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleTest.cs deleted file mode 100644 index e0f87e86c8..0000000000 --- a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleTest.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Shouldly; -using Volo.Abp.Identity; -using Xunit; - -namespace MyCompanyName.MyProjectName.Samples -{ - public class SampleTest : MyProjectNameApplicationTestBase - { - private readonly IIdentityUserAppService _userAppService; - - public SampleTest() - { - _userAppService = ServiceProvider.GetRequiredService(); - } - - [Fact] - public async Task Initial_Data_Should_Contain_Admin_User() - { - var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()); - result.TotalCount.ShouldBeGreaterThan(0); - result.Items.ShouldContain(u => u.UserName == "admin"); - } - } -} diff --git a/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleTests.cs b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleTests.cs new file mode 100644 index 0000000000..3baff2826f --- /dev/null +++ b/templates/mvc/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleTests.cs @@ -0,0 +1,59 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using MyCompanyName.MyProjectName.Users; +using Shouldly; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Identity; +using Volo.Abp.Uow; +using Xunit; + +namespace MyCompanyName.MyProjectName.Samples +{ + public class SampleTests : MyProjectNameApplicationTestBase + { + private readonly IIdentityUserAppService _userAppService; + private readonly IRepository _appUserRepository; + private readonly IUnitOfWorkManager _unitOfWorkManager; + + public SampleTests() + { + _userAppService = ServiceProvider.GetRequiredService(); + _appUserRepository = ServiceProvider.GetRequiredService>(); + _unitOfWorkManager = ServiceProvider.GetRequiredService(); + } + + [Fact] + public async Task Initial_Data_Should_Contain_Admin_User() + { + //Act + var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()); + + //Assert + result.TotalCount.ShouldBeGreaterThan(0); + result.Items.ShouldContain(u => u.UserName == "admin"); + } + + [Fact] + public async Task Should_Query_AppUser() + { + /* Need to manually start Unit Of Work because + * FirstOrDefaultAsync should be executed while db connection / context is available. + */ + using (var uow = _unitOfWorkManager.Begin()) + { + //Act + var adminUser = await _appUserRepository + .Where(u => u.UserName == "admin") + .FirstOrDefaultAsync(); + + //Assert + adminUser.ShouldNotBeNull(); + + await uow.CompleteAsync(); + } + } + } +} From 7e00a1461dbd8555c2ea0ae2dc7399b905bec367 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 13:42:21 +0300 Subject: [PATCH 21/44] Clean unused namespaces --- .../MyProjectNameDomainModule.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs index 565e4f8d5f..5fca840175 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs @@ -1,5 +1,4 @@ using MyCompanyName.MyProjectName.Localization.MyProjectName; -using MyCompanyName.MyProjectName.Settings; using Volo.Abp.Auditing; using Volo.Abp.AuditLogging; using Volo.Abp.BackgroundJobs; @@ -8,7 +7,6 @@ using Volo.Abp.Localization; using Volo.Abp.Localization.Resources.AbpValidation; using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.Identity; -using Volo.Abp.Settings; using Volo.Abp.VirtualFileSystem; namespace MyCompanyName.MyProjectName From 9b888c76868d497ea0f8711d63b1905a34de2e64 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Wed, 20 Mar 2019 14:05:37 +0300 Subject: [PATCH 22/44] resolved #896 Responsive problem for abp.io download page --- abp_io/src/Volo.AbpWebSite.Web/Pages/Templates.cshtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/abp_io/src/Volo.AbpWebSite.Web/Pages/Templates.cshtml b/abp_io/src/Volo.AbpWebSite.Web/Pages/Templates.cshtml index d7bc5aa603..4643510c34 100644 --- a/abp_io/src/Volo.AbpWebSite.Web/Pages/Templates.cshtml +++ b/abp_io/src/Volo.AbpWebSite.Web/Pages/Templates.cshtml @@ -14,7 +14,7 @@ @using (Html.BeginForm(FormMethod.Post)) {
-
+

Create New Project @@ -64,7 +64,7 @@

-
+

The Startup Project

See the documentation to understand how to run the downloaded project.

From 294f00305d56075d1c0847ba252153db15f00382 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Wed, 20 Mar 2019 14:11:09 +0300 Subject: [PATCH 23/44] Checked if identityUser is null in CheckPassword method of AbpAccountWebModule --- .../Areas/Account/Controllers/AccountController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs index 3992e15f49..700d52b3a9 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/AccountController.cs @@ -47,6 +47,12 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers { ValidateLoginInfo(login); var identityUser = await _userManager.FindByNameAsync(login.UserNameOrEmailAddress); + + if (identityUser == null) + { + return new AbpLoginResult(LoginResultType.InvalidUserNameOrPassword); + } + return GetAbpLoginResult(await _signInManager.CheckPasswordSignInAsync(identityUser, login.Password, true)); } From f94f5c575bff7951bf6e4189336c1fa7dd73e59f Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 14:29:02 +0300 Subject: [PATCH 24/44] Added comments to mvc template --- .../MyProjectNameConsts.cs | 4 ++-- .../EntityFrameworkCore/MyProjectNameDbContext.cs | 3 ++- .../MyProjectNameDbContextModelCreatingExtensions.cs | 7 ++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs index 86a322bb13..d939cfca9f 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs @@ -2,8 +2,8 @@ { public static class MyProjectNameConsts { - public const string DefaultDbTablePrefix = "App"; + public const string DbTablePrefix = "App"; - public const string DefaultDbSchema = null; + public const string DbSchema = null; } } diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs index 5b40bb037a..b96691dcc7 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs @@ -22,7 +22,7 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore { base.OnModelCreating(builder); - /* Configure your shared tables (with included modules) here */ + /* Configure the shared tables (with included modules) here */ builder.Entity(b => { @@ -33,6 +33,7 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore b.ConfigureConcurrencyStamp(); b.ConfigureAbpUser(); + //Moved customization to a method so we can share it with the MyProjectNameMigrationsDbContext class b.ConfigureCustomUserProperties(); }); diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs index f345d756db..49f4c45893 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs @@ -1,8 +1,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; -using MyCompanyName.MyProjectName.Users; using Volo.Abp; -using Volo.Abp.Identity; using Volo.Abp.Users; namespace MyCompanyName.MyProjectName.EntityFrameworkCore @@ -13,12 +11,11 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore { Check.NotNull(builder, nameof(builder)); - var tablePrefix = MyProjectNameConsts.DefaultDbTablePrefix; - var schema = MyProjectNameConsts.DefaultDbSchema; + /* Configure your own tables/entities inside here */ //builder.Entity(b => //{ - // b.ToTable(tablePrefix + "YourEntities", schema); + // b.ToTable(MyProjectNameConsts.DbTablePrefix + "YourEntities", MyProjectNameConsts.DbSchema); // //... //}); From e64412a3e566bd781d9a8493fac04d8c7ac5b6ca Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Wed, 20 Mar 2019 14:53:48 +0300 Subject: [PATCH 25/44] Added scroll to right side of permission modal #894 --- .../PermissionManagementModal.cshtml | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml index beb39387b8..d1081f2f84 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Pages/AbpPermissionManagement/PermissionManagementModal.cshtml @@ -14,23 +14,24 @@ - + @for (var i = 0; i < Model.Groups.Count; i++) {

@Model.Groups[i].DisplayName


- - @for (var j = 0; j < Model.Groups[i].Permissions.Count; j++) - { - - - } +
+ @for (var j = 0; j < Model.Groups[i].Permissions.Count; j++) + { + + + } +
}
From 7ffff19a1d5a5e40b55e8a93c1c83841898c5f80 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 15:09:07 +0300 Subject: [PATCH 26/44] Update MyProjectNameDbContextModelCreatingExtensions.cs --- .../MyProjectNameDbContextModelCreatingExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs index 49f4c45893..3528ed5279 100644 --- a/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs +++ b/templates/mvc/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs @@ -24,7 +24,7 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore public static void ConfigureCustomUserProperties(this EntityTypeBuilder b) where TUser: class, IUser { - //b.Property(nameof(AppUser.MyProperty))... + //b.Property(nameof(AppUser.MyProperty))... } } } \ No newline at end of file From f29a8445439dcffdabe99ccece39c1b3bb829076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atakan=20=C3=96zceviz?= Date: Wed, 20 Mar 2019 13:32:32 +0100 Subject: [PATCH 27/44] Cleanup k8s yml files. --- .../k8s/auth-server-deployment.yaml | 44 ++++++------ .../k8s/auth-server-service.yaml | 15 ++-- .../k8s/backend-admin-app-deployment.yaml | 44 ++++++------ .../backend-admin-app-gateway-deployment.yaml | 68 +++++++++--------- .../backend-admin-app-gateway-service.yaml | 15 ++-- .../k8s/backend-admin-app-service.yaml | 15 ++-- .../k8s/blogging-service-deployment.yaml | 56 +++++++-------- .../k8s/blogging-service-service.yaml | 15 ++-- .../k8s/dbdata-persistentvolumeclaim.yaml | 3 - .../MicroserviceDemo/k8s/expose-service.yaml | 12 +--- .../k8s/identity-service-deployment.yaml | 48 ++++++------- .../k8s/identity-service-service.yaml | 15 ++-- .../k8s/internal-gateway-deployment.yaml | 72 +++++++++---------- .../k8s/internal-gateway-service.yaml | 15 ++-- .../k8s/mongodb-deployment.yaml | 21 +++--- .../MicroserviceDemo/k8s/mongodb-service.yaml | 12 ++-- .../k8s/product-service-deployment.yaml | 54 +++++++------- .../k8s/product-service-service.yaml | 15 ++-- .../k8s/public-website-deployment.yaml | 44 ++++++------ .../public-website-gateway-deployment.yaml | 64 ++++++++--------- .../k8s/public-website-gateway-service.yaml | 15 ++-- .../k8s/public-website-service.yaml | 15 ++-- .../k8s/rabbitmq-deployment.yaml | 23 +++--- .../k8s/rabbitmq-service.yaml | 12 ++-- .../k8s/redis-deployment.yaml | 21 +++--- .../MicroserviceDemo/k8s/redis-service.yaml | 14 ++-- .../k8s/restore-database-job.yaml | 2 +- .../k8s/sqlserver-deployment.yaml | 34 ++++----- .../k8s/sqlserver-service.yaml | 15 ++-- 29 files changed, 360 insertions(+), 438 deletions(-) diff --git a/samples/MicroserviceDemo/k8s/auth-server-deployment.yaml b/samples/MicroserviceDemo/k8s/auth-server-deployment.yaml index 7ddbc30309..81a4b5c64d 100644 --- a/samples/MicroserviceDemo/k8s/auth-server-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/auth-server-deployment.yaml @@ -1,33 +1,31 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: auth-server name: auth-server spec: + selector: + matchLabels: + app: auth-server replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: auth-server + app: auth-server spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:51511 - - name: ConnectionStrings__Default - value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false - - name: RabbitMQ__Connections__Default__HostName - value: rabbitmq - - name: Redis__Configuration - value: redis - image: volosoft/microservice-demo-auth-server - name: auth-server - ports: - - containerPort: 51511 - resources: {} - restartPolicy: Always -status: {} + - name: auth-server + image: "volosoft/microservice-demo-auth-server" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:51511 + - name: ConnectionStrings__Default + value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false + - name: RabbitMQ__Connections__Default__HostName + value: rabbitmq + - name: Redis__Configuration + value: redis + ports: + - name: http + containerPort: 51511 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/auth-server-service.yaml b/samples/MicroserviceDemo/k8s/auth-server-service.yaml index d317ba1fae..1ff487ac16 100644 --- a/samples/MicroserviceDemo/k8s/auth-server-service.yaml +++ b/samples/MicroserviceDemo/k8s/auth-server-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: auth-server name: auth-server spec: - ports: - - port: 51511 - targetPort: 51511 selector: - io.kompose.service: auth-server -status: - loadBalancer: {} + app: auth-server + ports: + - protocol: TCP + port: 51511 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/backend-admin-app-deployment.yaml b/samples/MicroserviceDemo/k8s/backend-admin-app-deployment.yaml index f26cb02806..4f0f3d4602 100644 --- a/samples/MicroserviceDemo/k8s/backend-admin-app-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/backend-admin-app-deployment.yaml @@ -1,33 +1,31 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: backend-admin-app name: backend-admin-app spec: + selector: + matchLabels: + app: backend-admin-app replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: backend-admin-app + app: backend-admin-app spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80 - - name: AuthServer__Authority - value: http://auth-server:51511 - - name: Redis__Configuration - value: redis - - name: RemoteServices__Default__BaseUrl - value: http://backend-admin-app-gateway/ - image: volosoft/microservice-demo-backend-admin-app - name: backend-admin-app - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} + - name: backend-admin-app + image: "volosoft/microservice-demo-backend-admin-app" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: AuthServer__Authority + value: http://auth-server:51511 + - name: Redis__Configuration + value: redis + - name: RemoteServices__Default__BaseUrl + value: http://backend-admin-app-gateway/ + ports: + - name: http + containerPort: 80 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/backend-admin-app-gateway-deployment.yaml b/samples/MicroserviceDemo/k8s/backend-admin-app-gateway-deployment.yaml index c2f28623b2..21d4260a98 100644 --- a/samples/MicroserviceDemo/k8s/backend-admin-app-gateway-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/backend-admin-app-gateway-deployment.yaml @@ -1,45 +1,43 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: backend-admin-app-gateway name: backend-admin-app-gateway spec: + selector: + matchLabels: + app: backend-admin-app-gateway replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: backend-admin-app-gateway + app: backend-admin-app-gateway spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80 - - name: AuthServer__Authority - value: http://auth-server:51511 - - name: ConnectionStrings__Default - value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false - - name: GlobalConfiguration__BaseUrl - value: http://backend-admin-app-gateway - - name: ReRoutes__0__DownstreamHostAndPorts__0__Host - value: identity-service - - name: ReRoutes__0__DownstreamHostAndPorts__0__Port - value: "80" - - name: ReRoutes__1__DownstreamHostAndPorts__0__Host - value: product-service - - name: ReRoutes__1__DownstreamHostAndPorts__0__Port - value: "80" - - name: Redis__Configuration - value: redis - - name: RemoteServices__Default__BaseUrl - value: http://backend-admin-app-gateway/ - image: volosoft/microservice-demo-backend-admin-app-gateway - name: backend-admin-app-gateway - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} + - name: backend-admin-app-gateway + image: "volosoft/microservice-demo-backend-admin-app-gateway" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: AuthServer__Authority + value: http://auth-server:51511 + - name: ConnectionStrings__Default + value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false + - name: GlobalConfiguration__BaseUrl + value: http://backend-admin-app-gateway + - name: ReRoutes__0__DownstreamHostAndPorts__0__Host + value: identity-service + - name: ReRoutes__0__DownstreamHostAndPorts__0__Port + value: "80" + - name: ReRoutes__1__DownstreamHostAndPorts__0__Host + value: product-service + - name: ReRoutes__1__DownstreamHostAndPorts__0__Port + value: "80" + - name: Redis__Configuration + value: redis + - name: RemoteServices__Default__BaseUrl + value: http://backend-admin-app-gateway/ + ports: + - name: http + containerPort: 80 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/backend-admin-app-gateway-service.yaml b/samples/MicroserviceDemo/k8s/backend-admin-app-gateway-service.yaml index 4864ee547a..d773c940d2 100644 --- a/samples/MicroserviceDemo/k8s/backend-admin-app-gateway-service.yaml +++ b/samples/MicroserviceDemo/k8s/backend-admin-app-gateway-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: backend-admin-app-gateway name: backend-admin-app-gateway spec: - ports: - - port: 80 - targetPort: 80 selector: - io.kompose.service: backend-admin-app-gateway -status: - loadBalancer: {} + app: backend-admin-app-gateway + ports: + - protocol: TCP + port: 80 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/backend-admin-app-service.yaml b/samples/MicroserviceDemo/k8s/backend-admin-app-service.yaml index f8df4e57de..36a28cb7a1 100644 --- a/samples/MicroserviceDemo/k8s/backend-admin-app-service.yaml +++ b/samples/MicroserviceDemo/k8s/backend-admin-app-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: backend-admin-app name: backend-admin-app spec: - ports: - - port: 80 - targetPort: 80 selector: - io.kompose.service: backend-admin-app -status: - loadBalancer: {} + app: backend-admin-app + ports: + - protocol: TCP + port: 80 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/blogging-service-deployment.yaml b/samples/MicroserviceDemo/k8s/blogging-service-deployment.yaml index 6bf8d33a8c..5fa5c5542d 100644 --- a/samples/MicroserviceDemo/k8s/blogging-service-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/blogging-service-deployment.yaml @@ -1,39 +1,37 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: blogging-service name: blogging-service spec: + selector: + matchLabels: + app: blogging-service replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: blogging-service + app: blogging-service spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80 - - name: AuthServer__Authority - value: http://auth-server:51511 - - name: ConnectionStrings__Blogging - value: mongodb://mongodb|MsDemo_Blogging - - name: ConnectionStrings__Default - value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false - - name: RabbitMQ__Connections__Default__HostName - value: rabbitmq - - name: Redis__Configuration - value: redis - - name: RemoteServices__Default__BaseUrl - value: http://internal-gateway/ - image: volosoft/microservice-demo-blogging-service - name: blogging-service - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} + - name: blogging-service + image: "volosoft/microservice-demo-blogging-service" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: AuthServer__Authority + value: http://auth-server:51511 + - name: ConnectionStrings__Blogging + value: mongodb://mongodb|MsDemo_Blogging + - name: ConnectionStrings__Default + value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false + - name: RabbitMQ__Connections__Default__HostName + value: rabbitmq + - name: Redis__Configuration + value: redis + - name: RemoteServices__Default__BaseUrl + value: http://internal-gateway/ + ports: + - name: http + containerPort: 80 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/blogging-service-service.yaml b/samples/MicroserviceDemo/k8s/blogging-service-service.yaml index c2b359580a..4e756c01d7 100644 --- a/samples/MicroserviceDemo/k8s/blogging-service-service.yaml +++ b/samples/MicroserviceDemo/k8s/blogging-service-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: blogging-service name: blogging-service spec: - ports: - - port: 80 - targetPort: 80 selector: - io.kompose.service: blogging-service -status: - loadBalancer: {} + app: blogging-service + ports: + - protocol: TCP + port: 80 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/dbdata-persistentvolumeclaim.yaml b/samples/MicroserviceDemo/k8s/dbdata-persistentvolumeclaim.yaml index cfed8b93e2..6ba0609fb4 100644 --- a/samples/MicroserviceDemo/k8s/dbdata-persistentvolumeclaim.yaml +++ b/samples/MicroserviceDemo/k8s/dbdata-persistentvolumeclaim.yaml @@ -1,8 +1,6 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - labels: - io.kompose.service: dbdata name: dbdata spec: accessModes: @@ -10,4 +8,3 @@ spec: resources: requests: storage: 500Mi -status: {} diff --git a/samples/MicroserviceDemo/k8s/expose-service.yaml b/samples/MicroserviceDemo/k8s/expose-service.yaml index f7a7e7dfe5..b1b668a533 100644 --- a/samples/MicroserviceDemo/k8s/expose-service.yaml +++ b/samples/MicroserviceDemo/k8s/expose-service.yaml @@ -1,13 +1,11 @@ apiVersion: v1 kind: Service metadata: - labels: - io.kompose.service: auth-server name: auth-server-expose spec: type: LoadBalancer selector: - io.kompose.service: auth-server + app: auth-server ports: - protocol: TCP port: 51511 @@ -17,13 +15,11 @@ spec: apiVersion: v1 kind: Service metadata: - labels: - io.kompose.service: backend-admin-app name: backend-admin-app-expose spec: type: LoadBalancer selector: - io.kompose.service: backend-admin-app + app: backend-admin-app ports: - protocol: TCP port: 80 @@ -33,13 +29,11 @@ spec: apiVersion: v1 kind: Service metadata: - labels: - io.kompose.service: public-website name: public-website-expose spec: type: LoadBalancer selector: - io.kompose.service: public-website + app: public-website ports: - protocol: TCP port: 80 diff --git a/samples/MicroserviceDemo/k8s/identity-service-deployment.yaml b/samples/MicroserviceDemo/k8s/identity-service-deployment.yaml index 6179f57e44..add7d662c3 100644 --- a/samples/MicroserviceDemo/k8s/identity-service-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/identity-service-deployment.yaml @@ -1,35 +1,33 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: identity-service name: identity-service spec: + selector: + matchLabels: + app: identity-service replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: identity-service + app: identity-service spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80 - - name: AuthServer__Authority - value: http://auth-server:51511 - - name: ConnectionStrings__Default - value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false - - name: RabbitMQ__Connections__Default__HostName - value: rabbitmq - - name: Redis__Configuration - value: redis - image: volosoft/microservice-demo-identity-service - name: identity-service - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} + - name: identity-service + image: "volosoft/microservice-demo-identity-service" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: AuthServer__Authority + value: http://auth-server:51511 + - name: ConnectionStrings__Default + value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false + - name: RabbitMQ__Connections__Default__HostName + value: rabbitmq + - name: Redis__Configuration + value: redis + ports: + - name: http + containerPort: 80 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/identity-service-service.yaml b/samples/MicroserviceDemo/k8s/identity-service-service.yaml index 994f120b0b..6157e27437 100644 --- a/samples/MicroserviceDemo/k8s/identity-service-service.yaml +++ b/samples/MicroserviceDemo/k8s/identity-service-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: identity-service name: identity-service spec: - ports: - - port: 80 - targetPort: 80 selector: - io.kompose.service: identity-service -status: - loadBalancer: {} + app: identity-service + ports: + - protocol: TCP + port: 80 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/internal-gateway-deployment.yaml b/samples/MicroserviceDemo/k8s/internal-gateway-deployment.yaml index 9c7edf6cdb..e748456a64 100644 --- a/samples/MicroserviceDemo/k8s/internal-gateway-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/internal-gateway-deployment.yaml @@ -1,47 +1,45 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: internal-gateway name: internal-gateway spec: + selector: + matchLabels: + app: internal-gateway replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: internal-gateway + app: internal-gateway spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80 - - name: AuthServer__Authority - value: http://auth-server:51511 - - name: ConnectionStrings__Default - value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false - - name: GlobalConfiguration__BaseUrl - value: http://internal-gateway - - name: ReRoutes__0__DownstreamHostAndPorts__0__Host - value: identity-service - - name: ReRoutes__0__DownstreamHostAndPorts__0__Port - value: "80" - - name: ReRoutes__1__DownstreamHostAndPorts__0__Host - value: product-service - - name: ReRoutes__1__DownstreamHostAndPorts__0__Port - value: "80" - - name: ReRoutes__2__DownstreamHostAndPorts__0__Host - value: blogging-service - - name: ReRoutes__2__DownstreamHostAndPorts__0__Port - value: "80" - - name: Redis__Configuration - value: redis - image: volosoft/microservice-demo-internal-gateway - name: internal-gateway - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} + - name: internal-gateway + image: "volosoft/microservice-demo-internal-gateway" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: AuthServer__Authority + value: http://auth-server:51511 + - name: ConnectionStrings__Default + value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false + - name: GlobalConfiguration__BaseUrl + value: http://internal-gateway + - name: ReRoutes__0__DownstreamHostAndPorts__0__Host + value: identity-service + - name: ReRoutes__0__DownstreamHostAndPorts__0__Port + value: "80" + - name: ReRoutes__1__DownstreamHostAndPorts__0__Host + value: product-service + - name: ReRoutes__1__DownstreamHostAndPorts__0__Port + value: "80" + - name: ReRoutes__2__DownstreamHostAndPorts__0__Host + value: blogging-service + - name: ReRoutes__2__DownstreamHostAndPorts__0__Port + value: "80" + - name: Redis__Configuration + value: redis + ports: + - name: http + containerPort: 80 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/internal-gateway-service.yaml b/samples/MicroserviceDemo/k8s/internal-gateway-service.yaml index e2766c3c3a..b0d80b34a1 100644 --- a/samples/MicroserviceDemo/k8s/internal-gateway-service.yaml +++ b/samples/MicroserviceDemo/k8s/internal-gateway-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: internal-gateway name: internal-gateway spec: - ports: - - port: 80 - targetPort: 80 selector: - io.kompose.service: internal-gateway -status: - loadBalancer: {} + app: internal-gateway + ports: + - protocol: TCP + port: 80 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/mongodb-deployment.yaml b/samples/MicroserviceDemo/k8s/mongodb-deployment.yaml index 938af49960..dbe3b9bde2 100644 --- a/samples/MicroserviceDemo/k8s/mongodb-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/mongodb-deployment.yaml @@ -1,22 +1,19 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: mongodb name: mongodb spec: + selector: + matchLabels: + app: mongodb replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: mongodb + app: mongodb spec: containers: - - image: mongo - name: mongodb - ports: - - containerPort: 27017 - resources: {} - restartPolicy: Always -status: {} + - name: mongodb + image: "mongo" + ports: + - containerPort: 27017 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/mongodb-service.yaml b/samples/MicroserviceDemo/k8s/mongodb-service.yaml index 34958fb121..0752ee87ca 100644 --- a/samples/MicroserviceDemo/k8s/mongodb-service.yaml +++ b/samples/MicroserviceDemo/k8s/mongodb-service.yaml @@ -1,14 +1,10 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: mongodb name: mongodb spec: + selector: + app: mongodb ports: - port: 27017 - targetPort: 27017 - selector: - io.kompose.service: mongodb -status: - loadBalancer: {} + targetPort: 27017 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/product-service-deployment.yaml b/samples/MicroserviceDemo/k8s/product-service-deployment.yaml index 669de15ae1..238c7ea45f 100644 --- a/samples/MicroserviceDemo/k8s/product-service-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/product-service-deployment.yaml @@ -1,38 +1,36 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: product-service name: product-service spec: + selector: + matchLabels: + app: product-service replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: product-service + app: product-service spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80 - - name: AuthServer__Authority - value: http://auth-server:51511 - - name: ConnectionStrings__Default - value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated - Security=false - - name: ConnectionStrings__ProductManagement - value: Server=sqlserver;Database=MsDemo_ProductManagement;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false - - name: RabbitMQ__Connections__Default__HostName - value: rabbitmq - - name: Redis__Configuration - value: redis - image: volosoft/microservice-demo-product-service - name: product-service - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} + - name: product-service + image: "volosoft/microservice-demo-product-service" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: AuthServer__Authority + value: http://auth-server:51511 + - name: ConnectionStrings__Default + value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated + Security=false + - name: ConnectionStrings__ProductManagement + value: Server=sqlserver;Database=MsDemo_ProductManagement;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false + - name: RabbitMQ__Connections__Default__HostName + value: rabbitmq + - name: Redis__Configuration + value: redis + ports: + - name: http + containerPort: 80 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/product-service-service.yaml b/samples/MicroserviceDemo/k8s/product-service-service.yaml index 3c5d1f333b..b420f35361 100644 --- a/samples/MicroserviceDemo/k8s/product-service-service.yaml +++ b/samples/MicroserviceDemo/k8s/product-service-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: product-service name: product-service spec: - ports: - - port: 80 - targetPort: 80 selector: - io.kompose.service: product-service -status: - loadBalancer: {} + app: product-service + ports: + - protocol: TCP + port: 80 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/public-website-deployment.yaml b/samples/MicroserviceDemo/k8s/public-website-deployment.yaml index c643f68b99..321ad14565 100644 --- a/samples/MicroserviceDemo/k8s/public-website-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/public-website-deployment.yaml @@ -1,33 +1,31 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: public-website name: public-website spec: + selector: + matchLabels: + app: public-website replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: public-website + app: public-website spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80 - - name: AuthServer__Authority - value: http://auth-server:51511 - - name: Redis__Configuration - value: redis - - name: RemoteServices__Default__BaseUrl - value: http://public-website-gateway/ - image: volosoft/microservice-demo-public-website - name: public-website - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} + - name: public-website + image: "volosoft/microservice-demo-public-website" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: AuthServer__Authority + value: http://auth-server:51511 + - name: Redis__Configuration + value: redis + - name: RemoteServices__Default__BaseUrl + value: http://public-website-gateway/ + ports: + - name: http + containerPort: 80 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/public-website-gateway-deployment.yaml b/samples/MicroserviceDemo/k8s/public-website-gateway-deployment.yaml index 802f12a7e3..43804ea78a 100644 --- a/samples/MicroserviceDemo/k8s/public-website-gateway-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/public-website-gateway-deployment.yaml @@ -1,43 +1,41 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: public-website-gateway name: public-website-gateway spec: + selector: + matchLabels: + app: public-website-gateway replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: public-website-gateway + app: public-website-gateway spec: containers: - - env: - - name: ASPNETCORE_ENVIRONMENT - value: Development - - name: ASPNETCORE_URLS - value: http://0.0.0.0:80 - - name: AuthServer__Authority - value: http://auth-server:51511 - - name: ConnectionStrings__Default - value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false - - name: GlobalConfiguration__BaseUrl - value: http://public-website-gateway - - name: ReRoutes__0__DownstreamHostAndPorts__0__Host - value: product-service - - name: ReRoutes__0__DownstreamHostAndPorts__0__Port - value: "80" - - name: ReRoutes__1__DownstreamHostAndPorts__0__Host - value: blogging-service - - name: ReRoutes__1__DownstreamHostAndPorts__0__Port - value: "80" - - name: Redis__Configuration - value: redis - image: volosoft/microservice-demo-public-website-gateway - name: public-website-gateway - ports: - - containerPort: 80 - resources: {} - restartPolicy: Always -status: {} + - name: public-website-gateway + image: "volosoft/microservice-demo-public-website-gateway" + env: + - name: ASPNETCORE_ENVIRONMENT + value: Development + - name: ASPNETCORE_URLS + value: http://0.0.0.0:80 + - name: AuthServer__Authority + value: http://auth-server:51511 + - name: ConnectionStrings__Default + value: Server=sqlserver;Database=MsDemo_Identity;Trusted_Connection=True;MultipleActiveResultSets=true;User=sa;Password=yourStrong(!)Password;Integrated Security=false + - name: GlobalConfiguration__BaseUrl + value: http://public-website-gateway + - name: ReRoutes__0__DownstreamHostAndPorts__0__Host + value: product-service + - name: ReRoutes__0__DownstreamHostAndPorts__0__Port + value: "80" + - name: ReRoutes__1__DownstreamHostAndPorts__0__Host + value: blogging-service + - name: ReRoutes__1__DownstreamHostAndPorts__0__Port + value: "80" + - name: Redis__Configuration + value: redis + ports: + - name: http + containerPort: 80 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/public-website-gateway-service.yaml b/samples/MicroserviceDemo/k8s/public-website-gateway-service.yaml index 5ab4e428b9..d04c680685 100644 --- a/samples/MicroserviceDemo/k8s/public-website-gateway-service.yaml +++ b/samples/MicroserviceDemo/k8s/public-website-gateway-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: public-website-gateway name: public-website-gateway spec: - ports: - - port: 80 - targetPort: 80 selector: - io.kompose.service: public-website-gateway -status: - loadBalancer: {} + app: public-website-gateway + ports: + - protocol: TCP + port: 80 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/public-website-service.yaml b/samples/MicroserviceDemo/k8s/public-website-service.yaml index 5f5c4f56d9..5ac586cb19 100644 --- a/samples/MicroserviceDemo/k8s/public-website-service.yaml +++ b/samples/MicroserviceDemo/k8s/public-website-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: public-website name: public-website spec: - ports: - - port: 80 - targetPort: 80 selector: - io.kompose.service: public-website -status: - loadBalancer: {} + app: public-website + ports: + - protocol: TCP + port: 80 + targetPort: http \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/rabbitmq-deployment.yaml b/samples/MicroserviceDemo/k8s/rabbitmq-deployment.yaml index e455bebac6..283b1601a9 100644 --- a/samples/MicroserviceDemo/k8s/rabbitmq-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/rabbitmq-deployment.yaml @@ -1,23 +1,20 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: rabbitmq name: rabbitmq spec: + selector: + matchLabels: + app: rabbitmq replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: rabbitmq + app: rabbitmq spec: containers: - - image: rabbitmq:3-management-alpine - name: rabbitmq - ports: - - containerPort: 5672 - - containerPort: 15672 - resources: {} - restartPolicy: Always -status: {} + - name: rabbitmq + image: "rabbitmq:3-management-alpine" + ports: + - containerPort: 5672 + - containerPort: 15672 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/rabbitmq-service.yaml b/samples/MicroserviceDemo/k8s/rabbitmq-service.yaml index b8595193e8..07e7b2a618 100644 --- a/samples/MicroserviceDemo/k8s/rabbitmq-service.yaml +++ b/samples/MicroserviceDemo/k8s/rabbitmq-service.yaml @@ -1,18 +1,14 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: rabbitmq name: rabbitmq spec: + selector: + app: rabbitmq ports: - name: "5672" port: 5672 targetPort: 5672 - name: "15672" port: 15672 - targetPort: 15672 - selector: - io.kompose.service: rabbitmq -status: - loadBalancer: {} + targetPort: 15672 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/redis-deployment.yaml b/samples/MicroserviceDemo/k8s/redis-deployment.yaml index 35d9973110..5f0c6e50e4 100644 --- a/samples/MicroserviceDemo/k8s/redis-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/redis-deployment.yaml @@ -1,22 +1,19 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: redis name: redis spec: + selector: + matchLabels: + app: redis replicas: 1 - strategy: {} template: metadata: labels: - io.kompose.service: redis + app: redis spec: containers: - - image: redis - name: redis - ports: - - containerPort: 6379 - resources: {} - restartPolicy: Always -status: {} + - name: redis + image: "redis" + ports: + - containerPort: 6379 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/redis-service.yaml b/samples/MicroserviceDemo/k8s/redis-service.yaml index 8ef5014d20..8fef057052 100644 --- a/samples/MicroserviceDemo/k8s/redis-service.yaml +++ b/samples/MicroserviceDemo/k8s/redis-service.yaml @@ -1,14 +1,10 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: redis name: redis spec: - ports: - - port: 6379 - targetPort: 6379 selector: - io.kompose.service: redis -status: - loadBalancer: {} + app: redis + ports: + - port: 6379 + targetPort: 6379 \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/restore-database-job.yaml b/samples/MicroserviceDemo/k8s/restore-database-job.yaml index b35b67844f..fa403e95d8 100644 --- a/samples/MicroserviceDemo/k8s/restore-database-job.yaml +++ b/samples/MicroserviceDemo/k8s/restore-database-job.yaml @@ -12,7 +12,7 @@ spec: - name: SA_PASSWORD value: yourStrong(!)Password name: restore-database - image: volosoft/microservice-demo-restore-database + image: "volosoft/microservice-demo-restore-database" volumeMounts: - mountPath: /var/opt/mssql name: dbdata diff --git a/samples/MicroserviceDemo/k8s/sqlserver-deployment.yaml b/samples/MicroserviceDemo/k8s/sqlserver-deployment.yaml index 1de273530e..e95ce99ee7 100644 --- a/samples/MicroserviceDemo/k8s/sqlserver-deployment.yaml +++ b/samples/MicroserviceDemo/k8s/sqlserver-deployment.yaml @@ -1,35 +1,35 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: - labels: - io.kompose.service: sqlserver name: sqlserver spec: + selector: + matchLabels: + app: sqlserver replicas: 1 - strategy: - type: Recreate template: metadata: labels: - io.kompose.service: sqlserver + app: sqlserver spec: containers: - - env: + - name: sqlserver + image: mcr.microsoft.com/mssql/server + ports: + - containerPort: 1433 + env: + - name: MSSQL_PID + value: "Developer" - name: ACCEPT_EULA value: "Y" - name: SA_PASSWORD value: yourStrong(!)Password - image: mcr.microsoft.com/mssql/server - name: sqlserver - ports: - - containerPort: 1433 - resources: {} + - name: MSSQL_SA_PASSWORD + value: yourStrong(!)Password volumeMounts: - - mountPath: /var/opt/mssql - name: dbdata - restartPolicy: Always + - name: dbdata + mountPath: /var/opt/mssql volumes: - name: dbdata persistentVolumeClaim: - claimName: dbdata -status: {} + claimName: dbdata \ No newline at end of file diff --git a/samples/MicroserviceDemo/k8s/sqlserver-service.yaml b/samples/MicroserviceDemo/k8s/sqlserver-service.yaml index da4a98c85a..a72adb2567 100644 --- a/samples/MicroserviceDemo/k8s/sqlserver-service.yaml +++ b/samples/MicroserviceDemo/k8s/sqlserver-service.yaml @@ -1,14 +1,11 @@ -apiVersion: v1 kind: Service +apiVersion: v1 metadata: - labels: - io.kompose.service: sqlserver name: sqlserver spec: - ports: - - port: 1433 - targetPort: 1433 selector: - io.kompose.service: sqlserver -status: - loadBalancer: {} + app: sqlserver + ports: + - protocol: TCP + port: 1433 + targetPort: 1433 \ No newline at end of file From 12f5572b78155128fb67c8b29fab578443460f90 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 15:52:47 +0300 Subject: [PATCH 28/44] Updated EF Core migrations --- ...Initial.Designer.cs => 20190320125012_Initial.Designer.cs} | 2 +- .../{20190107113413_Initial.cs => 20190320125012_Initial.cs} | 0 .../MyCompanyName.MyProjectName.DemoApp.csproj | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) rename templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/{20190107113413_Initial.Designer.cs => 20190320125012_Initial.Designer.cs} (99%) rename templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/{20190107113413_Initial.cs => 20190320125012_Initial.cs} (100%) diff --git a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.Designer.cs b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190320125012_Initial.Designer.cs similarity index 99% rename from templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.Designer.cs rename to templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190320125012_Initial.Designer.cs index 8d0c81b5f8..91a4c096ff 100644 --- a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.Designer.cs +++ b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190320125012_Initial.Designer.cs @@ -10,7 +10,7 @@ using MyCompanyName.MyProjectName.DemoApp; namespace MyCompanyName.MyProjectName.DemoApp.Migrations { [DbContext(typeof(DemoAppDbContext))] - [Migration("20190107113413_Initial")] + [Migration("20190320125012_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.cs b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190320125012_Initial.cs similarity index 100% rename from templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190107113413_Initial.cs rename to templates/module/app/MyCompanyName.MyProjectName.DemoApp/Migrations/20190320125012_Initial.cs diff --git a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj index 4e019c6d9b..041d6cf9ce 100644 --- a/templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj +++ b/templates/module/app/MyCompanyName.MyProjectName.DemoApp/MyCompanyName.MyProjectName.DemoApp.csproj @@ -35,4 +35,8 @@ + + + + From 783dec9e28ba9b08cd1eecd2f1159ca597284ecd Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 15:53:57 +0300 Subject: [PATCH 29/44] Remove asp-validation-summary --- .../Pages/Identity/Users/CreateModal.cshtml | 1 - .../Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml | 1 - 2 files changed, 2 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml index ed45747c0c..d20d0a0026 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml @@ -31,7 +31,6 @@ }
-
diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml index be9cc9b205..247e59e46b 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml @@ -32,7 +32,6 @@ } -
From 956141e5f202ae674b12ec95c100575150d2a4c2 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Wed, 20 Mar 2019 16:44:24 +0300 Subject: [PATCH 30/44] setting management localization --- .../AbpSettingManagementWebModule.cs | 15 ++++++++ .../AbpSettingManagementResource.cs | 10 +++++ .../Resources/AbpSettingManagement/en.json | 6 +++ .../Resources/AbpSettingManagement/tr.json | 6 +++ .../SettingManagementMainMenuContributor.cs | 7 ++-- .../Pages/SettingManagement/Index.cshtml | 37 ++++++++++--------- .../Volo.Abp.SettingManagement.Web.csproj | 2 +- 7 files changed, 62 insertions(+), 21 deletions(-) create mode 100644 modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/AbpSettingManagementResource.cs create mode 100644 modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/en.json create mode 100644 modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/tr.json diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs index b10d3c69c3..f1fae6b2f3 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/AbpSettingManagementWebModule.cs @@ -1,5 +1,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; +using Volo.Abp.Localization; using Volo.Abp.Modularity; +using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Web.Navigation; using Volo.Abp.UI.Navigation; using Volo.Abp.VirtualFileSystem; @@ -22,6 +24,19 @@ namespace Volo.Abp.SettingManagement.Web { options.FileSets.AddEmbedded("Volo.Abp.SettingManagement.Web"); }); + + Configure(options => + { + options.Resources + .Add("en"); + }); + + Configure(options => + { + options.Resources + .Get() + .AddVirtualJson("/Localization/Resources/AbpSettingManagement"); + }); } } } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/AbpSettingManagementResource.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/AbpSettingManagementResource.cs new file mode 100644 index 0000000000..a89f749e4c --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/AbpSettingManagementResource.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Localization; + +namespace Volo.Abp.SettingManagement.Localization +{ + [LocalizationResourceName("AbpSettingManagement")] + public class AbpSettingManagementResource + { + + } +} diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/en.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/en.json new file mode 100644 index 0000000000..654885f10b --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/en.json @@ -0,0 +1,6 @@ +{ + "culture": "en", + "texts": { + "Settings": "Settings" + } +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/tr.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/tr.json new file mode 100644 index 0000000000..0e80027b84 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/tr.json @@ -0,0 +1,6 @@ +{ + "culture": "tr", + "texts": { + "Settings": "Ayarlar" + } +} \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs index 1fbd519bfd..79ed300398 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Navigation/SettingManagementMainMenuContributor.cs @@ -1,7 +1,9 @@ using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; using System.Linq; using System.Threading.Tasks; +using Volo.Abp.SettingManagement.Localization; using Volo.Abp.SettingManagement.Web.Pages.SettingManagement; using Volo.Abp.UI.Navigation; @@ -22,15 +24,14 @@ namespace Volo.Abp.SettingManagement.Web.Navigation return Task.CompletedTask; } - //TODO: Localize - //var l = context.ServiceProvider.GetRequiredService>(); + var l = context.ServiceProvider.GetRequiredService>(); context.Menu .GetAdministration() .AddItem( new ApplicationMenuItem( SettingManagementMenuNames.GroupName, - "Settings", + l["Settings"], "/SettingManagement", icon: "fa fa-cog" ) diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml index c14c416a36..edcc541bfe 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Pages/SettingManagement/Index.cshtml @@ -1,11 +1,14 @@ @page @using Volo.Abp.AspNetCore.Mvc.UI.Layout +@using Microsoft.AspNetCore.Mvc.Localization +@using Volo.Abp.SettingManagement.Localization @using Volo.Abp.SettingManagement.Web.Navigation @using Volo.Abp.SettingManagement.Web.Pages.SettingManagement @model IndexModel +@inject IHtmlLocalizer L @inject IPageLayout PageLayout @{ - PageLayout.Content.Title = /*L["Settings"].Value*/ "Settings"; + PageLayout.Content.Title = L["Settings"].Value; PageLayout.Content.MenuItemName = SettingManagementMenuNames.GroupName; } @section scripts { @@ -14,21 +17,21 @@ } -
- - +
+ + - - @foreach (var group in Model.SettingPageCreationContext.Groups) - { - + + @foreach (var group in Model.SettingPageCreationContext.Groups) + { + -

@group.DisplayName

-
- @await Component.InvokeAsync(group.ComponentType) -
- } -
-
-
-
\ No newline at end of file +

@group.DisplayName

+
+ @await Component.InvokeAsync(group.ComponentType) + + } + +
+
+
\ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj index b4d9324a10..bef5707d83 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Volo.Abp.SettingManagement.Web.csproj @@ -14,6 +14,7 @@ + @@ -25,7 +26,6 @@ - From b9c15f219ccb9531ee85bb81e85eeba74a8d1f8f Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 17:02:41 +0300 Subject: [PATCH 31/44] Fix BloggingDbContextModelBuilderExtensions --- .../BloggingDbContextModelBuilderExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/EntityFrameworkCore/BloggingDbContextModelBuilderExtensions.cs b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/EntityFrameworkCore/BloggingDbContextModelBuilderExtensions.cs index 7b7728c0f7..397739263a 100644 --- a/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/EntityFrameworkCore/BloggingDbContextModelBuilderExtensions.cs +++ b/modules/blogging/src/Volo.Blogging.EntityFrameworkCore/Volo/Blogging/EntityFrameworkCore/BloggingDbContextModelBuilderExtensions.cs @@ -27,7 +27,7 @@ namespace Volo.Blogging.EntityFrameworkCore { b.ToTable(options.TablePrefix + "Users", options.Schema); - b.ConfigureAbpUser(options); + b.ConfigureAbpUser(); b.ConfigureExtraProperties(); }); From 511718cfe7a4b275ff3815e1d42256d29bb43b02 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Wed, 20 Mar 2019 17:29:09 +0300 Subject: [PATCH 32/44] Revised module references for the service template. Fixed #872. --- .../IdentityServerHost/DemoAppDbContext.cs | 6 + .../IdentityServerHost.csproj | 8 +- ....cs => 20190320142333_Initial.Designer.cs} | 299 +++++++++++++++++- ...1_Initial.cs => 20190320142333_Initial.cs} | 220 ++++++++++++- .../DemoAppDbContextModelSnapshot.cs | 297 ++++++++++++++++- .../host/IdentityServerHost/appsettings.json | 5 +- .../DemoAppDbContext.cs | 3 +- ....cs => 20190320142412_Initial.Designer.cs} | 2 +- ...9_Initial.cs => 20190320142412_Initial.cs} | 0 .../_CreateSqlServerCacheDatabase.bat | 2 +- .../appsettings.json | 9 +- 11 files changed, 791 insertions(+), 60 deletions(-) rename templates/service/host/IdentityServerHost/Migrations/{20190107114341_Initial.Designer.cs => 20190320142333_Initial.Designer.cs} (75%) rename templates/service/host/IdentityServerHost/Migrations/{20190107114341_Initial.cs => 20190320142333_Initial.cs} (77%) rename templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/{20190214093219_Initial.Designer.cs => 20190320142412_Initial.Designer.cs} (99%) rename templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/{20190214093219_Initial.cs => 20190320142412_Initial.cs} (100%) diff --git a/templates/service/host/IdentityServerHost/DemoAppDbContext.cs b/templates/service/host/IdentityServerHost/DemoAppDbContext.cs index 754cd89dff..5d418a19e0 100644 --- a/templates/service/host/IdentityServerHost/DemoAppDbContext.cs +++ b/templates/service/host/IdentityServerHost/DemoAppDbContext.cs @@ -1,7 +1,10 @@ using Microsoft.EntityFrameworkCore; +using Volo.Abp.AuditLogging.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Identity.EntityFrameworkCore; using Volo.Abp.IdentityServer.EntityFrameworkCore; +using Volo.Abp.PermissionManagement.EntityFrameworkCore; +using Volo.Abp.SettingManagement.EntityFrameworkCore; namespace IdentityServerHost { @@ -17,6 +20,9 @@ namespace IdentityServerHost { base.OnModelCreating(modelBuilder); + modelBuilder.ConfigurePermissionManagement(); + modelBuilder.ConfigureSettingManagement(); + modelBuilder.ConfigureAuditLogging(); modelBuilder.ConfigureIdentity(); modelBuilder.ConfigureIdentityServer(); } diff --git a/templates/service/host/IdentityServerHost/IdentityServerHost.csproj b/templates/service/host/IdentityServerHost/IdentityServerHost.csproj index c5b8c3826d..7e72681de0 100644 --- a/templates/service/host/IdentityServerHost/IdentityServerHost.csproj +++ b/templates/service/host/IdentityServerHost/IdentityServerHost.csproj @@ -17,6 +17,9 @@ + + + @@ -26,9 +29,4 @@ - - - - - diff --git a/templates/service/host/IdentityServerHost/Migrations/20190107114341_Initial.Designer.cs b/templates/service/host/IdentityServerHost/Migrations/20190320142333_Initial.Designer.cs similarity index 75% rename from templates/service/host/IdentityServerHost/Migrations/20190107114341_Initial.Designer.cs rename to templates/service/host/IdentityServerHost/Migrations/20190320142333_Initial.Designer.cs index 1dd595dfd1..8ef18c7e12 100644 --- a/templates/service/host/IdentityServerHost/Migrations/20190107114341_Initial.Designer.cs +++ b/templates/service/host/IdentityServerHost/Migrations/20190320142333_Initial.Designer.cs @@ -10,7 +10,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace IdentityServerHost.Migrations { [DbContext(typeof(DemoAppDbContext))] - [Migration("20190107114341_Initial")] + [Migration("20190320142333_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -21,6 +21,202 @@ namespace IdentityServerHost.Migrations .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApplicationName") + .HasColumnName("ApplicationName") + .HasMaxLength(96); + + b.Property("BrowserInfo") + .HasColumnName("BrowserInfo") + .HasMaxLength(512); + + b.Property("ClientId") + .HasColumnName("ClientId") + .HasMaxLength(64); + + b.Property("ClientIpAddress") + .HasColumnName("ClientIpAddress") + .HasMaxLength(64); + + b.Property("ClientName") + .HasColumnName("ClientName") + .HasMaxLength(128); + + b.Property("Comments") + .HasColumnName("Comments") + .HasMaxLength(256); + + b.Property("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasColumnName("CorrelationId") + .HasMaxLength(64); + + b.Property("Exceptions") + .HasColumnName("Exceptions") + .HasMaxLength(4000); + + b.Property("ExecutionDuration") + .HasColumnName("ExecutionDuration"); + + b.Property("ExecutionTime"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("HttpMethod") + .HasColumnName("HttpMethod") + .HasMaxLength(16); + + b.Property("HttpStatusCode") + .HasColumnName("HttpStatusCode"); + + b.Property("ImpersonatorTenantId") + .HasColumnName("ImpersonatorTenantId"); + + b.Property("ImpersonatorUserId") + .HasColumnName("ImpersonatorUserId"); + + b.Property("TenantId") + .HasColumnName("TenantId"); + + b.Property("Url") + .HasColumnName("Url") + .HasMaxLength(256); + + b.Property("UserId") + .HasColumnName("UserId"); + + b.Property("UserName") + .HasColumnName("UserName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ExecutionTime"); + + b.HasIndex("TenantId", "UserId", "ExecutionTime"); + + b.ToTable("AbpAuditLogs"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuditLogId") + .HasColumnName("AuditLogId"); + + b.Property("ExecutionDuration") + .HasColumnName("ExecutionDuration"); + + b.Property("ExecutionTime") + .HasColumnName("ExecutionTime"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("MethodName") + .HasColumnName("MethodName") + .HasMaxLength(128); + + b.Property("Parameters") + .HasColumnName("Parameters") + .HasMaxLength(2000); + + b.Property("ServiceName") + .HasColumnName("ServiceName") + .HasMaxLength(256); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.HasIndex("TenantId", "ServiceName", "MethodName", "ExecutionTime"); + + b.ToTable("AbpAuditLogActions"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuditLogId") + .HasColumnName("AuditLogId"); + + b.Property("ChangeTime") + .HasColumnName("ChangeTime"); + + b.Property("ChangeType") + .HasColumnName("ChangeType"); + + b.Property("EntityId") + .IsRequired() + .HasColumnName("EntityId") + .HasMaxLength(128); + + b.Property("EntityTypeFullName") + .IsRequired() + .HasColumnName("EntityTypeFullName") + .HasMaxLength(128); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("TenantId") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.HasIndex("TenantId", "EntityTypeFullName", "EntityId"); + + b.ToTable("AbpEntityChanges"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EntityChangeId"); + + b.Property("NewValue") + .HasColumnName("NewValue") + .HasMaxLength(512); + + b.Property("OriginalValue") + .HasColumnName("OriginalValue") + .HasMaxLength(512); + + b.Property("PropertyName") + .IsRequired() + .HasColumnName("PropertyName") + .HasMaxLength(128); + + b.Property("PropertyTypeFullName") + .IsRequired() + .HasColumnName("PropertyTypeFullName") + .HasMaxLength(64); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("EntityChangeId"); + + b.ToTable("AbpEntityPropertyChanges"); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => { b.Property("Id") @@ -445,7 +641,7 @@ namespace IdentityServerHost.Migrations b.Property("BackChannelLogoutSessionRequired"); b.Property("BackChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("ClientClaimsPrefix") .HasMaxLength(200); @@ -458,7 +654,7 @@ namespace IdentityServerHost.Migrations .HasMaxLength(200); b.Property("ClientUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("ConcurrencyStamp"); @@ -477,14 +673,14 @@ namespace IdentityServerHost.Migrations b.Property("FrontChannelLogoutSessionRequired"); b.Property("FrontChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("IdentityTokenLifetime"); b.Property("IncludeJwtId"); b.Property("LogoUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("PairWiseSubjectSalt") .HasMaxLength(200); @@ -517,22 +713,15 @@ namespace IdentityServerHost.Migrations modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => { - b.Property("Id") - .ValueGeneratedOnAdd(); - b.Property("ClientId"); b.Property("Type") - .IsRequired() .HasMaxLength(250); b.Property("Value") - .IsRequired() .HasMaxLength(250); - b.HasKey("Id"); - - b.HasIndex("ClientId"); + b.HasKey("ClientId", "Type", "Value"); b.ToTable("IdentityServerClientClaims"); }); @@ -578,7 +767,7 @@ namespace IdentityServerHost.Migrations b.Property("ClientId"); b.Property("PostLogoutRedirectUri") - .HasMaxLength(2000); + .HasMaxLength(200); b.HasKey("ClientId", "PostLogoutRedirectUri"); @@ -590,11 +779,11 @@ namespace IdentityServerHost.Migrations b.Property("ClientId"); b.Property("Key") - .HasMaxLength(250); + .HasMaxLength(64); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(128); b.HasKey("ClientId", "Key"); @@ -606,7 +795,7 @@ namespace IdentityServerHost.Migrations b.Property("ClientId"); b.Property("RedirectUri") - .HasMaxLength(2000); + .HasMaxLength(200); b.HasKey("ClientId", "RedirectUri"); @@ -727,6 +916,82 @@ namespace IdentityServerHost.Migrations b.ToTable("IdentityServerIdentityResources"); }); + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey"); + + b.ToTable("AbpPermissionGrants"); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("ProviderKey") + .HasMaxLength(64); + + b.Property("ProviderName") + .HasMaxLength(64); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey"); + + b.ToTable("AbpSettings"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => + { + b.HasOne("Volo.Abp.AuditLogging.AuditLog") + .WithMany("Actions") + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.HasOne("Volo.Abp.AuditLogging.AuditLog") + .WithMany("EntityChanges") + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => + { + b.HasOne("Volo.Abp.AuditLogging.EntityChange") + .WithMany("PropertyChanges") + .HasForeignKey("EntityChangeId") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => { b.HasOne("Volo.Abp.Identity.IdentityRole") diff --git a/templates/service/host/IdentityServerHost/Migrations/20190107114341_Initial.cs b/templates/service/host/IdentityServerHost/Migrations/20190320142333_Initial.cs similarity index 77% rename from templates/service/host/IdentityServerHost/Migrations/20190107114341_Initial.cs rename to templates/service/host/IdentityServerHost/Migrations/20190320142333_Initial.cs index ddb2f14c1c..88588fb970 100644 --- a/templates/service/host/IdentityServerHost/Migrations/20190107114341_Initial.cs +++ b/templates/service/host/IdentityServerHost/Migrations/20190320142333_Initial.cs @@ -7,6 +7,37 @@ namespace IdentityServerHost.Migrations { protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "AbpAuditLogs", + columns: table => new + { + Id = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true), + ConcurrencyStamp = table.Column(nullable: true), + ApplicationName = table.Column(maxLength: 96, nullable: true), + UserId = table.Column(nullable: true), + UserName = table.Column(maxLength: 256, nullable: true), + TenantId = table.Column(nullable: true), + ImpersonatorUserId = table.Column(nullable: true), + ImpersonatorTenantId = table.Column(nullable: true), + ExecutionTime = table.Column(nullable: false), + ExecutionDuration = table.Column(nullable: false), + ClientIpAddress = table.Column(maxLength: 64, nullable: true), + ClientName = table.Column(maxLength: 128, nullable: true), + ClientId = table.Column(maxLength: 64, nullable: true), + CorrelationId = table.Column(maxLength: 64, nullable: true), + BrowserInfo = table.Column(maxLength: 512, nullable: true), + HttpMethod = table.Column(maxLength: 16, nullable: true), + Url = table.Column(maxLength: 256, nullable: true), + Exceptions = table.Column(maxLength: 4000, nullable: true), + Comments = table.Column(maxLength: 256, nullable: true), + HttpStatusCode = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); + }); + migrationBuilder.CreateTable( name: "AbpClaimTypes", columns: table => new @@ -27,6 +58,21 @@ namespace IdentityServerHost.Migrations table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); }); + migrationBuilder.CreateTable( + name: "AbpPermissionGrants", + columns: table => new + { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + Name = table.Column(maxLength: 128, nullable: false), + ProviderName = table.Column(maxLength: 64, nullable: false), + ProviderKey = table.Column(maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); + }); + migrationBuilder.CreateTable( name: "AbpRoles", columns: table => new @@ -46,6 +92,21 @@ namespace IdentityServerHost.Migrations table.PrimaryKey("PK_AbpRoles", x => x.Id); }); + migrationBuilder.CreateTable( + name: "AbpSettings", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(maxLength: 128, nullable: false), + Value = table.Column(maxLength: 2048, nullable: false), + ProviderName = table.Column(maxLength: 64, nullable: true), + ProviderKey = table.Column(maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSettings", x => x.Id); + }); + migrationBuilder.CreateTable( name: "AbpUsers", columns: table => new @@ -109,8 +170,8 @@ namespace IdentityServerHost.Migrations ClientId = table.Column(maxLength: 200, nullable: false), ClientName = table.Column(maxLength: 200, nullable: true), Description = table.Column(maxLength: 1000, nullable: true), - ClientUri = table.Column(maxLength: 2000, nullable: true), - LogoUri = table.Column(maxLength: 2000, nullable: true), + ClientUri = table.Column(maxLength: 300, nullable: true), + LogoUri = table.Column(maxLength: 300, nullable: true), Enabled = table.Column(nullable: false), ProtocolType = table.Column(maxLength: 200, nullable: false), RequireClientSecret = table.Column(nullable: false), @@ -120,9 +181,9 @@ namespace IdentityServerHost.Migrations RequirePkce = table.Column(nullable: false), AllowPlainTextPkce = table.Column(nullable: false), AllowAccessTokensViaBrowser = table.Column(nullable: false), - FrontChannelLogoutUri = table.Column(maxLength: 2000, nullable: true), + FrontChannelLogoutUri = table.Column(maxLength: 300, nullable: true), FrontChannelLogoutSessionRequired = table.Column(nullable: false), - BackChannelLogoutUri = table.Column(maxLength: 2000, nullable: true), + BackChannelLogoutUri = table.Column(maxLength: 300, nullable: true), BackChannelLogoutSessionRequired = table.Column(nullable: false), AllowOfflineAccess = table.Column(nullable: false), IdentityTokenLifetime = table.Column(nullable: false), @@ -186,6 +247,55 @@ namespace IdentityServerHost.Migrations table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); }); + migrationBuilder.CreateTable( + name: "AbpAuditLogActions", + columns: table => new + { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + AuditLogId = table.Column(nullable: false), + ServiceName = table.Column(maxLength: 256, nullable: true), + MethodName = table.Column(maxLength: 128, nullable: true), + Parameters = table.Column(maxLength: 2000, nullable: true), + ExecutionTime = table.Column(nullable: false), + ExecutionDuration = table.Column(nullable: false), + ExtraProperties = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); + table.ForeignKey( + name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityChanges", + columns: table => new + { + Id = table.Column(nullable: false), + AuditLogId = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + ChangeTime = table.Column(nullable: false), + ChangeType = table.Column(nullable: false), + EntityId = table.Column(maxLength: 128, nullable: false), + EntityTypeFullName = table.Column(maxLength: 128, nullable: false), + ExtraProperties = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "AbpRoleClaims", columns: table => new @@ -361,14 +471,13 @@ namespace IdentityServerHost.Migrations name: "IdentityServerClientClaims", columns: table => new { - Id = table.Column(nullable: false), ClientId = table.Column(nullable: false), Type = table.Column(maxLength: 250, nullable: false), Value = table.Column(maxLength: 250, nullable: false) }, constraints: table => { - table.PrimaryKey("PK_IdentityServerClientClaims", x => x.Id); + table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); table.ForeignKey( name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", column: x => x.ClientId, @@ -436,7 +545,7 @@ namespace IdentityServerHost.Migrations columns: table => new { ClientId = table.Column(nullable: false), - PostLogoutRedirectUri = table.Column(maxLength: 2000, nullable: false) + PostLogoutRedirectUri = table.Column(maxLength: 200, nullable: false) }, constraints: table => { @@ -454,8 +563,8 @@ namespace IdentityServerHost.Migrations columns: table => new { ClientId = table.Column(nullable: false), - Key = table.Column(maxLength: 250, nullable: false), - Value = table.Column(maxLength: 2000, nullable: false) + Key = table.Column(maxLength: 64, nullable: false), + Value = table.Column(maxLength: 128, nullable: false) }, constraints: table => { @@ -473,7 +582,7 @@ namespace IdentityServerHost.Migrations columns: table => new { ClientId = table.Column(nullable: false), - RedirectUri = table.Column(maxLength: 2000, nullable: false) + RedirectUri = table.Column(maxLength: 200, nullable: false) }, constraints: table => { @@ -543,6 +652,29 @@ namespace IdentityServerHost.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "AbpEntityPropertyChanges", + columns: table => new + { + Id = table.Column(nullable: false), + TenantId = table.Column(nullable: true), + EntityChangeId = table.Column(nullable: false), + NewValue = table.Column(maxLength: 512, nullable: true), + OriginalValue = table.Column(maxLength: 512, nullable: true), + PropertyName = table.Column(maxLength: 128, nullable: false), + PropertyTypeFullName = table.Column(maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", + column: x => x.EntityChangeId, + principalTable: "AbpEntityChanges", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "IdentityServerApiScopeClaims", columns: table => new @@ -562,6 +694,46 @@ namespace IdentityServerHost.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_AuditLogId", + table: "AbpAuditLogActions", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", + table: "AbpAuditLogActions", + columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "UserId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_AuditLogId", + table: "AbpEntityChanges", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", + table: "AbpEntityChanges", + columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityPropertyChanges_EntityChangeId", + table: "AbpEntityPropertyChanges", + column: "EntityChangeId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGrants_Name_ProviderName_ProviderKey", + table: "AbpPermissionGrants", + columns: new[] { "Name", "ProviderName", "ProviderKey" }); + migrationBuilder.CreateIndex( name: "IX_AbpRoleClaims_RoleId", table: "AbpRoleClaims", @@ -572,6 +744,11 @@ namespace IdentityServerHost.Migrations table: "AbpRoles", column: "NormalizedName"); + migrationBuilder.CreateIndex( + name: "IX_AbpSettings_Name_ProviderName_ProviderKey", + table: "AbpSettings", + columns: new[] { "Name", "ProviderName", "ProviderKey" }); + migrationBuilder.CreateIndex( name: "IX_AbpUserClaims_UserId", table: "AbpUserClaims", @@ -607,11 +784,6 @@ namespace IdentityServerHost.Migrations table: "AbpUsers", column: "UserName"); - migrationBuilder.CreateIndex( - name: "IX_IdentityServerClientClaims_ClientId", - table: "IdentityServerClientClaims", - column: "ClientId"); - migrationBuilder.CreateIndex( name: "IX_IdentityServerClients_ClientId", table: "IdentityServerClients", @@ -626,12 +798,24 @@ namespace IdentityServerHost.Migrations protected override void Down(MigrationBuilder migrationBuilder) { + migrationBuilder.DropTable( + name: "AbpAuditLogActions"); + migrationBuilder.DropTable( name: "AbpClaimTypes"); + migrationBuilder.DropTable( + name: "AbpEntityPropertyChanges"); + + migrationBuilder.DropTable( + name: "AbpPermissionGrants"); + migrationBuilder.DropTable( name: "AbpRoleClaims"); + migrationBuilder.DropTable( + name: "AbpSettings"); + migrationBuilder.DropTable( name: "AbpUserClaims"); @@ -686,6 +870,9 @@ namespace IdentityServerHost.Migrations migrationBuilder.DropTable( name: "IdentityServerPersistedGrants"); + migrationBuilder.DropTable( + name: "AbpEntityChanges"); + migrationBuilder.DropTable( name: "AbpRoles"); @@ -701,6 +888,9 @@ namespace IdentityServerHost.Migrations migrationBuilder.DropTable( name: "IdentityServerIdentityResources"); + migrationBuilder.DropTable( + name: "AbpAuditLogs"); + migrationBuilder.DropTable( name: "IdentityServerApiResources"); } diff --git a/templates/service/host/IdentityServerHost/Migrations/DemoAppDbContextModelSnapshot.cs b/templates/service/host/IdentityServerHost/Migrations/DemoAppDbContextModelSnapshot.cs index 2a102778ee..1aec48ea05 100644 --- a/templates/service/host/IdentityServerHost/Migrations/DemoAppDbContextModelSnapshot.cs +++ b/templates/service/host/IdentityServerHost/Migrations/DemoAppDbContextModelSnapshot.cs @@ -19,6 +19,202 @@ namespace IdentityServerHost.Migrations .HasAnnotation("Relational:MaxIdentifierLength", 128) .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ApplicationName") + .HasColumnName("ApplicationName") + .HasMaxLength(96); + + b.Property("BrowserInfo") + .HasColumnName("BrowserInfo") + .HasMaxLength(512); + + b.Property("ClientId") + .HasColumnName("ClientId") + .HasMaxLength(64); + + b.Property("ClientIpAddress") + .HasColumnName("ClientIpAddress") + .HasMaxLength(64); + + b.Property("ClientName") + .HasColumnName("ClientName") + .HasMaxLength(128); + + b.Property("Comments") + .HasColumnName("Comments") + .HasMaxLength(256); + + b.Property("ConcurrencyStamp"); + + b.Property("CorrelationId") + .HasColumnName("CorrelationId") + .HasMaxLength(64); + + b.Property("Exceptions") + .HasColumnName("Exceptions") + .HasMaxLength(4000); + + b.Property("ExecutionDuration") + .HasColumnName("ExecutionDuration"); + + b.Property("ExecutionTime"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("HttpMethod") + .HasColumnName("HttpMethod") + .HasMaxLength(16); + + b.Property("HttpStatusCode") + .HasColumnName("HttpStatusCode"); + + b.Property("ImpersonatorTenantId") + .HasColumnName("ImpersonatorTenantId"); + + b.Property("ImpersonatorUserId") + .HasColumnName("ImpersonatorUserId"); + + b.Property("TenantId") + .HasColumnName("TenantId"); + + b.Property("Url") + .HasColumnName("Url") + .HasMaxLength(256); + + b.Property("UserId") + .HasColumnName("UserId"); + + b.Property("UserName") + .HasColumnName("UserName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("TenantId", "ExecutionTime"); + + b.HasIndex("TenantId", "UserId", "ExecutionTime"); + + b.ToTable("AbpAuditLogs"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuditLogId") + .HasColumnName("AuditLogId"); + + b.Property("ExecutionDuration") + .HasColumnName("ExecutionDuration"); + + b.Property("ExecutionTime") + .HasColumnName("ExecutionTime"); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("MethodName") + .HasColumnName("MethodName") + .HasMaxLength(128); + + b.Property("Parameters") + .HasColumnName("Parameters") + .HasMaxLength(2000); + + b.Property("ServiceName") + .HasColumnName("ServiceName") + .HasMaxLength(256); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.HasIndex("TenantId", "ServiceName", "MethodName", "ExecutionTime"); + + b.ToTable("AbpAuditLogActions"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AuditLogId") + .HasColumnName("AuditLogId"); + + b.Property("ChangeTime") + .HasColumnName("ChangeTime"); + + b.Property("ChangeType") + .HasColumnName("ChangeType"); + + b.Property("EntityId") + .IsRequired() + .HasColumnName("EntityId") + .HasMaxLength(128); + + b.Property("EntityTypeFullName") + .IsRequired() + .HasColumnName("EntityTypeFullName") + .HasMaxLength(128); + + b.Property("ExtraProperties") + .HasColumnName("ExtraProperties"); + + b.Property("TenantId") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.HasIndex("TenantId", "EntityTypeFullName", "EntityId"); + + b.ToTable("AbpEntityChanges"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EntityChangeId"); + + b.Property("NewValue") + .HasColumnName("NewValue") + .HasMaxLength(512); + + b.Property("OriginalValue") + .HasColumnName("OriginalValue") + .HasMaxLength(512); + + b.Property("PropertyName") + .IsRequired() + .HasColumnName("PropertyName") + .HasMaxLength(128); + + b.Property("PropertyTypeFullName") + .IsRequired() + .HasColumnName("PropertyTypeFullName") + .HasMaxLength(64); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("EntityChangeId"); + + b.ToTable("AbpEntityPropertyChanges"); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityClaimType", b => { b.Property("Id") @@ -443,7 +639,7 @@ namespace IdentityServerHost.Migrations b.Property("BackChannelLogoutSessionRequired"); b.Property("BackChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("ClientClaimsPrefix") .HasMaxLength(200); @@ -456,7 +652,7 @@ namespace IdentityServerHost.Migrations .HasMaxLength(200); b.Property("ClientUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("ConcurrencyStamp"); @@ -475,14 +671,14 @@ namespace IdentityServerHost.Migrations b.Property("FrontChannelLogoutSessionRequired"); b.Property("FrontChannelLogoutUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("IdentityTokenLifetime"); b.Property("IncludeJwtId"); b.Property("LogoUri") - .HasMaxLength(2000); + .HasMaxLength(300); b.Property("PairWiseSubjectSalt") .HasMaxLength(200); @@ -515,22 +711,15 @@ namespace IdentityServerHost.Migrations modelBuilder.Entity("Volo.Abp.IdentityServer.Clients.ClientClaim", b => { - b.Property("Id") - .ValueGeneratedOnAdd(); - b.Property("ClientId"); b.Property("Type") - .IsRequired() .HasMaxLength(250); b.Property("Value") - .IsRequired() .HasMaxLength(250); - b.HasKey("Id"); - - b.HasIndex("ClientId"); + b.HasKey("ClientId", "Type", "Value"); b.ToTable("IdentityServerClientClaims"); }); @@ -576,7 +765,7 @@ namespace IdentityServerHost.Migrations b.Property("ClientId"); b.Property("PostLogoutRedirectUri") - .HasMaxLength(2000); + .HasMaxLength(200); b.HasKey("ClientId", "PostLogoutRedirectUri"); @@ -588,11 +777,11 @@ namespace IdentityServerHost.Migrations b.Property("ClientId"); b.Property("Key") - .HasMaxLength(250); + .HasMaxLength(64); b.Property("Value") .IsRequired() - .HasMaxLength(2000); + .HasMaxLength(128); b.HasKey("ClientId", "Key"); @@ -604,7 +793,7 @@ namespace IdentityServerHost.Migrations b.Property("ClientId"); b.Property("RedirectUri") - .HasMaxLength(2000); + .HasMaxLength(200); b.HasKey("ClientId", "RedirectUri"); @@ -725,6 +914,82 @@ namespace IdentityServerHost.Migrations b.ToTable("IdentityServerIdentityResources"); }); + modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("ProviderKey") + .IsRequired() + .HasMaxLength(64); + + b.Property("ProviderName") + .IsRequired() + .HasMaxLength(64); + + b.Property("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey"); + + b.ToTable("AbpPermissionGrants"); + }); + + modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128); + + b.Property("ProviderKey") + .HasMaxLength(64); + + b.Property("ProviderName") + .HasMaxLength(64); + + b.Property("Value") + .IsRequired() + .HasMaxLength(2048); + + b.HasKey("Id"); + + b.HasIndex("Name", "ProviderName", "ProviderKey"); + + b.ToTable("AbpSettings"); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => + { + b.HasOne("Volo.Abp.AuditLogging.AuditLog") + .WithMany("Actions") + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b => + { + b.HasOne("Volo.Abp.AuditLogging.AuditLog") + .WithMany("EntityChanges") + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Volo.Abp.AuditLogging.EntityPropertyChange", b => + { + b.HasOne("Volo.Abp.AuditLogging.EntityChange") + .WithMany("PropertyChanges") + .HasForeignKey("EntityChangeId") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b => { b.HasOne("Volo.Abp.Identity.IdentityRole") diff --git a/templates/service/host/IdentityServerHost/appsettings.json b/templates/service/host/IdentityServerHost/appsettings.json index 6e801d256d..98a4b98d4b 100644 --- a/templates/service/host/IdentityServerHost/appsettings.json +++ b/templates/service/host/IdentityServerHost/appsettings.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "Default": "Server=localhost;Database=IdentityServerHost;Trusted_Connection=True;MultipleActiveResultSets=true", - "SqlServerCache": "Server=localhost;Database=MyProjectNameCache;Trusted_Connection=True;MultipleActiveResultSets=true" + "Default": "Server=localhost;Database=MyProjectName_Identity;Trusted_Connection=True;MultipleActiveResultSets=true", + + "SqlServerCache": "Server=localhost;Database=MyProjectName_Cache;Trusted_Connection=True;MultipleActiveResultSets=true" } } \ No newline at end of file diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/DemoAppDbContext.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/DemoAppDbContext.cs index 1b3540e00b..ab9cad5293 100644 --- a/templates/service/host/MyCompanyName.MyProjectName.Host/DemoAppDbContext.cs +++ b/templates/service/host/MyCompanyName.MyProjectName.Host/DemoAppDbContext.cs @@ -21,8 +21,9 @@ namespace MyCompanyName.MyProjectName.Host modelBuilder.ConfigurePermissionManagement(); modelBuilder.ConfigureSettingManagement(); - modelBuilder.ConfigureMyProjectName(); modelBuilder.ConfigureAuditLogging(); + + modelBuilder.ConfigureMyProjectName(); } } } diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190214093219_Initial.Designer.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190320142412_Initial.Designer.cs similarity index 99% rename from templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190214093219_Initial.Designer.cs rename to templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190320142412_Initial.Designer.cs index ee67505ed5..423eb1cb0a 100644 --- a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190214093219_Initial.Designer.cs +++ b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190320142412_Initial.Designer.cs @@ -10,7 +10,7 @@ using MyCompanyName.MyProjectName.Host; namespace MyCompanyName.MyProjectName.Host.Migrations { [DbContext(typeof(DemoAppDbContext))] - [Migration("20190214093219_Initial")] + [Migration("20190320142412_Initial")] partial class Initial { protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190214093219_Initial.cs b/templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190320142412_Initial.cs similarity index 100% rename from templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190214093219_Initial.cs rename to templates/service/host/MyCompanyName.MyProjectName.Host/Migrations/20190320142412_Initial.cs diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/_CreateSqlServerCacheDatabase.bat b/templates/service/host/MyCompanyName.MyProjectName.Host/_CreateSqlServerCacheDatabase.bat index 6b8b9d7060..927f8a72d7 100644 --- a/templates/service/host/MyCompanyName.MyProjectName.Host/_CreateSqlServerCacheDatabase.bat +++ b/templates/service/host/MyCompanyName.MyProjectName.Host/_CreateSqlServerCacheDatabase.bat @@ -1 +1 @@ -dotnet sql-cache create "Server=localhost;Database=MyProjectNameCache;Trusted_Connection=True;MultipleActiveResultSets=true" dbo TestCache \ No newline at end of file +dotnet sql-cache create "Server=localhost;Database=MyProjectName_Cache;Trusted_Connection=True;MultipleActiveResultSets=true" dbo TestCache \ No newline at end of file diff --git a/templates/service/host/MyCompanyName.MyProjectName.Host/appsettings.json b/templates/service/host/MyCompanyName.MyProjectName.Host/appsettings.json index 76dc222001..a09353bfef 100644 --- a/templates/service/host/MyCompanyName.MyProjectName.Host/appsettings.json +++ b/templates/service/host/MyCompanyName.MyProjectName.Host/appsettings.json @@ -1,6 +1,11 @@ { "ConnectionStrings": { - "Default": "Server=localhost;Database=MyProjectNameHost;Trusted_Connection=True;MultipleActiveResultSets=true", - "SqlServerCache": "Server=localhost;Database=MyProjectNameCache;Trusted_Connection=True;MultipleActiveResultSets=true" + "Default": "Server=localhost;Database=MyProjectName_ModuleDb;Trusted_Connection=True;MultipleActiveResultSets=true", + + "AbpSettingManagement": "Server=localhost;Database=MyProjectName_Identity;Trusted_Connection=True;MultipleActiveResultSets=true", + "AbpPermissionManagement": "Server=localhost;Database=MyProjectName_Identity;Trusted_Connection=True;MultipleActiveResultSets=true", + "AbpAuditLogging": "Server=localhost;Database=MyProjectName_Identity;Trusted_Connection=True;MultipleActiveResultSets=true", + + "SqlServerCache": "Server=localhost;Database=MyProjectName_Cache;Trusted_Connection=True;MultipleActiveResultSets=true" } } \ No newline at end of file From 53af341f451bb5b7def6d6b1f5ffa4899ce01ff4 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 21 Mar 2019 11:12:31 +0800 Subject: [PATCH 33/44] Complete the missing Chinese localization. --- .../Resources/AbpAccount/Web/zh-Hans.json | 14 +++++----- .../Docs/ApplicationContracts/zh-Hans.json | 10 +++++++ .../Resources/Docs/Web/zh-Hans.json | 26 +++++++++++++++++++ .../Docs/Localization/Domain/zh-Hans.json | 15 ++++++----- .../ApplicationContracts/zh-Hans.json | 6 +++-- .../AbpPermissionManagement/zh-Hans.json | 4 ++- .../AbpSettingManagement/zh-Hans.json | 6 +++++ 7 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Localization/Resources/Docs/ApplicationContracts/zh-Hans.json create mode 100644 modules/docs/src/Volo.Docs.Admin.Web/Localization/Resources/Docs/Web/zh-Hans.json create mode 100644 modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/zh-Hans.json diff --git a/modules/account/src/Volo.Abp.Account.Web/Localization/Resources/AbpAccount/Web/zh-Hans.json b/modules/account/src/Volo.Abp.Account.Web/Localization/Resources/AbpAccount/Web/zh-Hans.json index fdaa5ff228..9ceb4af554 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Localization/Resources/AbpAccount/Web/zh-Hans.json +++ b/modules/account/src/Volo.Abp.Account.Web/Localization/Resources/AbpAccount/Web/zh-Hans.json @@ -11,12 +11,12 @@ "InvalidUserNameOrPassword": "用户名或密码错误!", "LoginIsNotAllowed": "无法登录!你需要验证邮箱地址/手机号.", "SelfRegistrationDisabledMessage": "应用程序未开放注册,请联系管理员添加新用户.", - "Login": "Login", - "Cancel": "Cancel", - "Register": "Register", - "UseAnotherServiceToLogIn.": "Use another service to log in.", - "InvalidLoginRequest": "Invalid login request", - "ThereAreNoLoginSchemesConfiguredForThisClient": "There are no login schemes configured for this client.", - "LogInUsingYourProviderAccount": "Log in using your {0} account" + "Login": "登录", + "Cancel": "取消", + "Register": "注册", + "UseAnotherServiceToLogIn.": "使用其他服务登录.", + "InvalidLoginRequest": "登录请求无效", + "ThereAreNoLoginSchemesConfiguredForThisClient": "没有为此客户端配置登录方案.", + "LogInUsingYourProviderAccount": "使用您的{0}帐户登录" } } diff --git a/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Localization/Resources/Docs/ApplicationContracts/zh-Hans.json b/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Localization/Resources/Docs/ApplicationContracts/zh-Hans.json new file mode 100644 index 0000000000..3c8847ceae --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Localization/Resources/Docs/ApplicationContracts/zh-Hans.json @@ -0,0 +1,10 @@ +{ + "culture": "zh-Hans", + "texts": { + "Permission:DocumentManagement": "文档管理", + "Permission:Projects": "项目", + "Permission:Edit": "编辑", + "Permission:Delete": "删除", + "Permission:Create": "创建" + } + } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Localization/Resources/Docs/Web/zh-Hans.json b/modules/docs/src/Volo.Docs.Admin.Web/Localization/Resources/Docs/Web/zh-Hans.json new file mode 100644 index 0000000000..36bc285090 --- /dev/null +++ b/modules/docs/src/Volo.Docs.Admin.Web/Localization/Resources/Docs/Web/zh-Hans.json @@ -0,0 +1,26 @@ +{ + "culture": "zh-Hans", + "texts": { + "Menu:DocumentManagement": "文档", + "Menu:ProjectManagement": "项目", + "CreateANewProject": "创建新项目", + "Edit": "编辑", + "Create": "创建", + "Projects": "项目", + "Name": "名称", + "ShortName": "简称", + "DocumentStoreType": "文件存储类型", + "Format": "格式", + "ShortNameInfoText": "将用于唯一的URL.", + "DisplayName:Name": "名称", + "DisplayName:ShortName": "简称", + "DisplayName:Format": "格式", + "DisplayName:DefaultDocumentName": "默认文档名称", + "DisplayName:NavigationDocumentName": "导航文档名称", + "DisplayName:MinimumVersion": "最低版本", + "DisplayName:MainWebsiteUrl": "主网站网址", + "DisplayName:LatestVersionBranchName": "最新版本的分支名称", + "DisplayName:GitHubRootUrl": "GitHub根网址", + "DisplayName:GitHubAccessToken": "GitHub访问令牌" + } + } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Localization/Domain/zh-Hans.json b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Localization/Domain/zh-Hans.json index 03a22148c2..f085265abf 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Localization/Domain/zh-Hans.json +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Localization/Domain/zh-Hans.json @@ -2,14 +2,17 @@ "culture": "zh-Hans", "texts": { "Documents": "文档", - "BackToWebsite": "返回网站", + "BackToWebsite": "返回主网站", + "Contributors": "贡献者", + "ShareOn": "分享到", "Version": "版本", "Edit": "编辑", - "InThisDocument": "在这个文档中", - "GoToTop": "返回顶部", + "Delete": "删除", + "InThisDocument": "在本文中", + "GoToTop": "到顶部", "Projects": "项目", - "NoProjectWarning": "当前并没有项目!", - "DocumentNotFound": "抱歉,您请求的文档不存在!", - "NavigationDocumentNotFound": "此版本并没有导航文档!" + "NoProjectWarning": "还没有项目!", + "DocumentNotFound": "找不到请求的文档!", + "NavigationDocumentNotFound": "这个版本没有导航文件!" } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/zh-Hans.json b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/zh-Hans.json index 616e9a62a3..cae53933d9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/zh-Hans.json +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Localization/ApplicationContracts/zh-Hans.json @@ -1,12 +1,14 @@ { "culture": "zh-Hans", "texts": { - "Permission:IdentityManagement": "身份认证管理", + "Volo.Abp.Identity:010001": "您无法删除自己的帐户!", + "Permission:IdentityManagement": "身份标识管理", "Permission:RoleManagement": "角色管理", "Permission:Create": "创建", "Permission:Edit": "编辑", "Permission:Delete": "删除", "Permission:ChangePermissions": "更改权限", - "Permission:UserManagement": "用户管理" + "Permission:UserManagement": "用户管理", + "Permission:UserLookup": "用户查询" } } \ No newline at end of file diff --git a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Localization/Resources/AbpPermissionManagement/zh-Hans.json b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Localization/Resources/AbpPermissionManagement/zh-Hans.json index 991c147b58..8384078b86 100644 --- a/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Localization/Resources/AbpPermissionManagement/zh-Hans.json +++ b/modules/permission-management/src/Volo.Abp.PermissionManagement.Web/Localization/Resources/AbpPermissionManagement/zh-Hans.json @@ -1,6 +1,8 @@ { "culture": "zh-Hans", "texts": { - "Permissions": "权限" + "Permissions": "权限", + "OnlyProviderPermissons": "只有这个提供商", + "All": "所有" } } \ No newline at end of file diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/zh-Hans.json b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/zh-Hans.json new file mode 100644 index 0000000000..060fa17388 --- /dev/null +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Web/Localization/Resources/AbpSettingManagement/zh-Hans.json @@ -0,0 +1,6 @@ +{ + "culture": "zh-Hans", + "texts": { + "Settings": "设置" + } + } \ No newline at end of file From 8a85149038fce893ab1648f238358342c1f1ad44 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 21 Mar 2019 08:20:51 +0300 Subject: [PATCH 34/44] localization improvements --- framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json | 1 + framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json | 1 + 2 files changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json index 3a2233c7a6..9bd814af5c 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json @@ -25,6 +25,7 @@ "Delete": "Delete", "Edit": "Edit", "ProcessingWithThreeDot": "Processing...", + "Welcome": "Welcome", "Login": "Login", "Register": "Register", "Logout": "Log out", diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json index 6162f7c35f..02ffb125f5 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json @@ -25,6 +25,7 @@ "Delete": "Sil", "Edit": "Düzenle", "ProcessingWithThreeDot": "İşleniyor...", + "Welcome": "Hoşgeldiniz", "Login": "Giriş", "Register": "Kaydol", "Logout": "Çıkış", From c609aa6a0d60603a4c225ff5c53670a278d4cdcb Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 21 Mar 2019 10:04:25 +0300 Subject: [PATCH 35/44] added Datatable localizations --- .../datatables/datatables-extensions.js | 17 +++++++++++++++++ .../Localization/Resources/AbpUi/en.json | 10 +++++++++- .../Localization/Resources/AbpUi/tr.json | 10 +++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js index bdb7976286..39199ccf93 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js @@ -338,6 +338,23 @@ } } + configuration.language = { + info: localize("PagerInfo"), + infoFiltered: localize("PagerInfoFiltered"), + infoEmpty: localize("PagerInfoEmpty"), + search: localize("PagerSearch"), + processing: localize("ProcessingWithThreeDot"), + loadingRecords: localize("LoadingWithThreeDot"), + lengthMenu: localize("PagerShowMenuEntries"), + emptyTable: localize("NoDataAvailableInDatatable"), + paginate: { + first: localize("PagerFirst"), + last: localize("PagerLast"), + previous: localize("PagerPrevious"), + next: localize("PagerNext") + } + }; + configuration.dom = '<"dataTable_filters"f>rt<"row dataTable_footer"<"col-auto"l><"col-auto"i><"col"p>>'; return configuration; diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json index 9bd814af5c..16af838025 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json @@ -25,15 +25,23 @@ "Delete": "Delete", "Edit": "Edit", "ProcessingWithThreeDot": "Processing...", + "LoadingWithThreeDot": "Loading...", "Welcome": "Welcome", "Login": "Login", "Register": "Register", "Logout": "Log out", "Submit": "Submit", "Back": "Back", + "PagerSearch": "Search", "PagerNext": "Next", "PagerPrevious": "Previous", - "PagerInfo": "Showing {0} to {1} of {2} entries.", + "PagerFirst": "First", + "PagerLast": "Last", + "PagerInfo": "Showing _START_ to _END_ of _TOTAL_ entries", + "PagerInfoEmpty": "Showing 0 to 0 of 0 entries", + "PagerInfoFiltered": "(filtered from _MAX_ total entries)", + "NoDataAvailableInDatatable": "No data available in table", + "PagerShowMenuEntries": "Show _MENU_ entries", "DatatableActionDropdownDefaultText": "Actions", "ChangePassword": "Change password", "PersonalInfo": "My profile" diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json index 02ffb125f5..a3af7c3a22 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json @@ -25,15 +25,23 @@ "Delete": "Sil", "Edit": "Düzenle", "ProcessingWithThreeDot": "İşleniyor...", + "LoadingWithThreeDot": "Yükleniyor...", "Welcome": "Hoşgeldiniz", "Login": "Giriş", "Register": "Kaydol", "Logout": "Çıkış", "Submit": "Gönder", "Back": "Geri", + "PagerSearch": "Ara", "PagerNext": "Sonraki", "PagerPrevious": "Önceki", - "PagerInfo": "{2} kayıttan {0} ile {1} arası gösteriliyor.", + "PagerFirst": "İlk", + "PagerLast": "Son", + "PagerInfo": "_TOTAL_ kayıttan _START_ ile _END_ arası gösteriliyor.", + "PagerInfoEmpty": "0 kayıttan 0 ile 0 arası gösteriliyor.", + "PagerInfoFiltered": "(_MAX_ kayıt arasından filtrelendi)", + "NoDataAvailableInDatatable": "Tabloda kayır mevcut değil.", + "PagerShowMenuEntries": "Sayfada _MENU_ kayıt göster.", "DatatableActionDropdownDefaultText": "İşlemler", "ChangePassword": "Şifre değiştir", "PersonalInfo": "Profilim" From e1dce26e32a757bcfa6d9e94250c3f1a7bf0b6d8 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 21 Mar 2019 10:48:20 +0300 Subject: [PATCH 36/44] Fix AbpDictionaryBasedStringLocalizer --- .../Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs index 0cfe90d9ef..b1741d0ca0 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpDictionaryBasedStringLocalizer.cs @@ -206,7 +206,7 @@ namespace Volo.Abp.Localization public IEnumerable GetAllStrings(bool includeParentCultures, bool includeBaseLocalizers) { - return _innerLocalizer.GetAllStrings(includeParentCultures, includeBaseLocalizers); + return _innerLocalizer.GetAllStrings(_cultureName, includeParentCultures, includeBaseLocalizers); } } } From 1b0626752cee1fb412bbc5d65175f34bdc5f70d3 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 21 Mar 2019 14:39:45 +0300 Subject: [PATCH 37/44] Fix IdentityUserAppService.Delete --- .../Volo/Abp/Identity/IdentityUserAppService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index 814d32fd19..251b429d33 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -80,7 +80,7 @@ namespace Volo.Abp.Identity [Authorize(IdentityPermissions.Users.Delete)] public async Task DeleteAsync(Guid id) { - if (CurrentUser.Id.Value == id) + if (CurrentUser.Id == id) { throw new BusinessException(code: IdentityErrorCodes.UserSelfDeletion); } From b20d9524ee24c6d8ec5dae8303cb9b30645475d5 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 21 Mar 2019 20:23:38 +0800 Subject: [PATCH 38/44] Datatable chinese localizations. --- .../Localization/Resources/AbpUi/zh-Hans.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/zh-Hans.json b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/zh-Hans.json index e3d8028f0a..c6979529a7 100644 --- a/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/zh-Hans.json +++ b/framework/src/Volo.Abp.UI/Localization/Resources/AbpUi/zh-Hans.json @@ -25,14 +25,23 @@ "Delete": "删除", "Edit": "修改", "ProcessingWithThreeDot": "处理中...", + "LoadingWithThreeDot": "加载中...", + "Welcome": "欢迎", "Login": "登录", "Register": "注册", "Logout": "注销", "Submit": "提交", "Back": "返回", + "PagerSearch": "搜索", "PagerNext": "下一页", "PagerPrevious": "上一页", + "PagerFirst": "首页", + "PagerLast": "尾页", "PagerInfo": "显示 {0} 到 {1} 个 {2} 条目.", + "PagerInfoEmpty": "显示0个条目中的0到0", + "PagerInfoFiltered": "(从 _MAX_ 总条目中过滤掉)", + "NoDataAvailableInDatatable": "表中没有数据", + "PagerShowMenuEntries": "显示 _MENU_ 实体", "DatatableActionDropdownDefaultText": "操作", "ChangePassword": "修改密码", "PersonalInfo": "个人信息" From f698a3b63f4ad1ef9c5f06a8d139a4e38f1b3553 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 22 Mar 2019 10:21:10 +0300 Subject: [PATCH 39/44] DistributedCache cleanup --- .../Volo/Abp/Caching/DistributedCache.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs index 477b0c764b..f65683042b 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Caching.Distributed; @@ -70,11 +69,12 @@ namespace Volo.Abp.Caching } catch (Exception ex) { - if ((bool) hideErrors) + if (hideErrors == true) { Logger.LogException(ex, LogLevel.Warning); return null; } + throw; } @@ -94,11 +94,14 @@ namespace Volo.Abp.Caching try { - cachedBytes = await Cache.GetAsync(NormalizeKey(key), CancellationTokenProvider.FallbackToProvider(token)); + cachedBytes = await Cache.GetAsync( + NormalizeKey(key), + CancellationTokenProvider.FallbackToProvider(token) + ); } catch (Exception ex) { - if ((bool)hideErrors) + if (hideErrors == true) { Logger.LogException(ex, LogLevel.Warning); return null; @@ -185,7 +188,7 @@ namespace Volo.Abp.Caching } catch (Exception ex) { - if ((bool) hideErrors) + if (hideErrors == true) { Logger.LogException(ex, LogLevel.Warning); return; @@ -210,7 +213,7 @@ namespace Volo.Abp.Caching } catch (Exception ex) { - if ((bool)hideErrors) + if (hideErrors == true) { Logger.LogException(ex, LogLevel.Warning); return; @@ -230,7 +233,7 @@ namespace Volo.Abp.Caching } catch (Exception ex) { - if ((bool) hideErrors) + if (hideErrors == true) { Logger.LogException(ex, LogLevel.Warning); return; @@ -250,7 +253,7 @@ namespace Volo.Abp.Caching } catch (Exception ex) { - if ((bool)hideErrors) + if (hideErrors == true) { Logger.LogException(ex, LogLevel.Warning); return; @@ -270,7 +273,7 @@ namespace Volo.Abp.Caching } catch (Exception ex) { - if ((bool) hideErrors) + if (hideErrors == true) { Logger.LogException(ex, LogLevel.Warning); } @@ -289,7 +292,7 @@ namespace Volo.Abp.Caching } catch (Exception ex) { - if ((bool)hideErrors) + if (hideErrors == true) { Logger.LogException(ex, LogLevel.Warning); return; From f127520c74ad71ff6a719ccc6638e6594c432148 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 22 Mar 2019 11:39:29 +0300 Subject: [PATCH 40/44] Add L property to ApplicationService base class. Resolves #903. --- .../Volo.Abp.Ddd.Application.csproj | 1 + .../Services/ApplicationService.cs | 28 +++++++++++++++---- .../Abp/Localization/AbpLocalizationModule.cs | 14 ++++++---- .../Volo/Abp/Localization/DefaultResource.cs | 8 ++++++ 4 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 framework/src/Volo.Abp.Localization/Volo/Abp/Localization/DefaultResource.cs diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo.Abp.Ddd.Application.csproj b/framework/src/Volo.Abp.Ddd.Application/Volo.Abp.Ddd.Application.csproj index 243c94e66a..cf3cb85cd0 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo.Abp.Ddd.Application.csproj +++ b/framework/src/Volo.Abp.Ddd.Application/Volo.Abp.Ddd.Application.csproj @@ -19,6 +19,7 @@ + diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs index 48865f38f2..3b2bbc7582 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs @@ -1,16 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; using JetBrains.Annotations; using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Localization; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; using Volo.Abp.Aspects; using Volo.Abp.Auditing; using Volo.Abp.Authorization; using Volo.Abp.DependencyInjection; using Volo.Abp.Features; using Volo.Abp.Guids; +using Volo.Abp.Localization; using Volo.Abp.MultiTenancy; using Volo.Abp.ObjectMapping; using Volo.Abp.Settings; @@ -21,8 +23,8 @@ using Volo.Abp.Validation; namespace Volo.Abp.Application.Services { - public abstract class ApplicationService : - IApplicationService, + public abstract class ApplicationService : + IApplicationService, IAvoidDuplicateCrossCuttingConcerns, IValidationEnabled, IUnitOfWorkEnabled, @@ -53,6 +55,22 @@ namespace Volo.Abp.Application.Services public IFeatureChecker FeatureChecker { get; set; } + public IStringLocalizerFactory StringLocalizerFactory { get; set; } + + public IStringLocalizer L => _localizer ?? (_localizer = StringLocalizerFactory.Create(LocalizationResource)); + private IStringLocalizer _localizer; + + protected Type LocalizationResource + { + get => _localizationResource; + set + { + _localizationResource = value; + _localizer = null; + } + } + private Type _localizationResource = typeof(DefaultResource); + protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current; protected ILogger Logger => _lazyLogger.Value; diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationModule.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationModule.cs index 23e61e417f..23de1929d6 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationModule.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationModule.cs @@ -1,5 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Localization.Resources.AbpValidation; +using Volo.Abp.Localization.Resources.AbpValidation; using Volo.Abp.Modularity; using Volo.Abp.Settings; using Volo.Abp.VirtualFileSystem; @@ -24,9 +23,14 @@ namespace Volo.Abp.Localization Configure(options => { - options.Resources - .Add("en") - .AddVirtualJson("/Localization/Resources/AbpValidation"); + options + .Resources + .Add("en"); + + options + .Resources + .Add("en") + .AddVirtualJson("/Localization/Resources/AbpValidation"); }); } } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/DefaultResource.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/DefaultResource.cs new file mode 100644 index 0000000000..a491446230 --- /dev/null +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/DefaultResource.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.Localization +{ + [LocalizationResourceName("Default")] + public class DefaultResource + { + + } +} From 6dfd4e975c6b47c07bda10576078932f422865c0 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 22 Mar 2019 11:39:40 +0300 Subject: [PATCH 41/44] Implement RemoteLanguageProvider --- .../Mvc/Client/RemoteFeatureChecker.cs | 4 +--- .../Mvc/Client/RemoteLanguageProvider.cs | 23 +++++++++++++++++++ ...ApplicationLocalizationConfigurationDto.cs | 5 ++++ .../AbpApplicationConfigurationAppService.cs | 11 ++++++--- 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs index 0643620ec9..f769f512a5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.Features; diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs new file mode 100644 index 0000000000..02c97c0598 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Localization; + +namespace Volo.Abp.AspNetCore.Mvc.Client +{ + public class RemoteLanguageProvider : ILanguageProvider, ITransientDependency + { + protected ICachedApplicationConfigurationClient ConfigurationClient { get; } + + public RemoteLanguageProvider(ICachedApplicationConfigurationClient configurationClient) + { + ConfigurationClient = configurationClient; + } + + public async Task> GetLanguagesAsync() + { + var configuration = await ConfigurationClient.GetAsync(); + return configuration.Localization.Languages; + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs index 05b5d8c7a6..2667734537 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationLocalizationConfigurationDto.cs @@ -1,16 +1,21 @@ using System; using System.Collections.Generic; +using Volo.Abp.Localization; namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations { [Serializable] public class ApplicationLocalizationConfigurationDto { + //TODO: Rename to Texts? public Dictionary> Values { get; set; } + public List Languages { get; set; } + public ApplicationLocalizationConfigurationDto() { Values = new Dictionary>(); + Languages = new List(); } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index 70eb04c707..223c83d594 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -24,6 +24,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations private readonly ISettingProvider _settingProvider; private readonly ISettingDefinitionManager _settingDefinitionManager; private readonly IFeatureDefinitionManager _featureDefinitionManager; + private readonly ILanguageProvider _languageProvider; public AbpApplicationConfigurationAppService( IOptions localizationOptions, @@ -33,7 +34,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations ICurrentUser currentUser, ISettingProvider settingProvider, SettingDefinitionManager settingDefinitionManager, - IFeatureDefinitionManager featureDefinitionManager) + IFeatureDefinitionManager featureDefinitionManager, + ILanguageProvider languageProvider) { _serviceProvider = serviceProvider; _abpAuthorizationPolicyProvider = abpAuthorizationPolicyProvider; @@ -42,6 +44,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations _settingProvider = settingProvider; _settingDefinitionManager = settingDefinitionManager; _featureDefinitionManager = featureDefinitionManager; + _languageProvider = languageProvider; _localizationOptions = localizationOptions.Value; } @@ -53,7 +56,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations { Auth = await GetAuthConfigAsync(), Features = await GetFeaturesConfigAsync(), - Localization = GetLocalizationConfig(), + Localization = await GetLocalizationConfigAsync(), CurrentUser = GetCurrentUser(), Setting = await GetSettingConfigAsync() }; @@ -87,10 +90,12 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations return authConfig; } - protected virtual ApplicationLocalizationConfigurationDto GetLocalizationConfig() + protected virtual async Task GetLocalizationConfigAsync() { var localizationConfig = new ApplicationLocalizationConfigurationDto(); + localizationConfig.Languages.AddRange(await _languageProvider.GetLanguagesAsync()); + foreach (var resource in _localizationOptions.Resources.Values) { var dictionary = new Dictionary(); From fa3fd1a14f930529909ef32f95b067912c3ae34b Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 22 Mar 2019 14:37:25 +0300 Subject: [PATCH 42/44] Directly use resource.ResourceName --- .../AbpApplicationConfigurationAppService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index 223c83d594..e6cfafdf48 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -109,8 +109,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations dictionary[localizedString.Name] = localizedString.Value; } - var resourceName = LocalizationResourceNameAttribute.GetName(resource.ResourceType); - localizationConfig.Values[resourceName] = dictionary; + localizationConfig.Values[resource.ResourceName] = dictionary; } return localizationConfig; From d9433687abace731a6ecc5924de60727d4b66d6c Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 22 Mar 2019 14:51:22 +0300 Subject: [PATCH 43/44] Add accept language header --- .../Client/DynamicProxying/DynamicHttpProxyInterceptor.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs index 10d2c98126..21f27cce49 100644 --- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Net.Http; +using System.Net.Http.Headers; using System.Reflection; using System.Threading; using System.Threading.Tasks; @@ -210,6 +212,9 @@ namespace Volo.Abp.Http.Client.DynamicProxying //CorrelationId requestMessage.Headers.Add(CorrelationIdOptions.HttpHeaderName, CorrelationIdProvider.Get()); + + //TODO: Is that the way we want? Couldn't send the culture (not ui culture) + requestMessage.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(CultureInfo.CurrentUICulture.Name)); } private string GetConfiguredApiVersion() From dd9fbcda6031aae417f28026e6ff2e31aafb2e0e Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Fri, 22 Mar 2019 15:17:06 +0300 Subject: [PATCH 44/44] Move change password to profile service --- .../Volo/Abp/Identity/IIdentityUserAppService.cs | 2 -- .../Volo/Abp/Identity/IProfileAppService.cs | 2 ++ .../Volo/Abp/Identity/IdentityUserAppService.cs | 12 ------------ .../Volo/Abp/Identity/ProfileAppService.cs | 6 ++++++ .../Volo/Abp/Identity/IdentityUserController.cs | 5 ----- .../Volo/Abp/Identity/ProfileController.cs | 10 ++++++---- .../Identity/Shared/ChangePasswordModal.cshtml.cs | 13 ++++++++----- 7 files changed, 22 insertions(+), 28 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs index 8927121bf9..f3e342503c 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityUserAppService.cs @@ -14,7 +14,5 @@ namespace Volo.Abp.Identity Task FindByUsernameAsync(string username); Task FindByEmailAsync(string email); - - Task ChangePasswordAsync(string currentPassword, string newPassword); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs index cb61fc6a82..142b5ad16a 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IProfileAppService.cs @@ -8,5 +8,7 @@ namespace Volo.Abp.Identity Task GetAsync(); Task UpdateAsync(UpdateProfileDto input); + + Task ChangePasswordAsync(string currentPassword, string newPassword); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs index 251b429d33..ad87b0041f 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs @@ -118,18 +118,6 @@ namespace Volo.Abp.Identity ); } - //TODO: Move this to the profile service! - public async Task ChangePasswordAsync(string currentPassword, string newPassword) - { - if (!CurrentUser.Id.HasValue) - { - throw new AbpException("Current user Id is null!"); - } - - var currentUser = await _userManager.GetByIdAsync(CurrentUser.Id.Value); - (await _userManager.ChangePasswordAsync(currentUser, currentPassword, newPassword)).CheckErrors(); - } - private async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input) { (await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs index a47734cd0c..64a78b81ca 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs @@ -49,5 +49,11 @@ namespace Volo.Abp.Identity return ObjectMapper.Map(user); } + + public async Task ChangePasswordAsync(string currentPassword, string newPassword) + { + var currentUser = await _userManager.GetByIdAsync(CurrentUser.GetId()); + (await _userManager.ChangePasswordAsync(currentUser, currentPassword, newPassword)).CheckErrors(); + } } } diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs index 2728e16fbd..acbc211b0f 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs @@ -64,10 +64,5 @@ namespace Volo.Abp.Identity { return _userAppService.FindByEmailAsync(email); } - - public Task ChangePasswordAsync(string currentPassword, string newPassword) - { - return _userAppService.ChangePasswordAsync(currentPassword, newPassword); - } } } diff --git a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs index b1bb8a744c..4547bbdc1c 100644 --- a/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs +++ b/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; @@ -27,5 +24,10 @@ namespace Volo.Abp.Identity { return _profileAppService.UpdateAsync(input); } + + public Task ChangePasswordAsync(string currentPassword, string newPassword) + { + return _profileAppService.ChangePasswordAsync(currentPassword, newPassword); + } } } diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml.cs index 0e753edd6c..29dda11426 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/ChangePasswordModal.cshtml.cs @@ -12,13 +12,14 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Shared [BindProperty] public ChangePasswordInfoModel ChangePasswordInfoModel { get; set; } - private readonly IIdentityUserAppService _userAppService; + private readonly IProfileAppService _profileAppService; private readonly IStringLocalizer _localizer; - public ChangePasswordModal(IIdentityUserAppService userAppService, + public ChangePasswordModal( + IProfileAppService profileAppService, IStringLocalizer localizer) { - _userAppService = userAppService; + _profileAppService = profileAppService; _localizer = localizer; } @@ -31,8 +32,10 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Shared throw new UserFriendlyException(_localizer.GetString("Identity.PasswordConfirmationFailed").Value); } - await _userAppService.ChangePasswordAsync(ChangePasswordInfoModel.CurrentPassword, - ChangePasswordInfoModel.NewPassword); + await _profileAppService.ChangePasswordAsync( + ChangePasswordInfoModel.CurrentPassword, + ChangePasswordInfoModel.NewPassword + ); return NoContent(); }