diff --git a/apiSpec/Microsoft_AspNetCore_Routing_AbpEndpointRouterOptions.md b/apiSpec/Microsoft_AspNetCore_Routing_AbpEndpointRouterOptions.md new file mode 100644 index 0000000000..f410fd77e3 --- /dev/null +++ b/apiSpec/Microsoft_AspNetCore_Routing_AbpEndpointRouterOptions.md @@ -0,0 +1,5 @@ +uid: Microsoft.AspNetCore.Routing.AbpEndpointRouterOptions +summary: '*Summary test' + +*Information Test* + diff --git a/docs/en/Unit-Of-Work.md b/docs/en/Unit-Of-Work.md index 7c76954642..0bbd81ebab 100644 --- a/docs/en/Unit-Of-Work.md +++ b/docs/en/Unit-Of-Work.md @@ -1,3 +1,356 @@ -## Unit of Work +# Unit of Work + +ABP Framework's Unit Of Work (UOW) implementation provides an abstraction and control on a **database connection and transaction** scope in an application. + +Once a new UOW started, it creates an **ambient scope** that is participated by **all the database operations** performed in the current scope and considered as a **single transaction boundary**. The operations are **committed** (on success) or **rolled back** (on exception) all together. + +ABP's UOW system is; + +* **Works conventional**, so most of the times you don't deal with UOW at all. +* **Database provider independent**. +* **Web independent**, that means you can create unit of work scopes in any type of applications beside web applications/services. + +## Conventions + +The following method types are considered as a unit of work: + +* ASP.NET Core MVC **Controller Actions**. +* ASP.NET Core Razor **Page Handlers**. +* **Application service** methods. +* **Repository methods**. + +A UOW automatically begins for these methods **except** if there is already a **surrounding (ambient)** UOW in action. Examples; + +* If you call a [repository](Repositories.md) method and there is no UOW started yet, it automatically **begins a new transactional UOW** that involves all the operations done in the repository method and **commits the transaction** if the repository method **doesn't throw any exception.** The repository method doesn't know about UOW or transaction at all. It just works on a regular database objects (`DbContext` for [EF Core](Entity-Framework-Core.md), for example) and the UOW is handled by the ABP Framework. +* If you call an [application service](Application-Services.md) method, the same UOW system works just as explained above. If the application service method uses some repositories, the repositories **don't begin a new UOW**, but **participates to the current unit of work** started by the ABP Framework for the application service method. +* The same is true for an ASP.NET Core controller action. If the operation has started with a controller action, then the **UOW scope is the controller action's method body**. + +All of these are automatically handled by the ABP Framework. + +### Database Transaction Behavior + +While the section above explains the UOW as it is database transaction, actually a UOW doesn't have to be transactional. By default; + +* **HTTP GET** requests don't start a transactional UOW. They still starts a UOW, but **doesn't create a database transaction**. +* All other HTTP request types start a UOW with a database transaction, if database level transactions are supported by the underlying database provider. + +This is because an HTTP GET request doesn't (and shouldn't) make any change in the database. You can change this behavior using the options explained below. + +## Default Options + +`AbpUnitOfWorkDefaultOptions` is used to configure the default options for the unit of work system. Configure the options in the `ConfigureServices` method of your [module](Module-Development-Basics.md). + +**Example: Completely disable the database transactions** + +````csharp +Configure(options => +{ + options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; +}); +```` + +### Option Properties + +* `TransactionBehavior` (`enum`: `UnitOfWorkTransactionBehavior`). A global point to configure the transaction behavior. Default value is `Auto` and work as explained in the "*Database Transaction Behavior*" section above. You can enable (even for HTTP GET requests) or disable transactions with this option. +* `TimeOut` (`TimeSpan?`): Used to set the timeout value for UOWs. **Default value is `null`** and uses to the default of the underlying database provider. +* `IsolationLevel` (`IsolationLevel?`): Used to set the [isolation level](https://docs.microsoft.com/en-us/dotnet/api/system.data.isolationlevel) of the database transaction, if the UOW is transactional. + +## Controlling the Unit Of Work + +In some cases, you may want to change the conventional transaction scope, create inner scopes or fine control the transaction behavior. The following sections cover these possibilities. + +### IUnitOfWorkEnabled Interface + +This is an easy way to enable UOW for a class (or a hierarchy of classes) that is not unit of work by the conventions explained above. + +**Example: Implement `IUnitOfWorkEnabled` for an arbitrary service** + +````csharp +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Uow; + +namespace AbpDemo +{ + public class MyService : ITransientDependency, IUnitOfWorkEnabled + { + public virtual async Task FooAsync() + { + //this is a method with a UOW scope + } + } +} +```` + +Then `MyService` (and any class derived from it) methods will be UOW. + +However, there are **some rules should be followed** in order to make it working; + +* If you are **not injecting** the service over an interface (like `IMyService`), then the methods of the service must be `virtual` (otherwise, [dynamic proxy / interception](Dynamic-Proxying-Interceptors.md) system can not work). +* Only `async` methods (methods returning a `Task` or `Task`) are intercepted. So, sync methods can not start a UOW. + +> Notice that if `FooAsync` is called inside a UOW scope, then it already participates to the UOW without needing to the `IUnitOfWorkEnabled` or any other configuration. + +### UnitOfWorkAttribute + +`UnitOfWork` attribute provides much more possibility like enabling or disabling UOW and controlling the transaction behavior. + +`UnitOfWork` attribute can be used for a **class** or a **method** level. + +**Example: Enable UOW for a specific method of a class** + +````csharp +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Uow; + +namespace AbpDemo +{ + public class MyService : ITransientDependency + { + [UnitOfWork] + public virtual async Task FooAsync() + { + //this is a method with a UOW scope + } + + public virtual async Task BarAsync() + { + //this is a method without UOW + } + } +} +```` + +**Example: Enable UOW for all the methods of a class** + +````csharp +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Uow; + +namespace AbpDemo +{ + [UnitOfWork] + public class MyService : ITransientDependency + { + public virtual async Task FooAsync() + { + //this is a method with a UOW scope + } + + public virtual async Task BarAsync() + { + //this is a method with a UOW scope + } + } +} +```` + +Again, the **same rules** are valid here: + +* If you are **not injecting** the service over an interface (like `IMyService`), then the methods of the service must be `virtual` (otherwise, [dynamic proxy / interception](Dynamic-Proxying-Interceptors.md) system can not work). +* Only `async` methods (methods returning a `Task` or `Task`) are intercepted. So, sync methods can not start a UOW. + +#### UnitOfWorkAttribute Properties + +* `IsTransactional` (`bool?`): Used to set whether the UOW should be transactional or not. **Default value is `null`**. if you leave it `null`, it is determined automatically based on the conventions and the configuration. +* `TimeOut` (`int?`): Used to set the timeout value for this UOW. **Default value is `null`** and fallbacks to the default configured value. +* `IsolationLevel` (`IsolationLevel?`): Used to set the [isolation level](https://docs.microsoft.com/en-us/dotnet/api/system.data.isolationlevel) of the database transaction, if the UOW is transactional. If not set, uses the default configured value. +* `IsDisabled` (`bool`): Used to disable the UOW for the current method/class. + +> If a method is called in an ambient UOW scope, then the `UnitOfWork` attribute is ignored and the method participates to the surrounding transaction in any way. + +**Example: Disable UOW for a controller action** + +````csharp +using System.Threading.Tasks; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Uow; + +namespace AbpDemo.Web +{ + public class MyController : AbpController + { + [UnitOfWork(IsDisabled = true)] + public virtual async Task FooAsync() + { + //... + } + } +} +```` + +## IUnitOfWorkManager + +`IUnitOfWorkManager` is the main service that is used to control the unit of work system. The following sections explains how to directly work with this service (while most of the times you won't need). + +### Begin a New Unit Of Work + +`IUnitOfWorkManager.Begin` method is used to create a new UOW scope. + +**Example: Create a new non-transactional UOW scope** + +````csharp +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Uow; + +namespace AbpDemo +{ + public class MyService : ITransientDependency + { + private readonly IUnitOfWorkManager _unitOfWorkManager; + + public MyService(IUnitOfWorkManager unitOfWorkManager) + { + _unitOfWorkManager = unitOfWorkManager; + } + + public virtual async Task FooAsync() + { + using (var uow = _unitOfWorkManager.Begin( + requiresNew: true, isTransactional: false + )) + { + //... + + await uow.CompleteAsync(); + } + } + } +} +```` + +`Begin` method gets the following optional parameters: + +* `requiresNew` (`bool`): Set `true` to ignore the surrounding unit of work and start a new UOW with the provided options. **Default value is `false`. If it is `false` and there is a surrounding UOW, `Begin` method doesn't actually begin a new UOW, but silently participates to the existing UOW.** +* `isTransactional` (`bool`). Default value is `false`. +* `isolationLevel` (`IsolationLevel?`): Used to set the [isolation level](https://docs.microsoft.com/en-us/dotnet/api/system.data.isolationlevel) of the database transaction, if the UOW is transactional. If not set, uses the default configured value. +* `TimeOut` (`TimeSpan?`): Used to set the timeout value for this UOW. **Default value is `null`** and fallbacks to the default configured value. + +### The Current Unit Of Work + +UOW is ambient, as explained before. If you need to access to the current unit of work, you can use the `IUnitOfWorkManager.Current` property. + +**Example: Get the current UOW** + +````csharp +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Uow; + +namespace AbpDemo +{ + public class MyProductService : ITransientDependency + { + private readonly IUnitOfWorkManager _unitOfWorkManager; + + public MyProductService(IUnitOfWorkManager unitOfWorkManager) + { + _unitOfWorkManager = unitOfWorkManager; + } + + public async Task FooAsync() + { + var uow = _unitOfWorkManager.Current; + //... + } + } +} +```` + +`Current` property returns a `IUnitOfWork` object. + +> **Current Unit Of Work can be `null`** if there is no surrounding unit of work. It won't be `null` if your class is a conventional UOW class, you manually made it UOW or it was called inside a UOW scope, as explained before. + +#### SaveChangesAsync + +`IUnitOfWork.SaveChangesAsync()` method can be needed to save all the changes until now to the database. If you are using EF Core, it behaves exactly same. If the current UOW is transactional, even saved changes can be rolled back on an error (for the supporting database providers). + +**Example: Save changes after inserting an entity to get its auto-increment id** + +````csharp +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace AbpDemo +{ + public class CategoryAppService : ApplicationService, ICategoryAppService + { + private readonly IRepository _categoryRepository; + + public CategoryAppService(IRepository categoryRepository) + { + _categoryRepository = categoryRepository; + } + + public async Task CreateAsync(string name) + { + var category = new Category {Name = name}; + await _categoryRepository.InsertAsync(category); + + //Saving changes to be able to get the auto increment id + await UnitOfWorkManager.Current.SaveChangesAsync(); + + return category.Id; + } + } +} +```` + +This example uses auto-increment `int` primary key for the `Category` [entity](Entities.md). Auto-increment PKs require to save the entity to the database to get the id of the new entity. + +This example is an [application service](Application-Services.md) derived from the base `ApplicationService` class, which already has the `IUnitOfWorkManager` service injected as the `UnitOfWorkManager` property. So, no need to inject it manually. + +Since getting the current UOW is pretty common, there is also a `CurrentUnitOfWork` property as a shortcut to the `UnitOfWorkManager.Current`. So, the example above can be changed to use it: + +````csharp +await CurrentUnitOfWork.SaveChangesAsync(); +```` + +##### Alternative to the SaveChanges() + +Since saving changes after inserting, updating or deleting an entity can be frequently needed, corresponding [repository](Repositories.md) methods has an optional `autoSave` parameter. So, the `CreateAsync` method above could be re-written as shown below: + +````csharp +public async Task CreateAsync(string name) +{ + var category = new Category {Name = name}; + await _categoryRepository.InsertAsync(category, autoSave: true); + return category.Id; +} +```` + +If your intent is just to save the changes after creating/updating/deleting an entity, it is suggested to use the `autoSave` option instead of manually using the `CurrentUnitOfWork.SaveChangesAsync()`. + +> **Note-1**: All changes are automatically saved when a unit of work ends without any error. So, don't call `SaveChangesAsync()` unless you really need it. +> +> **Note-2**: If you use `Guid` as the primary key, you never need to save changes on insert to just get the generated id, because `Guid` keys are set in the application and are immediately available once you create a new entity. + +#### Other IUnitOfWork Properties/Methods + +* `OnCompleted` method gets a callback action which is called when the unit of work successfully completed (where you can be sure that all changes are saved). +* `Failed` and `Disposed` events can be used to be notified if the UOW fails or when it is disposed. +* `Complete` and `Rollback` methods are used to complete (commit) or roll backs the current UOW, which are normally used internally by the ABP Framework but can be used if you manually start a transaction using the `IUnitOfWorkManager.Begin` method. +* `Options` can be used to get options that was used while starting the UOW. +* `Items` dictionary can be used to store and get arbitrary objects inside the same unit of work, which can be a point to implement custom logics. + +## ASP.NET Core Integration + +Unit of work system is fully integrated to the ASP.NET Core. It properly works when you use ASP.NET Core MVC Controllers or Razor Pages. It defines action filters and page filters for the UOW system. + +> You typically do nothing to configure the UOW when you use ASP.NET Core. + +### Unit Of Work Middleware + +`AbpUnitOfWorkMiddleware` is a middleware that can enable UOW in the ASP.NET Core request pipeline. This might be needed if you need to enlarge the UOW scope to cover some other middleware(s). + +**Example:** + +````csharp +app.UseUnitOfWork(); +app.UseConfiguredEndpoints(); +```` -TODO \ No newline at end of file diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 38cbe0d5a4..a7c6b0b163 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -285,7 +285,8 @@ "path": "Data-Transfer-Objects.md" }, { - "text": "Unit Of Work" + "text": "Unit Of Work", + "path": "Unit-Of-Work.md" } ] } 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 8064ff99d2..5f53694177 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 @@ -16,10 +16,14 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations public string DefaultResourceName { get; set; } + public Dictionary> LanguagesMap { get; set; } + + public Dictionary> LanguageFilesMap { 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.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationContext.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationContext.cs index 5d45f9c7e8..98fe3546c5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationContext.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationContext.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Generic; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Options; +using Volo.Abp.Localization; namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling { @@ -8,8 +11,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling { public List Files { get; } - public IServiceProvider ServiceProvider { get; } - public IFileProvider FileProvider { get; } public BundleConfigurationContext(IServiceProvider serviceProvider, IFileProvider fileProvider) @@ -18,5 +19,29 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling ServiceProvider = serviceProvider; FileProvider = fileProvider; } + + public IServiceProvider ServiceProvider { get; } + private readonly object _serviceProviderLock = new object(); + + private TRef LazyGetRequiredService(Type serviceType, ref TRef reference) + { + if (reference == null) + { + lock (_serviceProviderLock) + { + if (reference == null) + { + reference = (TRef)ServiceProvider.GetRequiredService(serviceType); + } + } + } + + return reference; + } + + private IOptions _abpLocalizationOptions; + + public AbpLocalizationOptions LocalizationOptions => + LazyGetRequiredService(typeof(IOptions), ref _abpLocalizationOptions).Value; } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs index 2971716b90..048da5e8df 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs @@ -73,7 +73,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers throw new AbpException($"Could not find the bundle file '{bundleFile}' from {nameof(IWebContentFileProvider)}"); } - AddHtmlTag(viewContext, context, output, bundleFile + "?_v=" + file.LastModified.UtcTicks); + if (file.Length > 0) + { + AddHtmlTag(viewContext, context, output, bundleFile + "?_v=" + file.LastModified.UtcTicks); + } } stopwatch.Stop(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Resources/IWebRequestResources.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Resources/IWebRequestResources.cs index f18a759b21..a1a03a42cf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Resources/IWebRequestResources.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Resources/IWebRequestResources.cs @@ -4,6 +4,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Resources { public interface IWebRequestResources { - List TryAdd(IEnumerable resources); + List TryAdd(List resources); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Resources/WebRequestResources.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Resources/WebRequestResources.cs index 8865095bc4..68bc42d6ad 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Resources/WebRequestResources.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Resources/WebRequestResources.cs @@ -1,23 +1,35 @@ using System.Collections.Generic; using System.Linq; +using Microsoft.AspNetCore.Http; using Volo.Abp.DependencyInjection; namespace Volo.Abp.AspNetCore.Mvc.UI.Resources { public class WebRequestResources : IWebRequestResources, IScopedDependency { - protected List Resources { get; } + protected Dictionary> Resources { get; } - public WebRequestResources() + protected IHttpContextAccessor HttpContextAccessor{ get; } + + public WebRequestResources(IHttpContextAccessor httpContextAccessor) { - Resources = new List(); + HttpContextAccessor = httpContextAccessor; + Resources = new Dictionary>(); } - public List TryAdd(IEnumerable resources) + public List TryAdd(List resources) { - var resourceToBeAdded = resources.Except(Resources).ToList(); - Resources.AddRange(resourceToBeAdded); - return resourceToBeAdded; + var path = HttpContextAccessor.HttpContext?.Request?.Path ?? ""; + + if (Resources.TryGetValue(path, out var res)) + { + var resourceToBeAdded = resources.Except(res).ToList(); + res.AddRange(resourceToBeAdded); + return resourceToBeAdded; + } + + Resources.Add(path, resources); + return resources; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/AbpAspNetCoreMvcUiPackagesModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/AbpAspNetCoreMvcUiPackagesModule.cs index ec82d4b3d6..a5ee47a753 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/AbpAspNetCoreMvcUiPackagesModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/AbpAspNetCoreMvcUiPackagesModule.cs @@ -1,4 +1,6 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.AspNetCore.Mvc.UI.Packages.BootstrapDatepicker; +using Volo.Abp.Localization; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Mvc.UI.Packages @@ -6,6 +8,18 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages [DependsOn(typeof(AbpAspNetCoreMvcUiBundlingModule))] public class AbpAspNetCoreMvcUiPackagesModule : AbpModule { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.AddLanguagesMapOrUpdate(BootstrapDatepickerScriptContributor.PackageName, + new NameValue("zh-Hans", "zh-CN"), + new NameValue("zh-Hant", "zh-TW")); + options.AddLanguageFilesMapOrUpdate(BootstrapDatepickerScriptContributor.PackageName, + new NameValue("zh-Hans", "zh-CN"), + new NameValue("zh-Hant", "zh-TW")); + }); + } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerScriptContributor.cs index fb29a8f2a5..ca852972d8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerScriptContributor.cs @@ -1,7 +1,8 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Globalization; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; +using Volo.Abp.Localization; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.BootstrapDatepicker @@ -9,11 +10,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.BootstrapDatepicker [DependsOn(typeof(JQueryScriptContributor))] public class BootstrapDatepickerScriptContributor : BundleContributor { - public static readonly Dictionary CultureMap = new Dictionary - { - {"zh-Hans", "zh-CN"} - }; - + public const string PackageName = "bootstrap-datepicker"; + public override void ConfigureBundle(BundleConfigurationContext context) { context.Files.AddIfNotContains("/libs/bootstrap-datepicker/bootstrap-datepicker.min.js"); @@ -26,12 +24,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.BootstrapDatepicker ? "en" : CultureInfo.CurrentUICulture.Name; - TryAddCultureFile(context, MapCultureName(cultureName)); + TryAddCultureFile(context, cultureName); } protected virtual bool TryAddCultureFile(BundleConfigurationContext context, string cultureName) { - var filePath = $"/libs/bootstrap-datepicker/locales/bootstrap-datepicker.{cultureName}.min.js"; + var fileName = context.LocalizationOptions.GetLanguageFilesMap(PackageName, cultureName); + var filePath = $"/libs/bootstrap-datepicker/locales/bootstrap-datepicker.{fileName}.min.js"; if (!context.FileProvider.GetFileInfo(filePath).Exists) { @@ -41,11 +40,5 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.BootstrapDatepicker context.Files.AddIfNotContains(filePath); return true; } - - protected virtual string MapCultureName(string cultureName) - { - return CultureMap.GetOrDefault(cultureName) ?? - cultureName; - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JQueryValidation/JQueryValidationScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JQueryValidation/JQueryValidationScriptContributor.cs index b4acf05ec6..586d8864cd 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JQueryValidation/JQueryValidationScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/JQueryValidation/JQueryValidationScriptContributor.cs @@ -2,6 +2,7 @@ using System.Globalization; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; +using Volo.Abp.Localization; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.JQueryValidation @@ -11,6 +12,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.JQueryValidation { public const string DefaultLocalizationFolder = "/libs/jquery-validation/localization/"; + public const string PackageName = "jquery-validation"; + public override void ConfigureBundle(BundleConfigurationContext context) { context.Files.AddIfNotContains("/libs/jquery-validation/jquery.validate.js"); @@ -25,7 +28,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.JQueryValidation var cultureName = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Replace('-', '_'); - if (TryAddCultureFile(context, MapCultureName(cultureName))) + var fileName = context.LocalizationOptions.GetLanguageFilesMap(PackageName, cultureName); + if (TryAddCultureFile(context, fileName)) { return; } @@ -35,7 +39,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.JQueryValidation return; } - TryAddCultureFile(context, MapCultureName(cultureName.Substring(0, cultureName.IndexOf('_')))); + fileName = context.LocalizationOptions.GetLanguageFilesMap(PackageName, + cultureName.Substring(0, cultureName.IndexOf('_'))); + TryAddCultureFile(context, fileName); } protected virtual bool TryAddCultureFile(BundleConfigurationContext context, string cultureName) @@ -51,10 +57,5 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.JQueryValidation context.Files.AddIfNotContains(filePath); return true; } - - protected virtual string MapCultureName(string cultureName) - { - return cultureName; - } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/Select2/Select2ScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/Select2/Select2ScriptContributor.cs index 81696d5e71..1e5f138f97 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/Select2/Select2ScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/Select2/Select2ScriptContributor.cs @@ -12,7 +12,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.Select2 { //TODO: Add select2.full.min.js or localize! context.Files.AddIfNotContains("/libs/select2/js/select2.min.js"); - context.Files.AddIfNotContains("/libs/select2/js/select2-bootstrap-modal-patch.js"); } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageSearchBox/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageSearchBox/Default.cshtml index a45223e825..d7a2e893d4 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageSearchBox/Default.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Shared/Components/AbpPageSearchBox/Default.cshtml @@ -6,7 +6,7 @@
- +
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index beef0d1f0c..56869350d5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -1,4 +1,4 @@ -(function ($) { +(function ($) { abp.dom = abp.dom || {}; @@ -73,25 +73,12 @@ abp.libs = abp.libs = abp.libs || {}; abp.libs.bootstrapDatepicker = { - languageMap: { - 'zh-Hans': 'zh-CN' - }, - mapLanguageName: function (name) { - return abp.libs.bootstrapDatepicker.languageMap[abp.localization.currentCulture.name] || name; - }, - isLanguageMapped: function (name) { - return abp.libs.bootstrapDatepicker.languageMap[abp.localization.currentCulture.name] !== undefined; - }, - getCurrentLanguageConfig: function () { - var mappedName = abp.libs.bootstrapDatepicker.mapLanguageName(abp.localization.currentCulture.name); - return $.fn.datepicker.dates[mappedName]; - }, + packageName: "bootstrap-datepicker", normalizeLanguageConfig: function () { - var languageConfig = abp.libs.bootstrapDatepicker.getCurrentLanguageConfig(); - if (languageConfig) { - if (!languageConfig.format || abp.libs.bootstrapDatepicker.isLanguageMapped(abp.localization.currentCulture.name)) { - languageConfig.format = abp.localization.currentCulture.dateTimeFormat.shortDatePattern.toLowerCase(); - } + var language = abp.localization.getLanguagesMap(this.packageName); + var languageConfig = $.fn.datepicker.dates[language]; + if (languageConfig && (!languageConfig.format || language !== abp.localization.currentCulture.name)) { + languageConfig.format = abp.localization.currentCulture.dateTimeFormat.shortDatePattern.toLowerCase(); } }, getFormattedValue: function (isoFormattedValue) { @@ -108,7 +95,7 @@ return { todayBtn: "linked", autoclose: true, - language: abp.libs.bootstrapDatepicker.mapLanguageName(abp.localization.currentCulture.cultureName) + language: abp.localization.getLanguagesMap(this.packageName) }; } }; @@ -132,7 +119,6 @@ abp.dom.initializers.initializeToolTips(args.$el.findWithSelf('[data-toggle="tooltip"]')); abp.dom.initializers.initializePopovers(args.$el.findWithSelf('[data-toggle="popover"]')); abp.dom.initializers.initializeTimeAgos(args.$el.findWithSelf('.timeago')); - abp.dom.initializers.initializeDatepickers(args.$el); abp.dom.initializers.initializeForms(args.$el.findWithSelf('form'), true); abp.dom.initializers.initializeScript(args.$el); }); @@ -156,4 +142,4 @@ $('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); }); -})(jQuery); \ No newline at end of file +})(jQuery); 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 6ad5b3276e..5aa8f07059 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 @@ -171,6 +171,9 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations ); } + localizationConfig.LanguagesMap = _localizationOptions.LanguagesMap; + localizationConfig.LanguageFilesMap = _localizationOptions.LanguageFilesMap; + return localizationConfig; } @@ -267,4 +270,4 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations }; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs index 07ada2fe3d..417c004f36 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs @@ -47,6 +47,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App if (context.BuildArgs.DatabaseProvider != DatabaseProvider.MongoDb) { + steps.Add(new AppTemplateRemoveMongodbCollectionFixtureStep()); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB")); steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.MongoDB.Tests", projectFolderPath: "/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests")); } @@ -167,4 +168,4 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App } } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateRemoveMongodbCollectionFixtureStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateRemoveMongodbCollectionFixtureStep.cs new file mode 100644 index 0000000000..bf069c61ea --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateRemoveMongodbCollectionFixtureStep.cs @@ -0,0 +1,70 @@ +using System.Collections.Generic; +using System.Linq; +using Volo.Abp.Cli.ProjectBuilding.Building; + +namespace Volo.Abp.Cli.ProjectBuilding.Templates.App +{ + public class AppTemplateRemoveMongodbCollectionFixtureStep : ProjectBuildPipelineStep + { + public override void Execute(ProjectBuildContext context) + { + //MyCompanyName.MyProjectName.Application.Tests + RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs"); + RemoveKeyword(context, + "/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs", + "[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]"); + + //MyCompanyName.MyProjectName.Domain.Tests + RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs"); + RemoveKeyword(context, + "/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs", + "[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]"); + + //MyCompanyName.MyProjectName.EntityFrameworkCore.Tests + RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs"); + RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs"); + RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs"); + RemoveKeyword(context, + "/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs", + "[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]"); + + //MyCompanyName.MyProjectName.Web.Tests + RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs"); + RemoveKeyword(context, + "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs", + "[Collection(MyProjectNameTestConsts.CollectionDefinitionName)]"); + + //MyCompanyName.MyProjectName.TestBase + RemoveFile(context, "/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs"); + } + + private static void RemoveFile(ProjectBuildContext context, string targetModuleFilePath) + { + var file = context.Files.FirstOrDefault(x => x.Name == targetModuleFilePath); + if (file != null) + { + context.Files.Remove(file); + } + } + + private static void RemoveKeyword(ProjectBuildContext context, string targetModuleFilePath, string keyword) + { + var file = context.GetFile(targetModuleFilePath); + + file.NormalizeLineEndings(); + + var lines = file.GetLines(); + var newLines = new List(); + + for (var i = 0; i < lines.Length; i++) + { + if (!lines[i].Contains(keyword)) + { + newLines.Add(lines[i]); + } + } + + file.SetLines(newLines); + } + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateSwitchEntityFrameworkCoreToMongoDbStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateSwitchEntityFrameworkCoreToMongoDbStep.cs index ca290ab83f..b0a778c323 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateSwitchEntityFrameworkCoreToMongoDbStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateSwitchEntityFrameworkCoreToMongoDbStep.cs @@ -16,7 +16,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App "MongoDB" ); - ChangeModuleDependency( + ChangeNamespaceAndKeyword( context, "/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs", "MyCompanyName.MyProjectName.EntityFrameworkCore", @@ -39,7 +39,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App "MongoDB" ); - ChangeModuleDependency( + ChangeNamespaceAndKeyword( context, "/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs", "MyCompanyName.MyProjectName.EntityFrameworkCore", @@ -62,7 +62,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App "MongoDB" ); - ChangeModuleDependency( + ChangeNamespaceAndKeyword( context, "/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs", "MyCompanyName.MyProjectName.EntityFrameworkCore", @@ -85,7 +85,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App "MongoDB" ); - ChangeModuleDependency( + ChangeNamespaceAndKeyword( context, "/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs", "MyCompanyName.MyProjectName.EntityFrameworkCore", @@ -108,7 +108,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App "MongoDB" ); - ChangeModuleDependency( + ChangeNamespaceAndKeyword( context, "/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs", "MyCompanyName.MyProjectName.EntityFrameworkCore", @@ -131,7 +131,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App "MongoDB.Tests" ); - ChangeModuleDependency( + ChangeNamespaceAndKeyword( context, "/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs", "MyCompanyName.MyProjectName.EntityFrameworkCore", @@ -139,6 +139,37 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App "MyProjectNameEntityFrameworkCoreTestModule", "MyProjectNameMongoDbTestModule" ); + + ChangeNamespaceAndKeyword( + context, + "/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs", + "MyCompanyName.MyProjectName.EntityFrameworkCore", + "MyCompanyName.MyProjectName.MongoDB", + "MyProjectNameEntityFrameworkCoreCollectionFixtureBase", + "MyProjectNameMongoDbCollectionFixtureBase" + ); + + //MyCompanyName.MyProjectName.Application.Tests + + ChangeNamespaceAndKeyword( + context, + "/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs", + "MyCompanyName.MyProjectName.EntityFrameworkCore", + "MyCompanyName.MyProjectName.MongoDB", + "MyProjectNameEntityFrameworkCoreCollectionFixtureBase", + "MyProjectNameMongoDbCollectionFixtureBase" + ); + + //MyCompanyName.MyProjectName.Web.Tests + + ChangeNamespaceAndKeyword( + context, + "/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs", + "MyCompanyName.MyProjectName.EntityFrameworkCore", + "MyCompanyName.MyProjectName.MongoDB", + "MyProjectNameEntityFrameworkCoreCollectionFixtureBase", + "MyProjectNameMongoDbCollectionFixtureBase" + ); } private void ChangeProjectReference( @@ -165,13 +196,13 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App throw new ApplicationException($"Could not find the '{oldReference}' reference in the project '{targetProjectFilePath}'!"); } - private void ChangeModuleDependency( + private void ChangeNamespaceAndKeyword( ProjectBuildContext context, string targetModuleFilePath, string oldNamespace, string newNamespace, - string oldModuleName, - string newModuleName) + string oldKeyword, + string newKeyword) { var file = context.GetFile(targetModuleFilePath); @@ -185,9 +216,9 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App { lines[i] = $"using {newNamespace};"; } - else if (lines[i].Contains(oldModuleName)) + else if (lines[i].Contains(oldKeyword)) { - lines[i] = lines[i].Replace(oldModuleName, newModuleName); + lines[i] = lines[i].Replace(oldKeyword, newKeyword); } } @@ -216,4 +247,4 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App throw new ApplicationException("Could not find the 'Default' connection string in appsettings.json file!"); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs index 2c49f6408a..fb2d2dfb1f 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs @@ -118,7 +118,7 @@ namespace Volo.Abp.EntityFrameworkCore modelBuilder.SetDatabaseProvider(provider.Value); } } - + protected virtual EfCoreDatabaseProvider? GetDatabaseProviderOrNull(ModelBuilder modelBuilder) { switch (Database.ProviderName) @@ -187,7 +187,7 @@ namespace Volo.Abp.EntityFrameworkCore Database.IsRelational() && !Database.GetCommandTimeout().HasValue) { - Database.SetCommandTimeout(initializationContext.UnitOfWork.Options.Timeout.Value.TotalSeconds.To()); + Database.SetCommandTimeout(TimeSpan.FromMilliseconds(initializationContext.UnitOfWork.Options.Timeout.Value)); } ChangeTracker.CascadeDeleteTiming = CascadeTiming.OnSaveChanges; @@ -627,4 +627,4 @@ namespace Volo.Abp.EntityFrameworkCore } } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EfCoreAsyncQueryableProvider.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EfCoreAsyncQueryableProvider.cs index f9ef8c86e0..68ff261588 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EfCoreAsyncQueryableProvider.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EfCoreAsyncQueryableProvider.cs @@ -1,5 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; @@ -16,19 +18,332 @@ namespace Volo.Abp.EntityFrameworkCore return queryable.Provider is EntityQueryProvider; } + public Task ContainsAsync(IQueryable queryable, T item, CancellationToken cancellationToken = default) + { + return queryable.ContainsAsync(item, cancellationToken); + } + + public Task AnyAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return queryable.AnyAsync(predicate, cancellationToken); + } + + public Task AllAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return queryable.AllAsync(predicate, cancellationToken); + } + public Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default) { return queryable.CountAsync(cancellationToken); } - public Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task CountAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) { - return queryable.ToListAsync(cancellationToken); + return queryable.CountAsync(predicate, cancellationToken); + } + + public Task LongCountAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.LongCountAsync(cancellationToken); + } + + public Task LongCountAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return queryable.LongCountAsync(predicate, cancellationToken); + } + + public Task FirstAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.FirstAsync(cancellationToken); + } + + public Task FirstAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return queryable.FirstAsync(predicate, cancellationToken); } public Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) { return queryable.FirstOrDefaultAsync(cancellationToken); } + + public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) + { + return queryable.FirstOrDefaultAsync(predicate, cancellationToken); + } + + public Task LastAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.LastAsync(cancellationToken); + } + + public Task LastAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return queryable.LastAsync(predicate, cancellationToken); + } + + public Task LastOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.LastOrDefaultAsync(cancellationToken); + } + + public Task LastOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) + { + return queryable.LastOrDefaultAsync(predicate, cancellationToken); + } + + public Task SingleAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SingleAsync(cancellationToken); + } + + public Task SingleAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return queryable.SingleAsync(predicate, cancellationToken); + } + + public Task SingleOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SingleOrDefaultAsync(cancellationToken); + } + + public Task SingleOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) + { + return queryable.SingleOrDefaultAsync(predicate, cancellationToken); + } + + public Task MinAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.MinAsync(cancellationToken); + } + + public Task MinAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.MinAsync(selector, cancellationToken); + } + + public Task MaxAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.MaxAsync(cancellationToken); + } + + public Task MaxAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.MaxAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.SumAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return queryable.AverageAsync(selector, cancellationToken); + } + + public Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.ToListAsync(cancellationToken); + } + + public Task ToArrayAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return queryable.ToArrayAsync(cancellationToken); + } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreDatabaseApi.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreDatabaseApi.cs index 767bdf6e27..cffda462b0 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreDatabaseApi.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreDatabaseApi.cs @@ -18,10 +18,5 @@ namespace Volo.Abp.Uow.EntityFrameworkCore { return DbContext.SaveChangesAsync(cancellationToken); } - - public void SaveChanges() - { - DbContext.SaveChanges(); - } } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreTransactionApi.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreTransactionApi.cs index 33f9aca1a7..99622dda96 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreTransactionApi.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreTransactionApi.cs @@ -21,7 +21,13 @@ namespace Volo.Abp.Uow.EntityFrameworkCore AttendedDbContexts = new List(); } - public void Commit() + public Task CommitAsync() + { + Commit(); + return Task.CompletedTask; + } + + protected void Commit() { DbContextTransaction.Commit(); @@ -36,12 +42,6 @@ namespace Volo.Abp.Uow.EntityFrameworkCore } } - public Task CommitAsync() - { - Commit(); - return Task.CompletedTask; - } - public void Dispose() { DbContextTransaction.Dispose(); diff --git a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs index e3fd273026..e20b60bf54 100644 --- a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs +++ b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs @@ -45,11 +45,8 @@ namespace Microsoft.Extensions.DependencyInjection AddHttpClientFactoryAndPolicy(services, remoteServiceConfigurationName, configureHttpClientBuilder); //TODO: Make a configuration option and add remoteServiceName inside it! - //TODO: Add option to change type filter - var serviceTypes = assembly.GetTypes().Where(t => - t.IsInterface && t.IsPublic && typeof(IRemoteService).IsAssignableFrom(t) - ); + var serviceTypes = assembly.GetTypes().Where(IsSuitableForDynamicClientProxying); foreach (var serviceType in serviceTypes) { @@ -155,7 +152,7 @@ namespace Microsoft.Extensions.DependencyInjection services.AddTransient(interceptorType); var interceptorAdapterType = typeof(AbpAsyncDeterminationInterceptor<>).MakeGenericType(interceptorType); - + var validationInterceptorAdapterType = typeof(AbpAsyncDeterminationInterceptor<>).MakeGenericType(typeof(ValidationInterceptor)); @@ -191,5 +188,21 @@ namespace Microsoft.Extensions.DependencyInjection return services; } + + /// + /// Checks wether the type is suitable to use with the dynamic proxying. + /// Currently the type is checked statically against some fixed conditions. + /// + /// Type to check + /// True, if the type is suitable for dynamic proxying. Otherwise false. + static bool IsSuitableForDynamicClientProxying(Type type) + { + //TODO: Add option to change type filter + + return type.IsInterface + && type.IsPublic + && !type.IsGenericType + && typeof(IRemoteService).IsAssignableFrom(type); + } } } diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs index e98c0738fd..e2e5b7b9fe 100644 --- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.DependencyInjection; +using System.Linq; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Http; using Volo.Abp.Castle; using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; @@ -21,5 +23,24 @@ namespace Volo.Abp.Http.Client var configuration = context.Services.GetConfiguration(); Configure(configuration); } + + public override void PostConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + if (options.HttpClientActions.Any()) + { + var httpClientNames = options.HttpClientProxies.Select(x => x.Value.RemoteServiceName); + foreach (var httpClientName in httpClientNames) + { + foreach (var httpClientAction in options.HttpClientActions) + { + context.Services.Configure(httpClientName, + x => x.HttpClientActions.Add(httpClientAction.Invoke(httpClientName))); + } + } + } + }); + } } } diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientOptions.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientOptions.cs index 5adcd7525f..54cc4eb624 100644 --- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientOptions.cs +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientOptions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Net.Http; using Volo.Abp.Http.Client.DynamicProxying; namespace Volo.Abp.Http.Client @@ -8,9 +9,12 @@ namespace Volo.Abp.Http.Client { public Dictionary HttpClientProxies { get; set; } + public List>> HttpClientActions { get; } + public AbpHttpClientOptions() { HttpClientProxies = new Dictionary(); + HttpClientActions = new List>>(); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs index c192fc8feb..b338385861 100644 --- a/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs +++ b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs @@ -25,17 +25,20 @@ namespace Volo.Abp.IdentityModel protected ICancellationTokenProvider CancellationTokenProvider { get; } protected IHttpClientFactory HttpClientFactory { get; } protected ICurrentTenant CurrentTenant { get; } + protected IdentityModelHttpRequestMessageOptions IdentityModelHttpRequestMessageOptions { get; } public IdentityModelAuthenticationService( IOptions options, ICancellationTokenProvider cancellationTokenProvider, IHttpClientFactory httpClientFactory, - ICurrentTenant currentTenant) + ICurrentTenant currentTenant, + IOptions identityModelHttpRequestMessageOptions) { ClientOptions = options.Value; CancellationTokenProvider = cancellationTokenProvider; HttpClientFactory = httpClientFactory; CurrentTenant = currentTenant; + IdentityModelHttpRequestMessageOptions = identityModelHttpRequestMessageOptions.Value; Logger = NullLogger.Instance; } @@ -74,7 +77,7 @@ namespace Volo.Abp.IdentityModel } var tokenResponse = await GetTokenResponse(discoveryResponse, configuration); - + if (tokenResponse.IsError) { if (tokenResponse.ErrorDescription != null) @@ -112,14 +115,16 @@ namespace Volo.Abp.IdentityModel { using (var httpClient = HttpClientFactory.CreateClient(HttpClientName)) { - return await httpClient.GetDiscoveryDocumentAsync(new DiscoveryDocumentRequest + var request = new DiscoveryDocumentRequest { Address = configuration.Authority, Policy = { RequireHttps = configuration.RequireHttps } - }); + }; + IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage(request); + return await httpClient.GetDiscoveryDocumentAsync(request); } } @@ -160,6 +165,7 @@ namespace Volo.Abp.IdentityModel UserName = configuration.UserName, Password = configuration.UserPassword }; + IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage(request); AddParametersToRequestAsync(configuration, request); @@ -177,6 +183,7 @@ namespace Volo.Abp.IdentityModel ClientId = configuration.ClientId, ClientSecret = configuration.ClientSecret }; + IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage(request); AddParametersToRequestAsync(configuration, request); diff --git a/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelHttpRequestMessageOptions.cs b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelHttpRequestMessageOptions.cs new file mode 100644 index 0000000000..23b26faaf6 --- /dev/null +++ b/framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelHttpRequestMessageOptions.cs @@ -0,0 +1,10 @@ +using System; +using System.Net.Http; + +namespace Volo.Abp.IdentityModel +{ + public class IdentityModelHttpRequestMessageOptions + { + public Action ConfigureHttpRequestMessage { get; set; } + } +} diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptions.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptions.cs index aba376d773..8974237f7d 100644 --- a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptions.cs +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptions.cs @@ -17,11 +17,17 @@ namespace Volo.Abp.Localization public List Languages { get; } + public Dictionary> LanguagesMap { get; } + + public Dictionary> LanguageFilesMap { get; } + public AbpLocalizationOptions() { Resources = new LocalizationResourceDictionary(); GlobalContributors = new TypeList(); Languages = new List(); + LanguagesMap = new Dictionary>(); + LanguageFilesMap = new Dictionary>(); } } } diff --git a/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptionsExtensions.cs b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptionsExtensions.cs new file mode 100644 index 0000000000..36355027db --- /dev/null +++ b/framework/src/Volo.Abp.Localization/Volo/Abp/Localization/AbpLocalizationOptionsExtensions.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Volo.Abp.Localization +{ + public static class AbpLocalizationOptionsExtensions + { + public static AbpLocalizationOptions AddLanguagesMapOrUpdate(this AbpLocalizationOptions localizationOptions, + string packageName, params NameValue[] maps) + { + foreach (var map in maps) + { + AddOrUpdate(localizationOptions.LanguagesMap, packageName, map); + } + + return localizationOptions; + } + + public static string GetLanguagesMap(this AbpLocalizationOptions localizationOptions, string packageName, + string language) + { + return localizationOptions.LanguagesMap.TryGetValue(packageName, out var maps) + ? maps.FirstOrDefault(x => x.Name == language)?.Value ?? language + : language; + } + + public static AbpLocalizationOptions AddLanguageFilesMapOrUpdate(this AbpLocalizationOptions localizationOptions, + string packageName, params NameValue[] maps) + { + foreach (var map in maps) + { + AddOrUpdate(localizationOptions.LanguageFilesMap, packageName, map); + } + + return localizationOptions; + } + + public static string GetLanguageFilesMap(this AbpLocalizationOptions localizationOptions, string packageName, + string language) + { + return localizationOptions.LanguageFilesMap.TryGetValue(packageName, out var maps) + ? maps.FirstOrDefault(x => x.Name == language)?.Value ?? language + : language; + } + + private static void AddOrUpdate(IDictionary> maps, string packageName, NameValue value) + { + if (maps.TryGetValue(packageName, out var existMaps)) + { + existMaps.GetOrAdd(x => x.Name == value.Name, () => value).Value = value.Value; + } + else + { + maps.Add(packageName, new List {value}); + } + } + } +} diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoDbAsyncQueryableProvider.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoDbAsyncQueryableProvider.cs index 8b0c56c812..206c4add39 100644 --- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoDbAsyncQueryableProvider.cs +++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoDbAsyncQueryableProvider.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; @@ -17,19 +18,337 @@ namespace Volo.Abp.MongoDB return queryable.Provider.GetType().Namespace?.StartsWith("MongoDB") ?? false; } + protected IMongoQueryable GetMongoQueryable(IQueryable queryable) + { + return (IMongoQueryable) queryable; + } + + public Task ContainsAsync(IQueryable queryable, T item, CancellationToken cancellationToken = default) + { + return Task.FromResult(GetMongoQueryable(queryable).Contains(item)); + } + + public Task AnyAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AnyAsync(predicate, cancellationToken); + } + + public Task AllAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return Task.FromResult(GetMongoQueryable(queryable).All(predicate)); + } + public Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default) { - return ((IMongoQueryable) queryable).CountAsync(cancellationToken); + return GetMongoQueryable(queryable).CountAsync(cancellationToken); } - public Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default) + public Task CountAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).CountAsync(predicate, cancellationToken); + } + + public Task LongCountAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).LongCountAsync(cancellationToken); + } + + public Task LongCountAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).LongCountAsync(predicate, cancellationToken); + } + + public Task FirstAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).FirstAsync(cancellationToken); + } + + public Task FirstAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) { - return ((IMongoQueryable) queryable).ToListAsync(cancellationToken); + return GetMongoQueryable(queryable).FirstAsync(predicate, cancellationToken); } public Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) { - return ((IMongoQueryable) queryable).FirstOrDefaultAsync(cancellationToken); + return GetMongoQueryable(queryable).FirstOrDefaultAsync(cancellationToken); + } + + public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).FirstOrDefaultAsync(predicate, cancellationToken); + } + + public Task LastAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return Task.FromResult(GetMongoQueryable(queryable).Last()); + } + + public Task LastAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return Task.FromResult(GetMongoQueryable(queryable).Last(predicate)); + } + + public Task LastOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return Task.FromResult(GetMongoQueryable(queryable).LastOrDefault()); + } + + public Task LastOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) + { + return Task.FromResult(GetMongoQueryable(queryable).LastOrDefault(predicate)); + } + + public Task SingleAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SingleAsync(cancellationToken); + } + + public Task SingleAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SingleAsync(predicate, cancellationToken); + } + + public Task SingleOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SingleOrDefaultAsync(cancellationToken); + } + + public Task SingleOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SingleOrDefaultAsync(predicate, cancellationToken); + } + + public Task MinAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).MinAsync(cancellationToken); + } + + public Task MinAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).MinAsync(selector, cancellationToken); + } + + public Task MaxAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).MaxAsync(cancellationToken); + } + + public Task MaxAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).MaxAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).AverageAsync(selector, cancellationToken); + } + + public Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return GetMongoQueryable(queryable).ToListAsync(cancellationToken); + } + + public async Task ToArrayAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + return (await GetMongoQueryable(queryable).ToListAsync(cancellationToken)).ToArray(); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs index ddd8fbbc3c..b54d64477f 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfo.cs @@ -18,10 +18,6 @@ namespace Volo.Abp.ObjectExtending [NotNull] public Type Type { get; } - [NotNull] - [Obsolete("Add validation attributes to the Attributes list instead! ValidationAttributes property will be removed in future versions.")] - public List ValidationAttributes { get; } - [NotNull] public List Attributes { get; } @@ -71,7 +67,6 @@ namespace Volo.Abp.ObjectExtending Name = Check.NotNull(name, nameof(name)); Configuration = new Dictionary(); - ValidationAttributes = new List(); Attributes = new List(); Validators = new List>(); diff --git a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoExtensions.cs b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoExtensions.cs index 4eac846314..d51bf5b13a 100644 --- a/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoExtensions.cs +++ b/framework/src/Volo.Abp.ObjectExtending/Volo/Abp/ObjectExtending/ObjectExtensionPropertyInfoExtensions.cs @@ -10,7 +10,6 @@ namespace Volo.Abp.ObjectExtending return propertyInfo .Attributes .OfType() - .Union(propertyInfo.ValidationAttributes) .ToArray(); } } diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs index 3548f81ad1..f5b3cf3a6d 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/AsyncQueryableExecuter.cs @@ -1,5 +1,7 @@ +using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; @@ -15,9 +17,36 @@ namespace Volo.Abp.Linq Providers = providers; } - public virtual Task CountAsync( - IQueryable queryable, - CancellationToken cancellationToken = default) + protected virtual IAsyncQueryableProvider FindProvider(IQueryable queryable) + { + return Providers.FirstOrDefault(p => p.CanExecute(queryable)); + } + + public Task ContainsAsync(IQueryable queryable, T item, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.ContainsAsync(queryable, item, cancellationToken) + : Task.FromResult(queryable.Contains(item)); + } + + public Task AnyAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AnyAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.Any(predicate)); + } + + public Task AllAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AllAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.All(predicate)); + } + + public Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); return provider != null @@ -25,19 +54,47 @@ namespace Volo.Abp.Linq : Task.FromResult(queryable.Count()); } - public virtual Task> ToListAsync( - IQueryable queryable, - CancellationToken cancellationToken = default) + public Task CountAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); return provider != null - ? provider.ToListAsync(queryable, cancellationToken) - : Task.FromResult(queryable.ToList()); + ? provider.CountAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.Count(predicate)); } - public virtual Task FirstOrDefaultAsync( - IQueryable queryable, - CancellationToken cancellationToken = default) + public Task LongCountAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.LongCountAsync(queryable, cancellationToken) + : Task.FromResult(queryable.LongCount()); + } + + public Task LongCountAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.LongCountAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.LongCount(predicate)); + } + + public Task FirstAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.FirstAsync(queryable, cancellationToken) + : Task.FromResult(queryable.First()); + } + + public Task FirstAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.FirstAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.First(predicate)); + } + + public Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) { var provider = FindProvider(queryable); return provider != null @@ -45,9 +102,447 @@ namespace Volo.Abp.Linq : Task.FromResult(queryable.FirstOrDefault()); } - protected virtual IAsyncQueryableProvider FindProvider(IQueryable queryable) + public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) { - return Providers.FirstOrDefault(p => p.CanExecute(queryable)); + var provider = FindProvider(queryable); + return provider != null + ? provider.FirstOrDefaultAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.FirstOrDefault(predicate)); + } + + public Task LastAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.LastAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Last()); + } + + public Task LastAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.LastAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.Last(predicate)); + } + + public Task LastOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.LastOrDefaultAsync(queryable, cancellationToken) + : Task.FromResult(queryable.LastOrDefault()); + } + + public Task LastOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.LastOrDefaultAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.LastOrDefault(predicate)); + } + + public Task SingleAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SingleAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Single()); + } + + public Task SingleAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SingleAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.Single(predicate)); + } + + public Task SingleOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SingleOrDefaultAsync(queryable, cancellationToken) + : Task.FromResult(queryable.SingleOrDefault()); + } + + public Task SingleOrDefaultAsync(IQueryable queryable, Expression> predicate, + CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SingleOrDefaultAsync(queryable, predicate, cancellationToken) + : Task.FromResult(queryable.SingleOrDefault(predicate)); + } + + public Task MinAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.MinAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Min()); + } + + public Task MinAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.MinAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Min(selector)); + } + + public Task MaxAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.MaxAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Max()); + } + + public Task MaxAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.MaxAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Max(selector)); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Sum()); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.SumAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Sum(selector)); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, cancellationToken) + : Task.FromResult(queryable.Average()); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task AverageAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.AverageAsync(queryable, selector, cancellationToken) + : Task.FromResult(queryable.Average(selector)); + } + + public Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.ToListAsync(queryable, cancellationToken) + : Task.FromResult(queryable.ToList()); + } + + public Task ToArrayAsync(IQueryable queryable, CancellationToken cancellationToken = default) + { + var provider = FindProvider(queryable); + return provider != null + ? provider.ToArrayAsync(queryable, cancellationToken) + : Task.FromResult(queryable.ToArray()); } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs index 0a19318c40..7273754b77 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableExecuter.cs @@ -1,25 +1,398 @@ +using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; +using JetBrains.Annotations; namespace Volo.Abp.Linq { public interface IAsyncQueryableExecuter { + #region Contains + + Task ContainsAsync( + [NotNull] IQueryable queryable, + [NotNull] T item, + CancellationToken cancellationToken = default); + + #endregion + + #region Any/All + + Task AnyAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + Task AllAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region Count/LongCount + Task CountAsync( - IQueryable queryable, - CancellationToken cancellationToken = default - ); + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task CountAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + + Task LongCountAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task LongCountAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region First/FirstOrDefault + + Task FirstAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task FirstAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); - Task> ToListAsync( - IQueryable queryable, - CancellationToken cancellationToken = default - ); Task FirstOrDefaultAsync( - IQueryable queryable, - CancellationToken cancellationToken = default - ); + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task FirstOrDefaultAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region Last/LastOrDefault + + Task LastAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task LastAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + + Task LastOrDefaultAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task LastOrDefaultAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region Single/SingleOrDefault + + Task SingleAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task SingleAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + Task SingleOrDefaultAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + Task SingleOrDefaultAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region Min + + Task MinAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task MinAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + #endregion + + #region Max + + Task MaxAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task MaxAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + #endregion + + #region Sum + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + #endregion + + #region Average + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + #endregion + + #region ToList/Array + + Task> ToListAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task ToArrayAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + #endregion } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs index 43d8b6d40e..ce62ea738c 100644 --- a/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs +++ b/framework/src/Volo.Abp.Threading/Volo/Abp/Linq/IAsyncQueryableProvider.cs @@ -1,18 +1,400 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; +using JetBrains.Annotations; namespace Volo.Abp.Linq { public interface IAsyncQueryableProvider { bool CanExecute(IQueryable queryable); - - Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default); - Task> ToListAsync(IQueryable queryable, CancellationToken cancellationToken = default); + #region Contains - Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default); + Task ContainsAsync( + [NotNull] IQueryable queryable, + [NotNull] T item, + CancellationToken cancellationToken = default); + + #endregion + + #region Any/All + + Task AnyAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + Task AllAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region Count/LongCount + + Task CountAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task CountAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + + Task LongCountAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task LongCountAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region First/FirstOrDefault + + Task FirstAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task FirstAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + + Task FirstOrDefaultAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task FirstOrDefaultAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region Last/LastOrDefault + + Task LastAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task LastAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + + Task LastOrDefaultAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task LastOrDefaultAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region Single/SingleOrDefault + + Task SingleAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task SingleAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + Task SingleOrDefaultAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + Task SingleOrDefaultAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> predicate, + CancellationToken cancellationToken = default); + + #endregion + + #region Min + + Task MinAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task MinAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + #endregion + + #region Max + + Task MaxAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task MaxAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + #endregion + + #region Sum + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task SumAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + #endregion + + #region Average + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable source, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + + Task AverageAsync( + [NotNull] IQueryable queryable, + [NotNull] Expression> selector, + CancellationToken cancellationToken = default); + + #endregion + + #region ToList/Array + + Task> ToListAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + + Task ToArrayAsync( + [NotNull] IQueryable queryable, + CancellationToken cancellationToken = default); + + #endregion } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkDefaultOptions.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkDefaultOptions.cs index 02d80e82a5..d0322b1e6e 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkDefaultOptions.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkDefaultOptions.cs @@ -4,7 +4,7 @@ using System.Data; namespace Volo.Abp.Uow { //TODO: Implement default options! - + /// /// Global (default) unit of work options /// @@ -17,7 +17,7 @@ namespace Volo.Abp.Uow public IsolationLevel? IsolationLevel { get; set; } - public TimeSpan? Timeout { get; set; } + public int? Timeout { get; set; } internal AbpUnitOfWorkOptions Normalize(AbpUnitOfWorkOptions options) { @@ -49,4 +49,4 @@ namespace Volo.Abp.Uow } } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs index a8f3f75a11..96da523739 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/AbpUnitOfWorkOptions.cs @@ -12,14 +12,17 @@ namespace Volo.Abp.Uow public IsolationLevel? IsolationLevel { get; set; } - public TimeSpan? Timeout { get; set; } + /// + /// Milliseconds + /// + public int? Timeout { get; set; } public AbpUnitOfWorkOptions() { - + } - public AbpUnitOfWorkOptions(bool isTransactional = false, IsolationLevel? isolationLevel = null, TimeSpan? timeout = null) + public AbpUnitOfWorkOptions(bool isTransactional = false, IsolationLevel? isolationLevel = null, int? timeout = null) { IsTransactional = isTransactional; IsolationLevel = isolationLevel; @@ -36,4 +39,4 @@ namespace Volo.Abp.Uow }; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAbpUnitOfWorkOptions.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAbpUnitOfWorkOptions.cs index 1f63a12b6d..c72712565e 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAbpUnitOfWorkOptions.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/IAbpUnitOfWorkOptions.cs @@ -9,6 +9,9 @@ namespace Volo.Abp.Uow IsolationLevel? IsolationLevel { get; } - TimeSpan? Timeout { get; } + /// + /// Milliseconds + /// + int? Timeout { get; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ISupportsSavingChanges.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ISupportsSavingChanges.cs index 4665f2a625..c9523bf702 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ISupportsSavingChanges.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ISupportsSavingChanges.cs @@ -5,8 +5,6 @@ namespace Volo.Abp.Uow { public interface ISupportsSavingChanges { - void SaveChanges(); - Task SaveChangesAsync(CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ITransactionApi.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ITransactionApi.cs index 6bd78cc824..01a506abe3 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ITransactionApi.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ITransactionApi.cs @@ -5,8 +5,6 @@ namespace Volo.Abp.Uow { public interface ITransactionApi : IDisposable { - void Commit(); - Task CommitAsync(); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs index 05f49df180..b42b745fb4 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs @@ -302,15 +302,7 @@ namespace Volo.Abp.Uow } } } - - protected virtual void CommitTransactions() - { - foreach (var transaction in GetAllActiveTransactionApis()) - { - transaction.Commit(); - } - } - + protected virtual async Task CommitTransactionsAsync() { foreach (var transaction in GetAllActiveTransactionApis()) diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkAttribute.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkAttribute.cs index 2dee2cd390..936b2dbb8b 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkAttribute.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkAttribute.cs @@ -22,7 +22,7 @@ namespace Volo.Abp.Uow /// Timeout of UOW As milliseconds. /// Uses default value if not supplied. /// - public TimeSpan? Timeout { get; set; } + public int? Timeout { get; set; } /// /// If this UOW is transactional, this option indicated the isolation level of the transaction. @@ -39,7 +39,7 @@ namespace Volo.Abp.Uow public UnitOfWorkAttribute() { - + } public UnitOfWorkAttribute(bool isTransactional) @@ -53,7 +53,7 @@ namespace Volo.Abp.Uow IsolationLevel = isolationLevel; } - public UnitOfWorkAttribute(bool isTransactional, IsolationLevel isolationLevel, TimeSpan timeout) + public UnitOfWorkAttribute(bool isTransactional, IsolationLevel isolationLevel, int timeout) { IsTransactional = isTransactional; IsolationLevel = isolationLevel; diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs index a0c52a49f4..f4f720095f 100644 --- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs +++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs @@ -8,11 +8,11 @@ namespace Volo.Abp.Uow { [NotNull] public static IUnitOfWork Begin( - [NotNull] this IUnitOfWorkManager unitOfWorkManager, + [NotNull] this IUnitOfWorkManager unitOfWorkManager, bool requiresNew = false, bool isTransactional = false, - IsolationLevel? isolationLevel = null, - TimeSpan? timeout = null) + IsolationLevel? isolationLevel = null, + int? timeout = null) { Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager)); @@ -40,4 +40,4 @@ namespace Volo.Abp.Uow unitOfWorkManager.TryBeginReserved(reservationName, new AbpUnitOfWorkOptions()); } } -} \ No newline at end of file +} diff --git a/modules/blogging/Volo.Blogging.sln b/modules/blogging/Volo.Blogging.sln index 454f1e6a96..607d2c3b1b 100644 --- a/modules/blogging/Volo.Blogging.sln +++ b/modules/blogging/Volo.Blogging.sln @@ -43,6 +43,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Blogging.MongoDB.Tests EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Blogging.Domain.Tests", "test\Volo.Blogging.Domain.Tests\Volo.Blogging.Domain.Tests.csproj", "{B6D7EF20-9921-490A-AA95-47E3E174DC9B}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "admin-app", "admin-app", "{BE2A423C-271E-469A-AD90-5640DEBEE9C1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "domain", "domain", "{A9EF3061-5205-46C7-ACAA-23931CB98E4F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "public-app", "public-app", "{1314C122-18F0-4C6B-895F-27645B6121FF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Blogging.Admin.Application.Contracts", "src\Volo.Blogging.Admin.Application.Contracts\Volo.Blogging.Admin.Application.Contracts.csproj", "{D8DF4D56-644E-4ADF-9DB9-712DDA62B129}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Blogging.Admin.Application", "src\Volo.Blogging.Admin.Application\Volo.Blogging.Admin.Application.csproj", "{CB5DEBB3-5C2E-48E9-AA42-497575BCC7A4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Blogging.Admin.HttpApi", "src\Volo.Blogging.Admin.HttpApi\Volo.Blogging.Admin.HttpApi.csproj", "{59BBAF94-CC8E-4313-9143-F2F5C36A7C45}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Blogging.Admin.HttpApi.Client", "src\Volo.Blogging.Admin.HttpApi.Client\Volo.Blogging.Admin.HttpApi.Client.csproj", "{58A63CC9-C886-448B-AB4E-068600294D86}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Blogging.Admin.Web", "src\Volo.Blogging.Admin.Web\Volo.Blogging.Admin.Web.csproj", "{DB75CA32-96A5-4D10-8DD0-E62A3D0DDBCB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -117,28 +133,56 @@ Global {B6D7EF20-9921-490A-AA95-47E3E174DC9B}.Debug|Any CPU.Build.0 = Debug|Any CPU {B6D7EF20-9921-490A-AA95-47E3E174DC9B}.Release|Any CPU.ActiveCfg = Release|Any CPU {B6D7EF20-9921-490A-AA95-47E3E174DC9B}.Release|Any CPU.Build.0 = Release|Any CPU + {D8DF4D56-644E-4ADF-9DB9-712DDA62B129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8DF4D56-644E-4ADF-9DB9-712DDA62B129}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8DF4D56-644E-4ADF-9DB9-712DDA62B129}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8DF4D56-644E-4ADF-9DB9-712DDA62B129}.Release|Any CPU.Build.0 = Release|Any CPU + {CB5DEBB3-5C2E-48E9-AA42-497575BCC7A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CB5DEBB3-5C2E-48E9-AA42-497575BCC7A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CB5DEBB3-5C2E-48E9-AA42-497575BCC7A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CB5DEBB3-5C2E-48E9-AA42-497575BCC7A4}.Release|Any CPU.Build.0 = Release|Any CPU + {59BBAF94-CC8E-4313-9143-F2F5C36A7C45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {59BBAF94-CC8E-4313-9143-F2F5C36A7C45}.Debug|Any CPU.Build.0 = Debug|Any CPU + {59BBAF94-CC8E-4313-9143-F2F5C36A7C45}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59BBAF94-CC8E-4313-9143-F2F5C36A7C45}.Release|Any CPU.Build.0 = Release|Any CPU + {58A63CC9-C886-448B-AB4E-068600294D86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {58A63CC9-C886-448B-AB4E-068600294D86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {58A63CC9-C886-448B-AB4E-068600294D86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {58A63CC9-C886-448B-AB4E-068600294D86}.Release|Any CPU.Build.0 = Release|Any CPU + {DB75CA32-96A5-4D10-8DD0-E62A3D0DDBCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DB75CA32-96A5-4D10-8DD0-E62A3D0DDBCB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DB75CA32-96A5-4D10-8DD0-E62A3D0DDBCB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DB75CA32-96A5-4D10-8DD0-E62A3D0DDBCB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {F1D954AD-001A-4533-A8CC-94DDCF70B552} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} - {9F3AECDD-0B96-4EB4-BB86-59B488350B76} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} - {237BF49B-5FD8-413C-BBD7-2313D91D0553} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} - {1678D922-E56D-4D6F-94F5-12AD13C1D919} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} - {87A423C6-900E-4D59-A4F2-B7C49D91E6F0} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} - {C20F42B4-0E93-43D3-B7CD-363D7E1B4750} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} - {03328648-6DE6-43C1-9A27-64771A73FAAD} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} - {A4DBA051-7FB9-4AD7-B9B7-6810B2268122} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} {0D50B2EE-5F62-4C1D-B04D-56BE0CF75967} = {EB4FB44A-FE39-4245-9DAD-D6437BCE3870} {14409939-5A35-4145-A5C4-F3AED1617243} = {EB4FB44A-FE39-4245-9DAD-D6437BCE3870} {BBE8D8BE-1B24-49FE-86EF-3848D4BB6829} = {25B3A516-5C0D-42E3-9294-E8A9346CEE4B} {0B9AAD44-1FCF-4AF1-838F-A09446E98E37} = {25B3A516-5C0D-42E3-9294-E8A9346CEE4B} {C949B953-80B3-4B36-B535-1AD74A34FEAC} = {25B3A516-5C0D-42E3-9294-E8A9346CEE4B} - {98C2D36A-F874-405D-8565-9CE59438E879} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} {4C818374-2DE8-422F-8585-975E8366DB26} = {EB4FB44A-FE39-4245-9DAD-D6437BCE3870} {0A29F64C-11F1-40B6-8E6D-91E86823775E} = {25B3A516-5C0D-42E3-9294-E8A9346CEE4B} {B6D7EF20-9921-490A-AA95-47E3E174DC9B} = {25B3A516-5C0D-42E3-9294-E8A9346CEE4B} + {BE2A423C-271E-469A-AD90-5640DEBEE9C1} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} + {A9EF3061-5205-46C7-ACAA-23931CB98E4F} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} + {1314C122-18F0-4C6B-895F-27645B6121FF} = {42BF26EF-B8C7-42DC-9FFB-3653109B7776} + {9F3AECDD-0B96-4EB4-BB86-59B488350B76} = {A9EF3061-5205-46C7-ACAA-23931CB98E4F} + {F1D954AD-001A-4533-A8CC-94DDCF70B552} = {A9EF3061-5205-46C7-ACAA-23931CB98E4F} + {87A423C6-900E-4D59-A4F2-B7C49D91E6F0} = {A9EF3061-5205-46C7-ACAA-23931CB98E4F} + {98C2D36A-F874-405D-8565-9CE59438E879} = {A9EF3061-5205-46C7-ACAA-23931CB98E4F} + {1678D922-E56D-4D6F-94F5-12AD13C1D919} = {1314C122-18F0-4C6B-895F-27645B6121FF} + {237BF49B-5FD8-413C-BBD7-2313D91D0553} = {1314C122-18F0-4C6B-895F-27645B6121FF} + {C20F42B4-0E93-43D3-B7CD-363D7E1B4750} = {1314C122-18F0-4C6B-895F-27645B6121FF} + {03328648-6DE6-43C1-9A27-64771A73FAAD} = {1314C122-18F0-4C6B-895F-27645B6121FF} + {A4DBA051-7FB9-4AD7-B9B7-6810B2268122} = {1314C122-18F0-4C6B-895F-27645B6121FF} + {D8DF4D56-644E-4ADF-9DB9-712DDA62B129} = {BE2A423C-271E-469A-AD90-5640DEBEE9C1} + {CB5DEBB3-5C2E-48E9-AA42-497575BCC7A4} = {BE2A423C-271E-469A-AD90-5640DEBEE9C1} + {59BBAF94-CC8E-4313-9143-F2F5C36A7C45} = {BE2A423C-271E-469A-AD90-5640DEBEE9C1} + {58A63CC9-C886-448B-AB4E-068600294D86} = {BE2A423C-271E-469A-AD90-5640DEBEE9C1} + {DB75CA32-96A5-4D10-8DD0-E62A3D0DDBCB} = {BE2A423C-271E-469A-AD90-5640DEBEE9C1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F2BAE819-78D4-407A-9201-22473B2850B0} diff --git a/modules/blogging/app/Volo.BloggingTestApp/BloggingTestAppModule.cs b/modules/blogging/app/Volo.BloggingTestApp/BloggingTestAppModule.cs index 8d57cb8aee..3d37192145 100644 --- a/modules/blogging/app/Volo.BloggingTestApp/BloggingTestAppModule.cs +++ b/modules/blogging/app/Volo.BloggingTestApp/BloggingTestAppModule.cs @@ -33,6 +33,7 @@ using Volo.Abp.Threading; using Volo.Abp.UI; using Volo.Abp.VirtualFileSystem; using Volo.Blogging; +using Volo.Blogging.Admin; using Volo.Blogging.Files; using Volo.BloggingTestApp.EntityFrameworkCore; using Volo.BloggingTestApp.MongoDB; @@ -42,6 +43,8 @@ namespace Volo.BloggingTestApp [DependsOn( typeof(BloggingWebModule), typeof(BloggingApplicationModule), + typeof(BloggingAdminWebModule), + typeof(BloggingAdminApplicationModule), #if MONGODB typeof(BloggingTestAppMongoDbModule), #else @@ -105,12 +108,12 @@ namespace Volo.BloggingTestApp options.CustomSchemaIds(type => type.FullName); }); - var cultures = new List - { - new CultureInfo("cs"), - new CultureInfo("en"), - new CultureInfo("tr"), - new CultureInfo("zh-Hans") + var cultures = new List + { + new CultureInfo("cs"), + new CultureInfo("en"), + new CultureInfo("tr"), + new CultureInfo("zh-Hans") }; Configure(options => diff --git a/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj b/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj index a677553ee5..6e269e702a 100644 --- a/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj +++ b/modules/blogging/app/Volo.BloggingTestApp/Volo.BloggingTestApp.csproj @@ -26,6 +26,8 @@ + + diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/FodyWeavers.xml b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/FodyWeavers.xsd b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo.Blogging.Admin.Application.Contracts.csproj b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo.Blogging.Admin.Application.Contracts.csproj new file mode 100644 index 0000000000..e7f7b6a8b5 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo.Blogging.Admin.Application.Contracts.csproj @@ -0,0 +1,31 @@ + + + + + + + netstandard2.0 + Volo.Blogging.Admin.Application.Contracts + Volo.Blogging.Admin.Application.Contracts + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminApplicationContractsModule.cs b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminApplicationContractsModule.cs new file mode 100644 index 0000000000..b2b6d000c0 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminApplicationContractsModule.cs @@ -0,0 +1,25 @@ +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; +using Volo.Blogging.Localization; + +namespace Volo.Blogging.Admin +{ + [DependsOn(typeof(BloggingDomainSharedModule))] + public class BloggingAdminApplicationContractsModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + Configure(options => + { + options.Resources + .Get() + .AddVirtualJson("Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts"); + }); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminPermissionDefinitionProvider.cs b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminPermissionDefinitionProvider.cs new file mode 100644 index 0000000000..77c8f98e62 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminPermissionDefinitionProvider.cs @@ -0,0 +1,25 @@ +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; +using Volo.Blogging.Localization; + +namespace Volo.Blogging.Admin +{ + public class BloggingAdminPermissionDefinitionProvider : PermissionDefinitionProvider + { + public override void Define(IPermissionDefinitionContext context) + { + var bloggingGroup = context.AddGroup(BloggingAdminPermissions.GroupName, L("Permission:BloggingAdmin")); + + var blogs = bloggingGroup.AddPermission(BloggingAdminPermissions.Blogs.Default, L("Permission:Blogs")); + blogs.AddChild(BloggingAdminPermissions.Blogs.Management, L("Permission:Management")); + blogs.AddChild(BloggingAdminPermissions.Blogs.Update, L("Permission:Edit")); + blogs.AddChild(BloggingAdminPermissions.Blogs.Delete, L("Permission:Delete")); + blogs.AddChild(BloggingAdminPermissions.Blogs.Create, L("Permission:Create")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminPermissions.cs b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminPermissions.cs new file mode 100644 index 0000000000..9150af601b --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminPermissions.cs @@ -0,0 +1,23 @@ +using Volo.Abp.Reflection; + +namespace Volo.Blogging.Admin +{ + public class BloggingAdminPermissions + { + public const string GroupName = "Blogging.Admin"; + + public static class Blogs + { + public const string Default = GroupName + ".Blog"; + public const string Management = Default + ".Management"; + public const string Delete = Default + ".Delete"; + public const string Update = Default + ".Update"; + public const string Create = Default + ".Create"; + } + + public static string[] GetAll() + { + return ReflectionHelper.GetPublicConstantsRecursively(typeof(BloggingAdminPermissions)); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminRemoteServiceConsts.cs b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminRemoteServiceConsts.cs new file mode 100644 index 0000000000..1c4282adad --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/BloggingAdminRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Blogging.Admin +{ + public static class BloggingAdminRemoteServiceConsts + { + public const string RemoteServiceName = "BloggingAdmin"; + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/BlogDto.cs b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/BlogDto.cs new file mode 100644 index 0000000000..38b87e277c --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/BlogDto.cs @@ -0,0 +1,14 @@ +using System; +using Volo.Abp.Application.Dtos; + +namespace Volo.Blogging.Admin.Blogs +{ + public class BlogDto : FullAuditedEntityDto + { + public string Name { get; set; } + + public string ShortName { get; set; } + + public string Description { get; set; } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/Dtos/CreateBlogDto.cs b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/CreateBlogDto.cs similarity index 82% rename from modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/Dtos/CreateBlogDto.cs rename to modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/CreateBlogDto.cs index 802e271e33..5f47311404 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/Dtos/CreateBlogDto.cs +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/CreateBlogDto.cs @@ -1,4 +1,4 @@ -namespace Volo.Blogging.Blogs.Dtos +namespace Volo.Blogging.Admin.Blogs { public class CreateBlogDto { @@ -8,4 +8,4 @@ namespace Volo.Blogging.Blogs.Dtos public string Description { get; set; } } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/IBlogManagementAppService.cs b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/IBlogManagementAppService.cs new file mode 100644 index 0000000000..3554413d5f --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/IBlogManagementAppService.cs @@ -0,0 +1,20 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace Volo.Blogging.Admin.Blogs +{ + public interface IBlogManagementAppService : IApplicationService + { + Task> GetListAsync(); + + Task GetAsync(Guid id); + + Task CreateAsync(CreateBlogDto input); + + Task UpdateAsync(Guid id, UpdateBlogDto input); + + Task DeleteAsync(Guid id); + } +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/Dtos/UpdateBlogDto.cs b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/UpdateBlogDto.cs similarity index 81% rename from modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/Dtos/UpdateBlogDto.cs rename to modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/UpdateBlogDto.cs index 2e3b0b7b4e..529ace6e0d 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/Dtos/UpdateBlogDto.cs +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Blogs/UpdateBlogDto.cs @@ -1,4 +1,4 @@ -namespace Volo.Blogging.Blogs.Dtos +namespace Volo.Blogging.Admin.Blogs { public class UpdateBlogDto { @@ -8,4 +8,4 @@ public string Description { get; set; } } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/cs.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/cs.json new file mode 100644 index 0000000000..1c8657c85c --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/cs.json @@ -0,0 +1,11 @@ +{ + "culture": "cs", + "texts": { + "Permission:BloggingAdmin": "Blog", + "Permission:Blogs": "Blogy", + "Permission:Management": "Správa", + "Permission:Edit": "Upravit", + "Permission:Create": "Vytvořit", + "Permission:Delete": "Smazat" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/de.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/de.json new file mode 100644 index 0000000000..5666cbb368 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/de.json @@ -0,0 +1,11 @@ +{ + "culture": "de", + "texts": { + "Permission:BloggingAdmin": "Blog", + "Permission:Blogs": "Blogs", + "Permission:Management": "Verwaltung", + "Permission:Edit": "Bearbeiten", + "Permission:Create": "Erstellen", + "Permission:Delete": "Löschen" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/en.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/en.json new file mode 100644 index 0000000000..f3708eacad --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/en.json @@ -0,0 +1,11 @@ +{ + "culture": "en", + "texts": { + "Permission:BloggingAdmin": "Blogging", + "Permission:Blogs": "Blogs", + "Permission:Management": "Management", + "Permission:Edit": "Edit", + "Permission:Create": "Create", + "Permission:Delete": "Delete" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/nl.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/nl.json new file mode 100644 index 0000000000..c1174611c1 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/nl.json @@ -0,0 +1,11 @@ +{ + "culture": "nl", + "texts": { + "Permission:BloggingAdmin": "Blog", + "Permission:Blogs": "Blogs", + "Permission:Management": "Beheer", + "Permission:Edit": "Bewerk", + "Permission:Create": "Maak aan", + "Permission:Delete": "Verwijder" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/pl-PL.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/pl-PL.json new file mode 100644 index 0000000000..e8f6135456 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/pl-PL.json @@ -0,0 +1,11 @@ +{ + "culture": "pl-PL", + "texts": { + "Permission:BloggingAdmin": "Blog", + "Permission:Blogs": "Blogi", + "Permission:Management": "Zarządzanie", + "Permission:Edit": "Edytuj", + "Permission:Create": "Utwórz", + "Permission:Delete": "Usuń" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/pt-BR.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/pt-BR.json new file mode 100644 index 0000000000..09fd08fe5a --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/pt-BR.json @@ -0,0 +1,11 @@ +{ + "culture": "pt-BR", + "texts": { + "Permission:BloggingAdmin": "Blog", + "Permission:Blogs": "Blogs", + "Permission:Management": "Gerenciamento", + "Permission:Edit": "Editar", + "Permission:Create": "Criar", + "Permission:Delete": "Excluir" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/sl.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/sl.json new file mode 100644 index 0000000000..455c49008c --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/sl.json @@ -0,0 +1,11 @@ +{ + "culture": "sl", + "texts": { + "Permission:BloggingAdmin": "Blog", + "Permission:Blogs": "Blogi", + "Permission:Management": "Upravljanje", + "Permission:Edit": "Urejanje", + "Permission:Create": "Ustvarjanje", + "Permission:Delete": "Brisanje" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/tr.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/tr.json new file mode 100644 index 0000000000..dedb5d3dd6 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/tr.json @@ -0,0 +1,11 @@ +{ + "culture": "tr", + "texts": { + "Permission:BloggingAdmin": "Blog", + "Permission:Blogs": "Bloglar", + "Permission:Management": "Yönetme", + "Permission:Edit": "Düzenle", + "Permission:Create": "Ekle", + "Permission:Delete": "Sil" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/vi.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/vi.json new file mode 100644 index 0000000000..387083b100 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/vi.json @@ -0,0 +1,11 @@ +{ + "culture": "vi", + "texts": { + "Permission:BloggingAdmin": "Blog", + "Permission:Blogs": "Blogs", + "Permission:Management": "Quản lý", + "Permission:Edit": "Sửa", + "Permission:Create": "Tạo", + "Permission:Delete": "Xóa" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/zh-Hans.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/zh-Hans.json new file mode 100644 index 0000000000..a17bb45c09 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/zh-Hans.json @@ -0,0 +1,11 @@ +{ + "culture": "zh-Hans", + "texts": { + "Permission:BloggingAdmin": "博客", + "Permission:Blogs": "博客", + "Permission:Management": "管理", + "Permission:Edit": "编辑", + "Permission:Create": "创建", + "Permission:Delete": "删除" + } + } diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/zh-Hant.json b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/zh-Hant.json new file mode 100644 index 0000000000..2d2d28dcbb --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application.Contracts/Volo/Blogging/Admin/Localization/Resources/Blogging/Admin/ApplicationContracts/zh-Hant.json @@ -0,0 +1,11 @@ +{ + "culture": "zh-Hant", + "texts": { + "Permission:BloggingAdmin": "部落格", + "Permission:Blogs": "部落格", + "Permission:Management": "管理", + "Permission:Edit": "標及", + "Permission:Create": "新增", + "Permission:Delete": "刪除" + } + } diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application/FodyWeavers.xml b/modules/blogging/src/Volo.Blogging.Admin.Application/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application/FodyWeavers.xsd b/modules/blogging/src/Volo.Blogging.Admin.Application/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application/Volo.Blogging.Admin.Application.csproj b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo.Blogging.Admin.Application.csproj new file mode 100644 index 0000000000..cf5354adb9 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo.Blogging.Admin.Application.csproj @@ -0,0 +1,20 @@ + + + + + + + netstandard2.0 + Volo.Blogging.Admin.Application + Volo.Blogging.Admin.Application + + + + + + + + + + + diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminAppServiceBase.cs b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminAppServiceBase.cs new file mode 100644 index 0000000000..4e8ff9d315 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminAppServiceBase.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Application.Services; +using Volo.Blogging.Localization; + +namespace Volo.Blogging.Admin +{ + public abstract class BloggingAdminAppServiceBase : ApplicationService + { + protected BloggingAdminAppServiceBase() + { + ObjectMapperContext = typeof(BloggingAdminApplicationModule); + LocalizationResource = typeof(BloggingResource); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminApplicationAutoMapperProfile.cs b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminApplicationAutoMapperProfile.cs new file mode 100644 index 0000000000..2f2cf74563 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminApplicationAutoMapperProfile.cs @@ -0,0 +1,14 @@ +using AutoMapper; +using Volo.Blogging.Admin.Blogs; +using Volo.Blogging.Blogs; + +namespace Volo.Blogging.Admin +{ + public class BloggingAdminApplicationAutoMapperProfile : Profile + { + public BloggingAdminApplicationAutoMapperProfile() + { + CreateMap(); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminApplicationModule.cs b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminApplicationModule.cs new file mode 100644 index 0000000000..2de8b3af07 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/BloggingAdminApplicationModule.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; +using Volo.Abp.Caching; +using Volo.Abp.Modularity; +using Volo.Blogging.Comments; +using Volo.Blogging.Posts; + +namespace Volo.Blogging.Admin +{ + [DependsOn( + typeof(BloggingDomainModule), + typeof(BloggingAdminApplicationContractsModule), + typeof(AbpCachingModule), + typeof(AbpAutoMapperModule))] + public class BloggingAdminApplicationModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAutoMapperObjectMapper(); + Configure(options => + { + options.AddProfile(validate: true); + }); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/Blogs/BlogManagementAppService.cs b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/Blogs/BlogManagementAppService.cs new file mode 100644 index 0000000000..1df6f52c9b --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Application/Volo/Blogging/Admin/Blogs/BlogManagementAppService.cs @@ -0,0 +1,64 @@ +using Microsoft.AspNetCore.Authorization; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Blogging.Blogs; + +namespace Volo.Blogging.Admin.Blogs +{ + public class BlogManagementAppService : BloggingAdminAppServiceBase, IBlogManagementAppService + { + private readonly IBlogRepository _blogRepository; + + public BlogManagementAppService(IBlogRepository blogRepository) + { + _blogRepository = blogRepository; + } + + public async Task> GetListAsync() + { + var blogs = await _blogRepository.GetListAsync(); + + return new ListResultDto( + ObjectMapper.Map, List>(blogs) + ); + } + + public async Task GetAsync(Guid id) + { + var blog = await _blogRepository.GetAsync(id); + + return ObjectMapper.Map(blog); + } + + [Authorize(BloggingAdminPermissions.Blogs.Create)] + public async Task CreateAsync(CreateBlogDto input) + { + var newBlog = await _blogRepository.InsertAsync(new Blog(GuidGenerator.Create(), input.Name, input.ShortName) + { + Description = input.Description + }); + + return ObjectMapper.Map(newBlog); + } + + [Authorize(BloggingAdminPermissions.Blogs.Update)] + public async Task UpdateAsync(Guid id, UpdateBlogDto input) + { + var blog = await _blogRepository.GetAsync(id); + + blog.SetName(input.Name); + blog.SetShortName(input.ShortName); + blog.Description = input.Description; + + return ObjectMapper.Map(blog); + } + + [Authorize(BloggingAdminPermissions.Blogs.Delete)] + public async Task DeleteAsync(Guid id) + { + await _blogRepository.DeleteAsync(id); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/FodyWeavers.xml b/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/FodyWeavers.xsd b/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/Volo.Blogging.Admin.HttpApi.Client.csproj b/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/Volo.Blogging.Admin.HttpApi.Client.csproj new file mode 100644 index 0000000000..55b11f728d --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/Volo.Blogging.Admin.HttpApi.Client.csproj @@ -0,0 +1,18 @@ + + + + + + + netstandard2.0 + Volo.Blogging.Admin.HttpApi.Client + Volo.Blogging.Admin.HttpApi.Client + + + + + + + + + diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/Volo/Blogging/Admin/BloggingAdminHttpApiClientModule.cs b/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/Volo/Blogging/Admin/BloggingAdminHttpApiClientModule.cs new file mode 100644 index 0000000000..9ccb1b5d15 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client/Volo/Blogging/Admin/BloggingAdminHttpApiClientModule.cs @@ -0,0 +1,19 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Modularity; + +namespace Volo.Blogging.Admin +{ + [DependsOn( + typeof(BloggingAdminApplicationContractsModule), + typeof(AbpHttpClientModule))] + public class BloggingAdminHttpApiClientModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddHttpClientProxies(typeof(BloggingAdminApplicationContractsModule).Assembly, + BloggingAdminRemoteServiceConsts.RemoteServiceName); + } + + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi/FodyWeavers.xml b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi/FodyWeavers.xsd b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo.Blogging.Admin.HttpApi.csproj b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo.Blogging.Admin.HttpApi.csproj new file mode 100644 index 0000000000..e9435610df --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo.Blogging.Admin.HttpApi.csproj @@ -0,0 +1,18 @@ + + + + + + + netcoreapp3.1 + Volo.Blogging.Admin.HttpApi + Volo.Blogging.Admin.HttpApi + + + + + + + + + diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo/Blogging/Admin/BlogManagementController.cs b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo/Blogging/Admin/BlogManagementController.cs new file mode 100644 index 0000000000..782a05a42e --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo/Blogging/Admin/BlogManagementController.cs @@ -0,0 +1,56 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Blogging.Admin.Blogs; + +namespace Volo.Blogging.Admin +{ + [RemoteService(Name = BloggingAdminRemoteServiceConsts.RemoteServiceName)] + [Area("bloggingAdmin")] + [Route("api/blogging/blogs/admin")] + public class BlogManagementController : AbpController, IBlogManagementAppService + { + private readonly IBlogManagementAppService _blogManagementAppService; + + public BlogManagementController(IBlogManagementAppService blogManagementAppService) + { + _blogManagementAppService = blogManagementAppService; + } + + [HttpGet] + public async Task> GetListAsync() + { + return await _blogManagementAppService.GetListAsync(); + } + + [HttpGet] + [Route("{id}")] + public async Task GetAsync(Guid id) + { + return await _blogManagementAppService.GetAsync(id); + } + + [HttpPost] + public async Task CreateAsync(CreateBlogDto input) + { + return await _blogManagementAppService.CreateAsync(input); + } + + [HttpPut] + [Route("{id}")] + public async Task UpdateAsync(Guid id, UpdateBlogDto input) + { + return await _blogManagementAppService.UpdateAsync(id, input); + } + + [HttpDelete] + [Route("{id}")] + public async Task DeleteAsync(Guid id) + { + await _blogManagementAppService.DeleteAsync(id); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo/Blogging/Admin/BloggingAdminHttpApiModule.cs b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo/Blogging/Admin/BloggingAdminHttpApiModule.cs new file mode 100644 index 0000000000..bd88cc14d5 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.HttpApi/Volo/Blogging/Admin/BloggingAdminHttpApiModule.cs @@ -0,0 +1,33 @@ +using Localization.Resources.AbpUi; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Blogging.Localization; +using Microsoft.Extensions.DependencyInjection; + +namespace Volo.Blogging.Admin +{ + [DependsOn( + typeof(BloggingAdminApplicationContractsModule), + typeof(AbpAspNetCoreMvcModule))] + public class BloggingAdminHttpApiModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(BloggingAdminHttpApiModule).Assembly); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes(typeof(AbpUiResource)); + }); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/AbpBloggingAdminWebAutoMapperProfile.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/AbpBloggingAdminWebAutoMapperProfile.cs new file mode 100644 index 0000000000..082daf9bae --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/AbpBloggingAdminWebAutoMapperProfile.cs @@ -0,0 +1,16 @@ +using AutoMapper; +using Volo.Blogging.Admin.Blogs; +using Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs; +using EditModel = Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs.EditModel; + +namespace Volo.Blogging.Admin +{ + public class AbpBloggingAdminWebAutoMapperProfile : Profile + { + public AbpBloggingAdminWebAutoMapperProfile() + { + CreateMap(); + CreateMap(); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Web/BloggingMenuContributor.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminMenuContributor.cs similarity index 58% rename from modules/blogging/src/Volo.Blogging.Web/BloggingMenuContributor.cs rename to modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminMenuContributor.cs index cac26eb312..0058738299 100644 --- a/modules/blogging/src/Volo.Blogging.Web/BloggingMenuContributor.cs +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminMenuContributor.cs @@ -1,13 +1,10 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Localization; -using System.Threading.Tasks; +using System.Threading.Tasks; using Volo.Abp.UI.Navigation; using Volo.Blogging.Localization; -namespace Volo.Blogging +namespace Volo.Blogging.Admin { - public class BloggingMenuContributor : IMenuContributor + public class BloggingAdminMenuContributor : IMenuContributor { public async Task ConfigureMenuAsync(MenuConfigurationContext context) { @@ -21,17 +18,17 @@ namespace Volo.Blogging { var l = context.GetLocalizer(); - if (await context.IsGrantedAsync(BloggingPermissions.Blogs.Management)) + if (await context.IsGrantedAsync(BloggingAdminPermissions.Blogs.Management)) { var managementRootMenuItem = new ApplicationMenuItem("BlogManagement", l["Menu:BlogManagement"]); //TODO: Using the same permission. Reconsider. - if (await context.IsGrantedAsync(BloggingPermissions.Blogs.Management)) + if (await context.IsGrantedAsync(BloggingAdminPermissions.Blogs.Management)) { - managementRootMenuItem.AddItem(new ApplicationMenuItem("BlogManagement.Blogs", l["Menu:Blogs"], "~/Admin/Blogs")); + managementRootMenuItem.AddItem(new ApplicationMenuItem("BlogManagement.Blogs", l["Menu:Blogs"], "~/Blogging/Admin/Blogs")); } - context.Menu.AddItem(managementRootMenuItem); + context.Menu.GetAdministration().AddItem(managementRootMenuItem); } } } diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminWebModule.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminWebModule.cs new file mode 100644 index 0000000000..f62333fb02 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/BloggingAdminWebModule.cs @@ -0,0 +1,53 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc.Localization; +using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.AutoMapper; +using Volo.Abp.Modularity; +using Volo.Abp.UI.Navigation; +using Volo.Abp.VirtualFileSystem; +using Volo.Blogging.Localization; + +namespace Volo.Blogging.Admin +{ + [DependsOn( + typeof(BloggingAdminHttpApiModule), + typeof(AbpAspNetCoreMvcUiBootstrapModule), + typeof(AbpAspNetCoreMvcUiBundlingModule), + typeof(AbpAutoMapperModule) + )] + public class BloggingAdminWebModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + context.Services.PreConfigure(options => + { + options.AddAssemblyResource(typeof(BloggingResource), typeof(BloggingAdminWebModule).Assembly); + }); + + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(BloggingAdminWebModule).Assembly); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.MenuContributors.Add(new BloggingAdminMenuContributor()); + }); + + Configure(options => + { + options.FileSets.AddEmbedded("Volo.Blogging.Admin"); + }); + + context.Services.AddAutoMapperObjectMapper(); + Configure(options => + { + options.AddProfile(validate: true); + }); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/FodyWeavers.xml b/modules/blogging/src/Volo.Blogging.Admin.Web/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/FodyWeavers.xsd b/modules/blogging/src/Volo.Blogging.Admin.Web/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Create.cshtml b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Create.cshtml similarity index 79% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Create.cshtml rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Create.cshtml index ec34de5f29..466c6b9578 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Create.cshtml +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Create.cshtml @@ -1,7 +1,7 @@ @page @using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal -@using Volo.Blogging.Pages.Blog -@model Volo.Blogging.Pages.Admin.Blogs.CreateModel +@inherits Volo.Blogging.Admin.Pages.Blogging.BloggingAdminPage +@model Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs.CreateModel @using Microsoft.AspNetCore.Mvc.Localization @using Volo.Blogging.Localization @inject IHtmlLocalizer L @@ -10,7 +10,7 @@ } - + diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Create.cshtml.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Create.cshtml.cs similarity index 69% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Create.cshtml.cs rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Create.cshtml.cs index f8c40a1b01..b2d89fbd55 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Create.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Create.cshtml.cs @@ -2,23 +2,20 @@ using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Blogging.Admin.Blogs; using Volo.Blogging.Blogs; -using Volo.Blogging.Blogs.Dtos; -using Volo.Blogging.Pages.Blog; -namespace Volo.Blogging.Pages.Admin.Blogs +namespace Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs { - public class CreateModel : BloggingPageModel + public class CreateModel : BloggingAdminPageModel { - private readonly IBlogAppService _blogAppService; + private readonly IBlogManagementAppService _blogAppService; private readonly IAuthorizationService _authorization; [BindProperty] public BlogCreateModalView Blog { get; set; } = new BlogCreateModalView(); - public CreateModel(IBlogAppService blogAppService, IAuthorizationService authorization) + public CreateModel(IBlogManagementAppService blogAppService, IAuthorizationService authorization) { _blogAppService = blogAppService; _authorization = authorization; @@ -26,7 +23,7 @@ namespace Volo.Blogging.Pages.Admin.Blogs public virtual async Task OnGetAsync() { - if (!await _authorization.IsGrantedAsync(BloggingPermissions.Blogs.Create)) + if (!await _authorization.IsGrantedAsync(BloggingAdminPermissions.Blogs.Create)) { return Redirect("/"); } @@ -38,7 +35,7 @@ namespace Volo.Blogging.Pages.Admin.Blogs { var blogDto = ObjectMapper.Map(Blog); - await _blogAppService.Create(blogDto); + await _blogAppService.CreateAsync(blogDto); return NoContent(); } @@ -59,4 +56,4 @@ namespace Volo.Blogging.Pages.Admin.Blogs } } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Edit.cshtml b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Edit.cshtml similarity index 73% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Edit.cshtml rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Edit.cshtml index 0d969aa8ad..7bd42e8549 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Edit.cshtml +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Edit.cshtml @@ -1,7 +1,7 @@ @page @using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal -@using Volo.Blogging.Pages.Blog -@model Volo.Blogging.Pages.Admin.Blogs.EditModel +@inherits Volo.Blogging.Admin.Pages.Blogging.BloggingAdminPage +@model Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs.EditModel @using Microsoft.AspNetCore.Mvc.Localization @using Volo.Blogging.Localization @inject IHtmlLocalizer L @@ -9,8 +9,7 @@ Layout = null; } - - + diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Edit.cshtml.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Edit.cshtml.cs similarity index 74% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Edit.cshtml.cs rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Edit.cshtml.cs index 9c40720261..536810e015 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Edit.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Edit.cshtml.cs @@ -1,20 +1,16 @@ using System; using System.ComponentModel.DataAnnotations; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Blogging.Admin.Blogs; using Volo.Blogging.Blogs; -using Volo.Blogging.Blogs.Dtos; -using Volo.Blogging.Pages.Blog; -using Volo.Blogging.Posts; -namespace Volo.Blogging.Pages.Admin.Blogs +namespace Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs { - public class EditModel : BloggingPageModel + public class EditModel : BloggingAdminPageModel { - private readonly IBlogAppService _blogAppService; + private readonly IBlogManagementAppService _blogAppService; private readonly IAuthorizationService _authorization; [BindProperty(SupportsGet = true)] @@ -23,7 +19,7 @@ namespace Volo.Blogging.Pages.Admin.Blogs [BindProperty] public BlogEditViewModel Blog { get; set; } = new BlogEditViewModel(); - public EditModel(IBlogAppService blogAppService, IAuthorizationService authorization) + public EditModel(IBlogManagementAppService blogAppService, IAuthorizationService authorization) { _blogAppService = blogAppService; _authorization = authorization; @@ -31,7 +27,7 @@ namespace Volo.Blogging.Pages.Admin.Blogs public virtual async Task OnGetAsync() { - if (!await _authorization.IsGrantedAsync(BloggingPermissions.Blogs.Update)) + if (!await _authorization.IsGrantedAsync(BloggingAdminPermissions.Blogs.Update)) { return Redirect("/"); } @@ -45,7 +41,7 @@ namespace Volo.Blogging.Pages.Admin.Blogs public virtual async Task OnPostAsync() { - await _blogAppService.Update(Blog.Id, new UpdateBlogDto() + await _blogAppService.UpdateAsync(Blog.Id, new UpdateBlogDto() { Name = Blog.Name, ShortName = Blog.ShortName, @@ -74,5 +70,5 @@ namespace Volo.Blogging.Pages.Admin.Blogs } } - -} \ No newline at end of file + +} diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Index.cshtml b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Index.cshtml similarity index 72% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Index.cshtml rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Index.cshtml index 43b803aa81..bd0d4a0bfb 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Index.cshtml +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Index.cshtml @@ -1,10 +1,12 @@ @page @using Microsoft.AspNetCore.Authorization +@using Volo.Blogging.Admin +@using Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs @using Volo.Blogging -@using Volo.Blogging.Pages.Blog -@model Volo.Blogging.Pages.Admin.Blogs.IndexModel @using Microsoft.AspNetCore.Mvc.Localization @using Volo.Blogging.Localization +@inherits Volo.Blogging.Admin.Pages.Blogging.BloggingAdminPage +@model IndexModel @inject IHtmlLocalizer L @inject IAuthorizationService Authorization @{ @@ -12,9 +14,11 @@ } @section scripts { - - - + + + + + } @@ -24,7 +28,7 @@

@L["Blogs"]

- @if (await Authorization.IsGrantedAsync(BloggingPermissions.Blogs.Create)) + @if (await Authorization.IsGrantedAsync(BloggingAdminPermissions.Blogs.Create)) { } diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Index.cshtml.cs similarity index 65% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Index.cshtml.cs rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Index.cshtml.cs index 038f2e63f3..22a09389ef 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/Index.cshtml.cs @@ -1,12 +1,10 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; -using Volo.Blogging.Pages.Blog; -namespace Volo.Blogging.Pages.Admin.Blogs +namespace Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs { - public class IndexModel : BloggingPageModel + public class IndexModel : BloggingAdminPageModel { private readonly IAuthorizationService _authorization; @@ -17,7 +15,7 @@ namespace Volo.Blogging.Pages.Admin.Blogs public virtual async Task OnGetAsync() { - if (!await _authorization.IsGrantedAsync(BloggingPermissions.Blogs.Management)) + if (!await _authorization.IsGrantedAsync(BloggingAdminPermissions.Blogs.Management)) { return Redirect("/"); } @@ -25,4 +23,4 @@ namespace Volo.Blogging.Pages.Admin.Blogs return Page(); } } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/create.js b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/create.js similarity index 100% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/create.js rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/create.js diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/edit.js b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/edit.js similarity index 100% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/edit.js rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/edit.js diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/index.js b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/index.js similarity index 85% rename from modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/index.js rename to modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/index.js index c2a18e083d..a89f4cf995 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Admin/Blogs/index.js +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/Blogging/Admin/Blogs/index.js @@ -1,8 +1,8 @@ $(function () { var l = abp.localization.getResource('Blogging'); - var _createModal = new abp.ModalManager(abp.appPath + 'Admin/Blogs/Create'); - var _editModal = new abp.ModalManager(abp.appPath + 'Admin/Blogs/Edit'); + var _createModal = new abp.ModalManager(abp.appPath + 'Blogging/Admin/Blogs/Create'); + var _editModal = new abp.ModalManager(abp.appPath + 'Blogging/Admin/Blogs/Edit'); var _dataTable = $('#BlogsTable').DataTable(abp.libs.datatables.normalizeConfiguration({ processing: true, @@ -14,7 +14,7 @@ autoWidth: false, scrollCollapse: true, order: [[3, "desc"]], - ajax: abp.libs.datatables.createAjax(volo.blogging.blogs.getList), + ajax: abp.libs.datatables.createAjax(volo.blogging.admin.blogManagement.getList), columnDefs: [ { rowAction: { @@ -22,7 +22,7 @@ [ { text: l('Edit'), - visible: abp.auth.isGranted('Blogging.Blog.Update'), + visible: abp.auth.isGranted('Blogging.Admin.Blog.Update'), action: function (data) { _editModal.open({ blogId: data.record.id @@ -31,10 +31,10 @@ }, { text: l('Delete'), - visible: abp.auth.isGranted('Blogging.Blog.Delete'), + visible: abp.auth.isGranted('Blogging.Admin.Blog.Delete'), confirmMessage: function (data) { return l('BlogDeletionWarningMessage') }, action: function (data) { - volo.blogging.blogs + volo.blogging.admin.blogManagement .delete(data.record.id) .then(function () { _dataTable.ajax.reload(); @@ -79,4 +79,4 @@ _dataTable.ajax.reload(); }); -}); \ No newline at end of file +}); diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/BloggingAdminPage.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/BloggingAdminPage.cs new file mode 100644 index 0000000000..819c3aa3cd --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/BloggingAdminPage.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc.Localization; +using Microsoft.AspNetCore.Mvc.Razor.Internal; +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Blogging.Localization; + +namespace Volo.Blogging.Admin.Pages.Blogging +{ + public abstract class BloggingAdminPage : AbpPage + { + [RazorInject] + public IHtmlLocalizer L { get; set; } + + public const string DefaultTitle = "Blogging"; + + public const int MaxShortContentLength = 200; + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/BloggingAdminPageModel.cs b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/BloggingAdminPageModel.cs new file mode 100644 index 0000000000..67951fc08b --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/BloggingAdminPageModel.cs @@ -0,0 +1,12 @@ +using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; + +namespace Volo.Blogging.Admin.Pages +{ + public abstract class BloggingAdminPageModel : AbpPageModel + { + public BloggingAdminPageModel() + { + ObjectMapperContext = typeof(BloggingAdminWebModule); + } + } +} diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/_ViewImports.cshtml b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/_ViewImports.cshtml new file mode 100644 index 0000000000..caae8c9ac5 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Pages/_ViewImports.cshtml @@ -0,0 +1,5 @@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap +@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling +@addTagHelper *, Volo.Blogging.Web \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/Properties/launchSettings.json b/modules/blogging/src/Volo.Blogging.Admin.Web/Properties/launchSettings.json new file mode 100644 index 0000000000..64a5fd912c --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50000/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Volo.Blogging.Web": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:50014/" + } + } +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/Volo.Blogging.Admin.Web.csproj b/modules/blogging/src/Volo.Blogging.Admin.Web/Volo.Blogging.Admin.Web.csproj new file mode 100644 index 0000000000..d15cf9c770 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/Volo.Blogging.Admin.Web.csproj @@ -0,0 +1,34 @@ + + + + + + + netcoreapp3.1 + Volo.Blogging.Admin.Web + Volo.Blogging.Admin.Web + 2.8 + Library + true + Volo.Blogging.Admin + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/compilerconfig.json b/modules/blogging/src/Volo.Blogging.Admin.Web/compilerconfig.json new file mode 100644 index 0000000000..d8e67fbeca --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/compilerconfig.json @@ -0,0 +1,18 @@ +[ + { + "outputFile": "Pages/Blog/Shared/Styles/blog.css", + "inputFile": "Pages/Blog/Shared/Styles/blog.scss" + }, + { + "outputFile": "Pages/Blog/Shared/Styles/_home.css", + "inputFile": "Pages/Blog/Shared/Styles/_home.scss" + }, + { + "outputFile": "Pages/Blog/Posts/Index.css", + "inputFile": "Pages/Blog/Posts/Index.scss" + }, + { + "outputFile": "Pages/Blogs/Shared/Styles/blog.css", + "inputFile": "Pages/Blogs/Shared/Styles/blog.scss" + } +] \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Admin.Web/compilerconfig.json.defaults b/modules/blogging/src/Volo.Blogging.Admin.Web/compilerconfig.json.defaults new file mode 100644 index 0000000000..c75eb7d519 --- /dev/null +++ b/modules/blogging/src/Volo.Blogging.Admin.Web/compilerconfig.json.defaults @@ -0,0 +1,49 @@ +{ + "compilers": { + "less": { + "autoPrefix": "", + "cssComb": "none", + "ieCompat": true, + "strictMath": false, + "strictUnits": false, + "relativeUrls": true, + "rootPath": "", + "sourceMapRoot": "", + "sourceMapBasePath": "", + "sourceMap": false + }, + "sass": { + "includePath": "", + "indentType": "space", + "indentWidth": 2, + "outputStyle": "nested", + "Precision": 5, + "relativeUrls": true, + "sourceMapRoot": "", + "sourceMap": false + }, + "stylus": { + "sourceMap": false + }, + "babel": { + "sourceMap": false + }, + "coffeescript": { + "bare": false, + "runtimeMode": "node", + "sourceMap": false + } + }, + "minifiers": { + "css": { + "enabled": true, + "termSemicolons": true, + "gzip": false + }, + "javascript": { + "enabled": true, + "termSemicolons": true, + "gzip": false + } + } +} \ No newline at end of file diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingPermissionDefinitionProvider.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingPermissionDefinitionProvider.cs index 65a6ab1ab7..6c2361230d 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingPermissionDefinitionProvider.cs +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingPermissionDefinitionProvider.cs @@ -10,12 +10,6 @@ namespace Volo.Blogging { var bloggingGroup = context.AddGroup(BloggingPermissions.GroupName, L("Permission:Blogging")); - var blogs = bloggingGroup.AddPermission(BloggingPermissions.Blogs.Default, L("Permission:Blogs")); - blogs.AddChild(BloggingPermissions.Blogs.Management, L("Permission:Management")); - blogs.AddChild(BloggingPermissions.Blogs.Update, L("Permission:Edit")); - blogs.AddChild(BloggingPermissions.Blogs.Delete, L("Permission:Delete")); - blogs.AddChild(BloggingPermissions.Blogs.Create, L("Permission:Create")); - var posts = bloggingGroup.AddPermission(BloggingPermissions.Posts.Default, L("Permission:Posts")); posts.AddChild(BloggingPermissions.Posts.Update, L("Permission:Edit")); posts.AddChild(BloggingPermissions.Posts.Delete, L("Permission:Delete")); diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingPermissions.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingPermissions.cs index fae85acf88..7aa05452e3 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingPermissions.cs +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/BloggingPermissions.cs @@ -6,15 +6,6 @@ namespace Volo.Blogging { public const string GroupName = "Blogging"; - public static class Blogs - { - public const string Default = GroupName + ".Blog"; - public const string Management = Default + ".Management"; - public const string Delete = Default + ".Delete"; - public const string Update = Default + ".Update"; - public const string Create = Default + ".Create"; - } - public static class Posts { public const string Default = GroupName + ".Post"; diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/IBlogAppService.cs b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/IBlogAppService.cs index fbac86d827..0710101b93 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/IBlogAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Blogs/IBlogAppService.cs @@ -13,11 +13,5 @@ namespace Volo.Blogging.Blogs Task GetByShortNameAsync(string shortName); Task GetAsync(Guid id); - - Task Create(CreateBlogDto input); - - Task Update(Guid id, UpdateBlogDto input); - - Task Delete(Guid id); } } diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/cs.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/cs.json index 5b11dd808c..30063c1d6d 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/cs.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/cs.json @@ -5,10 +5,6 @@ "Permission:Blogs": "Blogy", "Permission:Posts": "Příspěvky", "Permission:Tags": "Tagy", - "Permission:Comments": "Komentáře", - "Permission:Management": "Správa", - "Permission:Edit": "Upravit", - "Permission:Create": "Vytvořit", - "Permission:Delete": "Smazat" + "Permission:Comments": "Komentáře" } } diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/de.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/de.json index 9455b3cd44..9f2a7d4510 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/de.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/de.json @@ -3,12 +3,8 @@ "texts": { "Permission:Blogging": "Blog", "Permission:Blogs": "Blogs", - "Permission:Posts": "Beiträge", + "Permission:Posts": "Beitr�ge", "Permission:Tags": "Tags", - "Permission:Comments": "Kommentare", - "Permission:Management": "Verwaltung", - "Permission:Edit": "Bearbeiten", - "Permission:Create": "Erstellen", - "Permission:Delete": "Löschen" + "Permission:Comments": "Kommentare" } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/en.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/en.json index 425f8733bb..eb70a98276 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/en.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/en.json @@ -5,10 +5,6 @@ "Permission:Blogs": "Blogs", "Permission:Posts": "Posts", "Permission:Tags": "Tags", - "Permission:Comments": "Comments", - "Permission:Management": "Management", - "Permission:Edit": "Edit", - "Permission:Create": "Create", - "Permission:Delete": "Delete" + "Permission:Comments": "Comments" } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/nl.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/nl.json index 7e34f16b79..70440c8470 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/nl.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/nl.json @@ -5,10 +5,6 @@ "Permission:Blogs": "Blogs", "Permission:Posts": "Posts", "Permission:Tags": "Tags", - "Permission:Comments": "Kommentaar", - "Permission:Management": "Beheer", - "Permission:Edit": "Bewerk", - "Permission:Create": "Maak aan", - "Permission:Delete": "Verwijder" + "Permission:Comments": "Kommentaar" } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/pl-PL.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/pl-PL.json index 05ba8451c6..2a223d536b 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/pl-PL.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/pl-PL.json @@ -5,10 +5,6 @@ "Permission:Blogs": "Blogi", "Permission:Posts": "Posty", "Permission:Tags": "Tagi", - "Permission:Comments": "Komentarze", - "Permission:Management": "Zarządzanie", - "Permission:Edit": "Edytuj", - "Permission:Create": "Utwórz", - "Permission:Delete": "Usuń" + "Permission:Comments": "Komentarze" } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/pt-BR.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/pt-BR.json index 364e0303e5..9dd2977079 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/pt-BR.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/pt-BR.json @@ -5,10 +5,6 @@ "Permission:Blogs": "Blogs", "Permission:Posts": "Postagens", "Permission:Tags": "Etiquetas", - "Permission:Comments": "Comentários", - "Permission:Management": "Gerenciamento", - "Permission:Edit": "Editar", - "Permission:Create": "Criar", - "Permission:Delete": "Excluir" + "Permission:Comments": "Comentários" } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/sl.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/sl.json index a834583f0a..cad2be999f 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/sl.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/sl.json @@ -5,10 +5,6 @@ "Permission:Blogs": "Blogi", "Permission:Posts": "Objave", "Permission:Tags": "Oznake", - "Permission:Comments": "Komentarji", - "Permission:Management": "Upravljanje", - "Permission:Edit": "Urejanje", - "Permission:Create": "Ustvarjanje", - "Permission:Delete": "Brisanje" + "Permission:Comments": "Komentarji" } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/tr.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/tr.json index 9444a12b7b..1d158bc664 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/tr.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/tr.json @@ -5,10 +5,6 @@ "Permission:Blogs": "Bloglar", "Permission:Posts": "Yazılar", "Permission:Tags": "Etiketler", - "Permission:Comments": "Yorumlar", - "Permission:Management": "Yönetme", - "Permission:Edit": "Düzenle", - "Permission:Create": "Ekle", - "Permission:Delete": "Sil" + "Permission:Comments": "Yorumlar" } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/vi.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/vi.json index a32ee04bb9..2f65d48fae 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/vi.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/vi.json @@ -5,10 +5,6 @@ "Permission:Blogs": "Blogs", "Permission:Posts": "Bài viết", "Permission:Tags": "Thẻ", - "Permission:Comments": "Bình luận", - "Permission:Management": "Quản lý", - "Permission:Edit": "Sửa", - "Permission:Create": "Tạo", - "Permission:Delete": "Xóa" + "Permission:Comments": "Bình luận" } } diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/zh-Hans.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/zh-Hans.json index 16dd399bc0..afc509cd35 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/zh-Hans.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/zh-Hans.json @@ -1,14 +1,10 @@ { - "culture": "zh-Hans", - "texts": { - "Permission:Blogging": "博客", - "Permission:Blogs": "博客", - "Permission:Posts": "帖子", - "Permission:Tags": "标签", - "Permission:Comments": "评论", - "Permission:Management": "管理", - "Permission:Edit": "编辑", - "Permission:Create": "创建", - "Permission:Delete": "删除" - } - } \ No newline at end of file + "culture": "zh-Hans", + "texts": { + "Permission:Blogging": "博客", + "Permission:Blogs": "博客", + "Permission:Posts": "帖子", + "Permission:Tags": "标签", + "Permission:Comments": "评论" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/zh-Hant.json b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/zh-Hant.json index bca246ba43..487be120e5 100644 --- a/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/zh-Hant.json +++ b/modules/blogging/src/Volo.Blogging.Application.Contracts/Volo/Blogging/Localization/Resources/Blogging/ApplicationContracts/zh-Hant.json @@ -1,14 +1,10 @@ { - "culture": "zh-Hant", - "texts": { - "Permission:Blogging": "部落格", - "Permission:Blogs": "部落格", - "Permission:Posts": "文章", - "Permission:Tags": "標籤", - "Permission:Comments": "評論", - "Permission:Management": "管理", - "Permission:Edit": "標及", - "Permission:Create": "新增", - "Permission:Delete": "刪除" - } - } \ No newline at end of file + "culture": "zh-Hant", + "texts": { + "Permission:Blogging": "部落格", + "Permission:Blogs": "部落格", + "Permission:Posts": "文章", + "Permission:Tags": "標籤", + "Permission:Comments": "評論" + } +} diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs index 88b9a75410..1b0a903d2e 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs @@ -44,34 +44,5 @@ namespace Volo.Blogging.Blogs return ObjectMapper.Map(blog); } - - [Authorize(BloggingPermissions.Blogs.Create)] - public async Task Create(CreateBlogDto input) - { - var newBlog = await _blogRepository.InsertAsync(new Blog(GuidGenerator.Create(), input.Name, input.ShortName) - { - Description = input.Description - }); - - return ObjectMapper.Map(newBlog); - } - - [Authorize(BloggingPermissions.Blogs.Update)] - public async Task Update(Guid id, UpdateBlogDto input) - { - var blog = await _blogRepository.GetAsync(id); - - blog.SetName(input.Name); - blog.SetShortName(input.ShortName); - blog.Description = input.Description; - - return ObjectMapper.Map(blog); - } - - [Authorize(BloggingPermissions.Blogs.Delete)] - public async Task Delete(Guid id) - { - await _blogRepository.DeleteAsync(id); - } } } diff --git a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json index 18f8e00c8a..8ffe3d8fa7 100644 --- a/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json +++ b/modules/blogging/src/Volo.Blogging.Domain.Shared/Volo/Blogging/Localization/Resources/en.json @@ -2,7 +2,7 @@ "culture": "en", "texts": { "Menu:Blogs": "Blogs", - "Menu:BlogManagement": "Blog Management", + "Menu:BlogManagement": "Blogging", "Title": "Title", "Delete": "Delete", "Reply": "Reply", @@ -46,4 +46,4 @@ "ShareOn": "Share on", "TitleLengthWarning": "Keep your title size under 60 characters to be SEO friendly!" } -} \ No newline at end of file +} diff --git a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs index cb67ac3fb7..9ef141b3de 100644 --- a/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs +++ b/modules/blogging/src/Volo.Blogging.HttpApi/Volo/Blogging/BlogsController.cs @@ -40,25 +40,5 @@ namespace Volo.Blogging { return await _blogAppService.GetAsync(id); } - - [HttpPost] - public async Task Create(CreateBlogDto input) - { - return await _blogAppService.Create(input); - } - - [HttpPut] - [Route("{id}")] - public async Task Update(Guid id, UpdateBlogDto input) - { - return await _blogAppService.Update(id, input); - } - - [HttpDelete] - [Route("{id}")] - public async Task Delete(Guid id) - { - await _blogAppService.Delete(id); - } } } diff --git a/modules/blogging/src/Volo.Blogging.Web/AbpBloggingWebAutoMapperProfile.cs b/modules/blogging/src/Volo.Blogging.Web/AbpBloggingWebAutoMapperProfile.cs index ccd4a02953..e5d40c6be3 100644 --- a/modules/blogging/src/Volo.Blogging.Web/AbpBloggingWebAutoMapperProfile.cs +++ b/modules/blogging/src/Volo.Blogging.Web/AbpBloggingWebAutoMapperProfile.cs @@ -1,12 +1,7 @@ using AutoMapper; using Volo.Abp.AutoMapper; -using Volo.Blogging.Blogs; -using Volo.Blogging.Blogs.Dtos; -using Volo.Blogging.Pages.Admin.Blogs; using Volo.Blogging.Pages.Blog.Posts; using Volo.Blogging.Posts; -using EditModel = Volo.Blogging.Pages.Admin.Blogs.EditModel; -using IndexModel = Volo.Blogging.Pages.Blog.IndexModel; namespace Volo.Blogging { @@ -16,8 +11,6 @@ namespace Volo.Blogging { CreateMap().Ignore(x=>x.Tags); CreateMap(); - CreateMap(); - CreateMap(); } } } diff --git a/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs b/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs index 432857686f..e238f48a37 100644 --- a/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs +++ b/modules/blogging/src/Volo.Blogging.Web/BloggingWebModule.cs @@ -37,11 +37,6 @@ namespace Volo.Blogging public override void ConfigureServices(ServiceConfigurationContext context) { - Configure(options => - { - options.MenuContributors.Add(new BloggingMenuContributor()); - }); - Configure(options => { options.FileSets.AddEmbedded("Volo.Blogging"); diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Index.cshtml.cs index 2835b05dc5..32a451c8be 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Index.cshtml.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; @@ -34,4 +33,4 @@ namespace Volo.Blogging.Pages.Blog return Page(); } } -} \ No newline at end of file +} diff --git a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo.Blogging.Application.Tests.csproj b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo.Blogging.Application.Tests.csproj index e41384500b..2bc4009d26 100644 --- a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo.Blogging.Application.Tests.csproj +++ b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo.Blogging.Application.Tests.csproj @@ -11,6 +11,7 @@ + diff --git a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/BlogAppService_Tests.cs b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/BlogAppService_Tests.cs index 7c67db978b..8726330b39 100644 --- a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/BlogAppService_Tests.cs +++ b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/BlogAppService_Tests.cs @@ -1,13 +1,9 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Shouldly; using Volo.Blogging.Blogs; -using Volo.Blogging.Blogs.Dtos; -using Volo.Blogging.Comments; -using Volo.Blogging.Comments.Dtos; using Volo.Blogging.Pages.Blogs.Shared.Helpers; -using Volo.Blogging.Posts; +using Volo.Blogging.Admin.Blogs; using Xunit; namespace Volo.Blogging @@ -15,11 +11,13 @@ namespace Volo.Blogging public class BlogAppService_Tests : BloggingApplicationTestBase { private readonly IBlogAppService _blogAppService; + private readonly IBlogManagementAppService _blogManagementAppService; private readonly IBlogRepository _blogRepository; public BlogAppService_Tests() { _blogAppService = GetRequiredService(); + _blogManagementAppService = GetRequiredService(); _blogRepository = GetRequiredService(); } @@ -68,7 +66,7 @@ namespace Volo.Blogging var shortName = "test shortName"; var description = "test description"; - var blogDto = await _blogAppService.Create(new CreateBlogDto() { Name = name, ShortName = name, Description = description }); + var blogDto = await _blogManagementAppService.CreateAsync(new CreateBlogDto() { Name = name, ShortName = name, Description = description }); UsingDbContext(context => { @@ -85,9 +83,9 @@ namespace Volo.Blogging { var newDescription = "new description"; - var oldBlog = (await _blogRepository.GetListAsync()).FirstOrDefault(); ; + var oldBlog = (await _blogManagementAppService.GetListAsync()).Items.FirstOrDefault(); ; - await _blogAppService.Update(oldBlog.Id, new UpdateBlogDto() + await _blogManagementAppService.UpdateAsync(oldBlog.Id, new UpdateBlogDto() { Description = newDescription, Name = oldBlog.Name, ShortName = oldBlog.ShortName }); UsingDbContext(context => @@ -102,7 +100,7 @@ namespace Volo.Blogging { var blog = (await _blogRepository.GetListAsync()).First(); - await _blogAppService.Delete(blog.Id); + await _blogManagementAppService.DeleteAsync(blog.Id); } } } diff --git a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/BloggingApplicationTestModule.cs b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/BloggingApplicationTestModule.cs index ab2cbd12dd..fb3934ee5f 100644 --- a/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/BloggingApplicationTestModule.cs +++ b/modules/blogging/test/Volo.Blogging.Application.Tests/Volo/Blogging/BloggingApplicationTestModule.cs @@ -1,11 +1,13 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; +using Volo.Blogging.Admin; using Volo.Blogging.EntityFrameworkCore; namespace Volo.Blogging { [DependsOn( typeof(BloggingApplicationModule), + typeof(BloggingAdminApplicationModule), typeof(BloggingEntityFrameworkCoreTestModule), typeof(BloggingTestBaseModule))] public class BloggingApplicationTestModule : AbpModule 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 a68552d653..a184226117 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 @@ -9,6 +9,8 @@ namespace Volo.Abp.Identity { Task> GetRolesAsync(Guid id); + Task> GetAssignableRolesAsync(); + Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input); Task FindByUsernameAsync(string username); 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 166d71fa5e..74b210066f 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 @@ -12,13 +12,16 @@ namespace Volo.Abp.Identity { protected IdentityUserManager UserManager { get; } protected IIdentityUserRepository UserRepository { get; } + public IIdentityRoleRepository RoleRepository { get; } public IdentityUserAppService( IdentityUserManager userManager, - IIdentityUserRepository userRepository) + IIdentityUserRepository userRepository, + IIdentityRoleRepository roleRepository) { UserManager = userManager; UserRepository = userRepository; + RoleRepository = roleRepository; } //TODO: [Authorize(IdentityPermissions.Users.Default)] should go the IdentityUserAppService class. @@ -54,6 +57,14 @@ namespace Volo.Abp.Identity ); } + [Authorize(IdentityPermissions.Users.Default)] + public virtual async Task> GetAssignableRolesAsync() + { + var list = await RoleRepository.GetListAsync(); + return new ListResultDto( + ObjectMapper.Map, List>(list)); + } + [Authorize(IdentityPermissions.Users.Create)] public virtual async Task CreateAsync(IdentityUserCreateDto input) { @@ -92,7 +103,7 @@ namespace Volo.Abp.Identity (await UserManager.RemovePasswordAsync(user)).CheckErrors(); (await UserManager.AddPasswordAsync(user, input.Password)).CheckErrors(); } - + await CurrentUnitOfWork.SaveChangesAsync(); return ObjectMapper.Map(user); 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 b9b02a7150..1281135526 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 @@ -59,6 +59,13 @@ namespace Volo.Abp.Identity return UserAppService.GetRolesAsync(id); } + [HttpGet] + [Route("assignable-roles")] + public Task> GetAssignableRolesAsync() + { + return UserAppService.GetAssignableRolesAsync(); + } + [HttpPut] [Route("{id}/roles")] public virtual Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input) diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs index 9622d87de2..e7a1f4a26d 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs @@ -17,19 +17,17 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users public AssignedRoleViewModel[] Roles { get; set; } protected IIdentityUserAppService IdentityUserAppService { get; } - protected IIdentityRoleAppService IdentityRoleAppService { get; } - public CreateModalModel(IIdentityUserAppService identityUserAppService, IIdentityRoleAppService identityRoleAppService) + public CreateModalModel(IIdentityUserAppService identityUserAppService) { IdentityUserAppService = identityUserAppService; - IdentityRoleAppService = identityRoleAppService; } public virtual async Task OnGetAsync() { UserInfo = new UserInfoViewModel(); - var roleDtoList = (await IdentityRoleAppService.GetAllListAsync()).Items; + var roleDtoList = (await IdentityUserAppService.GetAssignableRolesAsync()).Items; Roles = ObjectMapper.Map, AssignedRoleViewModel[]>(roleDtoList); diff --git a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs index 7ffb58ccab..f14ec21fe6 100644 --- a/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs +++ b/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs @@ -19,19 +19,17 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users public AssignedRoleViewModel[] Roles { get; set; } protected IIdentityUserAppService IdentityUserAppService { get; } - protected IIdentityRoleAppService IdentityRoleAppService { get; } - public EditModalModel(IIdentityUserAppService identityUserAppService, IIdentityRoleAppService identityRoleAppService) + public EditModalModel(IIdentityUserAppService identityUserAppService) { IdentityUserAppService = identityUserAppService; - IdentityRoleAppService = identityRoleAppService; } public virtual async Task OnGetAsync(Guid id) { UserInfo = ObjectMapper.Map(await IdentityUserAppService.GetAsync(id)); - Roles = ObjectMapper.Map, AssignedRoleViewModel[]>((await IdentityRoleAppService.GetAllListAsync()).Items); + Roles = ObjectMapper.Map, AssignedRoleViewModel[]>((await IdentityUserAppService.GetAssignableRolesAsync()).Items); var userRoleNames = (await IdentityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList(); foreach (var role in Roles) @@ -101,4 +99,4 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users public bool IsAssigned { get; set; } } } -} \ No newline at end of file +} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerBuilderExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerBuilderExtensions.cs index 6719192fdd..81f4b8b629 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerBuilderExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerBuilderExtensions.cs @@ -1,9 +1,14 @@ -using System; +using System; using System.IdentityModel.Tokens.Jwt; +using System.IO; +using System.Security.Cryptography; using IdentityModel; +using IdentityServer4; +using IdentityServer4.Configuration; using IdentityServer4.Services; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using Newtonsoft.Json.Linq; using Volo.Abp.Identity; using Volo.Abp.IdentityServer.AspNetIdentity; using Volo.Abp.Security.Claims; @@ -49,5 +54,78 @@ namespace Volo.Abp.IdentityServer return builder; } + + public static IIdentityServerBuilder AddAbpDeveloperSigningCredential( + this IIdentityServerBuilder builder, + bool persistKey = true, + string filename = null, + IdentityServerConstants.RsaSigningAlgorithm signingAlgorithm = IdentityServerConstants.RsaSigningAlgorithm.RS256) + { + if (filename == null) + { + filename = Path.Combine(Directory.GetCurrentDirectory(), "tempkey.rsa"); + } + + if (File.Exists(filename)) + { + var keyFile = File.ReadAllText(filename); + + var json = JObject.Parse(keyFile); + var keyId = json.GetValue("KeyId").Value(); + var jsonParameters = json.GetValue("Parameters"); + RSAParameters rsaParameters; + rsaParameters.D = Convert.FromBase64String(jsonParameters["D"].Value()); + rsaParameters.DP = Convert.FromBase64String(jsonParameters["DP"].Value()); + rsaParameters.DQ = Convert.FromBase64String(jsonParameters["DQ"].Value()); + rsaParameters.Exponent = Convert.FromBase64String(jsonParameters["Exponent"].Value()); + rsaParameters.InverseQ = Convert.FromBase64String(jsonParameters["InverseQ"].Value()); + rsaParameters.Modulus = Convert.FromBase64String(jsonParameters["Modulus"].Value()); + rsaParameters.P = Convert.FromBase64String(jsonParameters["P"].Value()); + rsaParameters.Q = Convert.FromBase64String(jsonParameters["Q"].Value()); + + return builder.AddSigningCredential(CryptoHelper.CreateRsaSecurityKey(rsaParameters, keyId), signingAlgorithm); + } + else + { + var key = CryptoHelper.CreateRsaSecurityKey(); + + RSAParameters parameters; + + if (key.Rsa != null) + { + parameters = key.Rsa.ExportParameters(includePrivateParameters: true); + } + else + { + parameters = key.Parameters; + } + + var jObject = new JObject + { + { + "KeyId", key.KeyId + }, + { + "Parameters", new JObject + { + {"D", Convert.ToBase64String(parameters.D)}, + {"DP", Convert.ToBase64String(parameters.DP)}, + {"DQ", Convert.ToBase64String(parameters.DQ)}, + {"Exponent", Convert.ToBase64String(parameters.Exponent)}, + {"InverseQ", Convert.ToBase64String(parameters.InverseQ)}, + {"Modulus", Convert.ToBase64String(parameters.Modulus)}, + {"P", Convert.ToBase64String(parameters.P)}, + {"Q", Convert.ToBase64String(parameters.Q)} + } + } + }; + + if (persistKey) + { + File.WriteAllText(filename, jObject.ToString()); + } + return builder.AddSigningCredential(key, signingAlgorithm); + } + } } -} \ No newline at end of file +} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs index 95c8eec537..01001aeb35 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs @@ -67,7 +67,7 @@ namespace Volo.Abp.IdentityServer if (builderOptions.AddDeveloperSigningCredential) { - identityServerBuilder = identityServerBuilder.AddDeveloperSigningCredential(); + identityServerBuilder = identityServerBuilder.AddAbpDeveloperSigningCredential(); } identityServerBuilder.AddAbpIdentityServer(builderOptions); diff --git a/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/package.json b/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/package.json index 2fccd8b3bc..d92848c918 100644 --- a/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/package.json +++ b/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/package.json @@ -4,8 +4,6 @@ "private": true, "dependencies": { "@abp/aspnetcore.mvc.ui.theme.basic": "^2.7.0", - "@abp/virtual-file-explorer": "^2.7.0", - "@abp/clipboard": "^2.7.0", - "@abp/prismjs": "^2.7.0" + "@abp/virtual-file-explorer": "^2.7.0" } } diff --git a/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/yarn.lock b/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/yarn.lock index 6b7a5aca41..5c5cc57094 100644 --- a/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/yarn.lock +++ b/modules/virtual-file-explorer/app/Volo.Abp.VirtualFileExplorer.DemoApp/yarn.lock @@ -56,12 +56,12 @@ "@abp/core" "^2.7.0" bootstrap "^4.3.1" -"@abp/clipboard@^2.7.0": - version "2.7.0" - resolved "https://registry.yarnpkg.com/@abp/clipboard/-/clipboard-2.7.0.tgz#8f4b7aafae369759315481e5a331a832e61cc602" - integrity sha512-kPIASn3WPlpIUiluWPy1eIGKRZcueDGBz9K6houqyvPwspMpc0C+LtqN917svsYq4sAsaPFyGi3VfJE5lm4KZw== +"@abp/clipboard@^2.9.0": + version "2.9.0" + resolved "https://registry.yarnpkg.com/@abp/clipboard/-/clipboard-2.9.0.tgz#b6d7180fbe3d8043e71b182ee620efa4877b8cf6" + integrity sha512-1rGd0PTQRWUUn2KkfOZF+2pp7rw7iSV5nUGOJ3sdTc/rLiH8tKv8FL4Sdj9EfaCiU8QVwDVmLtd5Kt6fLxeKDg== dependencies: - "@abp/core" "^2.7.0" + "@abp/core" "^2.9.0" clipboard "^2.0.4" "@abp/core@^2.7.0": @@ -71,6 +71,13 @@ dependencies: "@abp/utils" "^2.7.0" +"@abp/core@^2.9.0": + version "2.9.0" + resolved "https://registry.yarnpkg.com/@abp/core/-/core-2.9.0.tgz#5460925a121c88f8afb69dbce65da1cd4257b024" + integrity sha512-6Hn6dPN47kqmJF0VbxNcDu370oNZPTlEGMm1dQcgM31DvOMS8ICy/4thxNYTTEr0DN9chujkw38aHFd2XqyBnw== + dependencies: + "@abp/utils" "^2.9.0" + "@abp/datatables.net-bs4@^2.7.0": version "2.7.0" resolved "https://registry.yarnpkg.com/@abp/datatables.net-bs4/-/datatables.net-bs4-2.7.0.tgz#a113ca6f02b63b57e678a3b12fc06c2daa4eaff6" @@ -150,12 +157,13 @@ "@abp/core" "^2.7.0" malihu-custom-scrollbar-plugin "^3.1.5" -"@abp/prismjs@^2.7.0": - version "2.7.0" - resolved "https://registry.yarnpkg.com/@abp/prismjs/-/prismjs-2.7.0.tgz#32794af1d83b19dd49b62f41cd2414fe021be70a" - integrity sha512-RIe+Q39R0kNInkmE7TrqyCVqk+SWFQNyjHRVkqJkdj2lqfs3mIg10EwRQxDLg2KdOutEaSaK05TEEwwFSjGx8A== +"@abp/prismjs@^2.9.0": + version "2.9.0" + resolved "https://registry.yarnpkg.com/@abp/prismjs/-/prismjs-2.9.0.tgz#d82ba6a5f03a09c4cc6697b3ae47955d3b4bbc20" + integrity sha512-WErltCoD6N1NTUTY9936OKzLjM/5lUJlB/utFs4gxR7yrtImW9ryUsjkRbIy42taZ+FkkB+suDDwa5g/9hujBA== dependencies: - "@abp/core" "^2.7.0" + "@abp/clipboard" "^2.9.0" + "@abp/core" "^2.9.0" prismjs "^1.17.1" "@abp/select2@^2.7.0": @@ -197,6 +205,21 @@ dependencies: just-compare "^1.3.0" +"@abp/utils@^2.9.0": + version "2.9.0" + resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-2.9.0.tgz#8a66b7e1d422eae5898d32af7810d6bd625276f2" + integrity sha512-0gvWUH3jT7YE4ym2C45uKDzHs/oOdMW5lPq9ncCZ58wMxTrgPvxXNuMmRW0P259OcXYiRwmsNtb09/WlTQQbKA== + dependencies: + just-compare "^1.3.0" + +"@abp/virtual-file-explorer@^2.7.0": + version "2.9.0" + resolved "https://registry.yarnpkg.com/@abp/virtual-file-explorer/-/virtual-file-explorer-2.9.0.tgz#a55b94c8beafbb8757ca0b9794e3fa957e61221d" + integrity sha512-/CWxu3q5QF5jshLX3lw4XNWxTBBOGvZDSkuCM/pE9XNPXjIu6G3YB9XCBmqvk8toSp0d6QjShwzPcjAKPCQcpA== + dependencies: + "@abp/clipboard" "^2.9.0" + "@abp/prismjs" "^2.9.0" + "@fortawesome/fontawesome-free@^5.11.2": version "5.13.0" resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.13.0.tgz#fcb113d1aca4b471b709e8c9c168674fbd6e06d9" diff --git a/npm/packs/aspnetcore.mvc.ui/package.json b/npm/packs/aspnetcore.mvc.ui/package.json index e73ca429d6..6a83218d4e 100644 --- a/npm/packs/aspnetcore.mvc.ui/package.json +++ b/npm/packs/aspnetcore.mvc.ui/package.json @@ -10,7 +10,7 @@ "gulp": "^4.0.2", "merge-stream": "^2.0.0", "path": "^0.12.7", - "rimraf": "^3.0.0" + "rimraf": "^3.0.2" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/bootstrap/package.json b/npm/packs/bootstrap/package.json index fdd81727f4..ba4072f27d 100644 --- a/npm/packs/bootstrap/package.json +++ b/npm/packs/bootstrap/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/core": "^2.9.0", - "bootstrap": "^4.3.1", + "bootstrap": "^4.5.0", "bootstrap-v4-rtl": "4.4.1-2" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" diff --git a/npm/packs/clipboard/package.json b/npm/packs/clipboard/package.json index 8b7992bafd..b8e93ae709 100644 --- a/npm/packs/clipboard/package.json +++ b/npm/packs/clipboard/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/core": "^2.9.0", - "clipboard": "^2.0.4" + "clipboard": "^2.0.6" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/codemirror/package.json b/npm/packs/codemirror/package.json index 298aaa36cf..4cf988efba 100644 --- a/npm/packs/codemirror/package.json +++ b/npm/packs/codemirror/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/core": "^2.9.0", - "codemirror": "^5.49.2" + "codemirror": "^5.54.0" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js index 190143da03..41837d2368 100644 --- a/npm/packs/core/src/abp.js +++ b/npm/packs/core/src/abp.js @@ -136,6 +136,38 @@ var abp = abp || {}; }; abp.localization.defaultResourceName = undefined; + abp.localization.currentCulture = { + cultureName: undefined + }; + + var getMapValue = function (packageMaps, packageName, language) { + language = language || abp.localization.currentCulture.name; + if (!packageMaps || !packageName || !language) { + return language; + } + + var packageMap = packageMaps[packageName]; + if (!packageMap) { + return language; + } + + for (var i = 0; i < packageMap.length; i++) { + var map = packageMap[i]; + if (map.name === language){ + return map.value; + } + } + + return language; + }; + + abp.localization.getLanguagesMap = function (packageName, language) { + return getMapValue(abp.localization.languagesMap, packageName, language); + }; + + abp.localization.getLanguageFilesMap = function (packageName, language) { + return getMapValue(abp.localization.languageFilesMap, packageName, language); + }; /* AUTHORIZATION **********************************************/ @@ -330,7 +362,7 @@ var abp = abp || {}; }; /* opts: { - * + * * } */ abp.ui.unblock = function (opts) { @@ -584,7 +616,7 @@ var abp = abp || {}; * This is a simple implementation created to be used by ABP. * Please use a complete cookie library if you need. * @param {string} key - * @param {string} value + * @param {string} value * @param {Date} expireDate (optional). If not specified the cookie will expire at the end of session. * @param {string} path (optional) */ diff --git a/npm/packs/datatables.net-bs4/package.json b/npm/packs/datatables.net-bs4/package.json index 4223e423f2..088a54695f 100644 --- a/npm/packs/datatables.net-bs4/package.json +++ b/npm/packs/datatables.net-bs4/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/datatables.net": "^2.9.0", - "datatables.net-bs4": "^1.10.20" + "datatables.net-bs4": "^1.10.21" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/datatables.net/package.json b/npm/packs/datatables.net/package.json index 5dedf993d1..040be671d9 100644 --- a/npm/packs/datatables.net/package.json +++ b/npm/packs/datatables.net/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/jquery": "^2.9.0", - "datatables.net": "^1.10.20" + "datatables.net": "^1.10.21" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/flag-icon-css/package.json b/npm/packs/flag-icon-css/package.json index d39770f086..e66cc044fd 100644 --- a/npm/packs/flag-icon-css/package.json +++ b/npm/packs/flag-icon-css/package.json @@ -5,7 +5,7 @@ "access": "public" }, "dependencies": { - "flag-icon-css": "^3.4.5" + "flag-icon-css": "^3.5.0" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/font-awesome/package.json b/npm/packs/font-awesome/package.json index 7e7f17cd97..a9515093c5 100644 --- a/npm/packs/font-awesome/package.json +++ b/npm/packs/font-awesome/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/core": "^2.9.0", - "@fortawesome/fontawesome-free": "^5.11.2" + "@fortawesome/fontawesome-free": "^5.13.0" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/jquery-form/abp.resourcemapping.js b/npm/packs/jquery-form/abp.resourcemapping.js index 4072aa89a7..2f8fab7e14 100644 --- a/npm/packs/jquery-form/abp.resourcemapping.js +++ b/npm/packs/jquery-form/abp.resourcemapping.js @@ -1,5 +1,6 @@ module.exports = { mappings: { - "@node_modules/jquery-form/dist/jquery.form.min.js": "@libs/jquery-form/" + "@node_modules/jquery-form/dist/jquery.form.min.js": "@libs/jquery-form/", + "@node_modules/jquery-form/dist/jquery.form.min.js.map": "@libs/jquery-form/" } } \ No newline at end of file diff --git a/npm/packs/jquery-form/package.json b/npm/packs/jquery-form/package.json index 06fbaf3f47..273cab07de 100644 --- a/npm/packs/jquery-form/package.json +++ b/npm/packs/jquery-form/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/jquery": "^2.9.0", - "jquery-form": "^4.2.2" + "jquery-form": "^4.3.0" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/jquery-validation/package.json b/npm/packs/jquery-validation/package.json index 12ede5bbd6..eed1c90ab5 100644 --- a/npm/packs/jquery-validation/package.json +++ b/npm/packs/jquery-validation/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/jquery": "^2.9.0", - "jquery-validation": "^1.19.1" + "jquery-validation": "^1.19.2" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/jquery/package.json b/npm/packs/jquery/package.json index 0bd179d074..6b1bfd73db 100644 --- a/npm/packs/jquery/package.json +++ b/npm/packs/jquery/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/core": "^2.9.0", - "jquery": "^3.4.1" + "jquery": "^3.5.1" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/luxon/package.json b/npm/packs/luxon/package.json index db5bb0512d..489fc20e48 100644 --- a/npm/packs/luxon/package.json +++ b/npm/packs/luxon/package.json @@ -5,7 +5,7 @@ "access": "public" }, "dependencies": { - "luxon": "^1.21.3" + "luxon": "^1.24.1" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/markdown-it/package.json b/npm/packs/markdown-it/package.json index 62855c404c..79b8832b13 100644 --- a/npm/packs/markdown-it/package.json +++ b/npm/packs/markdown-it/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/core": "^2.9.0", - "markdown-it": "^10.0.0" + "markdown-it": "^11.0.0" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/popper.js/abp.resourcemapping.js b/npm/packs/popper.js/abp.resourcemapping.js index e762aa6a93..06d224fb05 100644 --- a/npm/packs/popper.js/abp.resourcemapping.js +++ b/npm/packs/popper.js/abp.resourcemapping.js @@ -1,5 +1,6 @@ module.exports = { mappings: { - "@node_modules/popper.js/dist/umd/popper.min.js": "@libs/popper.js/" + "@node_modules/popper.js/dist/umd/popper.min.js": "@libs/popper.js/", + "@node_modules/popper.js/dist/umd/popper.min.js.map": "@libs/popper.js/" } } \ No newline at end of file diff --git a/npm/packs/prismjs/package.json b/npm/packs/prismjs/package.json index b636ffa05b..8afd71da08 100644 --- a/npm/packs/prismjs/package.json +++ b/npm/packs/prismjs/package.json @@ -7,7 +7,7 @@ "dependencies": { "@abp/clipboard": "^2.9.0", "@abp/core": "^2.9.0", - "prismjs": "^1.17.1" + "prismjs": "^1.20.0" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/select2/package.json b/npm/packs/select2/package.json index 097b40b83f..e57ff9223b 100644 --- a/npm/packs/select2/package.json +++ b/npm/packs/select2/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/core": "^2.9.0", - "select2": "^4.0.12" + "select2": "^4.0.13" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/signalr/package.json b/npm/packs/signalr/package.json index ec8d14f3f1..782bca4e4f 100644 --- a/npm/packs/signalr/package.json +++ b/npm/packs/signalr/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/core": "^2.9.0", - "@microsoft/signalr": "^3.1.3" + "@microsoft/signalr": "^3.1.5" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/packs/tui-editor/package.json b/npm/packs/tui-editor/package.json index 8fd81ee156..5f9b5889da 100644 --- a/npm/packs/tui-editor/package.json +++ b/npm/packs/tui-editor/package.json @@ -9,7 +9,7 @@ "@abp/highlight.js": "^2.9.0", "@abp/jquery": "^2.9.0", "@abp/markdown-it": "^2.9.0", - "tui-editor": "^1.4.8" + "tui-editor": "^1.4.10" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index 8fc6f7c06c..aa773a7755 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -147,6 +147,11 @@ $projects = ( "modules/blogging/src/Volo.Blogging.HttpApi", "modules/blogging/src/Volo.Blogging.MongoDB", "modules/blogging/src/Volo.Blogging.Web", + "modules/blogging/src/Volo.Blogging.Admin.Application", + "modules/blogging/src/Volo.Blogging.Admin.Application.Contracts", + "modules/blogging/src/Volo.Blogging.Admin.HttpApi", + "modules/blogging/src/Volo.Blogging.Admin.HttpApi.Client", + "modules/blogging/src/Volo.Blogging.Admin.Web", # modules/client-simulation "modules/client-simulation/src/Volo.ClientSimulation", diff --git a/templates/app/angular/package.json b/templates/app/angular/package.json index 8df33e4323..efc61110a0 100644 --- a/templates/app/angular/package.json +++ b/templates/app/angular/package.json @@ -24,6 +24,7 @@ "@angular/platform-browser": "~9.1.0", "@angular/platform-browser-dynamic": "~9.1.0", "@angular/router": "~9.1.0", + "@swimlane/ngx-datatable": "^17.0.0", "rxjs": "~6.5.4", "tslib": "^1.10.0", "zone.js": "~0.10.2" diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs index cc85590e61..dbc3805f25 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs @@ -14,7 +14,7 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore //builder.Entity(b => //{ // b.ToTable(MyProjectNameConsts.DbTablePrefix + "YourEntities", MyProjectNameConsts.DbSchema); - + // b.ConfigureByConvention(); //auto configure for the base class props // //... //}); } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs new file mode 100644 index 0000000000..ea5a2de740 --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs @@ -0,0 +1,11 @@ +using MyCompanyName.MyProjectName.EntityFrameworkCore; +using Xunit; + +namespace MyCompanyName.MyProjectName +{ + [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] + public class MyProjectNameApplicationCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase + { + + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs index 08bab7e852..836ee8f170 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs @@ -10,6 +10,7 @@ namespace MyCompanyName.MyProjectName.Samples * (like IIdentityUserAppService here). * Only test your own application services. */ + [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] public class SampleAppServiceTests : MyProjectNameApplicationTestBase { private readonly IIdentityUserAppService _userAppService; diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs new file mode 100644 index 0000000000..81a68dd7f8 --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs @@ -0,0 +1,11 @@ +using MyCompanyName.MyProjectName.EntityFrameworkCore; +using Xunit; + +namespace MyCompanyName.MyProjectName +{ + [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] + public class MyProjectNameDomainCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase + { + + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs index 26f2b14912..e39a6148a6 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs @@ -10,6 +10,7 @@ namespace MyCompanyName.MyProjectName.Samples * (like IdentityUserManager here). * Only test your own domain services. */ + [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] public class SampleDomainTests : MyProjectNameDomainTestBase { private readonly IIdentityUserRepository _identityUserRepository; diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs new file mode 100644 index 0000000000..858709c1c9 --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs @@ -0,0 +1,10 @@ +using Xunit; + +namespace MyCompanyName.MyProjectName.EntityFrameworkCore +{ + [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] + public class MyProjectNameEntityFrameworkCoreCollection : ICollectionFixture + { + + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs new file mode 100644 index 0000000000..bba037d413 --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs @@ -0,0 +1,10 @@ +using MyCompanyName.MyProjectName.EntityFrameworkCore; +using Xunit; + +namespace MyCompanyName.MyProjectName.EntityFrameworkCore +{ + public class MyProjectNameEntityFrameworkCoreCollectionFixtureBase : ICollectionFixture + { + + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs new file mode 100644 index 0000000000..120c141972 --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs @@ -0,0 +1,12 @@ +using System; + +namespace MyCompanyName.MyProjectName.EntityFrameworkCore +{ + public class MyProjectNameEntityFrameworkCoreFixture : IDisposable + { + public void Dispose() + { + + } + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs index 0175e202b1..15fd991d77 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs @@ -14,6 +14,7 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples * (like default AppUser repository IRepository here). * Only test your custom repository methods. */ + [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] public class SampleRepositoryTests : MyProjectNameEntityFrameworkCoreTestBase { private readonly IRepository _appUserRepository; diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MongoTestCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MongoTestCollection.cs deleted file mode 100644 index 42c85760c3..0000000000 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MongoTestCollection.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Xunit; - -namespace MyCompanyName.MyProjectName.MongoDB -{ - [CollectionDefinition(Name)] - public class MongoTestCollection : ICollectionFixture - { - public const string Name = "MongoDB Collection"; - } -} \ No newline at end of file diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoCollection.cs new file mode 100644 index 0000000000..52160c0e3c --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoCollection.cs @@ -0,0 +1,10 @@ +using Xunit; + +namespace MyCompanyName.MyProjectName.MongoDB +{ + [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] + public class MyProjectNameMongoCollection : MyProjectNameMongoDbCollectionFixtureBase + { + + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbCollectionFixtureBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbCollectionFixtureBase.cs new file mode 100644 index 0000000000..05c514a677 --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbCollectionFixtureBase.cs @@ -0,0 +1,10 @@ +using MyCompanyName.MyProjectName.MongoDB; +using Xunit; + +namespace MyCompanyName.MyProjectName.MongoDB +{ + public class MyProjectNameMongoDbCollectionFixtureBase : ICollectionFixture + { + + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MongoDbFixture.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbFixture.cs similarity index 80% rename from templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MongoDbFixture.cs rename to templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbFixture.cs index e471590369..d1a863eb2c 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MongoDbFixture.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbFixture.cs @@ -3,12 +3,12 @@ using Mongo2Go; namespace MyCompanyName.MyProjectName.MongoDB { - public class MongoDbFixture : IDisposable + public class MyProjectNameMongoDbFixture : IDisposable { private static readonly MongoDbRunner MongoDbRunner; public static readonly string ConnectionString; - static MongoDbFixture() + static MyProjectNameMongoDbFixture() { MongoDbRunner = MongoDbRunner.Start(); ConnectionString = MongoDbRunner.ConnectionString; diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestModule.cs index bcaf7494a7..44783b67e4 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestModule.cs @@ -12,9 +12,9 @@ namespace MyCompanyName.MyProjectName.MongoDB { public override void ConfigureServices(ServiceConfigurationContext context) { - var connectionString = MongoDbFixture.ConnectionString.EnsureEndsWith('/') + - "Db_" + - Guid.NewGuid().ToString("N"); + var connectionString = MyProjectNameMongoDbFixture.ConnectionString.EnsureEndsWith('/') + + "Db_" + + Guid.NewGuid().ToString("N"); Configure(options => { @@ -22,4 +22,4 @@ namespace MyCompanyName.MyProjectName.MongoDB }); } } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs index 17d8007c16..deee3b4b61 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs @@ -13,7 +13,7 @@ namespace MyCompanyName.MyProjectName.MongoDB.Samples * (like default AppUser repository IRepository here). * Only test your custom repository methods. */ - [Collection(MongoTestCollection.Name)] + [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] public class SampleRepositoryTests : MyProjectNameMongoDbTestBase { private readonly IRepository _appUserRepository; diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs new file mode 100644 index 0000000000..342185c841 --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs @@ -0,0 +1,7 @@ +namespace MyCompanyName.MyProjectName +{ + public static class MyProjectNameTestConsts + { + public const string CollectionDefinitionName = "MyProjectName collection"; + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs new file mode 100644 index 0000000000..453be8f7fc --- /dev/null +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs @@ -0,0 +1,11 @@ +using MyCompanyName.MyProjectName.EntityFrameworkCore; +using Xunit; + +namespace MyCompanyName.MyProjectName +{ + [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] + public class MyProjectNameWebCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase + { + + } +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs index b74d22c3f0..6d59438b47 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs @@ -4,6 +4,7 @@ using Xunit; namespace MyCompanyName.MyProjectName.Pages { + [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] public class Index_Tests : MyProjectNameWebTestBase { [Fact]