├── .gitattributes
├── src
├── AbpToExcel.DbMigrator
│ ├── appsettings.secrets.json
│ ├── AbpToExcelDbMigratorModule.cs
│ ├── appsettings.json
│ ├── Program.cs
│ ├── DbMigratorHostedService.cs
│ └── AbpToExcel.DbMigrator.csproj
├── AbpToExcel.HttpApi.Host
│ ├── appsettings.secrets.json
│ ├── appsettings.Development.json
│ ├── abp.resourcemapping.js
│ ├── wwwroot
│ │ ├── images
│ │ │ └── logo
│ │ │ │ └── leptonx
│ │ │ │ ├── logo-dark.png
│ │ │ │ ├── logo-light.png
│ │ │ │ ├── logo-dark-thumbnail.png
│ │ │ │ └── logo-light-thumbnail.png
│ │ └── global-styles.css
│ ├── package.json
│ ├── Controllers
│ │ └── HomeController.cs
│ ├── AbpToExcelBrandingProvider.cs
│ ├── appsettings.json
│ ├── web.config
│ ├── Properties
│ │ └── launchSettings.json
│ ├── AbpToExcel.HttpApi.Host.csproj
│ ├── Program.cs
│ └── AbpToExcelHttpApiHostModule.cs
├── AbpToExcel.Blazor
│ ├── wwwroot
│ │ ├── appsettings.Development.json
│ │ ├── favicon.ico
│ │ ├── images
│ │ │ └── logo
│ │ │ │ └── leptonx
│ │ │ │ ├── logo-dark.png
│ │ │ │ ├── logo-light.png
│ │ │ │ ├── logo-dark-thumbnail.png
│ │ │ │ └── logo-light-thumbnail.png
│ │ ├── js
│ │ │ └── exporttoexcel.js
│ │ ├── appsettings.json
│ │ ├── index.html
│ │ └── main.css
│ ├── Pages
│ │ ├── Index.razor.css
│ │ ├── Index.razor.cs
│ │ └── Index.razor
│ ├── Menus
│ │ ├── AbpToExcelMenus.cs
│ │ └── AbpToExcelMenuContributor.cs
│ ├── AbpToExcelBrandingProvider.cs
│ ├── AbpToExcelBlazorAutoMapperProfile.cs
│ ├── AbpToExcelComponentBase.cs
│ ├── AbpToExcelBundleContributor.cs
│ ├── _Imports.razor
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── AbpToExcel.Blazor.csproj
│ └── AbpToExcelBlazorModule.cs
├── AbpToExcel.Application
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ExcelExport
│ │ ├── ExportToExcelAppService.cs
│ │ └── ExcelFileGenerator.cs
│ ├── AbpToExcelApplicationAutoMapperProfile.cs
│ ├── AbpToExcelAppService.cs
│ ├── AbpToExcelApplicationModule.cs
│ └── AbpToExcel.Application.csproj
├── AbpToExcel.EntityFrameworkCore
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── EntityFrameworkCore
│ │ ├── EntityFrameworkCoreAbpToExcelDbSchemaMigrator.cs
│ │ ├── AbpToExcelDbContextFactory.cs
│ │ ├── AbpToExcelEfCoreEntityExtensionMappings.cs
│ │ ├── AbpToExcelEntityFrameworkCoreModule.cs
│ │ └── AbpToExcelDbContext.cs
│ └── AbpToExcel.EntityFrameworkCore.csproj
├── AbpToExcel.Domain
│ ├── Data
│ │ ├── IAbpToExcelDbSchemaMigrator.cs
│ │ ├── NullAbpToExcelDbSchemaMigrator.cs
│ │ └── AbpToExcelDbMigrationService.cs
│ ├── AbpToExcelConsts.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Settings
│ │ ├── AbpToExcelSettings.cs
│ │ └── AbpToExcelSettingDefinitionProvider.cs
│ ├── AbpToExcel.Domain.csproj
│ ├── AbpToExcelDomainModule.cs
│ └── OpenIddict
│ │ └── OpenIddictDataSeedContributor.cs
├── AbpToExcel.Domain.Shared
│ ├── AbpToExcelDomainErrorCodes.cs
│ ├── Localization
│ │ ├── AbpToExcelResource.cs
│ │ └── AbpToExcel
│ │ │ ├── zh-Hans.json
│ │ │ ├── zh-Hant.json
│ │ │ ├── ar.json
│ │ │ ├── fi.json
│ │ │ ├── is.json
│ │ │ ├── sl.json
│ │ │ ├── cs.json
│ │ │ ├── hi.json
│ │ │ ├── nl.json
│ │ │ ├── pl-PL.json
│ │ │ ├── sk.json
│ │ │ ├── en-GB.json
│ │ │ ├── en.json
│ │ │ ├── es.json
│ │ │ ├── fr.json
│ │ │ ├── it.json
│ │ │ ├── pt-BR.json
│ │ │ ├── hu.json
│ │ │ ├── vi.json
│ │ │ ├── de.json
│ │ │ ├── hr.json
│ │ │ ├── ro-RO.json
│ │ │ ├── ru.json
│ │ │ └── tr.json
│ ├── MultiTenancy
│ │ └── MultiTenancyConsts.cs
│ ├── AbpToExcelGlobalFeatureConfigurator.cs
│ ├── AbpToExcel.Domain.Shared.csproj
│ ├── AbpToExcelDomainSharedModule.cs
│ └── AbpToExcelModuleExtensionConfigurator.cs
├── AbpToExcel.HttpApi
│ ├── Models
│ │ └── Test
│ │ │ └── TestModel.cs
│ ├── Controllers
│ │ └── AbpToExcelController.cs
│ ├── AbpToExcel.HttpApi.csproj
│ └── AbpToExcelHttpApiModule.cs
├── AbpToExcel.Application.Contracts
│ ├── ExcelExport
│ │ └── IExportToExcelAppService.cs
│ ├── Permissions
│ │ ├── AbpToExcelPermissions.cs
│ │ └── AbpToExcelPermissionDefinitionProvider.cs
│ ├── AbpToExcelDtoExtensions.cs
│ ├── AbpToExcelApplicationContractsModule.cs
│ └── AbpToExcel.Application.Contracts.csproj
└── AbpToExcel.HttpApi.Client
│ ├── AbpToExcel.HttpApi.Client.csproj
│ └── AbpToExcelHttpApiClientModule.cs
├── test
├── AbpToExcel.HttpApi.Client.ConsoleTestApp
│ ├── appsettings.secrets.json
│ ├── appsettings.json
│ ├── Program.cs
│ ├── ClientDemoService.cs
│ ├── AbpToExcelConsoleApiClientModule.cs
│ ├── AbpToExcel.HttpApi.Client.ConsoleTestApp.csproj
│ └── ConsoleTestAppHostedService.cs
├── AbpToExcel.TestBase
│ ├── AbpToExcelTestConsts.cs
│ ├── AbpToExcelTestDataSeedContributor.cs
│ ├── Security
│ │ └── FakeCurrentPrincipalAccessor.cs
│ ├── AbpToExcel.TestBase.csproj
│ ├── AbpToExcelTestBaseModule.cs
│ └── AbpToExcelTestBase.cs
├── AbpToExcel.Application.Tests
│ ├── AbpToExcelApplicationTestBase.cs
│ ├── AbpToExcelApplicationTestModule.cs
│ ├── AbpToExcel.Application.Tests.csproj
│ └── Samples
│ │ └── SampleAppServiceTests.cs
├── AbpToExcel.Domain.Tests
│ ├── AbpToExcelDomainTestModule.cs
│ ├── AbpToExcelDomainTestBase.cs
│ ├── AbpToExcel.Domain.Tests.csproj
│ └── Samples
│ │ └── SampleDomainTests.cs
└── AbpToExcel.EntityFrameworkCore.Tests
│ ├── EntityFrameworkCore
│ ├── AbpToExcelEntityFrameworkCoreFixture.cs
│ ├── AbpToExcelEntityFrameworkCoreTestBase.cs
│ ├── AbpToExcelEntityFrameworkCoreCollectionFixtureBase.cs
│ ├── AbpToExcelEntityFrameworkCoreCollection.cs
│ ├── Domains
│ │ └── EfCoreSampleDomainTests.cs
│ ├── Applications
│ │ └── EfCoreSampleAppServiceTests.cs
│ ├── Samples
│ │ └── SampleRepositoryTests.cs
│ └── AbpToExcelEntityFrameworkCoreTestModule.cs
│ └── AbpToExcel.EntityFrameworkCore.Tests.csproj
├── exporttoexcel.jpg
├── .prettierrc
├── .vscode
├── extensions.json
├── tasks.json
└── launch.json
├── NuGet.Config
├── common.props
├── LICENSE
├── AbpToExcel.sln.DotSettings
├── .gitignore
├── README.md
└── AbpToExcel.sln
/.gitattributes:
--------------------------------------------------------------------------------
1 | **/wwwroot/libs/** linguist-vendored
2 |
--------------------------------------------------------------------------------
/src/AbpToExcel.DbMigrator/appsettings.secrets.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/appsettings.secrets.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | }
3 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/test/AbpToExcel.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json:
--------------------------------------------------------------------------------
1 | {
2 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/Pages/Index.razor.css:
--------------------------------------------------------------------------------
1 | /* Write here your styles for the Index page */
--------------------------------------------------------------------------------
/exporttoexcel.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/exporttoexcel.jpg
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true,
3 | "useTabs": false,
4 | "tabWidth": 4
5 | }
6 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "bartvanhoey.abpx"
4 | ]
5 | }
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/Pages/Index.razor.cs:
--------------------------------------------------------------------------------
1 | namespace AbpToExcel.Blazor.Pages;
2 |
3 | public partial class Index
4 | {
5 |
6 | }
7 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.Blazor/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/src/AbpToExcel.Application/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | [assembly:InternalsVisibleToAttribute("AbpToExcel.Application.Tests")]
3 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/images/logo/leptonx/logo-dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.Blazor/wwwroot/images/logo/leptonx/logo-dark.png
--------------------------------------------------------------------------------
/src/AbpToExcel.EntityFrameworkCore/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | [assembly:InternalsVisibleToAttribute("AbpToExcel.EntityFrameworkCore.Tests")]
3 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/images/logo/leptonx/logo-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.Blazor/wwwroot/images/logo/leptonx/logo-light.png
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/abp.resourcemapping.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | aliases: {
3 |
4 | },
5 | clean: [
6 |
7 | ],
8 | mappings: {
9 |
10 | }
11 | };
12 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/wwwroot/images/logo/leptonx/logo-dark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.HttpApi.Host/wwwroot/images/logo/leptonx/logo-dark.png
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/wwwroot/images/logo/leptonx/logo-light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.HttpApi.Host/wwwroot/images/logo/leptonx/logo-light.png
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/images/logo/leptonx/logo-dark-thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.Blazor/wwwroot/images/logo/leptonx/logo-dark-thumbnail.png
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/images/logo/leptonx/logo-light-thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.Blazor/wwwroot/images/logo/leptonx/logo-light-thumbnail.png
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "name": "my-app",
4 | "private": true,
5 | "dependencies": {
6 | "@abp/aspnetcore.mvc.ui.theme.leptonxlite": "~3.0.2"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/AbpToExcel.TestBase/AbpToExcelTestConsts.cs:
--------------------------------------------------------------------------------
1 | namespace AbpToExcel;
2 |
3 | public static class AbpToExcelTestConsts
4 | {
5 | public const string CollectionDefinitionName = "AbpToExcel collection";
6 | }
7 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/Data/IAbpToExcelDbSchemaMigrator.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace AbpToExcel.Data;
4 |
5 | public interface IAbpToExcelDbSchemaMigrator
6 | {
7 | Task MigrateAsync();
8 | }
9 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/wwwroot/images/logo/leptonx/logo-dark-thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.HttpApi.Host/wwwroot/images/logo/leptonx/logo-dark-thumbnail.png
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/wwwroot/images/logo/leptonx/logo-light-thumbnail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bartvanhoey/AbpToExcelRepo/HEAD/src/AbpToExcel.HttpApi.Host/wwwroot/images/logo/leptonx/logo-light-thumbnail.png
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/AbpToExcelConsts.cs:
--------------------------------------------------------------------------------
1 | namespace AbpToExcel;
2 |
3 | public static class AbpToExcelConsts
4 | {
5 | public const string DbTablePrefix = "App";
6 |
7 | public const string DbSchema = null;
8 | }
9 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 | [assembly:InternalsVisibleToAttribute("AbpToExcel.Domain.Tests")]
3 | [assembly:InternalsVisibleToAttribute("AbpToExcel.TestBase")]
4 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/AbpToExcelDomainErrorCodes.cs:
--------------------------------------------------------------------------------
1 | namespace AbpToExcel;
2 |
3 | public static class AbpToExcelDomainErrorCodes
4 | {
5 | /* You can add your business exception error codes here, as constants */
6 | }
7 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcelResource.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Localization;
2 |
3 | namespace AbpToExcel.Localization;
4 |
5 | [LocalizationResourceName("AbpToExcel")]
6 | public class AbpToExcelResource
7 | {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/zh-Hans.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "zh-Hans",
3 | "texts": {
4 | "Menu:Home": "首页",
5 | "Welcome": "欢迎",
6 | "LongWelcomeMessage": "欢迎使用本应用程序。这是一个基于 ABP 框架的启动项目。更多信息,请访问 abp.io。"
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi/Models/Test/TestModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AbpToExcel.Models.Test;
4 |
5 | public class TestModel
6 | {
7 | public string? Name { get; set; }
8 |
9 | public DateTime BirthDate { get; set; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/wwwroot/global-styles.css:
--------------------------------------------------------------------------------
1 | /* Your Global Styles */
2 |
3 | :root .lpx-brand-logo {
4 | --lpx-logo: url('/images/logo/leptonx/logo-light.png');
5 | --lpx-logo-icon: url('/images/logo/leptonx/logo-light-thumbnail.png');
6 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/zh-Hant.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "zh-Hant",
3 | "texts": {
4 | "Menu:Home": "首頁",
5 | "Welcome": "歡迎",
6 | "LongWelcomeMessage": "歡迎來到此應用程式. 這是一個基於ABP框架的起始專案. 有關更多訊息, 請瀏覽 abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/Menus/AbpToExcelMenus.cs:
--------------------------------------------------------------------------------
1 | namespace AbpToExcel.Blazor.Menus;
2 |
3 | public class AbpToExcelMenus
4 | {
5 | private const string Prefix = "AbpToExcel";
6 | public const string Home = Prefix + ".Home";
7 |
8 | //Add your menu items here...
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/test/AbpToExcel.Application.Tests/AbpToExcelApplicationTestBase.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Modularity;
2 |
3 | namespace AbpToExcel;
4 |
5 | public abstract class AbpToExcelApplicationTestBase : AbpToExcelTestBase
6 | where TStartupModule : IAbpModule
7 | {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/test/AbpToExcel.Domain.Tests/AbpToExcelDomainTestModule.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Modularity;
2 |
3 | namespace AbpToExcel;
4 |
5 | [DependsOn(
6 | typeof(AbpToExcelDomainModule),
7 | typeof(AbpToExcelTestBaseModule)
8 | )]
9 | public class AbpToExcelDomainTestModule : AbpModule
10 | {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/ar.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "ar",
3 | "texts": {
4 | "Menu:Home": "الصفحة الرئيسية",
5 | "Welcome": "مرحباً",
6 | "LongWelcomeMessage": "مرحبا بكم في التطبيق. هذا مشروع بدء تشغيل يعتمد على إطار عمل ABP. لمزيد من المعلومات ، يرجى زيارة abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/fi.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "fi",
3 | "texts": {
4 | "Menu:Home": "Koti",
5 | "Welcome": "Tervetuloa",
6 | "LongWelcomeMessage": "Tervetuloa sovellukseen. Tämä on ABP-kehykseen perustuva käynnistysprojekti. Lisätietoja on osoitteessa abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/is.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "is",
3 | "texts": {
4 | "Menu:Home": "Heim",
5 | "Welcome": "Velkomin",
6 | "LongWelcomeMessage": "Verið velkomin í forritið. Þetta er startup verkefni sem byggir á ABP. Nánari upplýsingar er að finna á abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/sl.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "sl",
3 | "texts": {
4 | "Menu:Home": "Domov",
5 | "Welcome": "Dobrodošli",
6 | "LongWelcomeMessage": "Dobrodošli v aplikaciji. To je začetni projekt na osnovi okolja ABP. Za več informacij obiščite abp.io."
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/EntityFrameworkCore/AbpToExcelEntityFrameworkCoreFixture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace AbpToExcel.EntityFrameworkCore;
4 |
5 | public class AbpToExcelEntityFrameworkCoreFixture : IDisposable
6 | {
7 | public void Dispose()
8 | {
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/EntityFrameworkCore/AbpToExcelEntityFrameworkCoreTestBase.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp;
2 |
3 | namespace AbpToExcel.EntityFrameworkCore;
4 |
5 | public abstract class AbpToExcelEntityFrameworkCoreTestBase : AbpToExcelTestBase
6 | {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/cs.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "cs",
3 | "texts": {
4 | "Menu:Home": "Úvod",
5 | "Welcome": "Vítejte",
6 | "LongWelcomeMessage": "Vítejte v aplikaci. Toto je startovací projekt založený na ABP frameworku. Pro více informací, navštivte abp.io."
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/hi.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "hi",
3 | "texts": {
4 | "Menu:Home": "घर",
5 | "Welcome": "स्वागत हे",
6 | "LongWelcomeMessage": "आवेदन करने के लिए आपका स्वागत है। यह एबीपी ढांचे पर आधारित एक स्टार्टअप परियोजना है। अधिक जानकारी के लिए, abp.io पर जाएं।"
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/nl.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "nl",
3 | "texts": {
4 | "Menu:Home": "Home",
5 | "Welcome": "Welkom",
6 | "LongWelcomeMessage": "Welkom bij de applicatie. Dit is een startup-project gebaseerd op het ABP-framework. Bezoek abp.io voor meer informatie."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/pl-PL.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "pl-PL",
3 | "texts": {
4 | "Menu:Home": "Home",
5 | "Welcome": "Witaj",
6 | "LongWelcomeMessage": "Witaj w aplikacji. To jest inicjalny projekt bazujący na ABP framework. Po więcej informacji odwiedź stronę abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/sk.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "sk",
3 | "texts": {
4 | "Menu:Home": "Domov",
5 | "Welcome": "Vitajte",
6 | "LongWelcomeMessage": "Vitajte v aplikácii. Toto je štartovací projekt založený na ABP frameworku. Viac informácií nájdete na stránke abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/en-GB.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "en-GB",
3 | "texts": {
4 | "Menu:Home": "Home",
5 | "Welcome": "Welcome",
6 | "LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/en.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "en",
3 | "texts": {
4 | "Menu:Home": "Home",
5 | "Welcome": "Welcome",
6 | "LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io."
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/es.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "es",
3 | "texts": {
4 | "Menu:Home": "Inicio",
5 | "Welcome": "Bienvenido",
6 | "LongWelcomeMessage": "Bienvenido a la aplicación, este es un proyecto base basado en el framework ABP. Para más información, visita abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/Settings/AbpToExcelSettings.cs:
--------------------------------------------------------------------------------
1 | namespace AbpToExcel.Settings;
2 |
3 | public static class AbpToExcelSettings
4 | {
5 | private const string Prefix = "AbpToExcel";
6 |
7 | //Add your own setting names here. Example:
8 | //public const string MySetting1 = Prefix + ".MySetting1";
9 | }
10 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/fr.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "fr",
3 | "texts": {
4 | "Menu:Home": "Accueil",
5 | "Welcome": "Bienvenue",
6 | "LongWelcomeMessage": "Bienvenue dans l'application. Il s'agit d'un projet de démarrage basé sur le framework ABP. Pour plus d'informations, visitez abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/it.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "it",
3 | "texts": {
4 | "Menu:Home": "Home",
5 | "Welcome": "Benvenuto",
6 | "LongWelcomeMessage": "Benvenuto nell'applicazione. Questo è un progetto di avvio basato sul framework ABP. Per ulteriori informazioni, visita abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/test/AbpToExcel.Application.Tests/AbpToExcelApplicationTestModule.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Modularity;
2 |
3 | namespace AbpToExcel;
4 |
5 | [DependsOn(
6 | typeof(AbpToExcelApplicationModule),
7 | typeof(AbpToExcelDomainTestModule)
8 | )]
9 | public class AbpToExcelApplicationTestModule : AbpModule
10 | {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/pt-BR.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "pt-BR",
3 | "texts": {
4 | "Menu:Home": "Principal",
5 | "Welcome": "Seja bem-vindo!",
6 | "LongWelcomeMessage": "Bem-vindo a esta aplicação. Este é um projeto inicial baseado no ABP framework. Para mais informações, visite abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Application.Contracts/ExcelExport/IExportToExcelAppService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Volo.Abp.Application.Services;
3 |
4 | namespace AbpToExcel.ExcelExport
5 | {
6 | public interface IExportToExcelAppService : IApplicationService
7 | {
8 | Task ExportToExcel();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/hu.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "hu",
3 | "texts": {
4 | "Menu:Home": "Kezdőlap",
5 | "Welcome": "Üdvözlöm",
6 | "LongWelcomeMessage": "Üdvözöljük az alkalmazásban. Ez egy ABP keretrendszeren alapuló startup projekt. További információkért látogasson el az abp.io oldalra."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/vi.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "vi",
3 | "texts": {
4 | "Menu:Home": "Trang chủ",
5 | "Welcome": "Chào mừng bạn",
6 | "LongWelcomeMessage": "Chào mừng bạn đến ứng dụng. Đây là một dự án khởi nghiệp dựa trên khung ABP. Để biết thêm thông tin, hãy truy cập abp.io."
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/Controllers/HomeController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Volo.Abp.AspNetCore.Mvc;
3 |
4 | namespace AbpToExcel.Controllers;
5 |
6 | public class HomeController : AbpController
7 | {
8 | public ActionResult Index()
9 | {
10 | return Redirect("~/swagger");
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/de.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "de",
3 | "texts": {
4 | "Menu:Home": "Home",
5 | "Welcome": "Willkommen",
6 | "LongWelcomeMessage": "Willkommen bei der Anwendung. Dies ist ein Startup-Projekt, das auf dem ABP-Framework basiert. Weitere Informationen finden Sie unter abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/hr.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "hr",
3 | "texts": {
4 | "Menu:Home": "Početna",
5 | "Welcome": "Dobrodošli",
6 | "LongWelcomeMessage": "Dobrodošli u aplikaciju. Ovo je startup projekt temeljen na ABP framework-u. Za više informacija posjetite abp.io."
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/ro-RO.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "ro-RO",
3 | "texts": {
4 | "Menu:Home": "Acasă",
5 | "Welcome": "Bun venit",
6 | "LongWelcomeMessage": "Bun venit la aplicaţie. Acesta este un proiect de pornire bazat pe framework-ul ABP. Pentru mai multe informaţii, vizitaţi, visit abp.io."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/AbpToExcelBrandingProvider.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.DependencyInjection;
2 | using Volo.Abp.Ui.Branding;
3 |
4 | namespace AbpToExcel.Blazor;
5 |
6 | [Dependency(ReplaceServices = true)]
7 | public class AbpToExcelBrandingProvider : DefaultBrandingProvider
8 | {
9 | public override string AppName => "AbpToExcel";
10 | }
11 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/AbpToExcelBrandingProvider.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.DependencyInjection;
2 | using Volo.Abp.Ui.Branding;
3 |
4 | namespace AbpToExcel;
5 |
6 | [Dependency(ReplaceServices = true)]
7 | public class AbpToExcelBrandingProvider : DefaultBrandingProvider
8 | {
9 | public override string AppName => "AbpToExcel";
10 | }
11 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/AbpToExcelBlazorAutoMapperProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 |
3 | namespace AbpToExcel.Blazor;
4 |
5 | public class AbpToExcelBlazorAutoMapperProfile : Profile
6 | {
7 | public AbpToExcelBlazorAutoMapperProfile()
8 | {
9 | //Define your AutoMapper configuration here for the Blazor project.
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/AbpToExcel.Domain.Tests/AbpToExcelDomainTestBase.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Modularity;
2 |
3 | namespace AbpToExcel;
4 |
5 | /* Inherit from this class for your domain layer tests. */
6 | public abstract class AbpToExcelDomainTestBase : AbpToExcelTestBase
7 | where TStartupModule : IAbpModule
8 | {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/ru.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "ru",
3 | "texts": {
4 | "Menu:Home": "Главная",
5 | "Welcome": "Добро пожаловать",
6 | "LongWelcomeMessage": "Добро пожаловать в приложение. Этот запущенный проект основан на фреймворке ABP. Для получения дополнительной информации посетите сайт abp.io."
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/Localization/AbpToExcel/tr.json:
--------------------------------------------------------------------------------
1 | {
2 | "culture": "tr",
3 | "texts": {
4 | "Menu:Home": "Ana sayfa",
5 | "Welcome": "Hoşgeldiniz",
6 | "LongWelcomeMessage": "Uygulamaya hoşgeldiniz. Bu, ABP framework'ü üzerine bina edilmiş bir başlangıç projesidir. Daha fazla bilgi için abp.io adresini ziyaret edebilirsiniz."
7 | }
8 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Application.Contracts/Permissions/AbpToExcelPermissions.cs:
--------------------------------------------------------------------------------
1 | namespace AbpToExcel.Permissions;
2 |
3 | public static class AbpToExcelPermissions
4 | {
5 | public const string GroupName = "AbpToExcel";
6 |
7 | //Add your own permission names. Example:
8 | //public const string MyPermission1 = GroupName + ".MyPermission1";
9 | }
10 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/js/exporttoexcel.js:
--------------------------------------------------------------------------------
1 | function saveAsFile(filename, bytesBase64) {
2 | var link = document.createElement('a');
3 | link.download = filename;
4 | link.href = 'data:application/octet-stream;base64,' + bytesBase64;
5 | document.body.appendChild(link); // Needed for Firefox
6 | link.click();
7 | document.body.removeChild(link);
8 | }
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/EntityFrameworkCore/AbpToExcelEntityFrameworkCoreCollectionFixtureBase.cs:
--------------------------------------------------------------------------------
1 | using AbpToExcel.EntityFrameworkCore;
2 | using Xunit;
3 |
4 | namespace AbpToExcel.EntityFrameworkCore;
5 |
6 | public class AbpToExcelEntityFrameworkCoreCollectionFixtureBase : ICollectionFixture
7 | {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/AbpToExcelComponentBase.cs:
--------------------------------------------------------------------------------
1 | using AbpToExcel.Localization;
2 | using Volo.Abp.AspNetCore.Components;
3 |
4 | namespace AbpToExcel.Blazor;
5 |
6 | public abstract class AbpToExcelComponentBase : AbpComponentBase
7 | {
8 | protected AbpToExcelComponentBase()
9 | {
10 | LocalizationResource = typeof(AbpToExcelResource);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/EntityFrameworkCore/AbpToExcelEntityFrameworkCoreCollection.cs:
--------------------------------------------------------------------------------
1 | using Xunit;
2 |
3 | namespace AbpToExcel.EntityFrameworkCore;
4 |
5 | [CollectionDefinition(AbpToExcelTestConsts.CollectionDefinitionName)]
6 | public class AbpToExcelEntityFrameworkCoreCollection : ICollectionFixture
7 | {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/EntityFrameworkCore/Domains/EfCoreSampleDomainTests.cs:
--------------------------------------------------------------------------------
1 | using AbpToExcel.Samples;
2 | using Xunit;
3 |
4 | namespace AbpToExcel.EntityFrameworkCore.Domains;
5 |
6 | [Collection(AbpToExcelTestConsts.CollectionDefinitionName)]
7 | public class EfCoreSampleDomainTests : SampleDomainTests
8 | {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/EntityFrameworkCore/Applications/EfCoreSampleAppServiceTests.cs:
--------------------------------------------------------------------------------
1 | using AbpToExcel.Samples;
2 | using Xunit;
3 |
4 | namespace AbpToExcel.EntityFrameworkCore.Applications;
5 |
6 | [Collection(AbpToExcelTestConsts.CollectionDefinitionName)]
7 | public class EfCoreSampleAppServiceTests : SampleAppServiceTests
8 | {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/MultiTenancy/MultiTenancyConsts.cs:
--------------------------------------------------------------------------------
1 | namespace AbpToExcel.MultiTenancy;
2 |
3 | public static class MultiTenancyConsts
4 | {
5 | /* Enable/disable multi-tenancy easily in a single point.
6 | * If you will never need to multi-tenancy, you can remove
7 | * related modules and code parts, including this file.
8 | */
9 | public const bool IsEnabled = true;
10 | }
11 |
--------------------------------------------------------------------------------
/src/AbpToExcel.DbMigrator/AbpToExcelDbMigratorModule.cs:
--------------------------------------------------------------------------------
1 | using AbpToExcel.EntityFrameworkCore;
2 | using Volo.Abp.Autofac;
3 | using Volo.Abp.Modularity;
4 |
5 | namespace AbpToExcel.DbMigrator;
6 |
7 | [DependsOn(
8 | typeof(AbpAutofacModule),
9 | typeof(AbpToExcelEntityFrameworkCoreModule),
10 | typeof(AbpToExcelApplicationContractsModule)
11 | )]
12 | public class AbpToExcelDbMigratorModule : AbpModule
13 | {
14 | }
15 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi/Controllers/AbpToExcelController.cs:
--------------------------------------------------------------------------------
1 | using AbpToExcel.Localization;
2 | using Volo.Abp.AspNetCore.Mvc;
3 |
4 | namespace AbpToExcel.Controllers;
5 |
6 | /* Inherit your controllers from this class.
7 | */
8 | public abstract class AbpToExcelController : AbpControllerBase
9 | {
10 | protected AbpToExcelController()
11 | {
12 | LocalizationResource = typeof(AbpToExcelResource);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application/ExcelExport/ExportToExcelAppService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Volo.Abp.Application.Services;
3 | using static AbpToExcel.ExcelExport.ExcelFileGenerator;
4 |
5 | namespace AbpToExcel.ExcelExport
6 | {
7 | public class ExportToExcelAppService : ApplicationService, IExportToExcelAppService
8 | {
9 | public Task ExportToExcel() => Task.FromResult(GenerateExcelFile());
10 | }
11 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/Settings/AbpToExcelSettingDefinitionProvider.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Settings;
2 |
3 | namespace AbpToExcel.Settings;
4 |
5 | public class AbpToExcelSettingDefinitionProvider : SettingDefinitionProvider
6 | {
7 | public override void Define(ISettingDefinitionContext context)
8 | {
9 | //Define your own settings here. Example:
10 | //context.Add(new SettingDefinition(AbpToExcelSettings.MySetting1));
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/AbpToExcel.TestBase/AbpToExcelTestDataSeedContributor.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Volo.Abp.Data;
3 | using Volo.Abp.DependencyInjection;
4 |
5 | namespace AbpToExcel;
6 |
7 | public class AbpToExcelTestDataSeedContributor : IDataSeedContributor, ITransientDependency
8 | {
9 | public Task SeedAsync(DataSeedContext context)
10 | {
11 | /* Seed additional test data... */
12 |
13 | return Task.CompletedTask;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/test/AbpToExcel.HttpApi.Client.ConsoleTestApp/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "RemoteServices": {
3 | "Default": {
4 | "BaseUrl": "https://localhost:44316"
5 | }
6 | },
7 | "IdentityClients": {
8 | "Default": {
9 | "GrantType": "password",
10 | "ClientId": "AbpToExcel_App",
11 | "UserName": "admin",
12 | "UserPassword": "1q2w3E*",
13 | "Authority": "https://localhost:44316",
14 | "Scope": "AbpToExcel"
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/Data/NullAbpToExcelDbSchemaMigrator.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Volo.Abp.DependencyInjection;
3 |
4 | namespace AbpToExcel.Data;
5 |
6 | /* This is used if database provider does't define
7 | * IAbpToExcelDbSchemaMigrator implementation.
8 | */
9 | public class NullAbpToExcelDbSchemaMigrator : IAbpToExcelDbSchemaMigrator, ITransientDependency
10 | {
11 | public Task MigrateAsync()
12 | {
13 | return Task.CompletedTask;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application/AbpToExcelApplicationAutoMapperProfile.cs:
--------------------------------------------------------------------------------
1 | using AutoMapper;
2 |
3 | namespace AbpToExcel;
4 |
5 | public class AbpToExcelApplicationAutoMapperProfile : Profile
6 | {
7 | public AbpToExcelApplicationAutoMapperProfile()
8 | {
9 | /* You can configure your AutoMapper mapping configuration here.
10 | * Alternatively, you can split your mapping configurations
11 | * into multiple profile classes for a better organization. */
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application/AbpToExcelAppService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using AbpToExcel.Localization;
5 | using Volo.Abp.Application.Services;
6 |
7 | namespace AbpToExcel;
8 |
9 | /* Inherit your application services from this class.
10 | */
11 | public abstract class AbpToExcelAppService : ApplicationService
12 | {
13 | protected AbpToExcelAppService()
14 | {
15 | LocalizationResource = typeof(AbpToExcelResource);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/AbpToExcelBundleContributor.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Bundling;
2 |
3 | namespace AbpToExcel.Blazor;
4 |
5 | /* Add your global styles/scripts here.
6 | * See https://docs.abp.io/en/abp/latest/UI/Blazor/Global-Scripts-Styles to learn how to use it
7 | */
8 | public class AbpToExcelBundleContributor : IBundleContributor
9 | {
10 | public void AddScripts(BundleContext context)
11 | {
12 |
13 | }
14 |
15 | public void AddStyles(BundleContext context)
16 | {
17 | context.Add("main.css", true);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/AbpToExcel.DbMigrator/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=AbpToExcel;Trusted_Connection=True;TrustServerCertificate=True"
4 | },
5 | "OpenIddict": {
6 | "Applications": {
7 | "AbpToExcel_Blazor": {
8 | "ClientId": "AbpToExcel_Blazor",
9 | "RootUrl": "https://localhost:44319"
10 | },
11 | "AbpToExcel_Swagger": {
12 | "ClientId": "AbpToExcel_Swagger",
13 | "RootUrl": "https://localhost:44316"
14 | }
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | latest
4 | 1.0.0
5 | $(NoWarn);CS1591
6 | app
7 |
8 |
9 |
10 |
11 | $(NoWarn);0436
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/_Imports.razor:
--------------------------------------------------------------------------------
1 | @using System.Net.Http
2 | @using Microsoft.AspNetCore.Authorization
3 | @using Microsoft.AspNetCore.Components.Authorization
4 | @using Microsoft.AspNetCore.Components.Forms
5 | @using Microsoft.AspNetCore.Components.Routing
6 | @using Microsoft.AspNetCore.Components.Web
7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http
8 | @using Microsoft.JSInterop
9 | @using Volo.Abp.AspNetCore.Components.Web
10 | @using AbpToExcel.Blazor
11 | @using Blazorise
12 | @using Blazorise.DataGrid
13 | @using Volo.Abp.BlazoriseUI
14 | @using Volo.Abp.BlazoriseUI.Components
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "App": {
3 | "SelfUrl": "https://localhost:44319"
4 | },
5 | "AuthServer": {
6 | "Authority": "https://localhost:44316",
7 | "ClientId": "AbpToExcel_Blazor",
8 | "ResponseType": "code"
9 | },
10 | "RemoteServices": {
11 | "Default": {
12 | "BaseUrl": "https://localhost:44316"
13 | }
14 | },
15 | "AbpCli": {
16 | "Bundle": {
17 | "Mode": "BundleAndMinify", /* Options: None, Bundle, BundleAndMinify */
18 | "Name": "global",
19 | "Parameters": {
20 |
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "App": {
3 | "SelfUrl": "https://localhost:44316",
4 | "CorsOrigins": "https://*.AbpToExcel.com,https://localhost:44319",
5 | "RedirectAllowedUrls": "https://localhost:44319"
6 | },
7 | "ConnectionStrings": {
8 | "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=AbpToExcel;Trusted_Connection=True;TrustServerCertificate=True"
9 | },
10 | "AuthServer": {
11 | "Authority": "https://localhost:44316",
12 | "RequireHttpsMetadata": false,
13 | "SwaggerClientId": "AbpToExcel_Swagger"
14 | },
15 | "StringEncryption": {
16 | "DefaultPassPhrase": "u6i1Yj4vAsN6KYV7"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
3 |
4 | namespace AbpToExcel.Blazor;
5 |
6 | public class Program
7 | {
8 | public async static Task Main(string[] args)
9 | {
10 | var builder = WebAssemblyHostBuilder.CreateDefault(args);
11 |
12 | var application = await builder.AddApplicationAsync(options =>
13 | {
14 | options.UseAutofac();
15 | });
16 |
17 | var host = builder.Build();
18 |
19 | await application.InitializeApplicationAsync(host.Services);
20 |
21 | await host.RunAsync();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/test/AbpToExcel.Domain.Tests/AbpToExcel.Domain.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/AbpToExcel.Application.Tests/AbpToExcel.Application.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/test/AbpToExcel.HttpApi.Client.ConsoleTestApp/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Microsoft.Extensions.Hosting;
5 |
6 | namespace AbpToExcel.HttpApi.Client.ConsoleTestApp;
7 |
8 | class Program
9 | {
10 | static async Task Main(string[] args)
11 | {
12 | await CreateHostBuilder(args).RunConsoleAsync();
13 | }
14 |
15 | public static IHostBuilder CreateHostBuilder(string[] args) =>
16 | Host.CreateDefaultBuilder(args)
17 | .AddAppSettingsSecretsJson()
18 | .ConfigureServices((hostContext, services) =>
19 | {
20 | services.AddHostedService();
21 | });
22 | }
23 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "https://localhost:44316",
7 | "sslPort": 44316
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "AbpToExcel.HttpApi.Host": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "applicationUrl": "https://localhost:44316",
22 | "environmentVariables": {
23 | "ASPNETCORE_ENVIRONMENT": "Development"
24 | }
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Application.Contracts/Permissions/AbpToExcelPermissionDefinitionProvider.cs:
--------------------------------------------------------------------------------
1 | using AbpToExcel.Localization;
2 | using Volo.Abp.Authorization.Permissions;
3 | using Volo.Abp.Localization;
4 |
5 | namespace AbpToExcel.Permissions;
6 |
7 | public class AbpToExcelPermissionDefinitionProvider : PermissionDefinitionProvider
8 | {
9 | public override void Define(IPermissionDefinitionContext context)
10 | {
11 | var myGroup = context.AddGroup(AbpToExcelPermissions.GroupName);
12 | //Define your own permissions here. Example:
13 | //myGroup.AddPermission(AbpToExcelPermissions.MyPermission1, L("Permission:MyPermission1"));
14 | }
15 |
16 | private static LocalizableString L(string name)
17 | {
18 | return LocalizableString.Create(name);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/AbpToExcel.EntityFrameworkCore.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/AbpToExcelGlobalFeatureConfigurator.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Threading;
2 |
3 | namespace AbpToExcel;
4 |
5 | public static class AbpToExcelGlobalFeatureConfigurator
6 | {
7 | private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
8 |
9 | public static void Configure()
10 | {
11 | OneTimeRunner.Run(() =>
12 | {
13 | /* You can configure (enable/disable) global features of the used modules here.
14 | *
15 | * YOU CAN SAFELY DELETE THIS CLASS AND REMOVE ITS USAGES IF YOU DON'T NEED TO IT!
16 | *
17 | * Please refer to the documentation to lear more about the Global Features System:
18 | * https://docs.abp.io/en/abp/latest/Global-Features
19 | */
20 | });
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/Pages/Index.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 | @using AbpToExcel.ExcelExport
3 | @inject IExportToExcelAppService ExportToExcelAppService
4 | @inject IJSRuntime JsRuntime
5 |
6 |
7 |
14 |
15 |
16 | @code {
17 | private async Task ExportToExcel()
18 | {
19 | var excelBytes = await ExportToExcelAppService.ExportToExcel();
20 | await JsRuntime.InvokeVoidAsync("saveAsFile", $"test_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.xlsx",
21 | Convert.ToBase64String(excelBytes));
22 | }
23 | }
--------------------------------------------------------------------------------
/test/AbpToExcel.TestBase/Security/FakeCurrentPrincipalAccessor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Security.Claims;
3 | using Volo.Abp.DependencyInjection;
4 | using Volo.Abp.Security.Claims;
5 |
6 | namespace AbpToExcel.Security;
7 |
8 | [Dependency(ReplaceServices = true)]
9 | public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor
10 | {
11 | protected override ClaimsPrincipal GetClaimsPrincipal()
12 | {
13 | return GetPrincipal();
14 | }
15 |
16 | private ClaimsPrincipal GetPrincipal()
17 | {
18 | return new ClaimsPrincipal(new ClaimsIdentity(new List
19 | {
20 | new Claim(AbpClaimTypes.UserId, "2e701e62-0953-4dd3-910b-dc6cc93ccb0d"),
21 | new Claim(AbpClaimTypes.UserName, "admin"),
22 | new Claim(AbpClaimTypes.Email, "admin@abp.io")
23 | }));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/test/AbpToExcel.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Volo.Abp.Account;
4 | using Volo.Abp.DependencyInjection;
5 |
6 | namespace AbpToExcel.HttpApi.Client.ConsoleTestApp;
7 |
8 | public class ClientDemoService : ITransientDependency
9 | {
10 | private readonly IProfileAppService _profileAppService;
11 |
12 | public ClientDemoService(IProfileAppService profileAppService)
13 | {
14 | _profileAppService = profileAppService;
15 | }
16 |
17 | public async Task RunAsync()
18 | {
19 | var output = await _profileAppService.GetAsync();
20 | Console.WriteLine($"UserName : {output.UserName}");
21 | Console.WriteLine($"Email : {output.Email}");
22 | Console.WriteLine($"Name : {output.Name}");
23 | Console.WriteLine($"Surname : {output.Surname}");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application.Contracts/AbpToExcelDtoExtensions.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Identity;
2 | using Volo.Abp.ObjectExtending;
3 | using Volo.Abp.Threading;
4 |
5 | namespace AbpToExcel;
6 |
7 | public static class AbpToExcelDtoExtensions
8 | {
9 | private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
10 |
11 | public static void Configure()
12 | {
13 | OneTimeRunner.Run(() =>
14 | {
15 | /* You can add extension properties to DTOs
16 | * defined in the depended modules.
17 | *
18 | * Example:
19 | *
20 | * ObjectExtensionManager.Instance
21 | * .AddOrUpdateProperty("Title");
22 | *
23 | * See the documentation for more:
24 | * https://docs.abp.io/en/abp/latest/Object-Extensions
25 | */
26 | });
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "https://localhost:44319",
7 | "sslPort": 44319
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
15 | "environmentVariables": {
16 | "ASPNETCORE_ENVIRONMENT": "Development"
17 | }
18 | },
19 | "AbpToExcel.Blazor": {
20 | "commandName": "Project",
21 | "launchBrowser": true,
22 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
23 | "applicationUrl": "https://localhost:44319",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | AbpToExcel.Blazor
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi/AbpToExcel.HttpApi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application.Contracts/AbpToExcelApplicationContractsModule.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Account;
2 | using Volo.Abp.FeatureManagement;
3 | using Volo.Abp.Identity;
4 | using Volo.Abp.Modularity;
5 | using Volo.Abp.ObjectExtending;
6 | using Volo.Abp.PermissionManagement;
7 | using Volo.Abp.SettingManagement;
8 | using Volo.Abp.TenantManagement;
9 |
10 | namespace AbpToExcel;
11 |
12 | [DependsOn(
13 | typeof(AbpToExcelDomainSharedModule),
14 | typeof(AbpAccountApplicationContractsModule),
15 | typeof(AbpFeatureManagementApplicationContractsModule),
16 | typeof(AbpIdentityApplicationContractsModule),
17 | typeof(AbpPermissionManagementApplicationContractsModule),
18 | typeof(AbpSettingManagementApplicationContractsModule),
19 | typeof(AbpTenantManagementApplicationContractsModule),
20 | typeof(AbpObjectExtendingModule)
21 | )]
22 | public class AbpToExcelApplicationContractsModule : AbpModule
23 | {
24 | public override void PreConfigureServices(ServiceConfigurationContext context)
25 | {
26 | AbpToExcelDtoExtensions.Configure();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application/AbpToExcelApplicationModule.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.Account;
2 | using Volo.Abp.AutoMapper;
3 | using Volo.Abp.FeatureManagement;
4 | using Volo.Abp.Identity;
5 | using Volo.Abp.Modularity;
6 | using Volo.Abp.PermissionManagement;
7 | using Volo.Abp.SettingManagement;
8 | using Volo.Abp.TenantManagement;
9 |
10 | namespace AbpToExcel;
11 |
12 | [DependsOn(
13 | typeof(AbpToExcelDomainModule),
14 | typeof(AbpAccountApplicationModule),
15 | typeof(AbpToExcelApplicationContractsModule),
16 | typeof(AbpIdentityApplicationModule),
17 | typeof(AbpPermissionManagementApplicationModule),
18 | typeof(AbpTenantManagementApplicationModule),
19 | typeof(AbpFeatureManagementApplicationModule),
20 | typeof(AbpSettingManagementApplicationModule)
21 | )]
22 | public class AbpToExcelApplicationModule : AbpModule
23 | {
24 | public override void ConfigureServices(ServiceConfigurationContext context)
25 | {
26 | Configure(options =>
27 | {
28 | options.AddMaps();
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/test/AbpToExcel.HttpApi.Client.ConsoleTestApp/AbpToExcelConsoleApiClientModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Extensions.DependencyInjection;
3 | using Polly;
4 | using Volo.Abp.Autofac;
5 | using Volo.Abp.Http.Client;
6 | using Volo.Abp.Http.Client.IdentityModel;
7 | using Volo.Abp.Modularity;
8 |
9 | namespace AbpToExcel.HttpApi.Client.ConsoleTestApp;
10 |
11 | [DependsOn(
12 | typeof(AbpAutofacModule),
13 | typeof(AbpToExcelHttpApiClientModule),
14 | typeof(AbpHttpClientIdentityModelModule)
15 | )]
16 | public class AbpToExcelConsoleApiClientModule : AbpModule
17 | {
18 | public override void PreConfigureServices(ServiceConfigurationContext context)
19 | {
20 | PreConfigure(options =>
21 | {
22 | options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
23 | {
24 | clientBuilder.AddTransientHttpErrorPolicy(
25 | policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
26 | );
27 | });
28 | });
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Bart Van Hoey
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/AbpToExcel.Application.Tests/Samples/SampleAppServiceTests.cs:
--------------------------------------------------------------------------------
1 | using Shouldly;
2 | using System.Threading.Tasks;
3 | using Volo.Abp.Identity;
4 | using Volo.Abp.Modularity;
5 | using Xunit;
6 |
7 | namespace AbpToExcel.Samples;
8 |
9 | /* This is just an example test class.
10 | * Normally, you don't test code of the modules you are using
11 | * (like IIdentityUserAppService here).
12 | * Only test your own application services.
13 | */
14 | public abstract class SampleAppServiceTests : AbpToExcelApplicationTestBase
15 | where TStartupModule : IAbpModule
16 | {
17 | private readonly IIdentityUserAppService _userAppService;
18 |
19 | protected SampleAppServiceTests()
20 | {
21 | _userAppService = GetRequiredService();
22 | }
23 |
24 | [Fact]
25 | public async Task Initial_Data_Should_Contain_Admin_User()
26 | {
27 | //Act
28 | var result = await _userAppService.GetListAsync(new GetIdentityUsersInput());
29 |
30 | //Assert
31 | result.TotalCount.ShouldBeGreaterThan(0);
32 | result.Items.ShouldContain(u => u.UserName == "admin");
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/AbpToExcel.EntityFrameworkCore/EntityFrameworkCore/EntityFrameworkCoreAbpToExcelDbSchemaMigrator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using AbpToExcel.Data;
6 | using Volo.Abp.DependencyInjection;
7 |
8 | namespace AbpToExcel.EntityFrameworkCore;
9 |
10 | public class EntityFrameworkCoreAbpToExcelDbSchemaMigrator
11 | : IAbpToExcelDbSchemaMigrator, ITransientDependency
12 | {
13 | private readonly IServiceProvider _serviceProvider;
14 |
15 | public EntityFrameworkCoreAbpToExcelDbSchemaMigrator(
16 | IServiceProvider serviceProvider)
17 | {
18 | _serviceProvider = serviceProvider;
19 | }
20 |
21 | public async Task MigrateAsync()
22 | {
23 | /* We intentionally resolve the AbpToExcelDbContext
24 | * from IServiceProvider (instead of directly injecting it)
25 | * to properly get the connection string of the current tenant in the
26 | * current scope.
27 | */
28 |
29 | await _serviceProvider
30 | .GetRequiredService()
31 | .Database
32 | .MigrateAsync();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application/AbpToExcel.Application.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application.Contracts/AbpToExcel.Application.Contracts.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | netstandard2.0;netstandard2.1;net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Client/AbpToExcel.HttpApi.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | netstandard2.0;netstandard2.1;net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/AbpToExcel.EntityFrameworkCore/EntityFrameworkCore/AbpToExcelDbContextFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.EntityFrameworkCore.Design;
5 | using Microsoft.Extensions.Configuration;
6 |
7 | namespace AbpToExcel.EntityFrameworkCore;
8 |
9 | /* This class is needed for EF Core console commands
10 | * (like Add-Migration and Update-Database commands) */
11 | public class AbpToExcelDbContextFactory : IDesignTimeDbContextFactory
12 | {
13 | public AbpToExcelDbContext CreateDbContext(string[] args)
14 | {
15 | AbpToExcelEfCoreEntityExtensionMappings.Configure();
16 |
17 | var configuration = BuildConfiguration();
18 |
19 | var builder = new DbContextOptionsBuilder()
20 | .UseSqlServer(configuration.GetConnectionString("Default"));
21 |
22 | return new AbpToExcelDbContext(builder.Options);
23 | }
24 |
25 | private static IConfigurationRoot BuildConfiguration()
26 | {
27 | var builder = new ConfigurationBuilder()
28 | .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../AbpToExcel.DbMigrator/"))
29 | .AddJsonFile("appsettings.json", optional: false);
30 |
31 | return builder.Build();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi/AbpToExcelHttpApiModule.cs:
--------------------------------------------------------------------------------
1 | using Localization.Resources.AbpUi;
2 | using AbpToExcel.Localization;
3 | using Volo.Abp.Account;
4 | using Volo.Abp.FeatureManagement;
5 | using Volo.Abp.Identity;
6 | using Volo.Abp.Localization;
7 | using Volo.Abp.Modularity;
8 | using Volo.Abp.PermissionManagement.HttpApi;
9 | using Volo.Abp.SettingManagement;
10 | using Volo.Abp.TenantManagement;
11 |
12 | namespace AbpToExcel;
13 |
14 | [DependsOn(
15 | typeof(AbpToExcelApplicationContractsModule),
16 | typeof(AbpAccountHttpApiModule),
17 | typeof(AbpIdentityHttpApiModule),
18 | typeof(AbpPermissionManagementHttpApiModule),
19 | typeof(AbpTenantManagementHttpApiModule),
20 | typeof(AbpFeatureManagementHttpApiModule),
21 | typeof(AbpSettingManagementHttpApiModule)
22 | )]
23 | public class AbpToExcelHttpApiModule : AbpModule
24 | {
25 | public override void ConfigureServices(ServiceConfigurationContext context)
26 | {
27 | ConfigureLocalization();
28 | }
29 |
30 | private void ConfigureLocalization()
31 | {
32 | Configure(options =>
33 | {
34 | options.Resources
35 | .Get()
36 | .AddBaseTypes(
37 | typeof(AbpUiResource)
38 | );
39 | });
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/wwwroot/main.css:
--------------------------------------------------------------------------------
1 | /* Global styles for the AbpToExcel application */
2 |
3 | :root .lpx-brand-logo {
4 | --lpx-logo: url('/images/logo/leptonx/logo-light.png');
5 | --lpx-logo-icon: url('/images/logo/leptonx/logo-light-thumbnail.png');
6 | }
7 |
8 | .spinner {
9 | width: 40px;
10 | height: 40px;
11 | display: block;
12 | position: fixed;
13 | top: calc( 50% - ( 40px / 2) );
14 | right: calc( 50% - ( 40px / 2) );
15 | }
16 |
17 | .double-bounce1, .double-bounce2 {
18 | width: 100%;
19 | height: 100%;
20 | border-radius: 50%;
21 | background-color: #333;
22 | opacity: 0.6;
23 | position: absolute;
24 | top: 0;
25 | left: 0;
26 | -webkit-animation: sk-bounce 2.0s infinite ease-in-out;
27 | animation: sk-bounce 2.0s infinite ease-in-out;
28 | }
29 |
30 | .double-bounce2 {
31 | -webkit-animation-delay: -1.0s;
32 | animation-delay: -1.0s;
33 | }
34 |
35 | @-webkit-keyframes sk-bounce {
36 | 0%, 100% {
37 | -webkit-transform: scale(0.0)
38 | }
39 |
40 | 50% {
41 | -webkit-transform: scale(1.0)
42 | }
43 | }
44 |
45 | @keyframes sk-bounce {
46 | 0%, 100% {
47 | transform: scale(0.0);
48 | -webkit-transform: scale(0.0);
49 | }
50 |
51 | 50% {
52 | transform: scale(1.0);
53 | -webkit-transform: scale(1.0);
54 | }
55 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/AbpToExcel.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/test/AbpToExcel.HttpApi.Client.ConsoleTestApp/AbpToExcel.HttpApi.Client.ConsoleTestApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net8.0
6 | enable
7 |
8 |
9 |
10 |
11 |
12 | PreserveNewest
13 | Always
14 |
15 |
16 |
17 | PreserveNewest
18 | Always
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/test/AbpToExcel.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Hosting;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Volo.Abp;
7 |
8 | namespace AbpToExcel.HttpApi.Client.ConsoleTestApp;
9 |
10 | public class ConsoleTestAppHostedService : IHostedService
11 | {
12 | private readonly IConfiguration _configuration;
13 |
14 | public ConsoleTestAppHostedService(IConfiguration configuration)
15 | {
16 | _configuration = configuration;
17 | }
18 |
19 | public async Task StartAsync(CancellationToken cancellationToken)
20 | {
21 | using (var application = await AbpApplicationFactory.CreateAsync(options =>
22 | {
23 | options.Services.ReplaceConfiguration(_configuration);
24 | options.UseAutofac();
25 | }))
26 | {
27 | await application.InitializeAsync();
28 |
29 | var demo = application.ServiceProvider.GetRequiredService();
30 | await demo.RunAsync();
31 |
32 | await application.ShutdownAsync();
33 | }
34 | }
35 |
36 | public Task StopAsync(CancellationToken cancellationToken)
37 | {
38 | return Task.CompletedTask;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Client/AbpToExcelHttpApiClientModule.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 | using Volo.Abp.Account;
3 | using Volo.Abp.FeatureManagement;
4 | using Volo.Abp.Identity;
5 | using Volo.Abp.Modularity;
6 | using Volo.Abp.PermissionManagement;
7 | using Volo.Abp.TenantManagement;
8 | using Volo.Abp.SettingManagement;
9 | using Volo.Abp.VirtualFileSystem;
10 |
11 | namespace AbpToExcel;
12 |
13 | [DependsOn(
14 | typeof(AbpToExcelApplicationContractsModule),
15 | typeof(AbpAccountHttpApiClientModule),
16 | typeof(AbpIdentityHttpApiClientModule),
17 | typeof(AbpPermissionManagementHttpApiClientModule),
18 | typeof(AbpTenantManagementHttpApiClientModule),
19 | typeof(AbpFeatureManagementHttpApiClientModule),
20 | typeof(AbpSettingManagementHttpApiClientModule)
21 | )]
22 | public class AbpToExcelHttpApiClientModule : AbpModule
23 | {
24 | public const string RemoteServiceName = "Default";
25 |
26 | public override void ConfigureServices(ServiceConfigurationContext context)
27 | {
28 | context.Services.AddHttpClientProxies(
29 | typeof(AbpToExcelApplicationContractsModule).Assembly,
30 | RemoteServiceName
31 | );
32 |
33 | Configure(options =>
34 | {
35 | options.FileSets.AddEmbedded();
36 | });
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/test/AbpToExcel.TestBase/AbpToExcel.TestBase.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | all
23 | runtime; build; native; contentfiles; analyzers
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/test/AbpToExcel.TestBase/AbpToExcelTestBaseModule.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 | using Volo.Abp;
3 | using Volo.Abp.Authorization;
4 | using Volo.Abp.Autofac;
5 | using Volo.Abp.BackgroundJobs;
6 | using Volo.Abp.Data;
7 | using Volo.Abp.Modularity;
8 | using Volo.Abp.Threading;
9 |
10 | namespace AbpToExcel;
11 |
12 | [DependsOn(
13 | typeof(AbpAutofacModule),
14 | typeof(AbpTestBaseModule),
15 | typeof(AbpAuthorizationModule),
16 | typeof(AbpBackgroundJobsAbstractionsModule)
17 | )]
18 | public class AbpToExcelTestBaseModule : AbpModule
19 | {
20 | public override void ConfigureServices(ServiceConfigurationContext context)
21 | {
22 | Configure(options =>
23 | {
24 | options.IsJobExecutionEnabled = false;
25 | });
26 |
27 | context.Services.AddAlwaysAllowAuthorization();
28 | }
29 |
30 | public override void OnApplicationInitialization(ApplicationInitializationContext context)
31 | {
32 | SeedTestData(context);
33 | }
34 |
35 | private static void SeedTestData(ApplicationInitializationContext context)
36 | {
37 | AsyncHelper.RunSync(async () =>
38 | {
39 | using (var scope = context.ServiceProvider.CreateScope())
40 | {
41 | await scope.ServiceProvider
42 | .GetRequiredService()
43 | .SeedAsync();
44 | }
45 | });
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/AbpToExcel.Domain.Shared.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | netstandard2.0;netstandard2.1;net8.0
7 | enable
8 | AbpToExcel
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/AbpToExcel.DbMigrator/Program.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Threading.Tasks;
3 | using Microsoft.Extensions.Configuration;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.Extensions.Hosting;
6 | using Microsoft.Extensions.Logging;
7 | using Serilog;
8 | using Serilog.Events;
9 |
10 | namespace AbpToExcel.DbMigrator;
11 |
12 | class Program
13 | {
14 | static async Task Main(string[] args)
15 | {
16 | Log.Logger = new LoggerConfiguration()
17 | .MinimumLevel.Information()
18 | .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
19 | .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning)
20 | #if DEBUG
21 | .MinimumLevel.Override("AbpToExcel", LogEventLevel.Debug)
22 | #else
23 | .MinimumLevel.Override("AbpToExcel", LogEventLevel.Information)
24 | #endif
25 | .Enrich.FromLogContext()
26 | .WriteTo.Async(c => c.File("Logs/logs.txt"))
27 | .WriteTo.Async(c => c.Console())
28 | .CreateLogger();
29 |
30 | await CreateHostBuilder(args).RunConsoleAsync();
31 | }
32 |
33 | public static IHostBuilder CreateHostBuilder(string[] args) =>
34 | Host.CreateDefaultBuilder(args)
35 | .AddAppSettingsSecretsJson()
36 | .ConfigureLogging((context, logging) => logging.ClearProviders())
37 | .ConfigureServices((hostContext, services) =>
38 | {
39 | services.AddHostedService();
40 | });
41 | }
42 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/AbpToExcel.Blazor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Shouldly;
3 | using System;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Volo.Abp.Domain.Repositories;
7 | using Volo.Abp.Identity;
8 | using Xunit;
9 |
10 | namespace AbpToExcel.EntityFrameworkCore.Samples;
11 |
12 | /* This is just an example test class.
13 | * Normally, you don't test ABP framework code
14 | * (like default AppUser repository IRepository here).
15 | * Only test your custom repository methods.
16 | */
17 | [Collection(AbpToExcelTestConsts.CollectionDefinitionName)]
18 | public class SampleRepositoryTests : AbpToExcelEntityFrameworkCoreTestBase
19 | {
20 | private readonly IRepository _appUserRepository;
21 |
22 | public SampleRepositoryTests()
23 | {
24 | _appUserRepository = GetRequiredService>();
25 | }
26 |
27 | [Fact]
28 | public async Task Should_Query_AppUser()
29 | {
30 | /* Need to manually start Unit Of Work because
31 | * FirstOrDefaultAsync should be executed while db connection / context is available.
32 | */
33 | await WithUnitOfWorkAsync(async () =>
34 | {
35 | //Act
36 | var adminUser = await (await _appUserRepository.GetQueryableAsync())
37 | .Where(u => u.UserName == "admin")
38 | .FirstOrDefaultAsync();
39 |
40 | //Assert
41 | adminUser.ShouldNotBeNull();
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/AbpToExcel.EntityFrameworkCore/AbpToExcel.EntityFrameworkCore.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | all
27 | runtime; build; native; contentfiles; analyzers
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/AbpToExcel.HttpApi.Host.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | net8.0
7 | enable
8 | AbpToExcel
9 | true
10 | AbpToExcel-4681b4fd-151f-4221-84a4-929d86723e4c
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/test/AbpToExcel.Domain.Tests/Samples/SampleDomainTests.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Shouldly;
3 | using Volo.Abp.Identity;
4 | using Volo.Abp.Modularity;
5 | using Xunit;
6 |
7 | namespace AbpToExcel.Samples;
8 |
9 | /* This is just an example test class.
10 | * Normally, you don't test code of the modules you are using
11 | * (like IdentityUserManager here).
12 | * Only test your own domain services.
13 | */
14 | public abstract class SampleDomainTests : AbpToExcelDomainTestBase
15 | where TStartupModule : IAbpModule
16 | {
17 | private readonly IIdentityUserRepository _identityUserRepository;
18 | private readonly IdentityUserManager _identityUserManager;
19 |
20 | protected SampleDomainTests()
21 | {
22 | _identityUserRepository = GetRequiredService();
23 | _identityUserManager = GetRequiredService();
24 | }
25 |
26 | [Fact]
27 | public async Task Should_Set_Email_Of_A_User()
28 | {
29 | IdentityUser adminUser;
30 |
31 | /* Need to manually start Unit Of Work because
32 | * FirstOrDefaultAsync should be executed while db connection / context is available.
33 | */
34 | await WithUnitOfWorkAsync(async () =>
35 | {
36 | adminUser = await _identityUserRepository
37 | .FindByNormalizedUserNameAsync("ADMIN");
38 |
39 | await _identityUserManager.SetEmailAsync(adminUser, "newemail@abp.io");
40 | await _identityUserRepository.UpdateAsync(adminUser);
41 | });
42 |
43 | adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN");
44 | adminUser.Email.ShouldBe("newemail@abp.io");
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/AbpToExcel.DbMigrator/DbMigratorHostedService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using System.Threading.Tasks;
3 | using Microsoft.Extensions.Configuration;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.Extensions.Hosting;
6 | using AbpToExcel.Data;
7 | using Serilog;
8 | using Volo.Abp;
9 | using Volo.Abp.Data;
10 |
11 | namespace AbpToExcel.DbMigrator;
12 |
13 | public class DbMigratorHostedService : IHostedService
14 | {
15 | private readonly IHostApplicationLifetime _hostApplicationLifetime;
16 | private readonly IConfiguration _configuration;
17 |
18 | public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime, IConfiguration configuration)
19 | {
20 | _hostApplicationLifetime = hostApplicationLifetime;
21 | _configuration = configuration;
22 | }
23 |
24 | public async Task StartAsync(CancellationToken cancellationToken)
25 | {
26 | using (var application = await AbpApplicationFactory.CreateAsync(options =>
27 | {
28 | options.Services.ReplaceConfiguration(_configuration);
29 | options.UseAutofac();
30 | options.Services.AddLogging(c => c.AddSerilog());
31 | options.AddDataMigrationEnvironment();
32 | }))
33 | {
34 | await application.InitializeAsync();
35 |
36 | await application
37 | .ServiceProvider
38 | .GetRequiredService()
39 | .MigrateAsync();
40 |
41 | await application.ShutdownAsync();
42 |
43 | _hostApplicationLifetime.StopApplication();
44 | }
45 | }
46 |
47 | public Task StopAsync(CancellationToken cancellationToken)
48 | {
49 | return Task.CompletedTask;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/AbpToExcel.DbMigrator/AbpToExcel.DbMigrator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Exe
7 | net8.0
8 | enable
9 |
10 |
11 |
12 |
13 |
14 | PreserveNewest
15 | Always
16 |
17 |
18 |
19 | PreserveNewest
20 | Always
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Microsoft.AspNetCore.Builder;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using Microsoft.Extensions.Hosting;
6 | using Serilog;
7 | using Serilog.Events;
8 |
9 | namespace AbpToExcel;
10 |
11 | public class Program
12 | {
13 | public async static Task Main(string[] args)
14 | {
15 | Log.Logger = new LoggerConfiguration()
16 | #if DEBUG
17 | .MinimumLevel.Debug()
18 | #else
19 | .MinimumLevel.Information()
20 | #endif
21 | .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
22 | .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
23 | .Enrich.FromLogContext()
24 | .WriteTo.Async(c => c.File("Logs/logs.txt"))
25 | .WriteTo.Async(c => c.Console())
26 | .CreateLogger();
27 |
28 | try
29 | {
30 | Log.Information("Starting AbpToExcel.HttpApi.Host.");
31 | var builder = WebApplication.CreateBuilder(args);
32 | builder.Host.AddAppSettingsSecretsJson()
33 | .UseAutofac()
34 | .UseSerilog();
35 | await builder.AddApplicationAsync();
36 | var app = builder.Build();
37 | await app.InitializeApplicationAsync();
38 | await app.RunAsync();
39 | return 0;
40 | }
41 | catch (Exception ex)
42 | {
43 | if (ex is HostAbortedException)
44 | {
45 | throw;
46 | }
47 |
48 | Log.Fatal(ex, "Host terminated unexpectedly!");
49 | return 1;
50 | }
51 | finally
52 | {
53 | Log.CloseAndFlush();
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "buildApi",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/src/AbpToExcel.HttpApi.Host/AbpToExcel.HttpApi.Host.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "buildDbMigrator",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "build",
22 | "${workspaceFolder}/src/AbpToExcel.DbMigrator/AbpToExcel.DbMigrator.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "publish",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "publish",
34 | "${workspaceFolder}/src/AbpToExcel.HttpApi.Host/AbpToExcel.HttpApi.Host.csproj",
35 | "/property:GenerateFullPaths=true",
36 | "/consoleloggerparameters:NoSummary"
37 | ],
38 | "problemMatcher": "$msCompile"
39 | },
40 | {
41 | "label": "watch",
42 | "command": "dotnet",
43 | "type": "process",
44 | "args": [
45 | "watch",
46 | "run",
47 | "${workspaceFolder}/src/AbpToExcel.HttpApi.Host/AbpToExcel.HttpApi.Host.csproj",
48 | "/property:GenerateFullPaths=true",
49 | "/consoleloggerparameters:NoSummary"
50 | ],
51 | "problemMatcher": "$msCompile"
52 | }
53 | ]
54 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.EntityFrameworkCore/EntityFrameworkCore/AbpToExcelEfCoreEntityExtensionMappings.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Volo.Abp.Identity;
3 | using Volo.Abp.ObjectExtending;
4 | using Volo.Abp.Threading;
5 |
6 | namespace AbpToExcel.EntityFrameworkCore;
7 |
8 | public static class AbpToExcelEfCoreEntityExtensionMappings
9 | {
10 | private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
11 |
12 | public static void Configure()
13 | {
14 | AbpToExcelGlobalFeatureConfigurator.Configure();
15 | AbpToExcelModuleExtensionConfigurator.Configure();
16 |
17 | OneTimeRunner.Run(() =>
18 | {
19 | /* You can configure extra properties for the
20 | * entities defined in the modules used by your application.
21 | *
22 | * This class can be used to map these extra properties to table fields in the database.
23 | *
24 | * USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING.
25 | * USE AbpToExcelModuleExtensionConfigurator CLASS (in the Domain.Shared project)
26 | * FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES
27 | *
28 | * Example: Map a property to a table field:
29 |
30 | ObjectExtensionManager.Instance
31 | .MapEfCoreProperty(
32 | "MyProperty",
33 | (entityBuilder, propertyBuilder) =>
34 | {
35 | propertyBuilder.HasMaxLength(128);
36 | }
37 | );
38 |
39 | * See the documentation for more:
40 | * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities
41 | */
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/test/AbpToExcel.TestBase/AbpToExcelTestBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Volo.Abp;
5 | using Volo.Abp.Modularity;
6 | using Volo.Abp.Uow;
7 | using Volo.Abp.Testing;
8 |
9 | namespace AbpToExcel;
10 |
11 | /* All test classes are derived from this class, directly or indirectly.
12 | */
13 | public abstract class AbpToExcelTestBase : AbpIntegratedTest
14 | where TStartupModule : IAbpModule
15 | {
16 | protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
17 | {
18 | options.UseAutofac();
19 | }
20 |
21 | protected virtual Task WithUnitOfWorkAsync(Func func)
22 | {
23 | return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
24 | }
25 |
26 | protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action)
27 | {
28 | using (var scope = ServiceProvider.CreateScope())
29 | {
30 | var uowManager = scope.ServiceProvider.GetRequiredService();
31 |
32 | using (var uow = uowManager.Begin(options))
33 | {
34 | await action();
35 |
36 | await uow.CompleteAsync();
37 | }
38 | }
39 | }
40 |
41 | protected virtual Task WithUnitOfWorkAsync(Func> func)
42 | {
43 | return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
44 | }
45 |
46 | protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func)
47 | {
48 | using (var scope = ServiceProvider.CreateScope())
49 | {
50 | var uowManager = scope.ServiceProvider.GetRequiredService();
51 |
52 | using (var uow = uowManager.Begin(options))
53 | {
54 | var result = await func();
55 | await uow.CompleteAsync();
56 | return result;
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/AbpToExcelDomainSharedModule.cs:
--------------------------------------------------------------------------------
1 | using AbpToExcel.Localization;
2 | using Volo.Abp.AuditLogging;
3 | using Volo.Abp.BackgroundJobs;
4 | using Volo.Abp.FeatureManagement;
5 | using Volo.Abp.Identity;
6 | using Volo.Abp.Localization;
7 | using Volo.Abp.Localization.ExceptionHandling;
8 | using Volo.Abp.Modularity;
9 | using Volo.Abp.OpenIddict;
10 | using Volo.Abp.PermissionManagement;
11 | using Volo.Abp.SettingManagement;
12 | using Volo.Abp.TenantManagement;
13 | using Volo.Abp.Validation.Localization;
14 | using Volo.Abp.VirtualFileSystem;
15 |
16 | namespace AbpToExcel;
17 |
18 | [DependsOn(
19 | typeof(AbpAuditLoggingDomainSharedModule),
20 | typeof(AbpBackgroundJobsDomainSharedModule),
21 | typeof(AbpFeatureManagementDomainSharedModule),
22 | typeof(AbpIdentityDomainSharedModule),
23 | typeof(AbpOpenIddictDomainSharedModule),
24 | typeof(AbpPermissionManagementDomainSharedModule),
25 | typeof(AbpSettingManagementDomainSharedModule),
26 | typeof(AbpTenantManagementDomainSharedModule)
27 | )]
28 | public class AbpToExcelDomainSharedModule : AbpModule
29 | {
30 | public override void PreConfigureServices(ServiceConfigurationContext context)
31 | {
32 | AbpToExcelGlobalFeatureConfigurator.Configure();
33 | AbpToExcelModuleExtensionConfigurator.Configure();
34 | }
35 |
36 | public override void ConfigureServices(ServiceConfigurationContext context)
37 | {
38 | Configure(options =>
39 | {
40 | options.FileSets.AddEmbedded();
41 | });
42 |
43 | Configure(options =>
44 | {
45 | options.Resources
46 | .Add("en")
47 | .AddBaseTypes(typeof(AbpValidationResource))
48 | .AddVirtualJson("/Localization/AbpToExcel");
49 |
50 | options.DefaultResourceType = typeof(AbpToExcelResource);
51 | });
52 |
53 | Configure(options =>
54 | {
55 | options.MapCodeNamespace("AbpToExcel", typeof(AbpToExcelResource));
56 | });
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/AbpToExcel.EntityFrameworkCore/EntityFrameworkCore/AbpToExcelEntityFrameworkCoreModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Extensions.DependencyInjection;
3 | using Volo.Abp.Uow;
4 | using Volo.Abp.AuditLogging.EntityFrameworkCore;
5 | using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
6 | using Volo.Abp.EntityFrameworkCore;
7 | using Volo.Abp.EntityFrameworkCore.SqlServer;
8 | using Volo.Abp.FeatureManagement.EntityFrameworkCore;
9 | using Volo.Abp.Identity.EntityFrameworkCore;
10 | using Volo.Abp.Modularity;
11 | using Volo.Abp.OpenIddict.EntityFrameworkCore;
12 | using Volo.Abp.PermissionManagement.EntityFrameworkCore;
13 | using Volo.Abp.SettingManagement.EntityFrameworkCore;
14 | using Volo.Abp.TenantManagement.EntityFrameworkCore;
15 |
16 | namespace AbpToExcel.EntityFrameworkCore;
17 |
18 | [DependsOn(
19 | typeof(AbpToExcelDomainModule),
20 | typeof(AbpIdentityEntityFrameworkCoreModule),
21 | typeof(AbpOpenIddictEntityFrameworkCoreModule),
22 | typeof(AbpPermissionManagementEntityFrameworkCoreModule),
23 | typeof(AbpSettingManagementEntityFrameworkCoreModule),
24 | typeof(AbpEntityFrameworkCoreSqlServerModule),
25 | typeof(AbpBackgroundJobsEntityFrameworkCoreModule),
26 | typeof(AbpAuditLoggingEntityFrameworkCoreModule),
27 | typeof(AbpTenantManagementEntityFrameworkCoreModule),
28 | typeof(AbpFeatureManagementEntityFrameworkCoreModule)
29 | )]
30 | public class AbpToExcelEntityFrameworkCoreModule : AbpModule
31 | {
32 | public override void PreConfigureServices(ServiceConfigurationContext context)
33 | {
34 | AbpToExcelEfCoreEntityExtensionMappings.Configure();
35 | }
36 |
37 | public override void ConfigureServices(ServiceConfigurationContext context)
38 | {
39 | context.Services.AddAbpDbContext(options =>
40 | {
41 | /* Remove "includeAllEntities: true" to create
42 | * default repositories only for aggregate roots */
43 | options.AddDefaultRepositories(includeAllEntities: true);
44 | });
45 |
46 | Configure(options =>
47 | {
48 | /* The main point to change your DBMS.
49 | * See also AbpToExcelMigrationsDbContextFactory for EF Core tooling. */
50 | options.UseSqlServer();
51 | });
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Application/ExcelExport/ExcelFileGenerator.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using DocumentFormat.OpenXml;
3 | using DocumentFormat.OpenXml.Packaging;
4 | using DocumentFormat.OpenXml.Spreadsheet;
5 |
6 | namespace AbpToExcel.ExcelExport
7 | {
8 | public static class ExcelFileGenerator
9 | {
10 | public static byte[] GenerateExcelFile()
11 | {
12 | var memoryStream = new MemoryStream();
13 |
14 | using var document = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook);
15 | var workbookPart = document.AddWorkbookPart();
16 | workbookPart.Workbook = new Workbook();
17 |
18 | var worksheetPart = workbookPart.AddNewPart();
19 | worksheetPart.Worksheet = new Worksheet(new SheetData());
20 |
21 | var sheets = workbookPart.Workbook.AppendChild(new Sheets());
22 |
23 | sheets.AppendChild(new Sheet
24 | {
25 | Id = workbookPart.GetIdOfPart(worksheetPart),
26 | SheetId = 1,
27 | Name = "Sheet 1"
28 | });
29 |
30 | var sheetData = worksheetPart.Worksheet.GetFirstChild();
31 |
32 | var row1 = new Row();
33 | row1.AppendChild(
34 | new Cell
35 | {
36 | CellValue = new CellValue("Abp Framework"),
37 | DataType = CellValues.String
38 | }
39 |
40 | );
41 |
42 | sheetData?.AppendChild(row1);
43 |
44 | var row2 = new Row();
45 | row2.AppendChild(
46 | new Cell
47 | {
48 | CellValue = new CellValue("Open Source"),
49 | DataType = CellValues.String
50 | }
51 | );
52 | sheetData?.AppendChild(row2);
53 |
54 | var row3 = new Row();
55 | row3.AppendChild(
56 | new Cell
57 | {
58 | CellValue = new CellValue("WEB APPLICATION FRAMEWORK"),
59 | DataType = CellValues.String
60 | }
61 | );
62 | sheetData?.AppendChild(row3);
63 |
64 | document.Save();
65 |
66 | return memoryStream.ToArray();
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/test/AbpToExcel.EntityFrameworkCore.Tests/EntityFrameworkCore/AbpToExcelEntityFrameworkCoreTestModule.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Data.Sqlite;
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Storage;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Volo.Abp;
7 | using Volo.Abp.EntityFrameworkCore;
8 | using Volo.Abp.EntityFrameworkCore.Sqlite;
9 | using Volo.Abp.FeatureManagement;
10 | using Volo.Abp.Modularity;
11 | using Volo.Abp.PermissionManagement;
12 | using Volo.Abp.Uow;
13 |
14 | namespace AbpToExcel.EntityFrameworkCore;
15 |
16 | [DependsOn(
17 | typeof(AbpToExcelApplicationTestModule),
18 | typeof(AbpToExcelEntityFrameworkCoreModule),
19 | typeof(AbpEntityFrameworkCoreSqliteModule)
20 | )]
21 | public class AbpToExcelEntityFrameworkCoreTestModule : AbpModule
22 | {
23 | private SqliteConnection? _sqliteConnection;
24 |
25 | public override void ConfigureServices(ServiceConfigurationContext context)
26 | {
27 | Configure(options =>
28 | {
29 | options.SaveStaticFeaturesToDatabase = false;
30 | options.IsDynamicFeatureStoreEnabled = false;
31 | });
32 | Configure(options =>
33 | {
34 | options.SaveStaticPermissionsToDatabase = false;
35 | options.IsDynamicPermissionStoreEnabled = false;
36 | });
37 | context.Services.AddAlwaysDisableUnitOfWorkTransaction();
38 |
39 | ConfigureInMemorySqlite(context.Services);
40 | }
41 |
42 | private void ConfigureInMemorySqlite(IServiceCollection services)
43 | {
44 | _sqliteConnection = CreateDatabaseAndGetConnection();
45 |
46 | services.Configure(options =>
47 | {
48 | options.Configure(context =>
49 | {
50 | context.DbContextOptions.UseSqlite(_sqliteConnection);
51 | });
52 | });
53 | }
54 |
55 | public override void OnApplicationShutdown(ApplicationShutdownContext context)
56 | {
57 | _sqliteConnection?.Dispose();
58 | }
59 |
60 | private static SqliteConnection CreateDatabaseAndGetConnection()
61 | {
62 | var connection = new SqliteConnection("Data Source=:memory:");
63 | connection.Open();
64 |
65 | var options = new DbContextOptionsBuilder()
66 | .UseSqlite(connection)
67 | .Options;
68 |
69 | using (var context = new AbpToExcelDbContext(options))
70 | {
71 | context.GetService().CreateTables();
72 | }
73 |
74 | return connection;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain.Shared/AbpToExcelModuleExtensionConfigurator.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using Volo.Abp.Identity;
3 | using Volo.Abp.ObjectExtending;
4 | using Volo.Abp.Threading;
5 |
6 | namespace AbpToExcel;
7 |
8 | public static class AbpToExcelModuleExtensionConfigurator
9 | {
10 | private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
11 |
12 | public static void Configure()
13 | {
14 | OneTimeRunner.Run(() =>
15 | {
16 | ConfigureExistingProperties();
17 | ConfigureExtraProperties();
18 | });
19 | }
20 |
21 | private static void ConfigureExistingProperties()
22 | {
23 | /* You can change max lengths for properties of the
24 | * entities defined in the modules used by your application.
25 | *
26 | * Example: Change user and role name max lengths
27 |
28 | AbpUserConsts.MaxNameLength = 99;
29 | IdentityRoleConsts.MaxNameLength = 99;
30 |
31 | * Notice: It is not suggested to change property lengths
32 | * unless you really need it. Go with the standard values wherever possible.
33 | *
34 | * If you are using EF Core, you will need to run the add-migration command after your changes.
35 | */
36 | }
37 |
38 | private static void ConfigureExtraProperties()
39 | {
40 | /* You can configure extra properties for the
41 | * entities defined in the modules used by your application.
42 | *
43 | * This class can be used to define these extra properties
44 | * with a high level, easy to use API.
45 | *
46 | * Example: Add a new property to the user entity of the identity module
47 |
48 | ObjectExtensionManager.Instance.Modules()
49 | .ConfigureIdentity(identity =>
50 | {
51 | identity.ConfigureUser(user =>
52 | {
53 | user.AddOrUpdateProperty( //property type: string
54 | "SocialSecurityNumber", //property name
55 | property =>
56 | {
57 | //validation rules
58 | property.Attributes.Add(new RequiredAttribute());
59 | property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4});
60 |
61 | property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true;
62 |
63 | //...other configurations for this property
64 | }
65 | );
66 | });
67 | });
68 |
69 | * See the documentation for more:
70 | * https://docs.abp.io/en/abp/latest/Module-Entity-Extensions
71 | */
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/Menus/AbpToExcelMenuContributor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Microsoft.Extensions.Configuration;
4 | using Microsoft.Extensions.DependencyInjection;
5 | using AbpToExcel.Localization;
6 | using AbpToExcel.MultiTenancy;
7 | using Volo.Abp.Account.Localization;
8 | using Volo.Abp.Authorization.Permissions;
9 | using Volo.Abp.Identity.Blazor;
10 | using Volo.Abp.SettingManagement.Blazor.Menus;
11 | using Volo.Abp.TenantManagement.Blazor.Navigation;
12 | using Volo.Abp.UI.Navigation;
13 | using Volo.Abp.Users;
14 |
15 | namespace AbpToExcel.Blazor.Menus;
16 |
17 | public class AbpToExcelMenuContributor : IMenuContributor
18 | {
19 | private readonly IConfiguration _configuration;
20 |
21 | public AbpToExcelMenuContributor(IConfiguration configuration)
22 | {
23 | _configuration = configuration;
24 | }
25 |
26 | public async Task ConfigureMenuAsync(MenuConfigurationContext context)
27 | {
28 | if (context.Menu.Name == StandardMenus.Main)
29 | {
30 | await ConfigureMainMenuAsync(context);
31 | }
32 | else if (context.Menu.Name == StandardMenus.User)
33 | {
34 | await ConfigureUserMenuAsync(context);
35 | }
36 | }
37 |
38 | private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
39 | {
40 | var l = context.GetLocalizer();
41 |
42 | context.Menu.Items.Insert(
43 | 0,
44 | new ApplicationMenuItem(
45 | AbpToExcelMenus.Home,
46 | l["Menu:Home"],
47 | "/",
48 | icon: "fas fa-home"
49 | )
50 | );
51 |
52 | var administration = context.Menu.GetAdministration();
53 |
54 | if (MultiTenancyConsts.IsEnabled)
55 | {
56 | administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
57 | }
58 | else
59 | {
60 | administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
61 | }
62 |
63 | administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
64 | administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3);
65 |
66 | return Task.CompletedTask;
67 | }
68 |
69 | private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
70 | {
71 | var accountStringLocalizer = context.GetLocalizer();
72 |
73 | var authServerUrl = _configuration["AuthServer:Authority"] ?? "";
74 |
75 | context.Menu.AddItem(new ApplicationMenuItem(
76 | "Account.Manage",
77 | accountStringLocalizer["MyAccount"],
78 | $"{authServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}",
79 | icon: "fa fa-cog",
80 | order: 1000,
81 | null).RequireAuthenticated());
82 |
83 | return Task.CompletedTask;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/AbpToExcel.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 | WARNING
4 | WARNING
5 | WARNING
6 | WARNING
7 | WARNING
8 | WARNING
9 | WARNING
10 | WARNING
11 | Required
12 | Required
13 | Required
14 | Required
15 | False
16 | True
17 | False
18 | False
19 | True
20 | False
21 | False
22 | SQL
23 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/AbpToExcelDomainModule.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.DependencyInjection;
2 | using Microsoft.Extensions.DependencyInjection.Extensions;
3 | using AbpToExcel.MultiTenancy;
4 | using Volo.Abp.AuditLogging;
5 | using Volo.Abp.BackgroundJobs;
6 | using Volo.Abp.Emailing;
7 | using Volo.Abp.FeatureManagement;
8 | using Volo.Abp.Identity;
9 | using Volo.Abp.Localization;
10 | using Volo.Abp.Modularity;
11 | using Volo.Abp.MultiTenancy;
12 | using Volo.Abp.OpenIddict;
13 | using Volo.Abp.PermissionManagement.Identity;
14 | using Volo.Abp.PermissionManagement.OpenIddict;
15 | using Volo.Abp.SettingManagement;
16 | using Volo.Abp.TenantManagement;
17 |
18 | namespace AbpToExcel;
19 |
20 | [DependsOn(
21 | typeof(AbpToExcelDomainSharedModule),
22 | typeof(AbpAuditLoggingDomainModule),
23 | typeof(AbpBackgroundJobsDomainModule),
24 | typeof(AbpFeatureManagementDomainModule),
25 | typeof(AbpIdentityDomainModule),
26 | typeof(AbpOpenIddictDomainModule),
27 | typeof(AbpPermissionManagementDomainOpenIddictModule),
28 | typeof(AbpPermissionManagementDomainIdentityModule),
29 | typeof(AbpSettingManagementDomainModule),
30 | typeof(AbpTenantManagementDomainModule),
31 | typeof(AbpEmailingModule)
32 | )]
33 | public class AbpToExcelDomainModule : AbpModule
34 | {
35 | public override void ConfigureServices(ServiceConfigurationContext context)
36 | {
37 | Configure(options =>
38 | {
39 | options.Languages.Add(new LanguageInfo("ar", "ar", "العربية", "ae"));
40 | options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
41 | options.Languages.Add(new LanguageInfo("en", "en", "English", "gb"));
42 | options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
43 | options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
44 | options.Languages.Add(new LanguageInfo("hr", "hr", "Croatian"));
45 | options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish", "fi"));
46 | options.Languages.Add(new LanguageInfo("fr", "fr", "Français", "fr"));
47 | options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
48 | options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
49 | options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
50 | options.Languages.Add(new LanguageInfo("ru", "ru", "Русский", "ru"));
51 | options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak", "sk"));
52 | options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe", "tr"));
53 | options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
54 | options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
55 | options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
56 | options.Languages.Add(new LanguageInfo("es", "es", "Español"));
57 | });
58 |
59 | Configure(options =>
60 | {
61 | options.IsEnabled = MultiTenancyConsts.IsEnabled;
62 | });
63 |
64 | #if DEBUG
65 | context.Services.Replace(ServiceDescriptor.Singleton());
66 | #endif
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/AbpToExcel.EntityFrameworkCore/EntityFrameworkCore/AbpToExcelDbContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 | using Volo.Abp.AuditLogging.EntityFrameworkCore;
3 | using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
4 | using Volo.Abp.Data;
5 | using Volo.Abp.DependencyInjection;
6 | using Volo.Abp.EntityFrameworkCore;
7 | using Volo.Abp.FeatureManagement.EntityFrameworkCore;
8 | using Volo.Abp.Identity;
9 | using Volo.Abp.Identity.EntityFrameworkCore;
10 | using Volo.Abp.OpenIddict.EntityFrameworkCore;
11 | using Volo.Abp.PermissionManagement.EntityFrameworkCore;
12 | using Volo.Abp.SettingManagement.EntityFrameworkCore;
13 | using Volo.Abp.TenantManagement;
14 | using Volo.Abp.TenantManagement.EntityFrameworkCore;
15 |
16 | namespace AbpToExcel.EntityFrameworkCore;
17 |
18 | [ReplaceDbContext(typeof(IIdentityDbContext))]
19 | [ReplaceDbContext(typeof(ITenantManagementDbContext))]
20 | [ConnectionStringName("Default")]
21 | public class AbpToExcelDbContext :
22 | AbpDbContext,
23 | IIdentityDbContext,
24 | ITenantManagementDbContext
25 | {
26 | /* Add DbSet properties for your Aggregate Roots / Entities here. */
27 |
28 | #region Entities from the modules
29 |
30 | /* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext
31 | * and replaced them for this DbContext. This allows you to perform JOIN
32 | * queries for the entities of these modules over the repositories easily. You
33 | * typically don't need that for other modules. But, if you need, you can
34 | * implement the DbContext interface of the needed module and use ReplaceDbContext
35 | * attribute just like IIdentityDbContext and ITenantManagementDbContext.
36 | *
37 | * More info: Replacing a DbContext of a module ensures that the related module
38 | * uses this DbContext on runtime. Otherwise, it will use its own DbContext class.
39 | */
40 |
41 | //Identity
42 | public DbSet Users { get; set; }
43 | public DbSet Roles { get; set; }
44 | public DbSet ClaimTypes { get; set; }
45 | public DbSet OrganizationUnits { get; set; }
46 | public DbSet SecurityLogs { get; set; }
47 | public DbSet LinkUsers { get; set; }
48 | public DbSet UserDelegations { get; set; }
49 |
50 | // Tenant Management
51 | public DbSet Tenants { get; set; }
52 | public DbSet TenantConnectionStrings { get; set; }
53 |
54 | #endregion
55 |
56 | public AbpToExcelDbContext(DbContextOptions options)
57 | : base(options)
58 | {
59 |
60 | }
61 |
62 | protected override void OnModelCreating(ModelBuilder builder)
63 | {
64 | base.OnModelCreating(builder);
65 |
66 | /* Include modules to your migration db context */
67 |
68 | builder.ConfigurePermissionManagement();
69 | builder.ConfigureSettingManagement();
70 | builder.ConfigureBackgroundJobs();
71 | builder.ConfigureAuditLogging();
72 | builder.ConfigureIdentity();
73 | builder.ConfigureOpenIddict();
74 | builder.ConfigureFeatureManagement();
75 | builder.ConfigureTenantManagement();
76 |
77 | /* Configure your own tables/entities inside here */
78 |
79 | //builder.Entity(b =>
80 | //{
81 | // b.ToTable(AbpToExcelConsts.DbTablePrefix + "YourEntities", AbpToExcelConsts.DbSchema);
82 | // b.ConfigureByConvention(); //auto configure for the base class props
83 | // //...
84 | //});
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Blazor",
9 | "type": "blazorwasm",
10 | "request": "launch",
11 | "cwd": "${workspaceFolder}/src/AbpToExcel.Blazor",
12 | "url": "https://localhost:44307"
13 | },
14 | {
15 | "name": "ApiDevelopment",
16 | "type": "coreclr",
17 | "request": "launch",
18 | "preLaunchTask": "buildApi",
19 | "program": "${workspaceFolder}/src/AbpToExcel.HttpApi.Host/bin/Debug/net8.0/AbpToExcel.HttpApi.Host.dll",
20 | "args": [],
21 | "cwd": "${workspaceFolder}/src/AbpToExcel.HttpApi.Host",
22 | "stopAtEntry": false,
23 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
24 | "serverReadyAction": {
25 | "action": "openExternally",
26 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
27 | },
28 | "env": {
29 | "ASPNETCORE_ENVIRONMENT": "Development"
30 | },
31 | "sourceFileMap": {
32 | "/Views": "${workspaceFolder}/Views"
33 | }
34 | },
35 | {
36 | "name": "ApiStaging",
37 | "type": "coreclr",
38 | "request": "launch",
39 | "preLaunchTask": "buildApi",
40 | "program": "${workspaceFolder}/src/AbpToExcel.HttpApi.Host/bin/Debug/net8.0/AbpToExcel.HttpApi.Host.dll",
41 | "args": [],
42 | "cwd": "${workspaceFolder}/src/AbpToExcel.HttpApi.Host",
43 | "stopAtEntry": false,
44 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
45 | "serverReadyAction": {
46 | "action": "openExternally",
47 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
48 | },
49 | "env": {
50 | "ASPNETCORE_ENVIRONMENT": "Staging"
51 | },
52 | "sourceFileMap": {
53 | "/Views": "${workspaceFolder}/Views"
54 | }
55 | },
56 | {
57 | "name": "DbMigratorDevelopment",
58 | "type": "coreclr",
59 | "request": "launch",
60 | "preLaunchTask": "buildDbMigrator",
61 | "program": "${workspaceFolder}/src/AbpToExcel.DbMigrator/bin/Debug/net8.0/AbpToExcel.DbMigrator.dll",
62 | "args": [],
63 | "cwd": "${workspaceFolder}/src/AbpToExcel.DbMigrator",
64 | "stopAtEntry": false,
65 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
66 | "serverReadyAction": {
67 | "action": "openExternally",
68 | "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
69 | },
70 | "env": {
71 | "ASPNETCORE_ENVIRONMENT": "Development"
72 | },
73 | "sourceFileMap": {
74 | "/Views": "${workspaceFolder}/Views"
75 | }
76 | },
77 | {
78 | "name": "DbMigratorStaging",
79 | "type": "coreclr",
80 | "request": "launch",
81 | "preLaunchTask": "buildDbMigrator",
82 | "program": "${workspaceFolder}/src/AbpToExcel.DbMigrator/bin/Debug/net8.0/AbpToExcel.DbMigrator.dll",
83 | "args": [],
84 | "cwd": "${workspaceFolder}/src/AbpToExcel.DbMigrator",
85 | "stopAtEntry": false,
86 | "env": {
87 | "ASPNETCORE_ENVIRONMENT": "Staging"
88 | },
89 | "sourceFileMap": {
90 | "/Views": "${workspaceFolder}/Views"
91 | }
92 | }
93 | ],
94 | "compounds": [
95 | {
96 | "name": "Compound",
97 | "configurations": ["ApiDevelopment", "Blazor"]
98 | }
99 | ]
100 | }
--------------------------------------------------------------------------------
/src/AbpToExcel.Blazor/AbpToExcelBlazorModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Http;
3 | using Blazorise.Bootstrap5;
4 | using Blazorise.Icons.FontAwesome;
5 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.DependencyInjection;
8 | using AbpToExcel.Blazor.Menus;
9 | using OpenIddict.Abstractions;
10 | using Volo.Abp.AspNetCore.Components.WebAssembly.LeptonXLiteTheme;
11 | using Volo.Abp.AspNetCore.Components.Web.LeptonXLiteTheme.Themes.LeptonXLite;
12 | using Volo.Abp.AspNetCore.Components.Web.Theming.Routing;
13 | using Volo.Abp.Autofac.WebAssembly;
14 | using Volo.Abp.AutoMapper;
15 | using Volo.Abp.Modularity;
16 | using Volo.Abp.UI.Navigation;
17 | using Volo.Abp.Identity.Blazor.WebAssembly;
18 | using Volo.Abp.Security.Claims;
19 | using Volo.Abp.SettingManagement.Blazor.WebAssembly;
20 | using Volo.Abp.TenantManagement.Blazor.WebAssembly;
21 |
22 | namespace AbpToExcel.Blazor;
23 |
24 | [DependsOn(
25 | typeof(AbpAutofacWebAssemblyModule),
26 | typeof(AbpToExcelHttpApiClientModule),
27 | typeof(AbpAspNetCoreComponentsWebAssemblyLeptonXLiteThemeModule),
28 | typeof(AbpIdentityBlazorWebAssemblyModule),
29 | typeof(AbpTenantManagementBlazorWebAssemblyModule),
30 | typeof(AbpSettingManagementBlazorWebAssemblyModule)
31 | )]
32 | public class AbpToExcelBlazorModule : AbpModule
33 | {
34 | public override void ConfigureServices(ServiceConfigurationContext context)
35 | {
36 | var environment = context.Services.GetSingletonInstance();
37 | var builder = context.Services.GetSingletonInstance();
38 |
39 | ConfigureAuthentication(builder);
40 | ConfigureHttpClient(context, environment);
41 | ConfigureBlazorise(context);
42 | ConfigureRouter(context);
43 | ConfigureUI(builder);
44 | ConfigureMenu(context);
45 | ConfigureAutoMapper(context);
46 | }
47 |
48 | private void ConfigureRouter(ServiceConfigurationContext context)
49 | {
50 | Configure(options =>
51 | {
52 | options.AppAssembly = typeof(AbpToExcelBlazorModule).Assembly;
53 | });
54 | }
55 |
56 | private void ConfigureMenu(ServiceConfigurationContext context)
57 | {
58 | Configure(options =>
59 | {
60 | options.MenuContributors.Add(new AbpToExcelMenuContributor(context.Services.GetConfiguration()));
61 | });
62 | }
63 |
64 | private void ConfigureBlazorise(ServiceConfigurationContext context)
65 | {
66 | context.Services
67 | .AddBootstrap5Providers()
68 | .AddFontAwesomeIcons();
69 | }
70 |
71 | private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)
72 | {
73 | builder.Services.AddOidcAuthentication(options =>
74 | {
75 | builder.Configuration.Bind("AuthServer", options.ProviderOptions);
76 | options.UserOptions.NameClaim = OpenIddictConstants.Claims.Name;
77 | options.UserOptions.RoleClaim = OpenIddictConstants.Claims.Role;
78 |
79 | options.ProviderOptions.DefaultScopes.Add("AbpToExcel");
80 | options.ProviderOptions.DefaultScopes.Add("roles");
81 | options.ProviderOptions.DefaultScopes.Add("email");
82 | options.ProviderOptions.DefaultScopes.Add("phone");
83 | });
84 | }
85 |
86 | private static void ConfigureUI(WebAssemblyHostBuilder builder)
87 | {
88 | builder.RootComponents.Add("#ApplicationContainer");
89 |
90 | }
91 |
92 | private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment)
93 | {
94 | context.Services.AddTransient(sp => new HttpClient
95 | {
96 | BaseAddress = new Uri(environment.BaseAddress)
97 | });
98 | }
99 |
100 | private void ConfigureAutoMapper(ServiceConfigurationContext context)
101 | {
102 | Configure(options =>
103 | {
104 | options.AddMaps();
105 | });
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
254 | # AbpToExcel
255 | src/AbpToExcel.Web/Logs/*
256 | src/AbpToExcel.Web.Host/Logs/*
257 | src/AbpToExcel.AuthServer/Logs/*
258 | src/AbpToExcel.HttpApi.Host/Logs/*
259 | src/AbpToExcel.HttpApi.Host/Logs/*
260 | src/AbpToExcel.DbMigrator/Logs/*
261 | src/AbpToExcel.Blazor.Server/Logs/*
262 | src/AbpToExcel.Blazor.Server.Tiered/Logs/*
263 |
264 | # Use abp install-libs to restore.
265 | **/wwwroot/libs/*
266 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # How to export Excel files from an ABP Blazor application
2 |
3 | ## Introduction
4 |
5 | In this article, I will show you how can export data to an Excel file from the ABP framework.
6 |
7 | ### Source Code
8 |
9 | The sample application has been developed with **Blazor** as the UI framework and **SQL Server** as the database provider.
10 |
11 | The source code of the completed application is [available on GitHub](https://github.com/bartvanhoey/AbpToExcelRepo).
12 |
13 | ## Requirements
14 |
15 | The following tools are needed to be able to run the solution.
16 |
17 | - .NET 8.0 SDK
18 | - VsCode, Visual Studio 2022 or another compatible IDE
19 | - ABP 8.0.0
20 |
21 | ## Development
22 |
23 | ### Create a new Application
24 |
25 | - Install or update the ABP CLI:
26 |
27 | ```bash
28 | dotnet tool install -g Volo.Abp.Cli || dotnet tool update -g Volo.Abp.Cli
29 | ```
30 |
31 | - Use the following ABP CLI command:
32 |
33 | ```bash
34 | abp new AbpToExcel -u blazor -o AbpToExcel
35 | ```
36 |
37 | ### Open & Run the Application
38 |
39 | - Open the solution in Visual Studio (or your favorite IDE).
40 | - Run the `AbpToExcel.DbMigrator` application to seed the initial data.
41 | - Run the `AbpToExcel.HttpApi.Host` application that starts the API.
42 | - Run the `AbpToExcel.Blazor` application to start the UI.
43 |
44 | ### Create the ExportToExcelAppService ApplicationService
45 |
46 | - Create a new folder **ExcelExport** in the **Application.Contracts** project.
47 |
48 | - Add a new **IExportToExcelAppService.cs** file to the **ExcelExport** folder with following content.
49 |
50 | ```csharp
51 | using System.Threading.Tasks;
52 | using Volo.Abp.Application.Services;
53 |
54 | namespace AbpToExcel.ExcelExport
55 | {
56 | public interface IExportToExcelAppService : IApplicationService
57 | {
58 | Task ExportToExcel();
59 | }
60 | }
61 |
62 | ```
63 |
64 | - Open a command prompt in the **Application** project and run the following command to install the necessary NuGet packages.
65 |
66 | ```bash
67 | dotnet add package documentformat.openxml
68 | ```
69 |
70 | - Create a new **ExcelExport** folder in the **Application** project.
71 |
72 | - Add a new file **ExcelFileGenerator.cs** to the **ExcelExport** folder and copy/paste code below.
73 |
74 | ```csharp
75 | using System.IO;
76 | using DocumentFormat.OpenXml;
77 | using DocumentFormat.OpenXml.Packaging;
78 | using DocumentFormat.OpenXml.Spreadsheet;
79 |
80 | namespace AbpToExcel.ExcelExport
81 | {
82 | public static class ExcelFileGenerator
83 | {
84 | public static byte[] GenerateExcelFile()
85 | {
86 | var memoryStream = new MemoryStream();
87 |
88 | using var document = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook);
89 | var workbookPart = document.AddWorkbookPart();
90 | workbookPart.Workbook = new Workbook();
91 |
92 | var worksheetPart = workbookPart.AddNewPart();
93 | worksheetPart.Worksheet = new Worksheet(new SheetData());
94 |
95 | var sheets = workbookPart.Workbook.AppendChild(new Sheets());
96 |
97 | sheets.AppendChild(new Sheet
98 | {
99 | Id = workbookPart.GetIdOfPart(worksheetPart),
100 | SheetId = 1,
101 | Name = "Sheet 1"
102 | });
103 |
104 | var sheetData = worksheetPart.Worksheet.GetFirstChild();
105 |
106 | var row1 = new Row();
107 | row1.AppendChild(
108 | new Cell
109 | {
110 | CellValue = new CellValue("Abp Framework"),
111 | DataType = CellValues.String
112 | }
113 |
114 | );
115 |
116 | sheetData?.AppendChild(row1);
117 |
118 | var row2 = new Row();
119 | row2.AppendChild(
120 | new Cell
121 | {
122 | CellValue = new CellValue("Open Source"),
123 | DataType = CellValues.String
124 | }
125 | );
126 | sheetData?.AppendChild(row2);
127 |
128 | var row3 = new Row();
129 | row3.AppendChild(
130 | new Cell
131 | {
132 | CellValue = new CellValue("WEB APPLICATION FRAMEWORK"),
133 | DataType = CellValues.String
134 | }
135 | );
136 | sheetData?.AppendChild(row3);
137 |
138 | document.Save();
139 |
140 | return memoryStream.ToArray();
141 | }
142 | }
143 | }
144 | ```
145 |
146 | - Add a new **ExportToExcelAppService.cs** file to the **Application** project and copy/paste the code below.
147 |
148 | ```csharp
149 | using System.Threading.Tasks;
150 | using Volo.Abp.Application.Services;
151 | using static AbpToExcel.ExcelExport.ExcelFileGenerator;
152 |
153 | namespace AbpToExcel.ExcelExport
154 | {
155 | public class ExportToExcelAppService : ApplicationService, IExportToExcelAppService
156 | {
157 | public Task ExportToExcel() => Task.FromResult(GenerateExcelFile());
158 | }
159 | }
160 | ```
161 |
162 | Run the **HttpApi.Host** application to see the export-to-excel endpoint in SwaggerUI.
163 |
164 | 
165 |
166 | ## Some JavaScript to download Excel files
167 |
168 | - Create a **js** folder to the **wwwwroot** folder of the **Blazor** project.
169 |
170 | - Add an **exporttoexcel.js** file to the **js** folder and copy/paste the code below.
171 |
172 | ```javascript
173 | function saveAsFile(filename, bytesBase64) {
174 | var link = document.createElement('a');
175 | link.download = filename;
176 | link.href = 'data:application/octet-stream;base64,' + bytesBase64;
177 | document.body.appendChild(link); // Needed for Firefox
178 | link.click();
179 | document.body.removeChild(link);
180 | }
181 | ```
182 |
183 | - Open the **index.html** file in the **wwwroot** folder of the **Blazor** project and add this line of code at the end.
184 |
185 | ```bash
186 |
187 | ```
188 |
189 | ## Call the IExportToExcelAppService from the Blazor project
190 |
191 | - Replace the content in the **index.razor** file with the following code.
192 |
193 | ```razor
194 | @page "/"
195 | @using AbpToExcel.ExcelExport
196 | @inject IExportToExcelAppService ExportToExcelAppService
197 | @inject IJSRuntime JsRuntime
198 |
199 |
200 |
207 |
208 |
209 | @code {
210 | private async Task ExportToExcel()
211 | {
212 | var excelBytes = await ExportToExcelAppService.ExportToExcel();
213 | await JsRuntime.InvokeVoidAsync("saveAsFile", $"test_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.xlsx",
214 | Convert.ToBase64String(excelBytes));
215 | }
216 | }
217 | ```
218 |
219 | ### Start both the Blazor and the**HttpApi.Host**project to run the application
220 |
221 | Run both the **HttpApi.Host** and **Blazor** applications and test the export to Excel file function.
222 |
223 | Get the [source code](https://github.com/bartvanhoey/AbpToExcelRepo.git) on GitHub.
224 |
225 | Enjoy and have fun!
226 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/Data/AbpToExcelDbMigrationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Runtime.InteropServices;
7 | using System.Threading.Tasks;
8 | using Microsoft.Extensions.Logging;
9 | using Microsoft.Extensions.Logging.Abstractions;
10 | using Volo.Abp.Data;
11 | using Volo.Abp.DependencyInjection;
12 | using Volo.Abp.Identity;
13 | using Volo.Abp.MultiTenancy;
14 | using Volo.Abp.TenantManagement;
15 |
16 | namespace AbpToExcel.Data;
17 |
18 | public class AbpToExcelDbMigrationService : ITransientDependency
19 | {
20 | public ILogger Logger { get; set; }
21 |
22 | private readonly IDataSeeder _dataSeeder;
23 | private readonly IEnumerable _dbSchemaMigrators;
24 | private readonly ITenantRepository _tenantRepository;
25 | private readonly ICurrentTenant _currentTenant;
26 |
27 | public AbpToExcelDbMigrationService(
28 | IDataSeeder dataSeeder,
29 | IEnumerable dbSchemaMigrators,
30 | ITenantRepository tenantRepository,
31 | ICurrentTenant currentTenant)
32 | {
33 | _dataSeeder = dataSeeder;
34 | _dbSchemaMigrators = dbSchemaMigrators;
35 | _tenantRepository = tenantRepository;
36 | _currentTenant = currentTenant;
37 |
38 | Logger = NullLogger.Instance;
39 | }
40 |
41 | public async Task MigrateAsync()
42 | {
43 | var initialMigrationAdded = AddInitialMigrationIfNotExist();
44 |
45 | if (initialMigrationAdded)
46 | {
47 | return;
48 | }
49 |
50 | Logger.LogInformation("Started database migrations...");
51 |
52 | await MigrateDatabaseSchemaAsync();
53 | await SeedDataAsync();
54 |
55 | Logger.LogInformation($"Successfully completed host database migrations.");
56 |
57 | var tenants = await _tenantRepository.GetListAsync(includeDetails: true);
58 |
59 | var migratedDatabaseSchemas = new HashSet();
60 | foreach (var tenant in tenants)
61 | {
62 | using (_currentTenant.Change(tenant.Id))
63 | {
64 | if (tenant.ConnectionStrings.Any())
65 | {
66 | var tenantConnectionStrings = tenant.ConnectionStrings
67 | .Select(x => x.Value)
68 | .ToList();
69 |
70 | if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings))
71 | {
72 | await MigrateDatabaseSchemaAsync(tenant);
73 |
74 | migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings);
75 | }
76 | }
77 |
78 | await SeedDataAsync(tenant);
79 | }
80 |
81 | Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations.");
82 | }
83 |
84 | Logger.LogInformation("Successfully completed all database migrations.");
85 | Logger.LogInformation("You can safely end this process...");
86 | }
87 |
88 | private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null)
89 | {
90 | Logger.LogInformation(
91 | $"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database...");
92 |
93 | foreach (var migrator in _dbSchemaMigrators)
94 | {
95 | await migrator.MigrateAsync();
96 | }
97 | }
98 |
99 | private async Task SeedDataAsync(Tenant? tenant = null)
100 | {
101 | Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed...");
102 |
103 | await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id)
104 | .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue)
105 | .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue)
106 | );
107 | }
108 |
109 | private bool AddInitialMigrationIfNotExist()
110 | {
111 | try
112 | {
113 | if (!DbMigrationsProjectExists())
114 | {
115 | return false;
116 | }
117 | }
118 | catch (Exception)
119 | {
120 | return false;
121 | }
122 |
123 | try
124 | {
125 | if (!MigrationsFolderExists())
126 | {
127 | AddInitialMigration();
128 | return true;
129 | }
130 | else
131 | {
132 | return false;
133 | }
134 | }
135 | catch (Exception e)
136 | {
137 | Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message);
138 | return false;
139 | }
140 | }
141 |
142 | private bool DbMigrationsProjectExists()
143 | {
144 | var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
145 |
146 | return dbMigrationsProjectFolder != null;
147 | }
148 |
149 | private bool MigrationsFolderExists()
150 | {
151 | var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
152 | return dbMigrationsProjectFolder != null && Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations"));
153 | }
154 |
155 | private void AddInitialMigration()
156 | {
157 | Logger.LogInformation("Creating initial migration...");
158 |
159 | string argumentPrefix;
160 | string fileName;
161 |
162 | if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
163 | {
164 | argumentPrefix = "-c";
165 | fileName = "/bin/bash";
166 | }
167 | else
168 | {
169 | argumentPrefix = "/C";
170 | fileName = "cmd.exe";
171 | }
172 |
173 | var procStartInfo = new ProcessStartInfo(fileName,
174 | $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\""
175 | );
176 |
177 | try
178 | {
179 | Process.Start(procStartInfo);
180 | }
181 | catch (Exception)
182 | {
183 | throw new Exception("Couldn't run ABP CLI...");
184 | }
185 | }
186 |
187 | private string? GetEntityFrameworkCoreProjectFolderPath()
188 | {
189 | var slnDirectoryPath = GetSolutionDirectoryPath();
190 |
191 | if (slnDirectoryPath == null)
192 | {
193 | throw new Exception("Solution folder not found!");
194 | }
195 |
196 | var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src");
197 |
198 | return Directory.GetDirectories(srcDirectoryPath)
199 | .FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore"));
200 | }
201 |
202 | private string? GetSolutionDirectoryPath()
203 | {
204 | var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
205 |
206 | while (currentDirectory != null && Directory.GetParent(currentDirectory.FullName) != null)
207 | {
208 | currentDirectory = Directory.GetParent(currentDirectory.FullName);
209 |
210 | if (currentDirectory != null && Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null)
211 | {
212 | return currentDirectory.FullName;
213 | }
214 | }
215 |
216 | return null;
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/src/AbpToExcel.HttpApi.Host/AbpToExcelHttpApiHostModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Cors;
7 | using Microsoft.AspNetCore.Extensions.DependencyInjection;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.DependencyInjection;
10 | using Microsoft.Extensions.Hosting;
11 | using AbpToExcel.EntityFrameworkCore;
12 | using AbpToExcel.MultiTenancy;
13 | using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
14 | using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling;
15 | using Microsoft.OpenApi.Models;
16 | using OpenIddict.Validation.AspNetCore;
17 | using Volo.Abp;
18 | using Volo.Abp.Account;
19 | using Volo.Abp.Account.Web;
20 | using Volo.Abp.AspNetCore.MultiTenancy;
21 | using Volo.Abp.AspNetCore.Mvc;
22 | using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
23 | using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
24 | using Volo.Abp.AspNetCore.Serilog;
25 | using Volo.Abp.Autofac;
26 | using Volo.Abp.Localization;
27 | using Volo.Abp.Modularity;
28 | using Volo.Abp.Security.Claims;
29 | using Volo.Abp.Swashbuckle;
30 | using Volo.Abp.UI.Navigation.Urls;
31 | using Volo.Abp.VirtualFileSystem;
32 |
33 | namespace AbpToExcel;
34 |
35 | [DependsOn(
36 | typeof(AbpToExcelHttpApiModule),
37 | typeof(AbpAutofacModule),
38 | typeof(AbpAspNetCoreMultiTenancyModule),
39 | typeof(AbpToExcelApplicationModule),
40 | typeof(AbpToExcelEntityFrameworkCoreModule),
41 | typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
42 | typeof(AbpAccountWebOpenIddictModule),
43 | typeof(AbpAspNetCoreSerilogModule),
44 | typeof(AbpSwashbuckleModule)
45 | )]
46 | public class AbpToExcelHttpApiHostModule : AbpModule
47 | {
48 | public override void PreConfigureServices(ServiceConfigurationContext context)
49 | {
50 | PreConfigure(builder =>
51 | {
52 | builder.AddValidation(options =>
53 | {
54 | options.AddAudiences("AbpToExcel");
55 | options.UseLocalServer();
56 | options.UseAspNetCore();
57 | });
58 | });
59 | }
60 |
61 | public override void ConfigureServices(ServiceConfigurationContext context)
62 | {
63 | var configuration = context.Services.GetConfiguration();
64 | var hostingEnvironment = context.Services.GetHostingEnvironment();
65 |
66 | ConfigureAuthentication(context);
67 | ConfigureBundles();
68 | ConfigureUrls(configuration);
69 | ConfigureConventionalControllers();
70 | ConfigureVirtualFileSystem(context);
71 | ConfigureCors(context, configuration);
72 | ConfigureSwaggerServices(context, configuration);
73 | }
74 |
75 | private void ConfigureAuthentication(ServiceConfigurationContext context)
76 | {
77 | context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
78 | context.Services.Configure(options =>
79 | {
80 | options.IsDynamicClaimsEnabled = true;
81 | });
82 | }
83 |
84 | private void ConfigureBundles()
85 | {
86 | Configure(options =>
87 | {
88 | options.StyleBundles.Configure(
89 | LeptonXLiteThemeBundles.Styles.Global,
90 | bundle =>
91 | {
92 | bundle.AddFiles("/global-styles.css");
93 | }
94 | );
95 | });
96 | }
97 |
98 | private void ConfigureUrls(IConfiguration configuration)
99 | {
100 | Configure(options =>
101 | {
102 | options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
103 | options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? Array.Empty());
104 |
105 | options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"];
106 | options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
107 | });
108 | }
109 |
110 | private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
111 | {
112 | var hostingEnvironment = context.Services.GetHostingEnvironment();
113 |
114 | if (hostingEnvironment.IsDevelopment())
115 | {
116 | Configure(options =>
117 | {
118 | options.FileSets.ReplaceEmbeddedByPhysical(
119 | Path.Combine(hostingEnvironment.ContentRootPath,
120 | $"..{Path.DirectorySeparatorChar}AbpToExcel.Domain.Shared"));
121 | options.FileSets.ReplaceEmbeddedByPhysical(
122 | Path.Combine(hostingEnvironment.ContentRootPath,
123 | $"..{Path.DirectorySeparatorChar}AbpToExcel.Domain"));
124 | options.FileSets.ReplaceEmbeddedByPhysical(
125 | Path.Combine(hostingEnvironment.ContentRootPath,
126 | $"..{Path.DirectorySeparatorChar}AbpToExcel.Application.Contracts"));
127 | options.FileSets.ReplaceEmbeddedByPhysical(
128 | Path.Combine(hostingEnvironment.ContentRootPath,
129 | $"..{Path.DirectorySeparatorChar}AbpToExcel.Application"));
130 | });
131 | }
132 | }
133 |
134 | private void ConfigureConventionalControllers()
135 | {
136 | Configure(options =>
137 | {
138 | options.ConventionalControllers.Create(typeof(AbpToExcelApplicationModule).Assembly);
139 | });
140 | }
141 |
142 | private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
143 | {
144 | context.Services.AddAbpSwaggerGenWithOAuth(
145 | configuration["AuthServer:Authority"]!,
146 | new Dictionary
147 | {
148 | {"AbpToExcel", "AbpToExcel API"}
149 | },
150 | options =>
151 | {
152 | options.SwaggerDoc("v1", new OpenApiInfo { Title = "AbpToExcel API", Version = "v1" });
153 | options.DocInclusionPredicate((docName, description) => true);
154 | options.CustomSchemaIds(type => type.FullName);
155 | });
156 | }
157 |
158 | private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
159 | {
160 | context.Services.AddCors(options =>
161 | {
162 | options.AddDefaultPolicy(builder =>
163 | {
164 | builder
165 | .WithOrigins(configuration["App:CorsOrigins"]?
166 | .Split(",", StringSplitOptions.RemoveEmptyEntries)
167 | .Select(o => o.RemovePostFix("/"))
168 | .ToArray() ?? Array.Empty())
169 | .WithAbpExposedHeaders()
170 | .SetIsOriginAllowedToAllowWildcardSubdomains()
171 | .AllowAnyHeader()
172 | .AllowAnyMethod()
173 | .AllowCredentials();
174 | });
175 | });
176 | }
177 |
178 | public override void OnApplicationInitialization(ApplicationInitializationContext context)
179 | {
180 | var app = context.GetApplicationBuilder();
181 | var env = context.GetEnvironment();
182 |
183 | if (env.IsDevelopment())
184 | {
185 | app.UseDeveloperExceptionPage();
186 | }
187 |
188 | app.UseAbpRequestLocalization();
189 |
190 | if (!env.IsDevelopment())
191 | {
192 | app.UseErrorPage();
193 | }
194 |
195 | app.UseCorrelationId();
196 | app.UseStaticFiles();
197 | app.UseRouting();
198 | app.UseCors();
199 | app.UseAuthentication();
200 | app.UseAbpOpenIddictValidation();
201 |
202 | if (MultiTenancyConsts.IsEnabled)
203 | {
204 | app.UseMultiTenancy();
205 | }
206 | app.UseUnitOfWork();
207 | app.UseDynamicClaims();
208 | app.UseAuthorization();
209 |
210 | app.UseSwagger();
211 | app.UseAbpSwaggerUI(c =>
212 | {
213 | c.SwaggerEndpoint("/swagger/v1/swagger.json", "AbpToExcel API");
214 |
215 | var configuration = context.ServiceProvider.GetRequiredService();
216 | c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
217 | c.OAuthScopes("AbpToExcel");
218 | });
219 |
220 | app.UseAuditing();
221 | app.UseAbpSerilogEnrichers();
222 | app.UseConfiguredEndpoints();
223 | }
224 | }
225 |
--------------------------------------------------------------------------------
/AbpToExcel.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29020.237
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.Domain", "src\AbpToExcel.Domain\AbpToExcel.Domain.csproj", "{554AD327-6DBA-4F8F-96F8-81CE7A0C863F}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.Application", "src\AbpToExcel.Application\AbpToExcel.Application.csproj", "{1A94A50E-06DC-43C1-80B5-B662820EC3EB}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.EntityFrameworkCore", "src\AbpToExcel.EntityFrameworkCore\AbpToExcel.EntityFrameworkCore.csproj", "{C956DD76-69C8-4A9C-83EA-D17DF83340FD}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CA9AC87F-097E-4F15-8393-4BC07735A5B0}"
13 | EndProject
14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{04DBDB01-70F4-4E06-B468-8F87850B22BE}"
15 | EndProject
16 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.Application.Tests", "test\AbpToExcel.Application.Tests\AbpToExcel.Application.Tests.csproj", "{50B2631D-129C-47B3-A587-029CCD6099BC}"
17 | EndProject
18 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.Domain.Shared", "src\AbpToExcel.Domain.Shared\AbpToExcel.Domain.Shared.csproj", "{42F719ED-8413-4895-B5B4-5AB56079BC66}"
19 | EndProject
20 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.Application.Contracts", "src\AbpToExcel.Application.Contracts\AbpToExcel.Application.Contracts.csproj", "{520659C8-C734-4298-A3DA-B539DB9DFC0B}"
21 | EndProject
22 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.HttpApi", "src\AbpToExcel.HttpApi\AbpToExcel.HttpApi.csproj", "{4164BDF7-F527-4E85-9CE6-E3C2D7426A27}"
23 | EndProject
24 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.HttpApi.Client", "src\AbpToExcel.HttpApi.Client\AbpToExcel.HttpApi.Client.csproj", "{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}"
25 | EndProject
26 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.EntityFrameworkCore.Tests", "test\AbpToExcel.EntityFrameworkCore.Tests\AbpToExcel.EntityFrameworkCore.Tests.csproj", "{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}"
27 | EndProject
28 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.TestBase", "test\AbpToExcel.TestBase\AbpToExcel.TestBase.csproj", "{91853F21-9CD9-4132-BC29-A7D5D84FFFE7}"
29 | EndProject
30 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.Domain.Tests", "test\AbpToExcel.Domain.Tests\AbpToExcel.Domain.Tests.csproj", "{E512F4D9-9375-480F-A2F6-A46509F9D824}"
31 | EndProject
32 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.HttpApi.Client.ConsoleTestApp", "test\AbpToExcel.HttpApi.Client.ConsoleTestApp\AbpToExcel.HttpApi.Client.ConsoleTestApp.csproj", "{EF480016-9127-4916-8735-D2466BDBC582}"
33 | EndProject
34 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.DbMigrator", "src\AbpToExcel.DbMigrator\AbpToExcel.DbMigrator.csproj", "{AA94D832-1CCC-4715-95A9-A483F23A1A5D}"
35 | EndProject
36 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.HttpApi.Host", "src\AbpToExcel.HttpApi.Host\AbpToExcel.HttpApi.Host.csproj", "{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}"
37 | EndProject
38 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpToExcel.Blazor", "src\AbpToExcel.Blazor\AbpToExcel.Blazor.csproj", "{27B2DDC7-8B75-4322-A312-25419C15D9D8}"
39 | EndProject
40 | Global
41 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
42 | Debug|Any CPU = Debug|Any CPU
43 | Release|Any CPU = Release|Any CPU
44 | EndGlobalSection
45 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
46 | {554AD327-6DBA-4F8F-96F8-81CE7A0C863F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {554AD327-6DBA-4F8F-96F8-81CE7A0C863F}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {554AD327-6DBA-4F8F-96F8-81CE7A0C863F}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {554AD327-6DBA-4F8F-96F8-81CE7A0C863F}.Release|Any CPU.Build.0 = Release|Any CPU
50 | {1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
53 | {1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Release|Any CPU.Build.0 = Release|Any CPU
54 | {C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 | {C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 | {C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Release|Any CPU.Build.0 = Release|Any CPU
58 | {50B2631D-129C-47B3-A587-029CCD6099BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59 | {50B2631D-129C-47B3-A587-029CCD6099BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
60 | {50B2631D-129C-47B3-A587-029CCD6099BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {50B2631D-129C-47B3-A587-029CCD6099BC}.Release|Any CPU.Build.0 = Release|Any CPU
62 | {42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63 | {42F719ED-8413-4895-B5B4-5AB56079BC66}.Debug|Any CPU.Build.0 = Debug|Any CPU
64 | {42F719ED-8413-4895-B5B4-5AB56079BC66}.Release|Any CPU.ActiveCfg = Release|Any CPU
65 | {42F719ED-8413-4895-B5B4-5AB56079BC66}.Release|Any CPU.Build.0 = Release|Any CPU
66 | {520659C8-C734-4298-A3DA-B539DB9DFC0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
67 | {520659C8-C734-4298-A3DA-B539DB9DFC0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
68 | {520659C8-C734-4298-A3DA-B539DB9DFC0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
69 | {520659C8-C734-4298-A3DA-B539DB9DFC0B}.Release|Any CPU.Build.0 = Release|Any CPU
70 | {4164BDF7-F527-4E85-9CE6-E3C2D7426A27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71 | {4164BDF7-F527-4E85-9CE6-E3C2D7426A27}.Debug|Any CPU.Build.0 = Debug|Any CPU
72 | {4164BDF7-F527-4E85-9CE6-E3C2D7426A27}.Release|Any CPU.ActiveCfg = Release|Any CPU
73 | {4164BDF7-F527-4E85-9CE6-E3C2D7426A27}.Release|Any CPU.Build.0 = Release|Any CPU
74 | {3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75 | {3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
76 | {3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
77 | {3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Release|Any CPU.Build.0 = Release|Any CPU
78 | {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
79 | {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Debug|Any CPU.Build.0 = Debug|Any CPU
80 | {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Release|Any CPU.ActiveCfg = Release|Any CPU
81 | {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Release|Any CPU.Build.0 = Release|Any CPU
82 | {91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83 | {91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
84 | {91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
85 | {91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Release|Any CPU.Build.0 = Release|Any CPU
86 | {E512F4D9-9375-480F-A2F6-A46509F9D824}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87 | {E512F4D9-9375-480F-A2F6-A46509F9D824}.Debug|Any CPU.Build.0 = Debug|Any CPU
88 | {E512F4D9-9375-480F-A2F6-A46509F9D824}.Release|Any CPU.ActiveCfg = Release|Any CPU
89 | {E512F4D9-9375-480F-A2F6-A46509F9D824}.Release|Any CPU.Build.0 = Release|Any CPU
90 | {EF480016-9127-4916-8735-D2466BDBC582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
91 | {EF480016-9127-4916-8735-D2466BDBC582}.Debug|Any CPU.Build.0 = Debug|Any CPU
92 | {EF480016-9127-4916-8735-D2466BDBC582}.Release|Any CPU.ActiveCfg = Release|Any CPU
93 | {EF480016-9127-4916-8735-D2466BDBC582}.Release|Any CPU.Build.0 = Release|Any CPU
94 | {AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95 | {AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
96 | {AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
97 | {AA94D832-1CCC-4715-95A9-A483F23A1A5D}.Release|Any CPU.Build.0 = Release|Any CPU
98 | {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
99 | {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Debug|Any CPU.Build.0 = Debug|Any CPU
100 | {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Release|Any CPU.ActiveCfg = Release|Any CPU
101 | {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Release|Any CPU.Build.0 = Release|Any CPU
102 | {27B2DDC7-8B75-4322-A312-25419C15D9D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
103 | {27B2DDC7-8B75-4322-A312-25419C15D9D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
104 | {27B2DDC7-8B75-4322-A312-25419C15D9D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
105 | {27B2DDC7-8B75-4322-A312-25419C15D9D8}.Release|Any CPU.Build.0 = Release|Any CPU
106 | EndGlobalSection
107 | GlobalSection(SolutionProperties) = preSolution
108 | HideSolutionNode = FALSE
109 | EndGlobalSection
110 | GlobalSection(NestedProjects) = preSolution
111 | {554AD327-6DBA-4F8F-96F8-81CE7A0C863F} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
112 | {1A94A50E-06DC-43C1-80B5-B662820EC3EB} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
113 | {C956DD76-69C8-4A9C-83EA-D17DF83340FD} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
114 | {50B2631D-129C-47B3-A587-029CCD6099BC} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
115 | {42F719ED-8413-4895-B5B4-5AB56079BC66} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
116 | {520659C8-C734-4298-A3DA-B539DB9DFC0B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
117 | {4164BDF7-F527-4E85-9CE6-E3C2D7426A27} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
118 | {3B5A0094-670D-4BB1-BFDD-61B88A8773DC} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
119 | {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
120 | {91853F21-9CD9-4132-BC29-A7D5D84FFFE7} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
121 | {E512F4D9-9375-480F-A2F6-A46509F9D824} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
122 | {EF480016-9127-4916-8735-D2466BDBC582} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
123 | {AA94D832-1CCC-4715-95A9-A483F23A1A5D} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
124 | {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
125 | {27B2DDC7-8B75-4322-A312-25419C15D9D8} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
126 | EndGlobalSection
127 | GlobalSection(ExtensibilityGlobals) = postSolution
128 | SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}
129 | EndGlobalSection
130 | EndGlobal
131 |
--------------------------------------------------------------------------------
/src/AbpToExcel.Domain/OpenIddict/OpenIddictDataSeedContributor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text.Json;
5 | using System.Threading.Tasks;
6 | using JetBrains.Annotations;
7 | using Microsoft.Extensions.Configuration;
8 | using Microsoft.Extensions.Localization;
9 | using OpenIddict.Abstractions;
10 | using Volo.Abp;
11 | using Volo.Abp.Authorization.Permissions;
12 | using Volo.Abp.Data;
13 | using Volo.Abp.DependencyInjection;
14 | using Volo.Abp.OpenIddict.Applications;
15 | using Volo.Abp.OpenIddict.Scopes;
16 | using Volo.Abp.PermissionManagement;
17 | using Volo.Abp.Uow;
18 |
19 | namespace AbpToExcel.OpenIddict;
20 |
21 | /* Creates initial data that is needed to property run the application
22 | * and make client-to-server communication possible.
23 | */
24 | public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency
25 | {
26 | private readonly IConfiguration _configuration;
27 | private readonly IOpenIddictApplicationRepository _openIddictApplicationRepository;
28 | private readonly IAbpApplicationManager _applicationManager;
29 | private readonly IOpenIddictScopeRepository _openIddictScopeRepository;
30 | private readonly IOpenIddictScopeManager _scopeManager;
31 | private readonly IPermissionDataSeeder _permissionDataSeeder;
32 | private readonly IStringLocalizer L;
33 |
34 | public OpenIddictDataSeedContributor(
35 | IConfiguration configuration,
36 | IOpenIddictApplicationRepository openIddictApplicationRepository,
37 | IAbpApplicationManager applicationManager,
38 | IOpenIddictScopeRepository openIddictScopeRepository,
39 | IOpenIddictScopeManager scopeManager,
40 | IPermissionDataSeeder permissionDataSeeder,
41 | IStringLocalizer l )
42 | {
43 | _configuration = configuration;
44 | _openIddictApplicationRepository = openIddictApplicationRepository;
45 | _applicationManager = applicationManager;
46 | _openIddictScopeRepository = openIddictScopeRepository;
47 | _scopeManager = scopeManager;
48 | _permissionDataSeeder = permissionDataSeeder;
49 | L = l;
50 | }
51 |
52 | [UnitOfWork]
53 | public virtual async Task SeedAsync(DataSeedContext context)
54 | {
55 | await CreateScopesAsync();
56 | await CreateApplicationsAsync();
57 | }
58 |
59 | private async Task CreateScopesAsync()
60 | {
61 | if (await _openIddictScopeRepository.FindByNameAsync("AbpToExcel") == null)
62 | {
63 | await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor {
64 | Name = "AbpToExcel", DisplayName = "AbpToExcel API", Resources = { "AbpToExcel" }
65 | });
66 | }
67 | }
68 |
69 | private async Task CreateApplicationsAsync()
70 | {
71 | var commonScopes = new List {
72 | OpenIddictConstants.Permissions.Scopes.Address,
73 | OpenIddictConstants.Permissions.Scopes.Email,
74 | OpenIddictConstants.Permissions.Scopes.Phone,
75 | OpenIddictConstants.Permissions.Scopes.Profile,
76 | OpenIddictConstants.Permissions.Scopes.Roles,
77 | "AbpToExcel"
78 | };
79 |
80 | var configurationSection = _configuration.GetSection("OpenIddict:Applications");
81 |
82 |
83 |
84 | // Blazor Client
85 | var blazorClientId = configurationSection["AbpToExcel_Blazor:ClientId"];
86 | if (!blazorClientId.IsNullOrWhiteSpace())
87 | {
88 | var blazorRootUrl = configurationSection["AbpToExcel_Blazor:RootUrl"]?.TrimEnd('/');
89 |
90 | await CreateApplicationAsync(
91 | name: blazorClientId!,
92 | type: OpenIddictConstants.ClientTypes.Public,
93 | consentType: OpenIddictConstants.ConsentTypes.Implicit,
94 | displayName: "Blazor Application",
95 | secret: null,
96 | grantTypes: new List { OpenIddictConstants.GrantTypes.AuthorizationCode, },
97 | scopes: commonScopes,
98 | redirectUri: $"{blazorRootUrl}/authentication/login-callback",
99 | clientUri: blazorRootUrl,
100 | postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback"
101 | );
102 | }
103 |
104 |
105 | // Swagger Client
106 | var swaggerClientId = configurationSection["AbpToExcel_Swagger:ClientId"];
107 | if (!swaggerClientId.IsNullOrWhiteSpace())
108 | {
109 | var swaggerRootUrl = configurationSection["AbpToExcel_Swagger:RootUrl"]?.TrimEnd('/');
110 |
111 | await CreateApplicationAsync(
112 | name: swaggerClientId!,
113 | type: OpenIddictConstants.ClientTypes.Public,
114 | consentType: OpenIddictConstants.ConsentTypes.Implicit,
115 | displayName: "Swagger Application",
116 | secret: null,
117 | grantTypes: new List { OpenIddictConstants.GrantTypes.AuthorizationCode, },
118 | scopes: commonScopes,
119 | redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
120 | clientUri: swaggerRootUrl
121 | );
122 | }
123 | }
124 |
125 | private async Task CreateApplicationAsync(
126 | [NotNull] string name,
127 | [NotNull] string type,
128 | [NotNull] string consentType,
129 | string displayName,
130 | string? secret,
131 | List grantTypes,
132 | List scopes,
133 | string? clientUri = null,
134 | string? redirectUri = null,
135 | string? postLogoutRedirectUri = null,
136 | List? permissions = null)
137 | {
138 | if (!string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Public,
139 | StringComparison.OrdinalIgnoreCase))
140 | {
141 | throw new BusinessException(L["NoClientSecretCanBeSetForPublicApplications"]);
142 | }
143 |
144 | if (string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Confidential,
145 | StringComparison.OrdinalIgnoreCase))
146 | {
147 | throw new BusinessException(L["TheClientSecretIsRequiredForConfidentialApplications"]);
148 | }
149 |
150 | var client = await _openIddictApplicationRepository.FindByClientIdAsync(name);
151 |
152 | var application = new AbpApplicationDescriptor {
153 | ClientId = name,
154 | ClientType = type,
155 | ClientSecret = secret,
156 | ConsentType = consentType,
157 | DisplayName = displayName,
158 | ClientUri = clientUri,
159 | };
160 |
161 | Check.NotNullOrEmpty(grantTypes, nameof(grantTypes));
162 | Check.NotNullOrEmpty(scopes, nameof(scopes));
163 |
164 | if (new[] { OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit }.All(
165 | grantTypes.Contains))
166 | {
167 | application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken);
168 |
169 | if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase))
170 | {
171 | application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken);
172 | application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeToken);
173 | }
174 | }
175 |
176 | if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace())
177 | {
178 | application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
179 | }
180 |
181 | var buildInGrantTypes = new[] {
182 | OpenIddictConstants.GrantTypes.Implicit, OpenIddictConstants.GrantTypes.Password,
183 | OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.ClientCredentials,
184 | OpenIddictConstants.GrantTypes.DeviceCode, OpenIddictConstants.GrantTypes.RefreshToken
185 | };
186 |
187 | foreach (var grantType in grantTypes)
188 | {
189 | if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode)
190 | {
191 | application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode);
192 | application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Code);
193 | }
194 |
195 | if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode ||
196 | grantType == OpenIddictConstants.GrantTypes.Implicit)
197 | {
198 | application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Authorization);
199 | }
200 |
201 | if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode ||
202 | grantType == OpenIddictConstants.GrantTypes.ClientCredentials ||
203 | grantType == OpenIddictConstants.GrantTypes.Password ||
204 | grantType == OpenIddictConstants.GrantTypes.RefreshToken ||
205 | grantType == OpenIddictConstants.GrantTypes.DeviceCode)
206 | {
207 | application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Token);
208 | application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Revocation);
209 | application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Introspection);
210 | }
211 |
212 | if (grantType == OpenIddictConstants.GrantTypes.ClientCredentials)
213 | {
214 | application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.ClientCredentials);
215 | }
216 |
217 | if (grantType == OpenIddictConstants.GrantTypes.Implicit)
218 | {
219 | application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Implicit);
220 | }
221 |
222 | if (grantType == OpenIddictConstants.GrantTypes.Password)
223 | {
224 | application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Password);
225 | }
226 |
227 | if (grantType == OpenIddictConstants.GrantTypes.RefreshToken)
228 | {
229 | application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.RefreshToken);
230 | }
231 |
232 | if (grantType == OpenIddictConstants.GrantTypes.DeviceCode)
233 | {
234 | application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode);
235 | application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device);
236 | }
237 |
238 | if (grantType == OpenIddictConstants.GrantTypes.Implicit)
239 | {
240 | application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdToken);
241 | if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase))
242 | {
243 | application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken);
244 | application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Token);
245 | }
246 | }
247 |
248 | if (!buildInGrantTypes.Contains(grantType))
249 | {
250 | application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.GrantType + grantType);
251 | }
252 | }
253 |
254 | var buildInScopes = new[] {
255 | OpenIddictConstants.Permissions.Scopes.Address, OpenIddictConstants.Permissions.Scopes.Email,
256 | OpenIddictConstants.Permissions.Scopes.Phone, OpenIddictConstants.Permissions.Scopes.Profile,
257 | OpenIddictConstants.Permissions.Scopes.Roles
258 | };
259 |
260 | foreach (var scope in scopes)
261 | {
262 | if (buildInScopes.Contains(scope))
263 | {
264 | application.Permissions.Add(scope);
265 | }
266 | else
267 | {
268 | application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.Scope + scope);
269 | }
270 | }
271 |
272 | if (redirectUri != null)
273 | {
274 | if (!redirectUri.IsNullOrEmpty())
275 | {
276 | if (!Uri.TryCreate(redirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString())
277 | {
278 | throw new BusinessException(L["InvalidRedirectUri", redirectUri]);
279 | }
280 |
281 | if (application.RedirectUris.All(x => x != uri))
282 | {
283 | application.RedirectUris.Add(uri);
284 | }
285 | }
286 | }
287 |
288 | if (postLogoutRedirectUri != null)
289 | {
290 | if (!postLogoutRedirectUri.IsNullOrEmpty())
291 | {
292 | if (!Uri.TryCreate(postLogoutRedirectUri, UriKind.Absolute, out var uri) ||
293 | !uri.IsWellFormedOriginalString())
294 | {
295 | throw new BusinessException(L["InvalidPostLogoutRedirectUri", postLogoutRedirectUri]);
296 | }
297 |
298 | if (application.PostLogoutRedirectUris.All(x => x != uri))
299 | {
300 | application.PostLogoutRedirectUris.Add(uri);
301 | }
302 | }
303 | }
304 |
305 | if (permissions != null)
306 | {
307 | await _permissionDataSeeder.SeedAsync(
308 | ClientPermissionValueProvider.ProviderName,
309 | name,
310 | permissions,
311 | null
312 | );
313 | }
314 |
315 | if (client == null)
316 | {
317 | await _applicationManager.CreateAsync(application);
318 | return;
319 | }
320 |
321 | if (!HasSameRedirectUris(client, application))
322 | {
323 | client.RedirectUris = JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
324 | client.PostLogoutRedirectUris = JsonSerializer.Serialize(application.PostLogoutRedirectUris.Select(q => q.ToString().TrimEnd('/')));
325 |
326 | await _applicationManager.UpdateAsync(client.ToModel());
327 | }
328 |
329 | if (!HasSameScopes(client, application))
330 | {
331 | client.Permissions = JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString()));
332 | await _applicationManager.UpdateAsync(client.ToModel());
333 | }
334 | }
335 |
336 | private bool HasSameRedirectUris(OpenIddictApplication existingClient, AbpApplicationDescriptor application)
337 | {
338 | return existingClient.RedirectUris == JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
339 | }
340 |
341 | private bool HasSameScopes(OpenIddictApplication existingClient, AbpApplicationDescriptor application)
342 | {
343 | return existingClient.Permissions == JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString().TrimEnd('/')));
344 | }
345 | }
346 |
--------------------------------------------------------------------------------