From 22f104ce792e33591d8916a3628b48844f6bb351 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 13 May 2020 16:07:17 +0800 Subject: [PATCH 01/53] Add time zone infrastructure. --- .../ApplicationConfigurationDto.cs | 7 ++- .../Mvc/ApplicationConfigurations/ClockDto.cs | 7 +++ .../ApplicationConfigurations/TimingDto.cs | 24 ++++++++ .../AbpApplicationConfigurationAppService.cs | 40 +++++++++++++ .../Volo.Abp.Timing/Volo.Abp.Timing.csproj | 13 ++++- .../Volo/Abp/Timing/AbpTimingModule.cs | 22 +++++++- .../Volo/Abp/Timing/ITimezoneProvider.cs | 18 ++++++ .../Resources/AbpTiming/AbpTimingResource.cs | 10 ++++ .../Localization/Resources/AbpTiming/en.json | 7 +++ .../Localization/Resources/AbpTiming/tr.json | 7 +++ .../Resources/AbpTiming/zh-Hans.json | 7 +++ .../Resources/AbpTiming/zh-Hant.json | 7 +++ .../Abp/Timing/TZConvertTimezoneProvider.cs | 36 ++++++++++++ .../Volo/Abp/Timing/TimingSettingNames.cs | 7 +++ .../Volo/Abp/Timing/TimingSettingProvider.cs | 25 +++++++++ npm/packs/core/src/abp.js | 56 +++++++++++++++++++ 16 files changed, 290 insertions(+), 3 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ClockDto.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TimingDto.cs create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/ITimezoneProvider.cs create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/AbpTimingResource.cs create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/en.json create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/tr.json create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hans.json create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hant.json create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TZConvertTimezoneProvider.cs create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TimingSettingNames.cs create mode 100644 framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TimingSettingProvider.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs index da99a3e948..0001f56c1c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationConfigurationDto.cs @@ -1,6 +1,7 @@ using System; using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending; using Volo.Abp.AspNetCore.Mvc.MultiTenancy; +using Volo.Abp.Timing; namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations { @@ -21,6 +22,10 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations public CurrentTenantDto CurrentTenant { get; set; } + public TimingDto Timing { get; set; } + + public ClockDto Clock { get; set; } + public ObjectExtensionsDto ObjectExtensions { get; set; } } -} \ No newline at end of file +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ClockDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ClockDto.cs new file mode 100644 index 0000000000..2cff97f814 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ClockDto.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +{ + public class ClockDto + { + public string Kind { get; set; } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TimingDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TimingDto.cs new file mode 100644 index 0000000000..bd95bfba0d --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/TimingDto.cs @@ -0,0 +1,24 @@ +namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations +{ + public class TimingDto + { + public TimeZone TimeZone { get; set; } + } + + public class TimeZone + { + public IanaTimeZone Iana { get; set; } + + public WindowsTimeZone Windows { get; set; } + } + + public class WindowsTimeZone + { + public string TimeZoneId { get; set; } + } + + public class IanaTimeZone + { + public string TimeZoneName { get; set; } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index a68a38b274..f68d4d1450 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -15,6 +15,7 @@ using Volo.Abp.Features; using Volo.Abp.Localization; using Volo.Abp.MultiTenancy; using Volo.Abp.Settings; +using Volo.Abp.Timing; using Volo.Abp.Users; namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations @@ -31,6 +32,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations private readonly ISettingDefinitionManager _settingDefinitionManager; private readonly IFeatureDefinitionManager _featureDefinitionManager; private readonly ILanguageProvider _languageProvider; + private readonly ITimezoneProvider _timezoneProvider; + private readonly AbpClockOptions _abpClockOptions; private readonly ICachedObjectExtensionsDtoService _cachedObjectExtensionsDtoService; public AbpApplicationConfigurationAppService( @@ -44,6 +47,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations ISettingDefinitionManager settingDefinitionManager, IFeatureDefinitionManager featureDefinitionManager, ILanguageProvider languageProvider, + ITimezoneProvider timezoneProvider, + IOptions abpClockOptions, ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService) { _serviceProvider = serviceProvider; @@ -54,6 +59,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations _settingDefinitionManager = settingDefinitionManager; _featureDefinitionManager = featureDefinitionManager; _languageProvider = languageProvider; + _timezoneProvider = timezoneProvider; + _abpClockOptions = abpClockOptions.Value; _cachedObjectExtensionsDtoService = cachedObjectExtensionsDtoService; _localizationOptions = localizationOptions.Value; _multiTenancyOptions = multiTenancyOptions.Value; @@ -74,6 +81,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations Setting = await GetSettingConfigAsync(), MultiTenancy = GetMultiTenancy(), CurrentTenant = GetCurrentTenant(), + Timing = await GetTimingConfigAsync(), + Clock = GetClockConfig(), ObjectExtensions = _cachedObjectExtensionsDtoService.Get() }; @@ -226,5 +235,36 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations return result; } + + protected virtual async Task GetTimingConfigAsync() + { + var result = new TimingDto(); + + var windowsTimeZoneId = await _settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); + if (!windowsTimeZoneId.IsNullOrWhiteSpace()) + { + result.TimeZone = new TimeZone + { + Windows = new WindowsTimeZone + { + TimeZoneId = windowsTimeZoneId + }, + Iana = new IanaTimeZone() + { + TimeZoneName = _timezoneProvider.WindowsToIana(windowsTimeZoneId) + } + }; + } + + return result; + } + + protected virtual ClockDto GetClockConfig() + { + return new ClockDto + { + Kind = Enum.GetName(typeof(DateTimeKind), _abpClockOptions.Kind) + }; + } } } diff --git a/framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj b/framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj index 4f9eb21f2f..53ef23fd62 100644 --- a/framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj +++ b/framework/src/Volo.Abp.Timing/Volo.Abp.Timing.csproj @@ -14,8 +14,19 @@ + + + + + + + - + + + + + diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs index d48cc01ef7..a306f3def9 100644 --- a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs @@ -1,9 +1,29 @@ -using Volo.Abp.Modularity; +using Volo.Abp.Localization; +using Volo.Abp.Localization.Resources.AbpLocalization; +using Volo.Abp.Modularity; +using Volo.Abp.Settings; +using Volo.Abp.Timing.Localization.Resources.AbpTiming; +using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.Timing { + [DependsOn(typeof(AbpVirtualFileSystemModule), typeof(AbpSettingsModule))] public class AbpTimingModule : AbpModule { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded("Volo.Abp", "Volo/Abp"); + }); + Configure(options => + { + options + .Resources + .Add("en") + .AddVirtualJson("/Timing/Localization/Resources/AbpTiming"); + }); + } } } diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/ITimezoneProvider.cs b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/ITimezoneProvider.cs new file mode 100644 index 0000000000..3ee1566803 --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/ITimezoneProvider.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace Volo.Abp.Timing +{ + public interface ITimezoneProvider + { + List GetWindowsTimezones(); + + List GetIanaTimezones(); + + string WindowsToIana(string windowsTimeZoneId); + + string IanaToWindows(string ianaTimeZoneName); + + TimeZoneInfo GetTimeZoneInfo(string windowsOrIanaTimeZoneId); + } +} diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/AbpTimingResource.cs b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/AbpTimingResource.cs new file mode 100644 index 0000000000..71f32d17cb --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/AbpTimingResource.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Localization; + +namespace Volo.Abp.Timing.Localization.Resources.AbpTiming +{ + [LocalizationResourceName("AbpTiming")] + public class AbpTimingResource + { + + } +} diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/en.json b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/en.json new file mode 100644 index 0000000000..c017c3ebea --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/en.json @@ -0,0 +1,7 @@ +{ + "culture": "en", + "texts": { + "DisplayName:Abp.Timing.Timezone": "Timezone", + "Description:Abp.Timing.Timezone": "Application time zone" + } +} diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/tr.json b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/tr.json new file mode 100644 index 0000000000..18139d6080 --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/tr.json @@ -0,0 +1,7 @@ +{ + "culture": "tr", + "texts": { + "DisplayName:Abp.Timing.Timezone": "saat dilimi", + "Description:Abp.Timing.Timezone": "Uygulama saat dilimi" + } +} diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hans.json b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hans.json new file mode 100644 index 0000000000..41315bbfb0 --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hans.json @@ -0,0 +1,7 @@ +{ + "culture": "zh-Hans", + "texts": { + "DisplayName:Abp.Timing.Timezone": "时区", + "Description:Abp.Timing.Timezone": "应用程序的时区" + } +} diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hant.json b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hant.json new file mode 100644 index 0000000000..5836792e3d --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hant.json @@ -0,0 +1,7 @@ +{ + "culture": "zh-Hant", + "texts": { + "DisplayName:Abp.Timing.Timezone": "時區", + "Description:Abp.Timing.Timezone": "應用程序的時區" + } +} diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TZConvertTimezoneProvider.cs b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TZConvertTimezoneProvider.cs new file mode 100644 index 0000000000..551b26e488 --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TZConvertTimezoneProvider.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TimeZoneConverter; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Timing +{ + public class TZConvertTimezoneProvider : ITimezoneProvider, ITransientDependency + { + public virtual List GetWindowsTimezones() + { + return TZConvert.KnownIanaTimeZoneNames.OrderBy(x => x).Select(x => new NameValue(x, x)).ToList(); + } + + public virtual List GetIanaTimezones() + { + return TZConvert.KnownIanaTimeZoneNames.OrderBy(x => x).Select(x => new NameValue(x, x)).ToList(); + } + + public virtual string WindowsToIana(string windowsTimeZoneId) + { + return TZConvert.WindowsToIana(windowsTimeZoneId); + } + + public virtual string IanaToWindows(string ianaTimeZoneName) + { + return TZConvert.IanaToWindows(ianaTimeZoneName); + } + + public virtual TimeZoneInfo GetTimeZoneInfo(string windowsOrIanaTimeZoneId) + { + return TZConvert.GetTimeZoneInfo(windowsOrIanaTimeZoneId); + } + } +} diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TimingSettingNames.cs b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TimingSettingNames.cs new file mode 100644 index 0000000000..15ba1bc9f9 --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TimingSettingNames.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Timing +{ + public static class TimingSettingNames + { + public const string TimeZone = "Abp.Timing.TimeZone"; + } +} diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TimingSettingProvider.cs b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TimingSettingProvider.cs new file mode 100644 index 0000000000..c2ebf73cfd --- /dev/null +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/TimingSettingProvider.cs @@ -0,0 +1,25 @@ +using Volo.Abp.Localization; +using Volo.Abp.Settings; +using Volo.Abp.Timing.Localization.Resources.AbpTiming; + +namespace Volo.Abp.Timing +{ + public class TimingSettingProvider : SettingDefinitionProvider + { + public override void Define(ISettingDefinitionContext context) + { + context.Add( + new SettingDefinition(TimingSettingNames.TimeZone, + "UTC", + L("DisplayName:Abp.Timing.Timezone"), + L("Description:Abp.Timing.Timezone"), + isVisibleToClients: true) + ); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js index fa42828306..722bd5f4a0 100644 --- a/npm/packs/core/src/abp.js +++ b/npm/packs/core/src/abp.js @@ -663,4 +663,60 @@ var abp = abp || {}; return abp.utils.getCookieValue(abp.security.antiForgery.tokenCookieName); }; + /* CLOCK *****************************************/ + abp.clock = abp.clock || {}; + + abp.clock.kind = 'Unspecified'; + + abp.clock.supportsMultipleTimezone = function () { + return abp.clock.kind === 'Utc'; + }; + + var toLocal = function (date) { + return new Date( + date.getUTCFullYear(), + date.getUTCMonth(), + date.getUTCDate(), + date.getUTCHours(), + date.getUTCMinutes(), + date.getUTCSeconds(), + date.getUTCMilliseconds() + ); + }; + + var toUtc = function (date) { + Date.UTC( + date.getUTCFullYear(), + date.getUTCMonth(), + date.getUTCDate(), + date.getUTCHours(), + date.getUTCMinutes(), + date.getUTCSeconds(), + date.getUTCMilliseconds() + ); + }; + + abp.clock.now = function () { + if (abp.clock.kind === 'Utc') { + return toUtc(new Date()); + } + return new Date(); + }; + + abp.clock.normalize = function (date) { + var kind = abp.clock.kind; + + if (kind === 'Unspecified') { + return date; + } + + if (kind === 'Local') { + return toLocal(new Date()); + } + + if (kind === 'Utc') { + return toUtc(new Date()); + } + }; + })(); \ No newline at end of file From 055ffa90cc79ba98744080920ddf3275841b9ead Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 14 May 2020 10:49:12 +0800 Subject: [PATCH 02/53] Update abp.js --- npm/packs/core/src/abp.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js index 722bd5f4a0..190143da03 100644 --- a/npm/packs/core/src/abp.js +++ b/npm/packs/core/src/abp.js @@ -711,12 +711,12 @@ var abp = abp || {}; } if (kind === 'Local') { - return toLocal(new Date()); + return toLocal(date); } if (kind === 'Utc') { - return toUtc(new Date()); + return toUtc(date); } }; -})(); \ No newline at end of file +})(); From eb6ff963fdcd40f8bef58defa706cc034e1bcfe8 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 28 May 2020 12:05:07 +0300 Subject: [PATCH 03/53] BlobStringDatabaseModule initial --- .../Volo.Abp.BlobStoring.Database.sln | 81 +++++++++++++++++++ ...o.Abp.BlobStoring.Database.sln.DotSettings | 23 ++++++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++++ ....BlobStoring.Database.Domain.Shared.csproj | 20 +++++ .../Database/DatabaseDomainSharedModule.cs | 37 +++++++++ .../Database/DatabaseErrorCodes.cs | 7 ++ .../Database/Localization/Database/cs.json | 6 ++ .../Database/Localization/Database/en.json | 6 ++ .../Database/Localization/Database/pl-PL.json | 6 ++ .../Database/Localization/Database/pt-BR.json | 6 ++ .../Database/Localization/Database/sl.json | 6 ++ .../Database/Localization/Database/tr.json | 6 ++ .../Database/Localization/Database/vi.json | 6 ++ .../Localization/Database/zh-Hans.json | 6 ++ .../Localization/Database/zh-Hant.json | 6 ++ .../Database/Localization/DatabaseResource.cs | 10 +++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++++ ...olo.Abp.BlobStoring.Database.Domain.csproj | 16 ++++ .../Database/DatabaseDbProperties.cs | 11 +++ .../Database/DatabaseDomainModule.cs | 12 +++ .../DatabaseSettingDefinitionProvider.cs | 14 ++++ .../Database/Settings/DatabaseSettings.cs | 11 +++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++++ ...toring.Database.EntityFrameworkCore.csproj | 16 ++++ .../EntityFrameworkCore/DatabaseDbContext.cs | 27 +++++++ ...atabaseDbContextModelCreatingExtensions.cs | 43 ++++++++++ .../DatabaseEntityFrameworkCoreModule.cs | 23 ++++++ ...atabaseModelBuilderConfigurationOptions.cs | 18 +++++ .../EntityFrameworkCore/IDatabaseDbContext.cs | 13 +++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++++ ...lo.Abp.BlobStoring.Database.MongoDB.csproj | 16 ++++ .../MongoDB/DatabaseMongoDbContext.cs | 20 +++++ .../DatabaseMongoDbContextExtensions.cs | 22 +++++ .../Database/MongoDB/DatabaseMongoDbModule.cs | 23 ++++++ ...seMongoModelBuilderConfigurationOptions.cs | 14 ++++ .../MongoDB/IDatabaseMongoDbContext.cs | 13 +++ .../DatabaseDomainTestBase.cs | 10 +++ .../DatabaseDomainTestModule.cs | 17 ++++ ...p.BlobStoring.Database.Domain.Tests.csproj | 13 +++ .../DatabaseEntityFrameworkCoreTestBase.cs | 10 +++ .../DatabaseEntityFrameworkCoreTestModule.cs | 41 ++++++++++ ....Database.EntityFrameworkCore.Tests.csproj | 17 ++++ .../MongoDB/DatabaseMongoDbTestBase.cs | 10 +++ .../MongoDB/DatabaseMongoDbTestModule.cs | 25 ++++++ .../MongoDB/MongoDbFixture.cs | 16 ++++ .../MongoDB/MongoTestCollection.cs | 10 +++ ....BlobStoring.Database.MongoDB.Tests.csproj | 15 ++++ .../DatabaseDataSeedContributor.cs | 27 +++++++ .../DatabaseTestBase.cs | 60 ++++++++++++++ .../DatabaseTestBaseModule.cs | 42 ++++++++++ .../Security/FakeCurrentPrincipalAccessor.cs | 43 ++++++++++ ...o.Abp.BlobStoring.Database.TestBase.csproj | 21 +++++ 56 files changed, 1053 insertions(+) create mode 100644 modules/blob-storing-database/Volo.Abp.BlobStoring.Database.sln create mode 100644 modules/blob-storing-database/Volo.Abp.BlobStoring.Database.sln.DotSettings create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/FodyWeavers.xml create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/FodyWeavers.xsd create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.csproj create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseDomainSharedModule.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseErrorCodes.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/cs.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/en.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pl-PL.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pt-BR.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/sl.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/tr.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/vi.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hans.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hant.json create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/DatabaseResource.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/FodyWeavers.xml create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/FodyWeavers.xsd create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDbProperties.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDomainModule.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettingDefinitionProvider.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettings.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/FodyWeavers.xml create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/FodyWeavers.xsd create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContext.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContextModelCreatingExtensions.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseEntityFrameworkCoreModule.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseModelBuilderConfigurationOptions.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IDatabaseDbContext.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/FodyWeavers.xml create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/FodyWeavers.xsd create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.csproj create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContext.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContextExtensions.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbModule.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoModelBuilderConfigurationOptions.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IDatabaseMongoDbContext.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestBase.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestModule.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.csproj create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestBase.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestBase.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbFixture.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoTestCollection.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.csproj create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseDataSeedContributor.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBase.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Security/FakeCurrentPrincipalAccessor.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj diff --git a/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.sln b/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.sln new file mode 100644 index 0000000000..37fafbe265 --- /dev/null +++ b/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.sln @@ -0,0 +1,81 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29001.49 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BlobStoring.Database.Domain.Shared", "src\Volo.Abp.BlobStoring.Database.Domain.Shared\Volo.Abp.BlobStoring.Database.Domain.Shared.csproj", "{D64C1577-4929-4B60-939E-96DE1534891A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BlobStoring.Database.Domain", "src\Volo.Abp.BlobStoring.Database.Domain\Volo.Abp.BlobStoring.Database.Domain.csproj", "{F2840BC7-0188-4606-9126-DADD0F5ABF7A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{649A3FFA-182F-4E56-9717-E6A9A2BEC545}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BlobStoring.Database.EntityFrameworkCore", "src\Volo.Abp.BlobStoring.Database.EntityFrameworkCore\Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj", "{0CE86223-D31D-4315-A1F5-87BA3EE1B844}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BlobStoring.Database.MongoDB", "src\Volo.Abp.BlobStoring.Database.MongoDB\Volo.Abp.BlobStoring.Database.MongoDB.csproj", "{F1C58097-4C08-4D88-8976-6B3389391481}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BlobStoring.Database.TestBase", "test\Volo.Abp.BlobStoring.Database.TestBase\Volo.Abp.BlobStoring.Database.TestBase.csproj", "{C5BB573D-3030-4BCB-88B7-F6A85C32766C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests", "test\Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests\Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj", "{527F645C-C1FC-406E-8479-81386C8ECF13}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BlobStoring.Database.MongoDB.Tests", "test\Volo.Abp.BlobStoring.Database.MongoDB.Tests\Volo.Abp.BlobStoring.Database.MongoDB.Tests.csproj", "{D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BlobStoring.Database.Domain.Tests", "test\Volo.Abp.BlobStoring.Database.Domain.Tests\Volo.Abp.BlobStoring.Database.Domain.Tests.csproj", "{E60895E5-79C4-447D-88B7-85CB5BA336A4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D64C1577-4929-4B60-939E-96DE1534891A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Release|Any CPU.Build.0 = Release|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Release|Any CPU.Build.0 = Release|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Release|Any CPU.Build.0 = Release|Any CPU + {F1C58097-4C08-4D88-8976-6B3389391481}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1C58097-4C08-4D88-8976-6B3389391481}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1C58097-4C08-4D88-8976-6B3389391481}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1C58097-4C08-4D88-8976-6B3389391481}.Release|Any CPU.Build.0 = Release|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Release|Any CPU.Build.0 = Release|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Release|Any CPU.Build.0 = Release|Any CPU + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6}.Release|Any CPU.Build.0 = Release|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {D64C1577-4929-4B60-939E-96DE1534891A} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {F2840BC7-0188-4606-9126-DADD0F5ABF7A} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {0CE86223-D31D-4315-A1F5-87BA3EE1B844} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {F1C58097-4C08-4D88-8976-6B3389391481} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {C5BB573D-3030-4BCB-88B7-F6A85C32766C} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {527F645C-C1FC-406E-8479-81386C8ECF13} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {D0AD9179-125C-40B2-A8EE-CD4C1EE24BB6} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {E60895E5-79C4-447D-88B7-85CB5BA336A4} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD} + EndGlobalSection +EndGlobal diff --git a/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.sln.DotSettings b/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.sln.DotSettings new file mode 100644 index 0000000000..cb0b2c919f --- /dev/null +++ b/modules/blob-storing-database/Volo.Abp.BlobStoring.Database.sln.DotSettings @@ -0,0 +1,23 @@ + + True + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + WARNING + Required + Required + Required + Required + False + True + False + False + True + False + False + SQL + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/FodyWeavers.xml b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/FodyWeavers.xsd b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.csproj b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.csproj new file mode 100644 index 0000000000..4178ed3659 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo.Abp.BlobStoring.Database.Domain.Shared.csproj @@ -0,0 +1,20 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + + diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseDomainSharedModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseDomainSharedModule.cs new file mode 100644 index 0000000000..b09799defe --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseDomainSharedModule.cs @@ -0,0 +1,37 @@ +using Volo.Abp.Modularity; +using Volo.Abp.Localization; +using Volo.Abp.BlobStoring.Database.Localization; +using Volo.Abp.Localization.ExceptionHandling; +using Volo.Abp.Validation; +using Volo.Abp.Validation.Localization; +using Volo.Abp.VirtualFileSystem; + +namespace Volo.Abp.BlobStoring.Database +{ + [DependsOn( + typeof(AbpValidationModule) + )] + public class DatabaseDomainSharedModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded("Volo.Abp.BlobStoring.Database"); + }); + + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("/Localization/Database"); + }); + + Configure(options => + { + options.MapCodeNamespace("Database", typeof(DatabaseResource)); + }); + } + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseErrorCodes.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseErrorCodes.cs new file mode 100644 index 0000000000..29c3623dd6 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseErrorCodes.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.BlobStoring.Database +{ + public static class DatabaseErrorCodes + { + //Add your business exception error codes here... + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/cs.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/cs.json new file mode 100644 index 0000000000..6a060a54c1 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/cs.json @@ -0,0 +1,6 @@ +{ + "culture": "cs", + "texts": { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/en.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/en.json new file mode 100644 index 0000000000..171d9a1220 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/en.json @@ -0,0 +1,6 @@ +{ + "culture": "en", + "texts": { + "ManageYourProfile": "Manage your profile" + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pl-PL.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pl-PL.json new file mode 100644 index 0000000000..3ea7b190ee --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pl-PL.json @@ -0,0 +1,6 @@ +{ + "culture": "pl-PL", + "texts": { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pt-BR.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pt-BR.json new file mode 100644 index 0000000000..6d746df04c --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pt-BR.json @@ -0,0 +1,6 @@ +{ + "culture": "pt-BR", + "texts": { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/sl.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/sl.json new file mode 100644 index 0000000000..687d42579c --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/sl.json @@ -0,0 +1,6 @@ +{ + "culture": "sl", + "texts": { + "ManageYourProfile": "Upravljajte svojim profilom" + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/tr.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/tr.json new file mode 100644 index 0000000000..2b48193353 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/tr.json @@ -0,0 +1,6 @@ +{ + "culture": "tr", + "texts": { + "ManageYourProfile": "Profil yönetimi" + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/vi.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/vi.json new file mode 100644 index 0000000000..d8eb5f3c75 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/vi.json @@ -0,0 +1,6 @@ +{ + "culture": "vi", + "texts": { + + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hans.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hans.json new file mode 100644 index 0000000000..99586f01c9 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hans.json @@ -0,0 +1,6 @@ +{ + "culture": "zh-Hans", + "texts": { + "ManageYourProfile": "管理个人资料" + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hant.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hant.json new file mode 100644 index 0000000000..ceea055597 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hant.json @@ -0,0 +1,6 @@ +{ + "culture": "zh-Hant", + "texts": { + "ManageYourProfile": "管理個人資料" + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/DatabaseResource.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/DatabaseResource.cs new file mode 100644 index 0000000000..60fddd3fc1 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/DatabaseResource.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Localization; + +namespace Volo.Abp.BlobStoring.Database.Localization +{ + [LocalizationResourceName("Database")] + public class DatabaseResource + { + + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/FodyWeavers.xml b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/FodyWeavers.xsd b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj new file mode 100644 index 0000000000..08aa82bf19 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj @@ -0,0 +1,16 @@ + + + + + + + netstandard2.0 + + + + + + + + + diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDbProperties.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDbProperties.cs new file mode 100644 index 0000000000..532a7e04c5 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDbProperties.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.BlobStoring.Database +{ + public static class DatabaseDbProperties + { + public static string DbTablePrefix { get; set; } = "Database"; + + public static string DbSchema { get; set; } = null; + + public const string ConnectionStringName = "Database"; + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDomainModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDomainModule.cs new file mode 100644 index 0000000000..55f5017497 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDomainModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Modularity; + +namespace Volo.Abp.BlobStoring.Database +{ + [DependsOn( + typeof(DatabaseDomainSharedModule) + )] + public class DatabaseDomainModule : AbpModule + { + + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettingDefinitionProvider.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettingDefinitionProvider.cs new file mode 100644 index 0000000000..ab9d392690 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettingDefinitionProvider.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Settings; + +namespace Volo.Abp.BlobStoring.Database.Settings +{ + public class DatabaseSettingDefinitionProvider : SettingDefinitionProvider + { + public override void Define(ISettingDefinitionContext context) + { + /* Define module settings here. + * Use names from DatabaseSettings class. + */ + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettings.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettings.cs new file mode 100644 index 0000000000..a723789c0c --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettings.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.BlobStoring.Database.Settings +{ + public static class DatabaseSettings + { + public const string GroupName = "Database"; + + /* Add constants for setting names. Example: + * public const string MySettingName = GroupName + ".MySettingName"; + */ + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/FodyWeavers.xml b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/FodyWeavers.xsd b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj new file mode 100644 index 0000000000..20c155c894 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj @@ -0,0 +1,16 @@ + + + + + + + netstandard2.0 + + + + + + + + + diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContext.cs new file mode 100644 index 0000000000..cb78c25a36 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContext.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + [ConnectionStringName(DatabaseDbProperties.ConnectionStringName)] + public class DatabaseDbContext : AbpDbContext, IDatabaseDbContext + { + /* Add DbSet for each Aggregate Root here. Example: + * public DbSet Questions { get; set; } + */ + + public DatabaseDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + builder.ConfigureDatabase(); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContextModelCreatingExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContextModelCreatingExtensions.cs new file mode 100644 index 0000000000..c4f2d81a31 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContextModelCreatingExtensions.cs @@ -0,0 +1,43 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Volo.Abp; + +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + public static class DatabaseDbContextModelCreatingExtensions + { + public static void ConfigureDatabase( + this ModelBuilder builder, + Action optionsAction = null) + { + Check.NotNull(builder, nameof(builder)); + + var options = new DatabaseModelBuilderConfigurationOptions( + DatabaseDbProperties.DbTablePrefix, + DatabaseDbProperties.DbSchema + ); + + optionsAction?.Invoke(options); + + /* Configure all entities here. Example: + + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(options.TablePrefix + "Questions", options.Schema); + + b.ConfigureByConvention(); + + //Properties + b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); + + //Relations + b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); + + //Indexes + b.HasIndex(q => q.CreationTime); + }); + */ + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseEntityFrameworkCoreModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseEntityFrameworkCoreModule.cs new file mode 100644 index 0000000000..29ff3fd264 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseEntityFrameworkCoreModule.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + [DependsOn( + typeof(DatabaseDomainModule), + typeof(AbpEntityFrameworkCoreModule) + )] + public class DatabaseEntityFrameworkCoreModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => + { + /* Add custom repositories here. Example: + * options.AddRepository(); + */ + }); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseModelBuilderConfigurationOptions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseModelBuilderConfigurationOptions.cs new file mode 100644 index 0000000000..ecc9f12d31 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseModelBuilderConfigurationOptions.cs @@ -0,0 +1,18 @@ +using JetBrains.Annotations; +using Volo.Abp.EntityFrameworkCore.Modeling; + +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + public class DatabaseModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions + { + public DatabaseModelBuilderConfigurationOptions( + [NotNull] string tablePrefix = "", + [CanBeNull] string schema = null) + : base( + tablePrefix, + schema) + { + + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IDatabaseDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IDatabaseDbContext.cs new file mode 100644 index 0000000000..1a15adf824 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IDatabaseDbContext.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + [ConnectionStringName(DatabaseDbProperties.ConnectionStringName)] + public interface IDatabaseDbContext : IEfCoreDbContext + { + /* Add DbSet for each Aggregate Root here. Example: + * DbSet Questions { get; } + */ + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/FodyWeavers.xml b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/FodyWeavers.xsd b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.csproj b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.csproj new file mode 100644 index 0000000000..dee196df48 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo.Abp.BlobStoring.Database.MongoDB.csproj @@ -0,0 +1,16 @@ + + + + + + + netstandard2.0 + + + + + + + + + diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContext.cs new file mode 100644 index 0000000000..cedfe26f79 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContext.cs @@ -0,0 +1,20 @@ +using Volo.Abp.Data; +using Volo.Abp.MongoDB; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + [ConnectionStringName(DatabaseDbProperties.ConnectionStringName)] + public class DatabaseMongoDbContext : AbpMongoDbContext, IDatabaseMongoDbContext + { + /* Add mongo collections here. Example: + * public IMongoCollection Questions => Collection(); + */ + + protected override void CreateModel(IMongoModelBuilder modelBuilder) + { + base.CreateModel(modelBuilder); + + modelBuilder.ConfigureDatabase(); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContextExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContextExtensions.cs new file mode 100644 index 0000000000..0f964076ce --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContextExtensions.cs @@ -0,0 +1,22 @@ +using System; +using Volo.Abp; +using Volo.Abp.MongoDB; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + public static class DatabaseMongoDbContextExtensions + { + public static void ConfigureDatabase( + this IMongoModelBuilder builder, + Action optionsAction = null) + { + Check.NotNull(builder, nameof(builder)); + + var options = new DatabaseMongoModelBuilderConfigurationOptions( + DatabaseDbProperties.DbTablePrefix + ); + + optionsAction?.Invoke(options); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbModule.cs new file mode 100644 index 0000000000..94f2ce745c --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbModule.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; +using Volo.Abp.MongoDB; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + [DependsOn( + typeof(DatabaseDomainModule), + typeof(AbpMongoDbModule) + )] + public class DatabaseMongoDbModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddMongoDbContext(options => + { + /* Add custom repositories here. Example: + * options.AddRepository(); + */ + }); + } + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoModelBuilderConfigurationOptions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoModelBuilderConfigurationOptions.cs new file mode 100644 index 0000000000..fbd5d8c57a --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoModelBuilderConfigurationOptions.cs @@ -0,0 +1,14 @@ +using JetBrains.Annotations; +using Volo.Abp.MongoDB; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + public class DatabaseMongoModelBuilderConfigurationOptions : AbpMongoModelBuilderConfigurationOptions + { + public DatabaseMongoModelBuilderConfigurationOptions( + [NotNull] string collectionPrefix = "") + : base(collectionPrefix) + { + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IDatabaseMongoDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IDatabaseMongoDbContext.cs new file mode 100644 index 0000000000..45148bb972 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IDatabaseMongoDbContext.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; +using Volo.Abp.MongoDB; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + [ConnectionStringName(DatabaseDbProperties.ConnectionStringName)] + public interface IDatabaseMongoDbContext : IAbpMongoDbContext + { + /* Define mongo collections here. Example: + * IMongoCollection Questions { get; } + */ + } +} diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestBase.cs new file mode 100644 index 0000000000..a4c230f34f --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestBase.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.BlobStoring.Database +{ + /* Inherit from this class for your domain layer tests. + * See SampleManager_Tests for example. + */ + public abstract class DatabaseDomainTestBase : DatabaseTestBase + { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestModule.cs new file mode 100644 index 0000000000..698261bb84 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestModule.cs @@ -0,0 +1,17 @@ +using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace Volo.Abp.BlobStoring.Database +{ + /* Domain tests are configured to use the EF Core provider. + * You can switch to MongoDB, however your domain tests should be + * database independent anyway. + */ + [DependsOn( + typeof(DatabaseEntityFrameworkCoreTestModule) + )] + public class DatabaseDomainTestModule : AbpModule + { + + } +} diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.csproj b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.csproj new file mode 100644 index 0000000000..20de7c154e --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/Volo.Abp.BlobStoring.Database.Domain.Tests.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp3.1 + Volo.Abp.BlobStoring.Database + + + + + + + + diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestBase.cs new file mode 100644 index 0000000000..7d6ab4cccf --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestBase.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + /* This class can be used as a base class for EF Core integration tests, + * while SampleRepository_Tests uses a different approach. + */ + public abstract class DatabaseEntityFrameworkCoreTestBase : DatabaseTestBase + { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs new file mode 100644 index 0000000000..59ab739c78 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs @@ -0,0 +1,41 @@ +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + [DependsOn( + typeof(DatabaseTestBaseModule), + typeof(DatabaseEntityFrameworkCoreModule) + )] + public class DatabaseEntityFrameworkCoreTestModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + var sqliteConnection = CreateDatabaseAndGetConnection(); + + Configure(options => + { + options.Configure(abpDbContextConfigurationContext => + { + abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); + }); + }); + } + + private static SqliteConnection CreateDatabaseAndGetConnection() + { + var connection = new SqliteConnection("Data Source=:memory:"); + connection.Open(); + + new DatabaseDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options + ).GetService().CreateTables(); + + return connection; + } + } +} diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj new file mode 100644 index 0000000000..8bdc5080aa --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj @@ -0,0 +1,17 @@ + + + + netcoreapp3.1 + Volo.Abp.BlobStoring.Database + + + + + + + + + + + + diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestBase.cs new file mode 100644 index 0000000000..26804bbbcb --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestBase.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + /* This class can be used as a base class for MongoDB integration tests, + * while SampleRepository_Tests uses a different approach. + */ + public abstract class DatabaseMongoDbTestBase : DatabaseTestBase + { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs new file mode 100644 index 0000000000..3d8b7d0b42 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs @@ -0,0 +1,25 @@ +using System; +using Volo.Abp.Data; +using Volo.Abp.Modularity; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + [DependsOn( + typeof(DatabaseTestBaseModule), + typeof(DatabaseMongoDbModule) + )] + public class DatabaseMongoDbTestModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + var connectionString = MongoDbFixture.ConnectionString.EnsureEndsWith('/') + + "Db_" + + Guid.NewGuid().ToString("N"); + + Configure(options => + { + options.ConnectionStrings.Default = connectionString; + }); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbFixture.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbFixture.cs new file mode 100644 index 0000000000..9473e5274d --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbFixture.cs @@ -0,0 +1,16 @@ +using System; +using Mongo2Go; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + public class MongoDbFixture : IDisposable + { + private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start(); + public static readonly string ConnectionString = MongoDbRunner.ConnectionString; + + public void Dispose() + { + MongoDbRunner?.Dispose(); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoTestCollection.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoTestCollection.cs new file mode 100644 index 0000000000..b9778249e4 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoTestCollection.cs @@ -0,0 +1,10 @@ +using Xunit; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + [CollectionDefinition(Name)] + public class MongoTestCollection : ICollectionFixture + { + public const string Name = "MongoDB Collection"; + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.csproj b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.csproj new file mode 100644 index 0000000000..9b37676068 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/Volo.Abp.BlobStoring.Database.MongoDB.Tests.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp3.1 + Volo.Abp.BlobStoring.Database + + + + + + + + + + diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseDataSeedContributor.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseDataSeedContributor.cs new file mode 100644 index 0000000000..4ccee29ad0 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseDataSeedContributor.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; + +namespace Volo.Abp.BlobStoring.Database +{ + public class DatabaseDataSeedContributor : IDataSeedContributor, ITransientDependency + { + private readonly IGuidGenerator _guidGenerator; + + public DatabaseDataSeedContributor( + IGuidGenerator guidGenerator) + { + _guidGenerator = guidGenerator; + } + + public Task SeedAsync(DataSeedContext context) + { + /* Instead of returning the Task.CompletedTask, you can insert your test data + * at this point! + */ + + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBase.cs new file mode 100644 index 0000000000..d52b5640cb --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBase.cs @@ -0,0 +1,60 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.Modularity; +using Volo.Abp.Uow; +using Volo.Abp.Testing; + +namespace Volo.Abp.BlobStoring.Database +{ + /* All test classes are derived from this class, directly or indirectly. */ + public abstract class DatabaseTestBase : AbpIntegratedTest + where TStartupModule : IAbpModule + { + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) + { + options.UseAutofac(); + } + + protected virtual Task WithUnitOfWorkAsync(Func func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } + + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + { + using (var scope = ServiceProvider.CreateScope()) + { + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) + { + await action(); + + await uow.CompleteAsync(); + } + } + } + + protected virtual Task WithUnitOfWorkAsync(Func> func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } + + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + { + using (var scope = ServiceProvider.CreateScope()) + { + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) + { + var result = await func(); + await uow.CompleteAsync(); + return result; + } + } + } + } +} diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs new file mode 100644 index 0000000000..67301fbbdd --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs @@ -0,0 +1,42 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.Authorization; +using Volo.Abp.Autofac; +using Volo.Abp.Data; +using Volo.Abp.Modularity; +using Volo.Abp.Threading; + +namespace Volo.Abp.BlobStoring.Database +{ + [DependsOn( + typeof(AbpAutofacModule), + typeof(AbpTestBaseModule), + typeof(AbpAuthorizationModule), + typeof(DatabaseDomainModule) + )] + public class DatabaseTestBaseModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAlwaysAllowAuthorization(); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + SeedTestData(context); + } + + private static void SeedTestData(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(async () => + { + using (var scope = context.ServiceProvider.CreateScope()) + { + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + } + }); + } + } +} diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Security/FakeCurrentPrincipalAccessor.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Security/FakeCurrentPrincipalAccessor.cs new file mode 100644 index 0000000000..e1b9aa1813 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Security/FakeCurrentPrincipalAccessor.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Security.Claims; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Security.Claims; + +namespace Volo.Abp.BlobStoring.Database.Security +{ + [Dependency(ReplaceServices = true)] + public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor + { + public override ClaimsPrincipal GetClaimsPrincipal() + { + return GetPrincipal(); + } + + private ClaimsPrincipal _principal; + + private ClaimsPrincipal GetPrincipal() + { + if (_principal == null) + { + lock (this) + { + if (_principal == null) + { + _principal = new ClaimsPrincipal( + new ClaimsIdentity( + new List + { + new Claim(AbpClaimTypes.UserId,"2e701e62-0953-4dd3-910b-dc6cc93ccb0d"), + new Claim(AbpClaimTypes.UserName,"admin"), + new Claim(AbpClaimTypes.Email,"admin@abp.io") + } + ) + ); + } + } + } + + return _principal; + } + } +} diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj new file mode 100644 index 0000000000..6fef4cb7df --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj @@ -0,0 +1,21 @@ + + + + netcoreapp3.1 + Volo.Abp.BlobStoring.Database + + + + + + + + + + + + + + + + From b956f489c90e8d1bb864a0929bf283b241c3ebb1 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 28 May 2020 12:45:01 +0300 Subject: [PATCH 04/53] Module classes renamed --- ...s => BlobStoringDatabaseDomainSharedModule.cs} | 10 +++++----- ...rCodes.cs => BlobStoringDatabaseErrorCodes.cs} | 2 +- .../{Database => BlobStoringDatabase}/cs.json | 0 .../{Database => BlobStoringDatabase}/en.json | 0 .../{Database => BlobStoringDatabase}/pl-PL.json | 0 .../{Database => BlobStoringDatabase}/pt-BR.json | 0 .../{Database => BlobStoringDatabase}/sl.json | 0 .../{Database => BlobStoringDatabase}/tr.json | 0 .../{Database => BlobStoringDatabase}/vi.json | 0 .../zh-Hans.json | 0 .../zh-Hant.json | 0 ...Resource.cs => BlobStoringDatabaseResource.cs} | 4 ++-- .../Volo.Abp.BlobStoring.Database.Domain.csproj | 1 + .../Database/BlobStoringDatabaseDbProperties.cs | 13 +++++++++++++ .../Database/BlobStoringDatabaseDomainModule.cs | 15 +++++++++++++++ .../BlobStoring/Database/DatabaseDbProperties.cs | 11 ----------- .../BlobStoring/Database/DatabaseDomainModule.cs | 12 ------------ ...obStoringDatabaseSettingDefinitionProvider.cs} | 4 ++-- ...Settings.cs => BlobStoringDatabaseSettings.cs} | 2 +- ...Context.cs => BlobStoringDatabaseDbContext.cs} | 6 +++--- ...ngDatabaseDbContextModelCreatingExtensions.cs} | 10 +++++----- ...obStoringDatabaseEntityFrameworkCoreModule.cs} | 6 +++--- ...ngDatabaseModelBuilderConfigurationOptions.cs} | 4 ++-- ...ontext.cs => IBlobStoringDatabaseDbContext.cs} | 4 ++-- ...xt.cs => BlobStoringDatabaseMongoDbContext.cs} | 4 ++-- ...lobStoringDatabaseMongoDbContextExtensions.cs} | 6 +++--- ...ule.cs => BlobStoringDatabaseMongoDbModule.cs} | 6 +++--- ...abaseMongoModelBuilderConfigurationOptions.cs} | 4 ++-- ...t.cs => IBlobStoringDatabaseMongoDbContext.cs} | 4 ++-- .../DatabaseEntityFrameworkCoreTestModule.cs | 6 +++--- .../MongoDB/DatabaseMongoDbTestModule.cs | 2 +- .../DatabaseTestBaseModule.cs | 2 +- 32 files changed, 72 insertions(+), 66 deletions(-) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/{DatabaseDomainSharedModule.cs => BlobStoringDatabaseDomainSharedModule.cs} (66%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/{DatabaseErrorCodes.cs => BlobStoringDatabaseErrorCodes.cs} (68%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/cs.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/en.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/pl-PL.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/pt-BR.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/sl.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/tr.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/vi.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/zh-Hans.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{Database => BlobStoringDatabase}/zh-Hant.json (100%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/{DatabaseResource.cs => BlobStoringDatabaseResource.cs} (52%) create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDbProperties.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDomainModule.cs delete mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDbProperties.cs delete mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDomainModule.cs rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/{DatabaseSettingDefinitionProvider.cs => BlobStoringDatabaseSettingDefinitionProvider.cs} (60%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/{DatabaseSettings.cs => BlobStoringDatabaseSettings.cs} (83%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/{DatabaseDbContext.cs => BlobStoringDatabaseDbContext.cs} (63%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/{DatabaseDbContextModelCreatingExtensions.cs => BlobStoringDatabaseDbContextModelCreatingExtensions.cs} (73%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/{DatabaseEntityFrameworkCoreModule.cs => BlobStoringDatabaseEntityFrameworkCoreModule.cs} (72%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/{DatabaseModelBuilderConfigurationOptions.cs => BlobStoringDatabaseModelBuilderConfigurationOptions.cs} (65%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/{IDatabaseDbContext.cs => IBlobStoringDatabaseDbContext.cs} (62%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/{DatabaseMongoDbContext.cs => BlobStoringDatabaseMongoDbContext.cs} (70%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/{DatabaseMongoDbContextExtensions.cs => BlobStoringDatabaseMongoDbContextExtensions.cs} (66%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/{DatabaseMongoDbModule.cs => BlobStoringDatabaseMongoDbModule.cs} (71%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/{DatabaseMongoModelBuilderConfigurationOptions.cs => BlobStoringDatabaseMongoModelBuilderConfigurationOptions.cs} (54%) rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/{IDatabaseMongoDbContext.cs => IBlobStoringDatabaseMongoDbContext.cs} (59%) diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseDomainSharedModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDomainSharedModule.cs similarity index 66% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseDomainSharedModule.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDomainSharedModule.cs index b09799defe..4dc89c9911 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseDomainSharedModule.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDomainSharedModule.cs @@ -11,26 +11,26 @@ namespace Volo.Abp.BlobStoring.Database [DependsOn( typeof(AbpValidationModule) )] - public class DatabaseDomainSharedModule : AbpModule + public class BlobStoringDatabaseDomainSharedModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { Configure(options => { - options.FileSets.AddEmbedded("Volo.Abp.BlobStoring.Database"); + options.FileSets.AddEmbedded("Volo.Abp.BlobStoring.Database"); }); Configure(options => { options.Resources - .Add("en") + .Add("en") .AddBaseTypes(typeof(AbpValidationResource)) - .AddVirtualJson("/Localization/Database"); + .AddVirtualJson("/Localization/BlobStoringDatabase"); }); Configure(options => { - options.MapCodeNamespace("Database", typeof(DatabaseResource)); + options.MapCodeNamespace("BlobStoringDatabase", typeof(BlobStoringDatabaseResource)); }); } } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseErrorCodes.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseErrorCodes.cs similarity index 68% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseErrorCodes.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseErrorCodes.cs index 29c3623dd6..fe066e74e5 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/DatabaseErrorCodes.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseErrorCodes.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.BlobStoring.Database { - public static class DatabaseErrorCodes + public static class BlobStoringDatabaseErrorCodes { //Add your business exception error codes here... } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/cs.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/cs.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/cs.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/cs.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/en.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/en.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/en.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/en.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pl-PL.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/pl-PL.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pl-PL.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/pl-PL.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pt-BR.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/pt-BR.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/pt-BR.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/pt-BR.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/sl.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/sl.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/sl.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/sl.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/tr.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/tr.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/tr.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/tr.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/vi.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/vi.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/vi.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/vi.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hans.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/zh-Hans.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hans.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/zh-Hans.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hant.json b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/zh-Hant.json similarity index 100% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/Database/zh-Hant.json rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabase/zh-Hant.json diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/DatabaseResource.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabaseResource.cs similarity index 52% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/DatabaseResource.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabaseResource.cs index 60fddd3fc1..6ee2f79810 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/DatabaseResource.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/Localization/BlobStoringDatabaseResource.cs @@ -2,8 +2,8 @@ namespace Volo.Abp.BlobStoring.Database.Localization { - [LocalizationResourceName("Database")] - public class DatabaseResource + [LocalizationResourceName("BlobStoringDatabase")] + public class BlobStoringDatabaseResource { } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj index 08aa82bf19..9e52acf207 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo.Abp.BlobStoring.Database.Domain.csproj @@ -10,6 +10,7 @@ + diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDbProperties.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDbProperties.cs new file mode 100644 index 0000000000..b673ad853f --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDbProperties.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; + +namespace Volo.Abp.BlobStoring.Database +{ + public static class BlobStoringDatabaseDbProperties + { + public static string DbTablePrefix { get; set; } = AbpCommonDbProperties.DbTablePrefix; + + public static string DbSchema { get; set; } = AbpCommonDbProperties.DbSchema; + + public const string ConnectionStringName = "AbpBlobStoring"; + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDomainModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDomainModule.cs new file mode 100644 index 0000000000..e49f9ce63b --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/BlobStoringDatabaseDomainModule.cs @@ -0,0 +1,15 @@ +using Volo.Abp.Domain; +using Volo.Abp.Modularity; + +namespace Volo.Abp.BlobStoring.Database +{ + [DependsOn( + typeof(AbpDddDomainModule), + typeof(AbpBlobStoringModule), + typeof(BlobStoringDatabaseDomainSharedModule) + )] + public class BlobStoringDatabaseDomainModule : AbpModule + { + + } +} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDbProperties.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDbProperties.cs deleted file mode 100644 index 532a7e04c5..0000000000 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDbProperties.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.BlobStoring.Database -{ - public static class DatabaseDbProperties - { - public static string DbTablePrefix { get; set; } = "Database"; - - public static string DbSchema { get; set; } = null; - - public const string ConnectionStringName = "Database"; - } -} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDomainModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDomainModule.cs deleted file mode 100644 index 55f5017497..0000000000 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseDomainModule.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Volo.Abp.Modularity; - -namespace Volo.Abp.BlobStoring.Database -{ - [DependsOn( - typeof(DatabaseDomainSharedModule) - )] - public class DatabaseDomainModule : AbpModule - { - - } -} diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettingDefinitionProvider.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettingDefinitionProvider.cs similarity index 60% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettingDefinitionProvider.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettingDefinitionProvider.cs index ab9d392690..4b7e927ac4 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettingDefinitionProvider.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettingDefinitionProvider.cs @@ -2,12 +2,12 @@ namespace Volo.Abp.BlobStoring.Database.Settings { - public class DatabaseSettingDefinitionProvider : SettingDefinitionProvider + public class BlobStoringDatabaseSettingDefinitionProvider : SettingDefinitionProvider { public override void Define(ISettingDefinitionContext context) { /* Define module settings here. - * Use names from DatabaseSettings class. + * Use names from BlobStoringDatabaseSettings class. */ } } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettings.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettings.cs similarity index 83% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettings.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettings.cs index a723789c0c..7d45d80169 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/DatabaseSettings.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettings.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.BlobStoring.Database.Settings { - public static class DatabaseSettings + public static class BlobStoringDatabaseSettings { public const string GroupName = "Database"; diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContext.cs similarity index 63% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContext.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContext.cs index cb78c25a36..81f031d36e 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContext.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContext.cs @@ -4,14 +4,14 @@ using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { - [ConnectionStringName(DatabaseDbProperties.ConnectionStringName)] - public class DatabaseDbContext : AbpDbContext, IDatabaseDbContext + [ConnectionStringName(BlobStoringDatabaseDbProperties.ConnectionStringName)] + public class BlobStoringDatabaseDbContext : AbpDbContext, IBlobStoringDatabaseDbContext { /* Add DbSet for each Aggregate Root here. Example: * public DbSet Questions { get; set; } */ - public DatabaseDbContext(DbContextOptions options) + public BlobStoringDatabaseDbContext(DbContextOptions options) : base(options) { diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContextModelCreatingExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs similarity index 73% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContextModelCreatingExtensions.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs index c4f2d81a31..f1addb0ee1 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseDbContextModelCreatingExtensions.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs @@ -4,17 +4,17 @@ using Volo.Abp; namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { - public static class DatabaseDbContextModelCreatingExtensions + public static class BlobStoringDatabaseDbContextModelCreatingExtensions { public static void ConfigureDatabase( this ModelBuilder builder, - Action optionsAction = null) + Action optionsAction = null) { Check.NotNull(builder, nameof(builder)); - var options = new DatabaseModelBuilderConfigurationOptions( - DatabaseDbProperties.DbTablePrefix, - DatabaseDbProperties.DbSchema + var options = new BlobStoringDatabaseModelBuilderConfigurationOptions( + BlobStoringDatabaseDbProperties.DbTablePrefix, + BlobStoringDatabaseDbProperties.DbSchema ); optionsAction?.Invoke(options); diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseEntityFrameworkCoreModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreModule.cs similarity index 72% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseEntityFrameworkCoreModule.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreModule.cs index 29ff3fd264..505951cde2 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseEntityFrameworkCoreModule.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreModule.cs @@ -5,14 +5,14 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { [DependsOn( - typeof(DatabaseDomainModule), + typeof(BlobStoringDatabaseDomainModule), typeof(AbpEntityFrameworkCoreModule) )] - public class DatabaseEntityFrameworkCoreModule : AbpModule + public class BlobStoringDatabaseEntityFrameworkCoreModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddAbpDbContext(options => + context.Services.AddAbpDbContext(options => { /* Add custom repositories here. Example: * options.AddRepository(); diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseModelBuilderConfigurationOptions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseModelBuilderConfigurationOptions.cs similarity index 65% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseModelBuilderConfigurationOptions.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseModelBuilderConfigurationOptions.cs index ecc9f12d31..324eb46c34 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/DatabaseModelBuilderConfigurationOptions.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseModelBuilderConfigurationOptions.cs @@ -3,9 +3,9 @@ using Volo.Abp.EntityFrameworkCore.Modeling; namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { - public class DatabaseModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions + public class BlobStoringDatabaseModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions { - public DatabaseModelBuilderConfigurationOptions( + public BlobStoringDatabaseModelBuilderConfigurationOptions( [NotNull] string tablePrefix = "", [CanBeNull] string schema = null) : base( diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IDatabaseDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IBlobStoringDatabaseDbContext.cs similarity index 62% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IDatabaseDbContext.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IBlobStoringDatabaseDbContext.cs index 1a15adf824..dd2d81565a 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IDatabaseDbContext.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IBlobStoringDatabaseDbContext.cs @@ -3,8 +3,8 @@ using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { - [ConnectionStringName(DatabaseDbProperties.ConnectionStringName)] - public interface IDatabaseDbContext : IEfCoreDbContext + [ConnectionStringName(BlobStoringDatabaseDbProperties.ConnectionStringName)] + public interface IBlobStoringDatabaseDbContext : IEfCoreDbContext { /* Add DbSet for each Aggregate Root here. Example: * DbSet Questions { get; } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContext.cs similarity index 70% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContext.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContext.cs index cedfe26f79..5f8d539274 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContext.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContext.cs @@ -3,8 +3,8 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB { - [ConnectionStringName(DatabaseDbProperties.ConnectionStringName)] - public class DatabaseMongoDbContext : AbpMongoDbContext, IDatabaseMongoDbContext + [ConnectionStringName(BlobStoringDatabaseDbProperties.ConnectionStringName)] + public class BlobStoringDatabaseMongoDbContext : AbpMongoDbContext, IBlobStoringDatabaseMongoDbContext { /* Add mongo collections here. Example: * public IMongoCollection Questions => Collection(); diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContextExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContextExtensions.cs similarity index 66% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContextExtensions.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContextExtensions.cs index 0f964076ce..995e8b155f 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbContextExtensions.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContextExtensions.cs @@ -4,7 +4,7 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB { - public static class DatabaseMongoDbContextExtensions + public static class BlobStoringDatabaseMongoDbContextExtensions { public static void ConfigureDatabase( this IMongoModelBuilder builder, @@ -12,8 +12,8 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB { Check.NotNull(builder, nameof(builder)); - var options = new DatabaseMongoModelBuilderConfigurationOptions( - DatabaseDbProperties.DbTablePrefix + var options = new BlobStoringDatabaseMongoModelBuilderConfigurationOptions( + BlobStoringDatabaseDbProperties.DbTablePrefix ); optionsAction?.Invoke(options); diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs similarity index 71% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbModule.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs index 94f2ce745c..7f822817ff 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoDbModule.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs @@ -5,14 +5,14 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB { [DependsOn( - typeof(DatabaseDomainModule), + typeof(BlobStoringDatabaseDomainModule), typeof(AbpMongoDbModule) )] - public class DatabaseMongoDbModule : AbpModule + public class BlobStoringDatabaseMongoDbModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - context.Services.AddMongoDbContext(options => + context.Services.AddMongoDbContext(options => { /* Add custom repositories here. Example: * options.AddRepository(); diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoModelBuilderConfigurationOptions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoModelBuilderConfigurationOptions.cs similarity index 54% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoModelBuilderConfigurationOptions.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoModelBuilderConfigurationOptions.cs index fbd5d8c57a..27133ac6dc 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/DatabaseMongoModelBuilderConfigurationOptions.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoModelBuilderConfigurationOptions.cs @@ -3,9 +3,9 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB { - public class DatabaseMongoModelBuilderConfigurationOptions : AbpMongoModelBuilderConfigurationOptions + public class BlobStoringDatabaseMongoModelBuilderConfigurationOptions : AbpMongoModelBuilderConfigurationOptions { - public DatabaseMongoModelBuilderConfigurationOptions( + public BlobStoringDatabaseMongoModelBuilderConfigurationOptions( [NotNull] string collectionPrefix = "") : base(collectionPrefix) { diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IDatabaseMongoDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IBlobStoringDatabaseMongoDbContext.cs similarity index 59% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IDatabaseMongoDbContext.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IBlobStoringDatabaseMongoDbContext.cs index 45148bb972..59b29ad187 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IDatabaseMongoDbContext.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IBlobStoringDatabaseMongoDbContext.cs @@ -3,8 +3,8 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB { - [ConnectionStringName(DatabaseDbProperties.ConnectionStringName)] - public interface IDatabaseMongoDbContext : IAbpMongoDbContext + [ConnectionStringName(BlobStoringDatabaseDbProperties.ConnectionStringName)] + public interface IBlobStoringDatabaseMongoDbContext : IAbpMongoDbContext { /* Define mongo collections here. Example: * IMongoCollection Questions { get; } diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs index 59ab739c78..5decc07eb4 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs @@ -9,7 +9,7 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { [DependsOn( typeof(DatabaseTestBaseModule), - typeof(DatabaseEntityFrameworkCoreModule) + typeof(BlobStoringDatabaseEntityFrameworkCoreModule) )] public class DatabaseEntityFrameworkCoreTestModule : AbpModule { @@ -31,8 +31,8 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore var connection = new SqliteConnection("Data Source=:memory:"); connection.Open(); - new DatabaseDbContext( - new DbContextOptionsBuilder().UseSqlite(connection).Options + new BlobStoringDatabaseDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options ).GetService().CreateTables(); return connection; diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs index 3d8b7d0b42..f1e2db75db 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs @@ -6,7 +6,7 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB { [DependsOn( typeof(DatabaseTestBaseModule), - typeof(DatabaseMongoDbModule) + typeof(BlobStoringDatabaseMongoDbModule) )] public class DatabaseMongoDbTestModule : AbpModule { diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs index 67301fbbdd..911c587344 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs @@ -12,7 +12,7 @@ namespace Volo.Abp.BlobStoring.Database typeof(AbpAutofacModule), typeof(AbpTestBaseModule), typeof(AbpAuthorizationModule), - typeof(DatabaseDomainModule) + typeof(BlobStoringDatabaseDomainModule) )] public class DatabaseTestBaseModule : AbpModule { From 05333bbf3ef695ac9e140eff7ded246b5eb82253 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 28 May 2020 16:16:05 +0300 Subject: [PATCH 05/53] settings removed --- ...BlobStoringDatabaseSettingDefinitionProvider.cs | 14 -------------- .../Settings/BlobStoringDatabaseSettings.cs | 11 ----------- 2 files changed, 25 deletions(-) delete mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettingDefinitionProvider.cs delete mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettings.cs diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettingDefinitionProvider.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettingDefinitionProvider.cs deleted file mode 100644 index 4b7e927ac4..0000000000 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettingDefinitionProvider.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Volo.Abp.Settings; - -namespace Volo.Abp.BlobStoring.Database.Settings -{ - public class BlobStoringDatabaseSettingDefinitionProvider : SettingDefinitionProvider - { - public override void Define(ISettingDefinitionContext context) - { - /* Define module settings here. - * Use names from BlobStoringDatabaseSettings class. - */ - } - } -} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettings.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettings.cs deleted file mode 100644 index 7d45d80169..0000000000 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Settings/BlobStoringDatabaseSettings.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.BlobStoring.Database.Settings -{ - public static class BlobStoringDatabaseSettings - { - public const string GroupName = "Database"; - - /* Add constants for setting names. Example: - * public const string MySettingName = GroupName + ".MySettingName"; - */ - } -} \ No newline at end of file From fc17e89cc5a8e6191e1839c18aff2460b17a7d3e Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 28 May 2020 17:31:08 +0300 Subject: [PATCH 06/53] Blob database provider added --- .../Volo/Abp/BlobStoring/Database/Blob.cs | 26 ++++++ .../Abp/BlobStoring/Database/Container.cs | 11 +++ .../Database/DatabaseBlobProvider.cs | 87 +++++++++++++++++++ .../BlobStoring/Database/IBlobRepository.cs | 17 ++++ .../Database/IContainerRepository.cs | 14 +++ 5 files changed, 155 insertions(+) create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IBlobRepository.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs new file mode 100644 index 0000000000..121352d6e8 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs @@ -0,0 +1,26 @@ +using System; +using Volo.Abp.Data; +using Volo.Abp.Domain.Entities; +using Volo.Abp.MultiTenancy; + +namespace Volo.Abp.BlobStoring.Database +{ + public class Blob : AggregateRoot, IMultiTenant + { + public Guid ContainerId { get; set; } + + public Guid? TenantId { get; } + + public string Name { get; set; } + + public byte[] Content { get; set; } + + public Blob(Guid id, Guid containerId, string name, byte[] content, Guid? tenantId) : base(id) + { + ContainerId = containerId; + Name = name; + Content = content; + TenantId = tenantId; + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs new file mode 100644 index 0000000000..8779a2778e --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs @@ -0,0 +1,11 @@ +using System; +using Volo.Abp.Domain.Entities; +using Volo.Abp.MultiTenancy; + +namespace Volo.Abp.BlobStoring.Database +{ + public class Container : AggregateRoot, IMultiTenant + { + public Guid? TenantId { get; } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs new file mode 100644 index 0000000000..6ca4692d10 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs @@ -0,0 +1,87 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.BlobStoring.Database +{ + public class DatabaseBlobProvider : BlobProviderBase, ITransientDependency + { + protected IBlobRepository BlobRepository { get; } + protected IContainerRepository ContainerRepository { get; } + + public DatabaseBlobProvider(IBlobRepository blobRepository, IContainerRepository containerRepository) + { + BlobRepository = blobRepository; + ContainerRepository = containerRepository; + } + + public override async Task SaveAsync(BlobProviderSaveArgs args) + { + var container = await ContainerRepository.GetContainerAsync(args.ContainerName); + + var blob = await BlobRepository.FindAsync(container.Id, args.BlobName, args.TenantId, args.CancellationToken); + + var content = await args.BlobStream.GetAllBytesAsync(args.CancellationToken); + + if (blob != null) + { + if (!args.OverrideExisting) + { + throw new BlobAlreadyExistsException($"Saving BLOB '{args.BlobName}' does already exists in the container '{args.ContainerName}'! Set {nameof(args.OverrideExisting)} if it should be overwritten."); + } + + blob.Content = content; + await BlobRepository.UpdateAsync(blob); + } + else + { + blob = new Blob(Guid.NewGuid(), container.Id, args.BlobName, content, args.TenantId); + await BlobRepository.InsertAsync(blob); + } + } + + public override async Task DeleteAsync(BlobProviderDeleteArgs args) + { + var container = await ContainerRepository.FindContainerAsync(args.ContainerName); + + if (container == null) + { + return false; + } + + return await BlobRepository.DeleteAsync(container.Id, args.BlobName, args.TenantId, args.CancellationToken); + } + + public override async Task ExistsAsync(BlobProviderExistsArgs args) + { + var container = await ContainerRepository.FindContainerAsync(args.ContainerName); + + if (container == null) + { + return false; + } + + return await BlobRepository.ExistsAsync(container.Id, args.BlobName, args.TenantId, args.CancellationToken); + } + + public override async Task GetOrNullAsync(BlobProviderGetArgs args) + { + var container = await ContainerRepository.FindContainerAsync(args.ContainerName); + + if (container == null) + { + return null; + } + + var blob = await BlobRepository.FindAsync(container.Id, args.BlobName, args.TenantId, args.CancellationToken); + + if (blob == null) + { + return null; + } + + return new MemoryStream(blob.Content); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IBlobRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IBlobRepository.cs new file mode 100644 index 0000000000..af0f237da2 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IBlobRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using JetBrains.Annotations; +using Volo.Abp.Domain.Repositories; + +namespace Volo.Abp.BlobStoring.Database +{ + public interface IBlobRepository : IBasicRepository + { + Task FindAsync(Guid containerId, [NotNull] string blobName, Guid? tenantId = null, CancellationToken cancellationToken = default); + + Task ExistsAsync(Guid containerId, [NotNull] string blobName, Guid? tenantId = null, CancellationToken cancellationToken = default); + + Task DeleteAsync(Guid containerId, [NotNull] string blobName, Guid? tenantId = null, CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs new file mode 100644 index 0000000000..8db5dcd148 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs @@ -0,0 +1,14 @@ +using System; +using System.Threading.Tasks; +using JetBrains.Annotations; +using Volo.Abp.Domain.Repositories; + +namespace Volo.Abp.BlobStoring.Database +{ + public interface IContainerRepository : IBasicRepository + { + Task GetContainerAsync([NotNull] string name); + + Task FindContainerAsync([NotNull] string name); + } +} \ No newline at end of file From 05e43c99e28af43b61225345365b931f54c51ec6 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 28 May 2020 18:31:19 +0300 Subject: [PATCH 07/53] Repositories implemented --- .../BlobStoring/Database/ContainerConsts.cs | 7 +++ .../Abp/BlobStoring/Database/Container.cs | 2 + .../BlobStoring/Database/IBlobRepository.cs | 6 +-- .../Database/IContainerRepository.cs | 5 +- .../BlobStoringDatabaseDbContext.cs | 9 ++-- ...atabaseDbContextModelCreatingExtensions.cs | 41 ++++++++-------- ...toringDatabaseEntityFrameworkCoreModule.cs | 6 +-- .../EfCoreBlobRepository.cs | 47 +++++++++++++++++++ .../EfCoreContainerRepository.cs | 26 ++++++++++ .../IBlobStoringDatabaseDbContext.cs | 9 ++-- .../BlobStoringDatabaseMongoDbContext.cs | 11 +++-- ...StoringDatabaseMongoDbContextExtensions.cs | 13 ++++- .../BlobStoringDatabaseMongoDbModule.cs | 5 +- .../IBlobStoringDatabaseMongoDbContext.cs | 9 ++-- .../Database/MongoDB/MongoBlobRepository.cs | 47 +++++++++++++++++++ .../MongoDB/MongoContainerRepository.cs | 27 +++++++++++ 16 files changed, 221 insertions(+), 49 deletions(-) create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/ContainerConsts.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreBlobRepository.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreContainerRepository.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoBlobRepository.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoContainerRepository.cs diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/ContainerConsts.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/ContainerConsts.cs new file mode 100644 index 0000000000..fa11c6464c --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/ContainerConsts.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.BlobStoring.Database +{ + public static class ContainerConsts + { + public const int MaxNameLength = 64; // TODO: find best length + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs index 8779a2778e..2426758892 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs @@ -7,5 +7,7 @@ namespace Volo.Abp.BlobStoring.Database public class Container : AggregateRoot, IMultiTenant { public Guid? TenantId { get; } + + public string Name { get; set; } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IBlobRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IBlobRepository.cs index af0f237da2..e12603c772 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IBlobRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IBlobRepository.cs @@ -8,10 +8,10 @@ namespace Volo.Abp.BlobStoring.Database { public interface IBlobRepository : IBasicRepository { - Task FindAsync(Guid containerId, [NotNull] string blobName, Guid? tenantId = null, CancellationToken cancellationToken = default); + Task FindAsync(Guid containerId, [NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); - Task ExistsAsync(Guid containerId, [NotNull] string blobName, Guid? tenantId = null, CancellationToken cancellationToken = default); + Task ExistsAsync(Guid containerId, [NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); - Task DeleteAsync(Guid containerId, [NotNull] string blobName, Guid? tenantId = null, CancellationToken cancellationToken = default); + Task DeleteAsync(Guid containerId, [NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs index 8db5dcd148..02d854e5c4 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; using Volo.Abp.Domain.Repositories; @@ -7,8 +8,8 @@ namespace Volo.Abp.BlobStoring.Database { public interface IContainerRepository : IBasicRepository { - Task GetContainerAsync([NotNull] string name); + Task GetContainerAsync([NotNull] string name, CancellationToken cancellationToken = default); - Task FindContainerAsync([NotNull] string name); + Task FindContainerAsync([NotNull] string name, CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContext.cs index 81f031d36e..13b5c12429 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContext.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContext.cs @@ -7,9 +7,9 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore [ConnectionStringName(BlobStoringDatabaseDbProperties.ConnectionStringName)] public class BlobStoringDatabaseDbContext : AbpDbContext, IBlobStoringDatabaseDbContext { - /* Add DbSet for each Aggregate Root here. Example: - * public DbSet Questions { get; set; } - */ + public DbSet Containers { get; set; } + + public DbSet Blobs { get; set; } public BlobStoringDatabaseDbContext(DbContextOptions options) : base(options) @@ -21,7 +21,8 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { base.OnModelCreating(builder); - builder.ConfigureDatabase(); + builder.ConfigureDatabaseBlobStoring(); } + } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs index f1addb0ee1..c14474ec02 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs @@ -1,12 +1,12 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Volo.Abp; +using Microsoft.EntityFrameworkCore; +using System; +using Volo.Abp.EntityFrameworkCore.Modeling; namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { public static class BlobStoringDatabaseDbContextModelCreatingExtensions { - public static void ConfigureDatabase( + public static void ConfigureDatabaseBlobStoring( this ModelBuilder builder, Action optionsAction = null) { @@ -19,25 +19,28 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore optionsAction?.Invoke(options); - /* Configure all entities here. Example: + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Containers", options.Schema); + + b.ConfigureByConvention(); - builder.Entity(b => + b.Property(p => p.Name).IsRequired().HasMaxLength(ContainerConsts.MaxNameLength); + + b.HasIndex(x => x.Name); + }); + + builder.Entity(b => { - //Configure table & schema name - b.ToTable(options.TablePrefix + "Questions", options.Schema); - + b.ToTable(options.TablePrefix + "Blobs", options.Schema); + b.ConfigureByConvention(); - - //Properties - b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); - - //Relations - b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); - - //Indexes - b.HasIndex(q => q.CreationTime); + + b.Property(p => p.Name).IsRequired().HasMaxLength(ContainerConsts.MaxNameLength); + b.Property(p => p.ContainerId).IsRequired(); + + b.HasIndex(x => x.Name); }); - */ } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreModule.cs index 505951cde2..7e2d00521e 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreModule.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreModule.cs @@ -14,9 +14,9 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { context.Services.AddAbpDbContext(options => { - /* Add custom repositories here. Example: - * options.AddRepository(); - */ + options.AddRepository(); + + options.AddRepository(); }); } } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreBlobRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreBlobRepository.cs new file mode 100644 index 0000000000..a6ac7ae2c1 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreBlobRepository.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + public class EfCoreBlobRepository : EfCoreRepository, IBlobRepository + { + public EfCoreBlobRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task FindAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + { + return await DbSet.FirstOrDefaultAsync( + x => x.ContainerId == containerId && + x.Name == name && + x.TenantId == tenantId, + GetCancellationToken(cancellationToken)); + } + + public virtual async Task ExistsAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + { + return await DbSet.AnyAsync( + x => x.ContainerId == containerId && + x.Name == name && + x.TenantId == tenantId, + GetCancellationToken(cancellationToken)); + } + + public virtual async Task DeleteAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + { + var blob = await FindAsync(containerId, name, tenantId, cancellationToken); + + if (blob == null) + { + return false; + } + + await base.DeleteAsync(blob.Id, cancellationToken: GetCancellationToken(cancellationToken)); + return true; + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreContainerRepository.cs new file mode 100644 index 0000000000..bb6d9b2922 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreContainerRepository.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore; + +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + public class EfCoreContainerRepository : EfCoreRepository, IContainerRepository + { + public EfCoreContainerRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task GetContainerAsync(string name, CancellationToken cancellationToken = default) + { + return await DbSet.FirstAsync(x => x.Name == name, GetCancellationToken(cancellationToken)); + } + + public virtual async Task FindContainerAsync(string name, CancellationToken cancellationToken = default) + { + return await DbSet.FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken)); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IBlobStoringDatabaseDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IBlobStoringDatabaseDbContext.cs index dd2d81565a..201efcb27a 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IBlobStoringDatabaseDbContext.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/IBlobStoringDatabaseDbContext.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Data; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore @@ -6,8 +7,8 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore [ConnectionStringName(BlobStoringDatabaseDbProperties.ConnectionStringName)] public interface IBlobStoringDatabaseDbContext : IEfCoreDbContext { - /* Add DbSet for each Aggregate Root here. Example: - * DbSet Questions { get; } - */ + DbSet Containers { get; } + + DbSet Blobs { get; } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContext.cs index 5f8d539274..6dd9f11979 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContext.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContext.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Data; +using MongoDB.Driver; +using Volo.Abp.Data; using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB @@ -6,15 +7,15 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB [ConnectionStringName(BlobStoringDatabaseDbProperties.ConnectionStringName)] public class BlobStoringDatabaseMongoDbContext : AbpMongoDbContext, IBlobStoringDatabaseMongoDbContext { - /* Add mongo collections here. Example: - * public IMongoCollection Questions => Collection(); - */ + public IMongoCollection Containers => Collection(); + + public IMongoCollection Blobs => Collection(); protected override void CreateModel(IMongoModelBuilder modelBuilder) { base.CreateModel(modelBuilder); - modelBuilder.ConfigureDatabase(); + modelBuilder.ConfigureDatabaseBlobStoring(); } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContextExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContextExtensions.cs index 995e8b155f..fa9442cd65 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContextExtensions.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbContextExtensions.cs @@ -1,12 +1,11 @@ using System; -using Volo.Abp; using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB { public static class BlobStoringDatabaseMongoDbContextExtensions { - public static void ConfigureDatabase( + public static void ConfigureDatabaseBlobStoring( this IMongoModelBuilder builder, Action optionsAction = null) { @@ -17,6 +16,16 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB ); optionsAction?.Invoke(options); + + builder.Entity(b => + { + b.CollectionName = options.CollectionPrefix + "Containers"; + }); + + builder.Entity(b => + { + b.CollectionName = options.CollectionPrefix + "Blobs"; + }); } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs index 7f822817ff..a802c97f76 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs @@ -14,9 +14,8 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB { context.Services.AddMongoDbContext(options => { - /* Add custom repositories here. Example: - * options.AddRepository(); - */ + options.AddRepository(); + options.AddRepository(); }); } } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IBlobStoringDatabaseMongoDbContext.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IBlobStoringDatabaseMongoDbContext.cs index 59b29ad187..7f90312a6d 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IBlobStoringDatabaseMongoDbContext.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/IBlobStoringDatabaseMongoDbContext.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Data; +using MongoDB.Driver; +using Volo.Abp.Data; using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB @@ -6,8 +7,8 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB [ConnectionStringName(BlobStoringDatabaseDbProperties.ConnectionStringName)] public interface IBlobStoringDatabaseMongoDbContext : IAbpMongoDbContext { - /* Define mongo collections here. Example: - * IMongoCollection Questions { get; } - */ + IMongoCollection Containers { get; } + + IMongoCollection Blobs { get; } } } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoBlobRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoBlobRepository.cs new file mode 100644 index 0000000000..e77c0a7300 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoBlobRepository.cs @@ -0,0 +1,47 @@ +using MongoDB.Driver.Linq; +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories.MongoDB; +using Volo.Abp.MongoDB; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + public class MongoBlobRepository : MongoDbRepository, IBlobRepository + { + public MongoBlobRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task FindAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + { + return await GetMongoQueryable().FirstOrDefaultAsync( + x => x.ContainerId == containerId && + x.Name == name && + x.TenantId == tenantId, + GetCancellationToken(cancellationToken)); + } + + public virtual async Task ExistsAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + { + return await GetMongoQueryable().AnyAsync( + x => x.ContainerId == containerId && + x.Name == name && + x.TenantId == tenantId, + GetCancellationToken(cancellationToken)); + } + + public virtual async Task DeleteAsync(Guid containerId, string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + { + var blob = await FindAsync(containerId, name, tenantId, cancellationToken); + + if (blob == null) + { + return false; + } + + await base.DeleteAsync(blob, cancellationToken: GetCancellationToken(cancellationToken)); + return true; + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoContainerRepository.cs new file mode 100644 index 0000000000..e3483190d2 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoContainerRepository.cs @@ -0,0 +1,27 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using MongoDB.Driver; +using MongoDB.Driver.Linq; +using Volo.Abp.Domain.Repositories.MongoDB; +using Volo.Abp.MongoDB; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + public class MongoContainerRepository : MongoDbRepository, IContainerRepository + { + public MongoContainerRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task GetContainerAsync(string name, CancellationToken cancellationToken = default) + { + return await GetMongoQueryable().Where(x => x.Name == name).FirstAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task FindContainerAsync(string name, CancellationToken cancellationToken = default) + { + return await GetMongoQueryable().Where(x => x.Name == name).FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); + } + } +} \ No newline at end of file From e6dad62ffd1246556198b4b3b2625f333441d926 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 28 May 2020 20:04:34 +0300 Subject: [PATCH 08/53] Tests added --- .../Abp/BlobStoring/Database/Container.cs | 8 +++++ ...aseBlobContainerConfigurationExtensions.cs | 31 ++++++++++++++++ .../Database/DatabaseBlobProvider.cs | 8 ++--- .../DatabaseBlobProviderConfiguration.cs | 12 +++++++ .../Database/IContainerRepository.cs | 6 ++-- .../EfCoreContainerRepository.cs | 21 ++++++++--- .../BlobStoringDatabaseMongoDbModule.cs | 4 +-- .../MongoDB/MongoContainerRepository.cs | 27 -------------- ...Repository.cs => MongoDbBlobRepository.cs} | 4 +-- .../MongoDB/MongoDbContainerRepository.cs | 35 +++++++++++++++++++ ...s => BlobStoringDatabaseDomainTestBase.cs} | 2 +- .../BlobStoringDatabaseDomainTestModule.cs | 13 +++++++ .../DatabaseDomainTestModule.cs | 17 --------- ...ringDatabaseEntityFrameworkCoreTestBase.cs | 7 ++++ ...gDatabaseEntityFrameworkCoreTestModule.cs} | 4 +-- .../DatabaseEntityFrameworkCoreTestBase.cs | 10 ------ .../EfCoreContainer_Test.cs | 7 ++++ .../BlobStoringDatabaseMongoDbTestBase.cs | 7 ++++ ...> BlobStoringDatabaseMongoDbTestModule.cs} | 4 +-- .../MongoDB/DatabaseMongoDbTestBase.cs | 10 ------ .../MongoDB/MongoDbContainer_Test.cs | 7 ++++ ...BlobStoringDatabaseDataSeedContributor.cs} | 4 +-- ...Base.cs => BlobStoringDatabaseTestBase.cs} | 3 +- ...s => BlobStoringDatabaseTestBaseModule.cs} | 13 +++++-- ...o.Abp.BlobStoring.Database.TestBase.csproj | 1 + 25 files changed, 174 insertions(+), 91 deletions(-) create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobContainerConfigurationExtensions.cs create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProviderConfiguration.cs delete mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoContainerRepository.cs rename modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/{MongoBlobRepository.cs => MongoDbBlobRepository.cs} (85%) create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbContainerRepository.cs rename modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/{DatabaseDomainTestBase.cs => BlobStoringDatabaseDomainTestBase.cs} (57%) create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/BlobStoringDatabaseDomainTestModule.cs delete mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestModule.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestBase.cs rename modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/{DatabaseEntityFrameworkCoreTestModule.cs => BlobStoringDatabaseEntityFrameworkCoreTestModule.cs} (91%) delete mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestBase.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/EfCoreContainer_Test.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/BlobStoringDatabaseMongoDbTestBase.cs rename modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/{DatabaseMongoDbTestModule.cs => BlobStoringDatabaseMongoDbTestModule.cs} (84%) delete mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestBase.cs create mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbContainer_Test.cs rename modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/{DatabaseDataSeedContributor.cs => BlobStoringDatabaseDataSeedContributor.cs} (78%) rename modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/{DatabaseTestBase.cs => BlobStoringDatabaseTestBase.cs} (91%) rename modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/{DatabaseTestBaseModule.cs => BlobStoringDatabaseTestBaseModule.cs} (72%) diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs index 2426758892..d96868840a 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs @@ -1,4 +1,5 @@ using System; +using JetBrains.Annotations; using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; @@ -9,5 +10,12 @@ namespace Volo.Abp.BlobStoring.Database public Guid? TenantId { get; } public string Name { get; set; } + + public Container(Guid id, [NotNull]string name, Guid? tenantId = null) : base(id) + { + // Todo: check null and length etc + TenantId = tenantId; + Name = name; + } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobContainerConfigurationExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobContainerConfigurationExtensions.cs new file mode 100644 index 0000000000..2746e39352 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobContainerConfigurationExtensions.cs @@ -0,0 +1,31 @@ +using System; + +namespace Volo.Abp.BlobStoring.Database +{ + public static class DatabaseBlobContainerConfigurationExtensions + { + public static DatabaseBlobProviderConfiguration GetDatabaseConfiguration( + this BlobContainerConfiguration containerConfiguration) + { + return new DatabaseBlobProviderConfiguration(containerConfiguration); + } + + public static BlobContainerConfiguration UseDatabase( + this BlobContainerConfiguration containerConfiguration, + Action fileSystemConfigureAction) + { + containerConfiguration.ProviderType = typeof(DatabaseBlobProvider); + + fileSystemConfigureAction(new DatabaseBlobProviderConfiguration(containerConfiguration)); + + return containerConfiguration; + } + + public static BlobContainerConfiguration UseDatabase(this BlobContainerConfiguration containerConfiguration) + { + containerConfiguration.ProviderType = typeof(DatabaseBlobProvider); + + return containerConfiguration; + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs index 6ca4692d10..e99e8ed193 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs @@ -18,7 +18,7 @@ namespace Volo.Abp.BlobStoring.Database public override async Task SaveAsync(BlobProviderSaveArgs args) { - var container = await ContainerRepository.GetContainerAsync(args.ContainerName); + var container = await ContainerRepository.CreateIfNotExistAsync(args.ContainerName, args.TenantId, args.CancellationToken); var blob = await BlobRepository.FindAsync(container.Id, args.BlobName, args.TenantId, args.CancellationToken); @@ -43,7 +43,7 @@ namespace Volo.Abp.BlobStoring.Database public override async Task DeleteAsync(BlobProviderDeleteArgs args) { - var container = await ContainerRepository.FindContainerAsync(args.ContainerName); + var container = await ContainerRepository.FindAsync(args.ContainerName, args.TenantId, args.CancellationToken); if (container == null) { @@ -55,7 +55,7 @@ namespace Volo.Abp.BlobStoring.Database public override async Task ExistsAsync(BlobProviderExistsArgs args) { - var container = await ContainerRepository.FindContainerAsync(args.ContainerName); + var container = await ContainerRepository.FindAsync(args.ContainerName, args.TenantId, args.CancellationToken); if (container == null) { @@ -67,7 +67,7 @@ namespace Volo.Abp.BlobStoring.Database public override async Task GetOrNullAsync(BlobProviderGetArgs args) { - var container = await ContainerRepository.FindContainerAsync(args.ContainerName); + var container = await ContainerRepository.FindAsync(args.ContainerName, args.TenantId, args.CancellationToken); if (container == null) { diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProviderConfiguration.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProviderConfiguration.cs new file mode 100644 index 0000000000..878c0c48c1 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProviderConfiguration.cs @@ -0,0 +1,12 @@ +namespace Volo.Abp.BlobStoring.Database +{ + public class DatabaseBlobProviderConfiguration + { + private readonly BlobContainerConfiguration _containerConfiguration; + + public DatabaseBlobProviderConfiguration(BlobContainerConfiguration containerConfiguration) + { + _containerConfiguration = containerConfiguration; + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs index 02d854e5c4..f3358f2520 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/IContainerRepository.cs @@ -8,8 +8,8 @@ namespace Volo.Abp.BlobStoring.Database { public interface IContainerRepository : IBasicRepository { - Task GetContainerAsync([NotNull] string name, CancellationToken cancellationToken = default); - - Task FindContainerAsync([NotNull] string name, CancellationToken cancellationToken = default); + Task CreateIfNotExistAsync([NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); + + Task FindAsync([NotNull] string name, Guid? tenantId = null, CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreContainerRepository.cs index bb6d9b2922..1c35bac904 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreContainerRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/EfCoreContainerRepository.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using System; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; @@ -13,14 +14,24 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { } - public virtual async Task GetContainerAsync(string name, CancellationToken cancellationToken = default) + public virtual async Task CreateIfNotExistAsync(string name, Guid? tenantId = null, CancellationToken cancellationToken = default) { - return await DbSet.FirstAsync(x => x.Name == name, GetCancellationToken(cancellationToken)); - } + var container = await FindAsync(name, tenantId, cancellationToken); + if (container != null) + { + return container; + } + + container = new Container(Guid.NewGuid(), name, tenantId); + await base.InsertAsync(container, true, GetCancellationToken(cancellationToken)); - public virtual async Task FindContainerAsync(string name, CancellationToken cancellationToken = default) + return container; + } + + public virtual async Task FindAsync(string name, Guid? tenantId = null, CancellationToken cancellationToken = default) { - return await DbSet.FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken)); + return await DbSet.WhereIf(tenantId != null, x => x.TenantId == tenantId) + .FirstOrDefaultAsync(x => x.Name == name, GetCancellationToken(cancellationToken)); } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs index a802c97f76..868dff97a5 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/BlobStoringDatabaseMongoDbModule.cs @@ -14,8 +14,8 @@ namespace Volo.Abp.BlobStoring.Database.MongoDB { context.Services.AddMongoDbContext(options => { - options.AddRepository(); - options.AddRepository(); + options.AddRepository(); + options.AddRepository(); }); } } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoContainerRepository.cs deleted file mode 100644 index e3483190d2..0000000000 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoContainerRepository.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using MongoDB.Driver; -using MongoDB.Driver.Linq; -using Volo.Abp.Domain.Repositories.MongoDB; -using Volo.Abp.MongoDB; - -namespace Volo.Abp.BlobStoring.Database.MongoDB -{ - public class MongoContainerRepository : MongoDbRepository, IContainerRepository - { - public MongoContainerRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } - - public virtual async Task GetContainerAsync(string name, CancellationToken cancellationToken = default) - { - return await GetMongoQueryable().Where(x => x.Name == name).FirstAsync(GetCancellationToken(cancellationToken)); - } - - public virtual async Task FindContainerAsync(string name, CancellationToken cancellationToken = default) - { - return await GetMongoQueryable().Where(x => x.Name == name).FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); - } - } -} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoBlobRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbBlobRepository.cs similarity index 85% rename from modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoBlobRepository.cs rename to modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbBlobRepository.cs index e77c0a7300..185751d1a5 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoBlobRepository.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbBlobRepository.cs @@ -7,9 +7,9 @@ using Volo.Abp.MongoDB; namespace Volo.Abp.BlobStoring.Database.MongoDB { - public class MongoBlobRepository : MongoDbRepository, IBlobRepository + public class MongoDbBlobRepository : MongoDbRepository, IBlobRepository { - public MongoBlobRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) + public MongoDbBlobRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) { } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbContainerRepository.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbContainerRepository.cs new file mode 100644 index 0000000000..47911d685e --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.MongoDB/Volo/Abp/BlobStoring/Database/MongoDB/MongoDbContainerRepository.cs @@ -0,0 +1,35 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.Domain.Repositories.MongoDB; +using Volo.Abp.MongoDB; + +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + public class MongoDbContainerRepository : MongoDbRepository, IContainerRepository + { + public MongoDbContainerRepository(IMongoDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public virtual async Task CreateIfNotExistAsync(string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + { + var container = await FindAsync(name, tenantId, cancellationToken); + + if (container != null) + { + return container; + } + + container = new Container(Guid.NewGuid(), name, tenantId); + await InsertAsync(container, true, GetCancellationToken(cancellationToken)); + + return container; + } + + public virtual async Task FindAsync(string name, Guid? tenantId = null, CancellationToken cancellationToken = default) + { + return await base.FindAsync(x => x.Name == name, cancellationToken: GetCancellationToken(cancellationToken)); + } + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/BlobStoringDatabaseDomainTestBase.cs similarity index 57% rename from modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestBase.cs rename to modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/BlobStoringDatabaseDomainTestBase.cs index a4c230f34f..405ac84008 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestBase.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/BlobStoringDatabaseDomainTestBase.cs @@ -3,7 +3,7 @@ /* Inherit from this class for your domain layer tests. * See SampleManager_Tests for example. */ - public abstract class DatabaseDomainTestBase : DatabaseTestBase + public abstract class BlobStoringDatabaseDomainTestBase : BlobStoringDatabaseTestBase { } diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/BlobStoringDatabaseDomainTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/BlobStoringDatabaseDomainTestModule.cs new file mode 100644 index 0000000000..a7ad7427f8 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/BlobStoringDatabaseDomainTestModule.cs @@ -0,0 +1,13 @@ +using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace Volo.Abp.BlobStoring.Database +{ + [DependsOn( + typeof(BlobStoringDatabaseEntityFrameworkCoreTestModule) + )] + public class BlobStoringDatabaseDomainTestModule : AbpModule + { + + } +} diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestModule.cs deleted file mode 100644 index 698261bb84..0000000000 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.Domain.Tests/DatabaseDomainTestModule.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; -using Volo.Abp.Modularity; - -namespace Volo.Abp.BlobStoring.Database -{ - /* Domain tests are configured to use the EF Core provider. - * You can switch to MongoDB, however your domain tests should be - * database independent anyway. - */ - [DependsOn( - typeof(DatabaseEntityFrameworkCoreTestModule) - )] - public class DatabaseDomainTestModule : AbpModule - { - - } -} diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestBase.cs new file mode 100644 index 0000000000..d465616047 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestBase.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + public abstract class BlobStoringDatabaseEntityFrameworkCoreTestBase : BlobStoringDatabaseTestBase + { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs similarity index 91% rename from modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs rename to modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs index 5decc07eb4..617c9373b9 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs @@ -8,10 +8,10 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { [DependsOn( - typeof(DatabaseTestBaseModule), + typeof(BlobStoringDatabaseTestBaseModule), typeof(BlobStoringDatabaseEntityFrameworkCoreModule) )] - public class DatabaseEntityFrameworkCoreTestModule : AbpModule + public class BlobStoringDatabaseEntityFrameworkCoreTestModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestBase.cs deleted file mode 100644 index 7d6ab4cccf..0000000000 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/DatabaseEntityFrameworkCoreTestBase.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore -{ - /* This class can be used as a base class for EF Core integration tests, - * while SampleRepository_Tests uses a different approach. - */ - public abstract class DatabaseEntityFrameworkCoreTestBase : DatabaseTestBase - { - - } -} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/EfCoreContainer_Test.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/EfCoreContainer_Test.cs new file mode 100644 index 0000000000..5902923c83 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/EfCoreContainer_Test.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore +{ + public class EfCoreContainer_Test : BlobStoringDatabaseTestBase + { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/BlobStoringDatabaseMongoDbTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/BlobStoringDatabaseMongoDbTestBase.cs new file mode 100644 index 0000000000..c96746cbb2 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/BlobStoringDatabaseMongoDbTestBase.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + public abstract class BlobStoringDatabaseMongoDbTestBase : BlobStoringDatabaseTestBase + { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/BlobStoringDatabaseMongoDbTestModule.cs similarity index 84% rename from modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs rename to modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/BlobStoringDatabaseMongoDbTestModule.cs index f1e2db75db..03eb96f6d3 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/BlobStoringDatabaseMongoDbTestModule.cs @@ -5,10 +5,10 @@ using Volo.Abp.Modularity; namespace Volo.Abp.BlobStoring.Database.MongoDB { [DependsOn( - typeof(DatabaseTestBaseModule), + typeof(BlobStoringDatabaseTestBaseModule), typeof(BlobStoringDatabaseMongoDbModule) )] - public class DatabaseMongoDbTestModule : AbpModule + public class BlobStoringDatabaseMongoDbTestModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestBase.cs deleted file mode 100644 index 26804bbbcb..0000000000 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/DatabaseMongoDbTestBase.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Volo.Abp.BlobStoring.Database.MongoDB -{ - /* This class can be used as a base class for MongoDB integration tests, - * while SampleRepository_Tests uses a different approach. - */ - public abstract class DatabaseMongoDbTestBase : DatabaseTestBase - { - - } -} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbContainer_Test.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbContainer_Test.cs new file mode 100644 index 0000000000..20b275a035 --- /dev/null +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbContainer_Test.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.BlobStoring.Database.MongoDB +{ + public class MongoDbContainer_Test : BlobStoringDatabaseTestBase + { + + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseDataSeedContributor.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseDataSeedContributor.cs similarity index 78% rename from modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseDataSeedContributor.cs rename to modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseDataSeedContributor.cs index 4ccee29ad0..8dc8ea382a 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseDataSeedContributor.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseDataSeedContributor.cs @@ -5,11 +5,11 @@ using Volo.Abp.Guids; namespace Volo.Abp.BlobStoring.Database { - public class DatabaseDataSeedContributor : IDataSeedContributor, ITransientDependency + public class BlobStoringDatabaseDataSeedContributor : IDataSeedContributor, ITransientDependency { private readonly IGuidGenerator _guidGenerator; - public DatabaseDataSeedContributor( + public BlobStoringDatabaseDataSeedContributor( IGuidGenerator guidGenerator) { _guidGenerator = guidGenerator; diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBase.cs similarity index 91% rename from modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBase.cs rename to modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBase.cs index d52b5640cb..bac1f18c9d 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBase.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBase.cs @@ -8,8 +8,7 @@ using Volo.Abp.Testing; namespace Volo.Abp.BlobStoring.Database { - /* All test classes are derived from this class, directly or indirectly. */ - public abstract class DatabaseTestBase : AbpIntegratedTest + public abstract class BlobStoringDatabaseTestBase : BlobContainer_Tests where TStartupModule : IAbpModule { protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBaseModule.cs similarity index 72% rename from modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs rename to modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBaseModule.cs index 911c587344..11b23fb0a6 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/DatabaseTestBaseModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBaseModule.cs @@ -12,13 +12,22 @@ namespace Volo.Abp.BlobStoring.Database typeof(AbpAutofacModule), typeof(AbpTestBaseModule), typeof(AbpAuthorizationModule), - typeof(BlobStoringDatabaseDomainModule) + typeof(BlobStoringDatabaseDomainModule), + typeof(AbpBlobStoringTestModule) )] - public class DatabaseTestBaseModule : AbpModule + public class BlobStoringDatabaseTestBaseModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { context.Services.AddAlwaysAllowAuthorization(); + + Configure(options => + { + options.Containers.ConfigureAll((containerName, containerConfiguration) => + { + containerConfiguration.UseDatabase(); + }); + }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj index 6fef4cb7df..8dfa603e98 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/Volo.Abp.BlobStoring.Database.TestBase.csproj @@ -15,6 +15,7 @@ + From 529bb08bf9f39a963442a4e701e5c32d2c4c9efd Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 20:52:33 +0300 Subject: [PATCH 09/53] feat: add getLocaleDirection to localization utils --- .../src/lib/tests/localization-utils.spec.ts | 44 +++++++++++++++++++ .../core/src/lib/utils/localization-utils.ts | 9 ++++ 2 files changed, 53 insertions(+) diff --git a/npm/ng-packs/packages/core/src/lib/tests/localization-utils.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/localization-utils.spec.ts index f5319edc2d..1409c0da21 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/localization-utils.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/localization-utils.spec.ts @@ -2,9 +2,53 @@ import { createLocalizationPipeKeyGenerator, createLocalizer, createLocalizerWithFallback, + getLocaleDirection, } from '../utils/localization-utils'; describe('Localization Utils', () => { + describe('#getLocaleDirection', () => { + test.each` + locale | expected + ${undefined} | ${'ltr'} + ${null} | ${'ltr'} + ${''} | ${'ltr'} + ${'en'} | ${'ltr'} + ${'en-US'} | ${'ltr'} + ${'pt'} | ${'ltr'} + ${'pt-PT'} | ${'ltr'} + ${'ar'} | ${'rtl'} + ${'ar-AE'} | ${'rtl'} + ${'ar-QA'} | ${'rtl'} + ${'ckb'} | ${'rtl'} + ${'ckb-IR'} | ${'rtl'} + ${'fa'} | ${'rtl'} + ${'fa-AF'} | ${'rtl'} + ${'he'} | ${'rtl'} + ${'ks'} | ${'rtl'} + ${'ksb'} | ${'ltr'} + ${'ksf'} | ${'ltr'} + ${'ksh'} | ${'ltr'} + ${'lrc'} | ${'rtl'} + ${'lrc-IQ'} | ${'rtl'} + ${'mzn'} | ${'rtl'} + ${'pa'} | ${'ltr'} + ${'pa-Arab'} | ${'rtl'} + ${'ps'} | ${'rtl'} + ${'ps-PK'} | ${'rtl'} + ${'sd'} | ${'rtl'} + ${'ug'} | ${'rtl'} + ${'ur'} | ${'rtl'} + ${'ur-IN'} | ${'rtl'} + ${'uz'} | ${'ltr'} + ${'uz-Arab'} | ${'rtl'} + ${'yi'} | ${'rtl'} + ${'zh'} | ${'ltr'} + ${'zh-Hans'} | ${'ltr'} + `('should return $expected when $locale is given as parameter', ({ locale, expected }) => { + expect(getLocaleDirection(locale)).toBe(expected); + }); + }); + describe('#createLocalizer', () => { const localize = createLocalizer({ values: { foo: { bar: 'baz' }, x: { y: 'z' } }, diff --git a/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts index ed094f7fc7..09478c8ed8 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts @@ -1,5 +1,14 @@ import { ApplicationConfiguration } from '../models/application-configuration'; +// This will not be necessary when only Angukar 9.1+ is supported +export function getLocaleDirection(locale: string): 'ltr' | 'rtl' { + return /^(ar(-[A-Z]{2})?|ckb(-IR)?|fa(-AF)?|he|ks|lrc(-IQ)?|mzn|pa-Arab|ps(-PK)?|sd|ug|ur(-IN)?|uz-Arab|yi)$/.test( + locale, + ) + ? 'rtl' + : 'ltr'; +} + export function createLocalizer(localization: ApplicationConfiguration.Localization) { return (resourceName: string, key: string, defaultValue: string) => { if (resourceName === '_') return key; From 41259e39a029e5d6af81e59a0d89ded7d174fff4 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 28 May 2020 21:05:01 +0300 Subject: [PATCH 10/53] Constants added --- .../Abp/BlobStoring/Database/BlobConsts.cs | 9 ++++++ .../BlobStoring/Database/ContainerConsts.cs | 2 +- .../Volo/Abp/BlobStoring/Database/Blob.cs | 28 +++++++++++++++---- .../Abp/BlobStoring/Database/Container.cs | 3 +- .../Database/DatabaseBlobProvider.cs | 2 +- ...atabaseDbContextModelCreatingExtensions.cs | 3 +- 6 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobConsts.cs diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobConsts.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobConsts.cs new file mode 100644 index 0000000000..f0edc35777 --- /dev/null +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/BlobConsts.cs @@ -0,0 +1,9 @@ +namespace Volo.Abp.BlobStoring.Database +{ + public static class BlobConsts + { + public const int MaxNameLength = 256; + + public const int MaxContentLength = 2_000_000_000; // 2 GB + } +} \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/ContainerConsts.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/ContainerConsts.cs index fa11c6464c..383883eca6 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/ContainerConsts.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain.Shared/Volo/Abp/BlobStoring/Database/ContainerConsts.cs @@ -2,6 +2,6 @@ { public static class ContainerConsts { - public const int MaxNameLength = 64; // TODO: find best length + public const int MaxNameLength = 128; } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs index 121352d6e8..56040fe6ce 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs @@ -1,5 +1,5 @@ -using System; -using Volo.Abp.Data; +using JetBrains.Annotations; +using System; using Volo.Abp.Domain.Entities; using Volo.Abp.MultiTenancy; @@ -13,14 +13,32 @@ namespace Volo.Abp.BlobStoring.Database public string Name { get; set; } - public byte[] Content { get; set; } + public byte[] Content { get; private set; } - public Blob(Guid id, Guid containerId, string name, byte[] content, Guid? tenantId) : base(id) + public Blob(Guid id, Guid containerId, [NotNull]string name, byte[] content, Guid? tenantId) : base(id) { + Check.NotNullOrWhiteSpace(name, nameof(name), BlobConsts.MaxNameLength); + CheckContent(content); + + Content = content; ContainerId = containerId; Name = name; - Content = content; TenantId = tenantId; } + + public virtual void SetContent(byte[] content) + { + CheckContent(content); + + Content = content; + } + + protected void CheckContent(byte[] content) + { + if (content.Length >= BlobConsts.MaxContentLength) + { + throw new AbpException("Blob content size cannot be more than 2GB."); + } + } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs index d96868840a..927e98ae25 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs @@ -13,7 +13,8 @@ namespace Volo.Abp.BlobStoring.Database public Container(Guid id, [NotNull]string name, Guid? tenantId = null) : base(id) { - // Todo: check null and length etc + Check.NotNullOrWhiteSpace(name, nameof(name), ContainerConsts.MaxNameLength); + TenantId = tenantId; Name = name; } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs index e99e8ed193..f749410429 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobProvider.cs @@ -31,7 +31,7 @@ namespace Volo.Abp.BlobStoring.Database throw new BlobAlreadyExistsException($"Saving BLOB '{args.BlobName}' does already exists in the container '{args.ContainerName}'! Set {nameof(args.OverrideExisting)} if it should be overwritten."); } - blob.Content = content; + blob.SetContent(content); await BlobRepository.UpdateAsync(blob); } else diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs index c14474ec02..9a3d52c4c9 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.EntityFrameworkCore/Volo/Abp/BlobStoring/Database/EntityFrameworkCore/BlobStoringDatabaseDbContextModelCreatingExtensions.cs @@ -36,8 +36,9 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore b.ConfigureByConvention(); - b.Property(p => p.Name).IsRequired().HasMaxLength(ContainerConsts.MaxNameLength); + b.Property(p => p.Name).IsRequired().HasMaxLength(BlobConsts.MaxNameLength); b.Property(p => p.ContainerId).IsRequired(); + b.Property(p => p.Content).HasMaxLength(BlobConsts.MaxContentLength); b.HasIndex(x => x.Name); }); From c903e8909adf4fb84ac1ce2236aae575ae8fb651 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 28 May 2020 21:05:25 +0300 Subject: [PATCH 11/53] BlobStoringDatabase module added to build list --- build/common.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/build/common.ps1 b/build/common.ps1 index 70a432818b..680d2e9fdb 100644 --- a/build/common.ps1 +++ b/build/common.ps1 @@ -20,6 +20,7 @@ $solutionPaths = ( "../modules/background-jobs", "../modules/client-simulation", "../modules/virtual-file-explorer", + "../modules/blob-storing-database", "../templates/module/aspnet-core", "../templates/app/aspnet-core", "../samples/MicroserviceDemo", From 9a0c250374195522cc87cfde7437dfa26bce5a93 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:09:44 +0300 Subject: [PATCH 12/53] feat: keep element as public property on loading strategy --- .../packages/core/src/lib/strategies/loading.strategy.ts | 8 +++++--- .../packages/core/src/lib/tests/loading.strategy.spec.ts | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/strategies/loading.strategy.ts b/npm/ng-packs/packages/core/src/lib/strategies/loading.strategy.ts index be89a751ed..f1f3abe30c 100644 --- a/npm/ng-packs/packages/core/src/lib/strategies/loading.strategy.ts +++ b/npm/ng-packs/packages/core/src/lib/strategies/loading.strategy.ts @@ -5,6 +5,8 @@ import { CrossOriginStrategy, CROSS_ORIGIN_STRATEGY } from './cross-origin.strat import { DomStrategy, DOM_STRATEGY } from './dom.strategy'; export abstract class LoadingStrategy { + element: T; + constructor( public path: string, protected domStrategy: DomStrategy = DOM_STRATEGY.AppendToHead(), @@ -14,10 +16,10 @@ export abstract class LoadingStrategy(): Observable { + this.element = this.createElement(); + return of(null).pipe( - switchMap(() => - fromLazyLoad(this.createElement(), this.domStrategy, this.crossOriginStrategy), - ), + switchMap(() => fromLazyLoad(this.element, this.domStrategy, this.crossOriginStrategy)), ); } } diff --git a/npm/ng-packs/packages/core/src/lib/tests/loading.strategy.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/loading.strategy.spec.ts index 4b950cf533..4215e6eee5 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/loading.strategy.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/loading.strategy.spec.ts @@ -39,6 +39,7 @@ describe('ScriptLoadingStrategy', () => { const strategy = new ScriptLoadingStrategy(path, domStrategy, crossOriginStrategy); strategy.createStream().subscribe(event => { + expect(strategy.element.tagName).toBe('SCRIPT'); expect(event.detail.crossOrigin).toBe('use-credentials'); done(); }); @@ -78,6 +79,7 @@ describe('StyleLoadingStrategy', () => { const strategy = new StyleLoadingStrategy(path, domStrategy, crossOriginStrategy); strategy.createStream().subscribe(event => { + expect(strategy.element.tagName).toBe('LINK'); expect(event.detail.crossOrigin).toBe('use-credentials'); done(); }); From bb9851cb1525733aace42081a6b4a70b622c269a Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:10:06 +0300 Subject: [PATCH 13/53] feat: add remove method to lazy loading service --- .../src/lib/services/lazy-load.service.ts | 13 +++++++-- .../src/lib/tests/lazy-load.service.spec.ts | 28 ++++++++++++++++++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts b/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts index cec9d4a6cf..d58788d878 100644 --- a/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts @@ -8,7 +8,7 @@ import { uuid } from '../utils'; providedIn: 'root', }) export class LazyLoadService { - readonly loaded = new Set(); + readonly loaded = new Map(); loadedLibraries: { [url: string]: ReplaySubject } = {}; @@ -45,7 +45,7 @@ export class LazyLoadService { throwError(new CustomEvent('error')), ), ), - tap(() => this.loaded.add(strategy.path)), + tap(() => this.loaded.set(strategy.path, strategy.element)), delay(100), shareReplay({ bufferSize: 1, refCount: true }), ); @@ -113,4 +113,13 @@ export class LazyLoadService { }); }); } + + remove(path: string): boolean { + if (!this.loaded.has(path)) return false; + + const element = this.loaded.get(path); + element.parentNode.removeChild(element); + this.loaded.delete(path); + return true; + } } diff --git a/npm/ng-packs/packages/core/src/lib/tests/lazy-load.service.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/lazy-load.service.spec.ts index 3596da2591..4868fb78f3 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/lazy-load.service.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/lazy-load.service.spec.ts @@ -49,7 +49,7 @@ describe('LazyLoadService', () => { it('should emit a custom load event if loaded if resource is loaded before', done => { const loadEvent = new CustomEvent('load'); - service.loaded.add(strategy.path); + service.loaded.set(strategy.path, null); service.load(strategy).subscribe(event => { expect(event).toEqual(loadEvent); @@ -57,6 +57,32 @@ describe('LazyLoadService', () => { }); }); }); + + describe('#remove', () => { + const service = new LazyLoadService(); + + it('should remove an already lazy loaded element and return true', () => { + const script = document.createElement('script'); + document.body.appendChild(script); + service.loaded.set('x', script); + + expect(document.body.lastElementChild).toBe(script); + + const result = service.remove('x'); + + expect(document.body.lastElementChild).toBeNull(); + expect(service.loaded.has('x')).toBe(false); + expect(result).toBe(true); + }); + + it('should return false when path not found', () => { + service.loaded.set('foo', null); + + const result = service.remove('bar'); + + expect(result).toBe(false); + }); + }); }); describe('LazyLoadService (Deprecated)', () => { From f48887d1f23d15971a959714069a26d87876314d Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:11:17 +0300 Subject: [PATCH 14/53] feat: add a LocaleDirection type --- npm/ng-packs/packages/theme-shared/src/lib/models/common.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/models/common.ts b/npm/ng-packs/packages/theme-shared/src/lib/models/common.ts index d75c854476..09171179c4 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/models/common.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/models/common.ts @@ -14,3 +14,5 @@ export interface HttpErrorConfig { hideCloseIcon?: boolean; }; } + +export type LocaleDirection = 'ltr' | 'rtl'; From fe8ea095640e617aa0800d012661bc1ce7eed680 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:16:09 +0300 Subject: [PATCH 15/53] build: create bootstrap style chunks for ltr and rtl --- npm/ng-packs/angular.json | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/npm/ng-packs/angular.json b/npm/ng-packs/angular.json index 39a10f827b..bf45811340 100644 --- a/npm/ng-packs/angular.json +++ b/npm/ng-packs/angular.json @@ -440,18 +440,27 @@ "assets": ["apps/dev-app/src/favicon.ico", "apps/dev-app/src/assets"], "extractCss": true, "styles": [ - "apps/dev-app/src/styles.scss", - "node_modules/bootstrap/dist/css/bootstrap.min.css", + { + "input": "node_modules/@abp/ng.theme.shared/styles/bootstrap-rtl.min.css", + "inject": false, + "bundleName": "bootstrap-rtl.min" + }, + { + "input": "node_modules/bootstrap/dist/css/bootstrap.min.css", + "inject": true, + "bundleName": "bootstrap-ltr.min" + }, { "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", - "lazy": true, + "inject": false, "bundleName": "fontawesome-all.min" }, { "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", - "lazy": true, + "inject": false, "bundleName": "fontawesome-v4-shims.min" - } + }, + "apps/dev-app/src/styles.scss" ], "scripts": [] }, From 832c47e0f1dcf07901409f16ffc7240386696f79 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:20:48 +0300 Subject: [PATCH 16/53] feat: inject fontawesome chunks instead of lazy loading --- npm/ng-packs/angular.json | 4 ++-- .../apps/dev-app/src/app/app.component.ts | 19 ++----------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/npm/ng-packs/angular.json b/npm/ng-packs/angular.json index bf45811340..2b876fe21c 100644 --- a/npm/ng-packs/angular.json +++ b/npm/ng-packs/angular.json @@ -452,12 +452,12 @@ }, { "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", - "inject": false, + "inject": true, "bundleName": "fontawesome-all.min" }, { "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", - "inject": false, + "inject": true, "bundleName": "fontawesome-v4-shims.min" }, "apps/dev-app/src/styles.scss" diff --git a/npm/ng-packs/apps/dev-app/src/app/app.component.ts b/npm/ng-packs/apps/dev-app/src/app/app.component.ts index 8187365734..bf2a27962a 100644 --- a/npm/ng-packs/apps/dev-app/src/app/app.component.ts +++ b/npm/ng-packs/apps/dev-app/src/app/app.component.ts @@ -1,6 +1,4 @@ -import { LazyLoadService, LOADING_STRATEGY } from '@abp/ng.core'; -import { Component, OnInit } from '@angular/core'; -import { forkJoin } from 'rxjs'; +import { Component } from '@angular/core'; @Component({ selector: 'app-root', @@ -9,17 +7,4 @@ import { forkJoin } from 'rxjs'; `, }) -export class AppComponent implements OnInit { - constructor(private lazyLoadService: LazyLoadService) {} - - ngOnInit() { - forkJoin( - this.lazyLoadService.load( - LOADING_STRATEGY.PrependAnonymousStyleToHead('fontawesome-v4-shims.min.css'), - ), - this.lazyLoadService.load( - LOADING_STRATEGY.PrependAnonymousStyleToHead('fontawesome-all.min.css'), - ), - ).subscribe(); - } -} +export class AppComponent {} From 80c530f803be7d4be2394f5baec4491a810db205 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:23:08 +0300 Subject: [PATCH 17/53] feat: apply style chunk changes to template --- templates/app/angular/angular.json | 15 ++++++++++----- .../app/angular/src/app/app.component.ts | 19 ++----------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/templates/app/angular/angular.json b/templates/app/angular/angular.json index 567b8f95c7..4f176a44b8 100644 --- a/templates/app/angular/angular.json +++ b/templates/app/angular/angular.json @@ -26,22 +26,27 @@ "extractCss": true, "assets": ["src/favicon.ico", "src/assets"], "styles": [ + { + "input": "node_modules/@abp/ng.theme.shared/styles/bootstrap-rtl.min.css", + "inject": false, + "bundleName": "bootstrap-rtl.min" + }, { "input": "node_modules/bootstrap/dist/css/bootstrap.min.css", "inject": true, - "bundleName": "bootstrap.min" + "bundleName": "bootstrap-ltr.min" }, - "src/styles.scss", { "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", - "inject": false, + "inject": true, "bundleName": "fontawesome-all.min" }, { "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", - "inject": false, + "inject": true, "bundleName": "fontawesome-v4-shims.min" - } + }, + "apps/dev-app/src/styles.scss" ], "scripts": [] }, diff --git a/templates/app/angular/src/app/app.component.ts b/templates/app/angular/src/app/app.component.ts index 963806c4f4..bf2a27962a 100644 --- a/templates/app/angular/src/app/app.component.ts +++ b/templates/app/angular/src/app/app.component.ts @@ -1,6 +1,4 @@ -import { LazyLoadService, LOADING_STRATEGY } from '@abp/ng.core'; -import { Component, OnInit } from '@angular/core'; -import { forkJoin } from 'rxjs'; +import { Component } from '@angular/core'; @Component({ selector: 'app-root', @@ -9,17 +7,4 @@ import { forkJoin } from 'rxjs'; `, }) -export class AppComponent implements OnInit { - constructor(private lazyLoadService: LazyLoadService) {} - - ngOnInit() { - forkJoin( - this.lazyLoadService.load( - LOADING_STRATEGY.PrependAnonymousStyleToHead('fontawesome-v4-shims.min.css') - ), - this.lazyLoadService.load( - LOADING_STRATEGY.PrependAnonymousStyleToHead('fontawesome-all.min.css') - ) - ).subscribe(); - } -} +export class AppComponent {} From cb2533f4299e67c2cdd47c08655e2456016b68b6 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:24:33 +0300 Subject: [PATCH 18/53] feat: add a lazy styles token --- npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts | 1 + .../packages/theme-shared/src/lib/tokens/lazy-styles.token.ts | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tokens/lazy-styles.token.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts b/npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts index 1bdd74c53e..a923c8fc23 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/tokens/index.ts @@ -1,2 +1,3 @@ export * from './append-content.token'; export * from './http-error.token'; +export * from './lazy-styles.token'; diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tokens/lazy-styles.token.ts b/npm/ng-packs/packages/theme-shared/src/lib/tokens/lazy-styles.token.ts new file mode 100644 index 0000000000..73ca3044fc --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tokens/lazy-styles.token.ts @@ -0,0 +1,3 @@ +import { InjectionToken } from '@angular/core'; + +export const LAZY_STYLES = new InjectionToken('LAZY_STYLES'); From bf90091a7e024a89f1e7b5cb00c9620c759db47f Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:25:24 +0300 Subject: [PATCH 19/53] feat: add rtl fixes and bootstrap pattern --- .../packages/theme-shared/src/lib/constants/styles.ts | 11 +++++++++++ npm/ng-packs/packages/theme-shared/src/public-api.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts b/npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts index 4458117d16..f2b405b744 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts @@ -13,6 +13,15 @@ export default ` text-align: right; } +[dir=rtl] .data-tables-filter { + text-align: left; +} + +[dir=rtl] .dropdown-menu-right { + left: 0; + right: auto; +} + .pointer { cursor: pointer; } @@ -155,3 +164,5 @@ export default ` /* Date: Thu, 28 May 2020 23:29:34 +0300 Subject: [PATCH 20/53] feat: add rtl fixes to basic theme styles --- .../packages/theme-basic/src/lib/constants/styles.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts b/npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts index 0d9ebcc300..0fa787953e 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts +++ b/npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts @@ -2,7 +2,6 @@ export default ` .content-header-title { font-size: 24px; } - .entry-row { margin-bottom: 15px; } @@ -26,17 +25,25 @@ export default ` border-radius: 0.25rem; min-height: 44px; } +[dir=rtl] .navbar .dropdown-menu a { + text-align: right; +} .navbar .dropdown-submenu a::after { transform: rotate(-90deg); position: absolute; right: 16px; top: 18px; } +[dir=rtl] .navbar .dropdown-submenu a::after { + transform: rotate(90deg); + left: 16px; + right: auto; + top: 20px; +} .navbar .dropdown-submenu .dropdown-menu { top: 0; left: 100%; } - .card-header .btn { padding: 2px 6px; } From 03c077ee2f403ba03b768ed7fcca6736665e1e0b Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:30:40 +0300 Subject: [PATCH 21/53] feat: add a lazy style handler and provider factory --- .../theme-shared/src/lib/handlers/index.ts | 1 + .../src/lib/handlers/lazy-style.handler.ts | 96 +++++++++++++++++++ .../src/lib/tests/lazy-style.handler.spec.ts | 66 +++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts create mode 100644 npm/ng-packs/packages/theme-shared/src/lib/tests/lazy-style.handler.spec.ts diff --git a/npm/ng-packs/packages/theme-shared/src/lib/handlers/index.ts b/npm/ng-packs/packages/theme-shared/src/lib/handlers/index.ts index 7b46abdd69..11eb07398e 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/handlers/index.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/handlers/index.ts @@ -1 +1,2 @@ export * from './error.handler'; +export * from './lazy-style.handler'; diff --git a/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts b/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts new file mode 100644 index 0000000000..11fe0f0da8 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts @@ -0,0 +1,96 @@ +import { + getLocaleDirection, + LazyLoadService, + LOADING_STRATEGY, + LocalizationService, +} from '@abp/ng.core'; +import { Injectable, Injector } from '@angular/core'; +import { map, startWith } from 'rxjs/operators'; +import { BOOTSTRAP } from '../constants/styles'; +import { LocaleDirection } from '../models/common'; +import { LAZY_STYLES } from '../tokens/lazy-styles.token'; + +@Injectable({ + providedIn: 'root', +}) +export class LazyStyleHandler { + private lazyLoad: LazyLoadService; + private styles: string[]; + private _dir: LocaleDirection = 'ltr'; + + set dir(dir: LocaleDirection) { + if (dir === this._dir) return; + + this.switchCSS(dir); + this.setHtmlDir(dir); + this._dir = dir; + } + + get dir(): LocaleDirection { + return this._dir; + } + + constructor(injector: Injector) { + this.setStyles(injector); + this.setLazyLoad(injector); + this.listenToLanguageChanges(injector); + } + + private getLoadedBootstrap(): LoadedStyle { + const href = createLazyStyleHref(BOOTSTRAP, this.dir); + const selector = `[href$="${href}"]`; + const link = document.querySelector(selector); + return { href, link }; + } + + private listenToLanguageChanges(injector: Injector) { + const l10n = injector.get(LocalizationService); + + // will always listen, no need to unsubscribe + l10n.languageChange + .pipe( + map(({ payload }) => payload), + startWith(l10n.currentLang), + ) + .subscribe(locale => { + this.dir = getLocaleDirection(locale); + }); + } + + private setHtmlDir(dir: LocaleDirection) { + document.querySelector('html').dir = dir; + } + + private setLazyLoad(injector: Injector) { + this.lazyLoad = injector.get(LazyLoadService); + const { href, link } = this.getLoadedBootstrap(); + this.lazyLoad.loaded.set(href, link); + } + + private setStyles(injector: Injector) { + this.styles = injector.get(LAZY_STYLES, [BOOTSTRAP]); + } + + private switchCSS(dir: LocaleDirection) { + this.styles.forEach(style => { + const oldHref = createLazyStyleHref(style, this.dir); + const newHref = createLazyStyleHref(style, dir); + + const strategy = LOADING_STRATEGY.PrependAnonymousStyleToHead(newHref); + this.lazyLoad.load(strategy).subscribe(() => this.lazyLoad.remove(oldHref)); + }); + } +} + +export function createLazyStyleHref(style: string, dir: string): string { + return style.replace(/{{\s*dir\s*}}/g, dir); +} + +export function initLazyStyleHandler(injector: Injector) { + return () => new LazyStyleHandler(injector); +} + +interface LoadedStyle { + href: string; + link: HTMLLinkElement; +} diff --git a/npm/ng-packs/packages/theme-shared/src/lib/tests/lazy-style.handler.spec.ts b/npm/ng-packs/packages/theme-shared/src/lib/tests/lazy-style.handler.spec.ts new file mode 100644 index 0000000000..5836bee474 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/src/lib/tests/lazy-style.handler.spec.ts @@ -0,0 +1,66 @@ +import { LazyLoadService, LOADING_STRATEGY, LocalizationService } from '@abp/ng.core'; +import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest'; +import { EMPTY, of } from 'rxjs'; +import { BOOTSTRAP } from '../constants/styles'; +import { createLazyStyleHref, initLazyStyleHandler, LazyStyleHandler } from '../handlers'; + +const languageChange = of({ payload: 'en' }); + +describe('LazyStyleHandler', () => { + let spectator: SpectatorService; + let handler: LazyStyleHandler; + let lazyLoad: LazyLoadService; + + const createService = createServiceFactory({ + service: LazyStyleHandler, + providers: [ + { + provide: LocalizationService, + useValue: { currentLang: 'en', languageChange }, + }, + ], + }); + + beforeEach(() => { + spectator = createService(); + handler = spectator.service; + lazyLoad = handler['lazyLoad']; + }); + + describe('#dir', () => { + it('should initially be "ltr"', () => { + expect(handler.dir).toBe('ltr'); + }); + + it('should set bootstrap to rtl', () => { + const oldHref = createLazyStyleHref(BOOTSTRAP, 'ltr'); + const newHref = createLazyStyleHref(BOOTSTRAP, 'rtl'); + lazyLoad.loaded.set(newHref, null); // avoid actual loading + const load = jest.spyOn(lazyLoad, 'load'); + const remove = jest.spyOn(lazyLoad, 'remove'); + const strategy = LOADING_STRATEGY.PrependAnonymousStyleToHead(newHref); + + handler.dir = 'rtl'; + + expect(load).toHaveBeenCalledWith(strategy); + expect(remove).toHaveBeenCalledWith(oldHref); + }); + }); +}); + +describe('initLazyStyleHandler', () => { + it('should return a LazyStyleHandler factory', () => { + const generator = (function*() { + yield undefined; // LAZY_STYLES + yield { loaded: new Map() }; // LazyLoadService + yield { currentLang: 'en', languageChange: EMPTY }; // LocalizationService + })(); + + const injector = { + get: () => generator.next().value as any, + }; + const factory = initLazyStyleHandler(injector); + + expect(factory()).toBeInstanceOf(LazyStyleHandler); + }); +}); From a7f9ea3f41a2167fa936e8118fe2260ebb66a2ff Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:31:11 +0300 Subject: [PATCH 22/53] feat: use initLazyStyleHandler in forRoot of ThemeShared --- .../packages/theme-shared/src/lib/theme-shared.module.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts b/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts index 5d53ed2124..72ec96f569 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts @@ -22,6 +22,7 @@ import styles from './constants/styles'; import { LoadingDirective } from './directives/loading.directive'; import { TableSortDirective } from './directives/table-sort.directive'; import { ErrorHandler } from './handlers/error.handler'; +import { initLazyStyleHandler } from './handlers/lazy-style.handler'; import { RootParams } from './models/common'; import { THEME_SHARED_APPEND_CONTENT } from './tokens/append-content.token'; import { httpErrorConfigFactory, HTTP_ERROR_CONFIG } from './tokens/http-error.token'; @@ -104,6 +105,12 @@ export class ThemeSharedModule { deps: [THEME_SHARED_APPEND_CONTENT], useFactory: noop, }, + { + provide: APP_INITIALIZER, + multi: true, + deps: [Injector], + useFactory: initLazyStyleHandler, + }, { provide: HTTP_ERROR_CONFIG, useValue: options.httpErrorConfig }, { provide: 'HTTP_ERROR_CONFIG', From 63aa6a6328678e24e237bda30d7a3860e1de0df6 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:31:44 +0300 Subject: [PATCH 23/53] feat: avoid making lazy style handler public --- npm/ng-packs/packages/theme-shared/src/public-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/theme-shared/src/public-api.ts b/npm/ng-packs/packages/theme-shared/src/public-api.ts index e201dc92ec..df27b079f4 100644 --- a/npm/ng-packs/packages/theme-shared/src/public-api.ts +++ b/npm/ng-packs/packages/theme-shared/src/public-api.ts @@ -7,7 +7,7 @@ export * from './lib/animations'; export * from './lib/components'; export { BOOTSTRAP } from './lib/constants/styles'; export * from './lib/directives'; -export * from './lib/handlers'; +export { ErrorHandler } from './lib/handlers'; export * from './lib/models'; export * from './lib/services'; export * from './lib/tokens'; From 4e14df048ab3ed199d7adfcaa9433672798a0fc5 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:43:20 +0300 Subject: [PATCH 24/53] feat: avoid null values when removing loaded elements --- .../packages/core/src/lib/services/lazy-load.service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts b/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts index d58788d878..4ba89949fd 100644 --- a/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts +++ b/npm/ng-packs/packages/core/src/lib/services/lazy-load.service.ts @@ -115,9 +115,10 @@ export class LazyLoadService { } remove(path: string): boolean { - if (!this.loaded.has(path)) return false; - const element = this.loaded.get(path); + + if (!element) return false; + element.parentNode.removeChild(element); this.loaded.delete(path); return true; From a2523973c2b23b0b93169cd0cdbf0fa9a91d80cf Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 28 May 2020 23:48:13 +0300 Subject: [PATCH 25/53] fix: use important to override text-left class --- npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts b/npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts index 0fa787953e..2de9931873 100644 --- a/npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts +++ b/npm/ng-packs/packages/theme-basic/src/lib/constants/styles.ts @@ -26,7 +26,7 @@ export default ` min-height: 44px; } [dir=rtl] .navbar .dropdown-menu a { - text-align: right; + text-align: right!important; } .navbar .dropdown-submenu a::after { transform: rotate(-90deg); From 79ee6297b627c6ffb92ad79327580bd9f63413dc Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 29 May 2020 00:08:58 +0300 Subject: [PATCH 26/53] docs: add how to migrate a project for RTL support --- docs/en/UI/Angular/Localization.md | 62 ++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/docs/en/UI/Angular/Localization.md b/docs/en/UI/Angular/Localization.md index d627f466ba..c8b73b08f3 100644 --- a/docs/en/UI/Angular/Localization.md +++ b/docs/en/UI/Angular/Localization.md @@ -130,6 +130,68 @@ this.store.selectSnapshot( Localization resources are stored in the `localization` property of `ConfigState`. +## RTL Support + +As of v2.9 ABP has RTL support. If you are generating a new project with v2.9 and above, everything is set, you do not need to do any changes. If you are migrating your project from an earlier version, please follow the 2 steps below: + +#### Step 1. Create Chunks for Bootstrap LTR and RTL + +Find [styles configuration in angular.json](https://angular.io/guide/workspace-config#style-script-config) and make sure the chunks in your project has `bootstrap-rtl.min` and `bootstrap-ltr.min` as shown below. + +```json +{ + "projects": { + "MyProjectName": { + "architect": { + "build": { + "options": { + "styles": [ + { + "input": "node_modules/@abp/ng.theme.shared/styles/bootstrap-rtl.min.css", + "inject": false, + "bundleName": "bootstrap-rtl.min" + }, + { + "input": "node_modules/bootstrap/dist/css/bootstrap.min.css", + "inject": true, + "bundleName": "bootstrap-ltr.min" + }, + { + "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", + "inject": true, + "bundleName": "fontawesome-all.min" + }, + { + "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", + "inject": true, + "bundleName": "fontawesome-v4-shims.min" + }, + "apps/dev-app/src/styles.scss" + ], + } + } + } + } + } +} + +#### Step 2. Clear Lazy Loaded Fontawesome in AppComponent + +If you have created and injected chunks for Fontawesome as seen above, you no longer need the lazy loading in the `AppComponent` which was implemented before v2.9. Simply remove them. The `AppComponent` in the template of the new version looks like this: + +```js +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + template: ` + + + `, +}) +export class AppComponent {} +``` + ## See Also From 286412b7d2a0b263452eb903da011fd44cdebac5 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 29 May 2020 00:24:15 +0300 Subject: [PATCH 27/53] refactor: remove unnecessary RTL style --- .../packages/theme-shared/src/lib/constants/styles.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts b/npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts index f2b405b744..a691f96ead 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/constants/styles.ts @@ -17,11 +17,6 @@ export default ` text-align: left; } -[dir=rtl] .dropdown-menu-right { - left: 0; - right: auto; -} - .pointer { cursor: pointer; } From 1b727aa10318e76415ab189c7f1084ada838620d Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 29 May 2020 09:59:44 +0300 Subject: [PATCH 28/53] fix: refer to correct styles.scss in angular.json --- templates/app/angular/angular.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/app/angular/angular.json b/templates/app/angular/angular.json index 4f176a44b8..dfcaa5b9d3 100644 --- a/templates/app/angular/angular.json +++ b/templates/app/angular/angular.json @@ -46,7 +46,7 @@ "inject": true, "bundleName": "fontawesome-v4-shims.min" }, - "apps/dev-app/src/styles.scss" + "src/styles.scss" ], "scripts": [] }, From 59beff177c630a461c5d9a9c4cfbd303a8b73d78 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 29 May 2020 11:49:34 +0300 Subject: [PATCH 29/53] feat: add direction to document body instead of html --- .../theme-shared/src/lib/handlers/lazy-style.handler.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts b/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts index 11fe0f0da8..f1688502c5 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts @@ -22,7 +22,7 @@ export class LazyStyleHandler { if (dir === this._dir) return; this.switchCSS(dir); - this.setHtmlDir(dir); + this.setBodyDir(dir); this._dir = dir; } @@ -53,12 +53,13 @@ export class LazyStyleHandler { startWith(l10n.currentLang), ) .subscribe(locale => { + if (locale === 'tr') locale = 'ar'; this.dir = getLocaleDirection(locale); }); } - private setHtmlDir(dir: LocaleDirection) { - document.querySelector('html').dir = dir; + private setBodyDir(dir: LocaleDirection) { + document.body.dir = dir; } private setLazyLoad(injector: Injector) { From 990c54a3fe90e46563bda39da3f064266736671d Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 29 May 2020 11:50:11 +0300 Subject: [PATCH 30/53] feat: calculate table column position when RTL --- .../lib/components/table/table.component.html | 4 ++-- .../lib/components/table/table.component.ts | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.html b/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.html index eeaf0d40d9..6cbea56304 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.html +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.html @@ -21,7 +21,7 @@
-
+
@@ -31,7 +31,7 @@
diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts b/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts index da17aab136..15b7b4eda0 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts @@ -1,9 +1,9 @@ import { - AfterViewInit, Component, ElementRef, EventEmitter, Input, + OnInit, Output, TemplateRef, TrackByFunction, @@ -17,7 +17,7 @@ import { styleUrls: ['table.component.scss'], encapsulation: ViewEncapsulation.None, }) -export class TableComponent { +export class TableComponent implements OnInit { private _totalRecords: number; bodyScrollLeft = 0; @@ -87,4 +87,20 @@ export class TableComponent { trackByFn: TrackByFunction = (_, value) => { return typeof value === 'object' ? value[this.trackingProp] || value : value; }; + + marginCalculator: MarginCalculator; + + ngOnInit() { + this.marginCalculator = document.body.dir === 'rtl' ? rtlCalculator : ltrCalculator; + } +} + +function ltrCalculator(div: HTMLDivElement): string { + return `0 auto 0 -${div.scrollLeft}px`; +} + +function rtlCalculator(div: HTMLDivElement): string { + return `0 ${-(div.scrollWidth - div.clientWidth - div.scrollLeft)}px 0 auto`; } + +type MarginCalculator = (div: HTMLDivElement) => string; From d0236057beaebd002e93974b366fcf1ca668c127 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 29 May 2020 12:02:50 +0300 Subject: [PATCH 31/53] fix: avoid field not allowed after method lint error --- .../theme-shared/src/lib/components/table/table.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts b/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts index 15b7b4eda0..a30b4464fc 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/components/table/table.component.ts @@ -84,12 +84,12 @@ export class TableComponent implements OnInit { return this.value.slice(start, start + this.rows); } + marginCalculator: MarginCalculator; + trackByFn: TrackByFunction = (_, value) => { return typeof value === 'object' ? value[this.trackingProp] || value : value; }; - marginCalculator: MarginCalculator; - ngOnInit() { this.marginCalculator = document.body.dir === 'rtl' ? rtlCalculator : ltrCalculator; } From 6b743ce3a121878cd05c7ce9fb89421a80800f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 12:20:22 +0300 Subject: [PATCH 32/53] Arrange column length for oracle. --- ...yServerDbContextModelCreatingExtensions.cs | 69 +++++++++++-------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs index 5eff3195c9..89d69f3d24 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs @@ -65,7 +65,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.GrantType }); + b.HasKey(x => new {x.ClientId, x.GrantType}); b.Property(x => x.GrantType).HasMaxLength(ClientGrantTypeConsts.GrantTypeMaxLength).IsRequired(); }); @@ -76,15 +76,16 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.RedirectUri }); + b.HasKey(x => new {x.ClientId, x.RedirectUri}); - if (IsMySql(builder, options)) + if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql)) { b.Property(x => x.RedirectUri).HasMaxLength(300).IsRequired(); } else { - b.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLength).IsRequired(); + b.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLength) + .IsRequired(); } }); @@ -94,15 +95,16 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.PostLogoutRedirectUri }); + b.HasKey(x => new {x.ClientId, x.PostLogoutRedirectUri}); - if (IsMySql(builder, options)) + if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql)) { b.Property(x => x.PostLogoutRedirectUri).HasMaxLength(300).IsRequired(); } else { - b.Property(x => x.PostLogoutRedirectUri).HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLength).IsRequired(); + b.Property(x => x.PostLogoutRedirectUri) + .HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLength).IsRequired(); } }); @@ -112,7 +114,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.Scope }); + b.HasKey(x => new {x.ClientId, x.Scope}); b.Property(x => x.Scope).HasMaxLength(ClientScopeConsts.ScopeMaxLength).IsRequired(); }); @@ -123,11 +125,11 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.Type, x.Value }); + b.HasKey(x => new {x.ClientId, x.Type, x.Value}); b.Property(x => x.Type).HasMaxLength(SecretConsts.TypeMaxLength).IsRequired(); - if (IsMySql(builder, options)) + if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle)) { b.Property(x => x.Value).HasMaxLength(300).IsRequired(); } @@ -145,7 +147,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.Type, x.Value }); + b.HasKey(x => new {x.ClientId, x.Type, x.Value}); b.Property(x => x.Type).HasMaxLength(ClientClaimConsts.TypeMaxLength).IsRequired(); b.Property(x => x.Value).HasMaxLength(ClientClaimConsts.ValueMaxLength).IsRequired(); @@ -157,7 +159,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.Provider }); + b.HasKey(x => new {x.ClientId, x.Provider}); b.Property(x => x.Provider).HasMaxLength(ClientIdPRestrictionConsts.ProviderMaxLength).IsRequired(); }); @@ -168,7 +170,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.Origin }); + b.HasKey(x => new {x.ClientId, x.Origin}); b.Property(x => x.Origin).HasMaxLength(ClientCorsOriginConsts.OriginMaxLength).IsRequired(); }); @@ -179,7 +181,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ClientId, x.Key }); + b.HasKey(x => new {x.ClientId, x.Key}); b.Property(x => x.Key).HasMaxLength(ClientPropertyConsts.KeyMaxLength).IsRequired(); b.Property(x => x.Value).HasMaxLength(ClientPropertyConsts.ValueMaxLength).IsRequired(); @@ -197,7 +199,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.Property(x => x.ClientId).HasMaxLength(PersistedGrantConsts.ClientIdMaxLength).IsRequired(); b.Property(x => x.CreationTime).IsRequired(); - if (IsMySql(builder, options)) + if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql)) { b.Property(x => x.Data).HasMaxLength(10000).IsRequired(); } @@ -208,7 +210,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.HasKey(x => x.Key); //TODO: What about Id!!! - b.HasIndex(x => new { x.SubjectId, x.ClientId, x.Type }); + b.HasIndex(x => new {x.SubjectId, x.ClientId, x.Type}); b.HasIndex(x => x.Expiration); }); @@ -234,7 +236,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.IdentityResourceId, x.Type }); + b.HasKey(x => new {x.IdentityResourceId, x.Type}); b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); }); @@ -263,12 +265,12 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ApiResourceId, x.Type, x.Value }); + b.HasKey(x => new {x.ApiResourceId, x.Type, x.Value}); b.Property(x => x.Type).HasMaxLength(SecretConsts.TypeMaxLength).IsRequired(); b.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength); - if (IsMySql(builder, options)) + if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle)) { b.Property(x => x.Value).HasMaxLength(300).IsRequired(); } @@ -284,7 +286,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ApiResourceId, x.Type }); + b.HasKey(x => new {x.ApiResourceId, x.Type}); b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); }); @@ -295,13 +297,13 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ApiResourceId, x.Name }); + b.HasKey(x => new {x.ApiResourceId, x.Name}); b.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired(); b.Property(x => x.DisplayName).HasMaxLength(ApiScopeConsts.DisplayNameMaxLength); b.Property(x => x.Description).HasMaxLength(ApiScopeConsts.DescriptionMaxLength); - b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => new { x.ApiResourceId, x.Name }).IsRequired(); + b.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => new {x.ApiResourceId, x.Name}).IsRequired(); }); builder.Entity(b => @@ -310,7 +312,7 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.ApiResourceId, x.Name, x.Type }); + b.HasKey(x => new {x.ApiResourceId, x.Name, x.Type}); b.Property(x => x.Type).HasMaxLength(UserClaimConsts.TypeMaxLength).IsRequired(); b.Property(x => x.Name).HasMaxLength(ApiScopeConsts.NameMaxLength).IsRequired(); @@ -329,18 +331,27 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore b.Property(x => x.Expiration).IsRequired(); b.Property(x => x.Data).HasMaxLength(50000).IsRequired(); - b.HasIndex(x => new { x.UserCode }).IsUnique(); + b.HasIndex(x => new {x.UserCode}).IsUnique(); b.HasIndex(x => x.DeviceCode).IsUnique(); b.HasIndex(x => x.Expiration); }); } - private static bool IsMySql( + private static bool IsDatabaseProvider( ModelBuilder modelBuilder, - IdentityServerModelBuilderConfigurationOptions options) + IdentityServerModelBuilderConfigurationOptions options, + params EfCoreDatabaseProvider[] providers) { - return options.DatabaseProvider == EfCoreDatabaseProvider.MySql || - modelBuilder.IsUsingMySQL(); + foreach (var provider in providers) + { + if (options.DatabaseProvider == EfCoreDatabaseProvider.MySql || + modelBuilder.GetDatabaseProvider() == provider) + { + return true; + } + } + + return false; } } -} +} \ No newline at end of file From 5f6c5e8345393be0de14005edb1fc55e30a09749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 12:20:30 +0300 Subject: [PATCH 33/53] Arrange column length for oracle. --- .../AbpAuditLoggingDbContextModelBuilderExtensions.cs | 11 ++++++++++- ...ettingManagementDbContextModelBuilderExtensions.cs | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingDbContextModelBuilderExtensions.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingDbContextModelBuilderExtensions.cs index 619eed057c..59480bb1bb 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingDbContextModelBuilderExtensions.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingDbContextModelBuilderExtensions.cs @@ -36,7 +36,16 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore b.Property(x => x.HttpMethod).HasMaxLength(AuditLogConsts.MaxHttpMethodLength).HasColumnName(nameof(AuditLog.HttpMethod)); b.Property(x => x.Url).HasMaxLength(AuditLogConsts.MaxUrlLength).HasColumnName(nameof(AuditLog.Url)); b.Property(x => x.HttpStatusCode).HasColumnName(nameof(AuditLog.HttpStatusCode)); - b.Property(x => x.Exceptions).HasMaxLength(AuditLogConsts.MaxExceptionsLength).HasColumnName(nameof(AuditLog.Exceptions)); + + if (builder.IsUsingOracle()) + { + b.Property(x => x.Exceptions).HasMaxLength(2000).HasColumnName(nameof(AuditLog.Exceptions)); + } + else + { + b.Property(x => x.Exceptions).HasMaxLength(AuditLogConsts.MaxExceptionsLength).HasColumnName(nameof(AuditLog.Exceptions)); + } + b.Property(x => x.Comments).HasMaxLength(AuditLogConsts.MaxCommentsLength).HasColumnName(nameof(AuditLog.Comments)); b.Property(x => x.ExecutionDuration).HasColumnName(nameof(AuditLog.ExecutionDuration)); b.Property(x => x.ImpersonatorTenantId).HasColumnName(nameof(AuditLog.ImpersonatorTenantId)); diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs index 715d7abfd0..be6467c601 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs @@ -41,7 +41,16 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore b.ConfigureByConvention(); b.Property(x => x.Name).HasMaxLength(SettingConsts.MaxNameLength).IsRequired(); - b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLength).IsRequired(); + + if (builder.IsUsingOracle()) + { + b.Property(x => x.Value).HasMaxLength(2000).IsRequired(); + } + else + { + b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLength).IsRequired(); + } + b.Property(x => x.ProviderName).HasMaxLength(SettingConsts.MaxProviderNameLength); b.Property(x => x.ProviderKey).HasMaxLength(SettingConsts.MaxProviderKeyLength); From 99543577efd90b94301403e3df701f594b4fc64b Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Fri, 29 May 2020 12:27:20 +0300 Subject: [PATCH 34/53] fix: remove mock RTL --- .../packages/theme-shared/src/lib/handlers/lazy-style.handler.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts b/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts index f1688502c5..bed1a5bbd5 100644 --- a/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts +++ b/npm/ng-packs/packages/theme-shared/src/lib/handlers/lazy-style.handler.ts @@ -53,7 +53,6 @@ export class LazyStyleHandler { startWith(l10n.currentLang), ) .subscribe(locale => { - if (locale === 'tr') locale = 'ar'; this.dir = getLocaleDirection(locale); }); } From 2d55bda0135b44950230dc1a03ea5b594847ca7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 12:36:15 +0300 Subject: [PATCH 35/53] Created Entity-Framework-Core-Oracle document. --- docs/en/Entity-Framework-Core-Oracle.md | 44 +++++++++++++++++++++ docs/en/Entity-Framework-Core-Other-DBMS.md | 1 + docs/en/docs-nav.json | 4 ++ 3 files changed, 49 insertions(+) create mode 100644 docs/en/Entity-Framework-Core-Oracle.md diff --git a/docs/en/Entity-Framework-Core-Oracle.md b/docs/en/Entity-Framework-Core-Oracle.md new file mode 100644 index 0000000000..ed15ae79ea --- /dev/null +++ b/docs/en/Entity-Framework-Core-Oracle.md @@ -0,0 +1,44 @@ +# Switch to EF Core Oracle Provider + +This document explains how to switch to the **Oracle** database provider for **[the application startup template](Startup-Templates/Application.md)** which comes with SQL Server provider pre-configured. + +> This document uses a paid library of [Devart](https://www.devart.com/dotconnect/oracle/) company, because it is the only library for Oracle that supports EF Core 3.x. + +## Replace the Volo.Abp.EntityFrameworkCore.SqlServer Package + +`.EntityFrameworkCore` project in the solution depends on the [Volo.Abp.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.SqlServer) NuGet package. Remove this package and add the same version of the [Volo.Abp.EntityFrameworkCore.Oracle.Devart](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.Oracle.Devart) package. + +## Replace the Module Dependency + +Find ***YourProjectName*EntityFrameworkCoreModule** class inside the `.EntityFrameworkCore` project, remove `typeof(AbpEntityFrameworkCoreSqlServerModule)` from the `DependsOn` attribute, add `typeof(AbpEntityFrameworkCoreOracleDevartModule)` (also replace `using Volo.Abp.EntityFrameworkCore.SqlServer;` with `using Volo.Abp.EntityFrameworkCore.Oracle.Devart;`). + +## UseOracle() + +Find `UseSqlServer()` calls in your solution, replace with `UseOracle()`. Check the following files: + +* *YourProjectName*EntityFrameworkCoreModule.cs inside the `.EntityFrameworkCore` project. +* *YourProjectName*MigrationsDbContextFactory.cs inside the `.EntityFrameworkCore.DbMigrations` project. + +> Depending on your solution structure, you may find more code files need to be changed. + +## Change the Connection Strings + +Oracle connection strings are different than SQL Server connection strings. So, check all `appsettings.json` files in your solution and replace the connection strings inside them. See the [connectionstrings.com]( https://www.connectionstrings.com/mysql/ ) for details of Oracle connection string options. + +You typically will change the `appsettings.json` inside the `.DbMigrator` and `.Web` projects, but it depends on your solution structure. + +## Re-Generate the Migrations + +The startup template uses [Entity Framework Core's Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/). EF Core Migrations depend on the selected DBMS provider. So, changing the DBMS provider will cause the migration fails. + +* Delete the Migrations folder under the `.EntityFrameworkCore.DbMigrations` project and re-build the solution. +* Run `Add-Migration "Initial"` on the Package Manager Console (select the `.DbMigrator` (or `.Web`) project as the startup project in the Solution Explorer and select the `.EntityFrameworkCore.DbMigrations` project as the default project in the Package Manager Console). + +This will create a database migration with all database objects (tables) configured. + +Run the `.DbMigrator` project to create the database and seed the initial data. + +## Run the Application + +It is ready. Just run the application and enjoy coding. + diff --git a/docs/en/Entity-Framework-Core-Other-DBMS.md b/docs/en/Entity-Framework-Core-Other-DBMS.md index d902a8d93e..d9190df844 100644 --- a/docs/en/Entity-Framework-Core-Other-DBMS.md +++ b/docs/en/Entity-Framework-Core-Other-DBMS.md @@ -6,6 +6,7 @@ ABP framework provides **integration packages** for some common DBMSs to make th * [MySQL](Entity-Framework-Core-MySQL.md) * [PostgreSQL](Entity-Framework-Core-PostgreSQL.md) +* [Oracle](Entity-Framework-Core-Oracle.md) * [SQLite](Entity-Framework-Core-SQLite.md) However, you can configure your DBMS provider **without** these integration packages. While using the integration package is always recommended (it also makes standard for the depended version across different modules), you can do it manually if there is no integration package for your DBMS provider. diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 58e477cec9..9db7916f11 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -440,6 +440,10 @@ "text": "To PostgreSQL", "path": "Entity-Framework-Core-PostgreSQL.md" }, + { + "text": "To Oracle", + "path": "Entity-Framework-Core-Oracle.md" + }, { "text": "To SQLite", "path": "Entity-Framework-Core-SQLite.md" From 632454c776f1901a0d3cfa0d10b14b97f5caa944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 12:40:49 +0300 Subject: [PATCH 36/53] Remove "Change the Migrations DbContext" section which is not needed anymore. --- docs/en/Entity-Framework-Core-MySQL.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/docs/en/Entity-Framework-Core-MySQL.md b/docs/en/Entity-Framework-Core-MySQL.md index d1fa66e1a4..a04d6073fc 100644 --- a/docs/en/Entity-Framework-Core-MySQL.md +++ b/docs/en/Entity-Framework-Core-MySQL.md @@ -25,23 +25,6 @@ MySQL connection strings are different than SQL Server connection strings. So, c You typically will change the `appsettings.json` inside the `.DbMigrator` and `.Web` projects, but it depends on your solution structure. -## Change the Migrations DbContext - -MySQL DBMS has some slight differences than the SQL Server. Some module database mapping configuration (especially the field lengths) causes problems with MySQL. For example, some of the the [IdentityServer module](Modules/IdentityServer.md) tables has such problems and it provides an option to configure the fields based on your DBMS. - -The startup template contains a *YourProjectName*MigrationsDbContext which is responsible to maintain and migrate the database schema. This DbContext basically calls extension methods of the depended modules to configure their database tables. - -Open the *YourProjectName*MigrationsDbContext and change the `builder.ConfigureIdentityServer();` line as shown below: - -````csharp -builder.ConfigureIdentityServer(options => -{ - options.DatabaseProvider = EfCoreDatabaseProvider.MySql; -}); -```` - -Then `ConfigureIdentityServer()` method will set the field lengths to not exceed the MySQL limits. Refer to related module documentation if you have any problem while creating or executing the database migrations. - ## Re-Generate the Migrations The startup template uses [Entity Framework Core's Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/). EF Core Migrations depend on the selected DBMS provider. So, changing the DBMS provider will cause the migration fails. From 25992a88fa8650d363404d34fc0c96713b7bb1b8 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Fri, 29 May 2020 14:40:55 +0300 Subject: [PATCH 37/53] Revert "BlobStoringDatabase module added to build list" This reverts commit c903e8909adf4fb84ac1ce2236aae575ae8fb651. --- build/common.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/build/common.ps1 b/build/common.ps1 index 680d2e9fdb..70a432818b 100644 --- a/build/common.ps1 +++ b/build/common.ps1 @@ -20,7 +20,6 @@ $solutionPaths = ( "../modules/background-jobs", "../modules/client-simulation", "../modules/virtual-file-explorer", - "../modules/blob-storing-database", "../templates/module/aspnet-core", "../templates/app/aspnet-core", "../samples/MicroserviceDemo", From 42a5a786aebc3863655b035fdc01bd4a09548e87 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Fri, 29 May 2020 14:58:44 +0300 Subject: [PATCH 38/53] name fix --- .../Volo/Abp/BlobStoring/Database/Blob.cs | 8 +++--- ...aseBlobContainerConfigurationExtensions.cs | 4 +-- .../BlobStoringDatabaseDataSeedContributor.cs | 27 ------------------- .../BlobStoringDatabaseTestBaseModule.cs | 21 --------------- 4 files changed, 6 insertions(+), 54 deletions(-) delete mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseDataSeedContributor.cs diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs index 56040fe6ce..f156597d22 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs @@ -18,7 +18,7 @@ namespace Volo.Abp.BlobStoring.Database public Blob(Guid id, Guid containerId, [NotNull]string name, byte[] content, Guid? tenantId) : base(id) { Check.NotNullOrWhiteSpace(name, nameof(name), BlobConsts.MaxNameLength); - CheckContent(content); + CheckContentLength(content); Content = content; ContainerId = containerId; @@ -28,16 +28,16 @@ namespace Volo.Abp.BlobStoring.Database public virtual void SetContent(byte[] content) { - CheckContent(content); + CheckContentLength(content); Content = content; } - protected void CheckContent(byte[] content) + protected virtual void CheckContentLength(byte[] content) { if (content.Length >= BlobConsts.MaxContentLength) { - throw new AbpException("Blob content size cannot be more than 2GB."); + throw new AbpException($"Blob content size cannot be more than {BlobConsts.MaxContentLength} Bytes."); } } } diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobContainerConfigurationExtensions.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobContainerConfigurationExtensions.cs index 2746e39352..c302e00634 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobContainerConfigurationExtensions.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/DatabaseBlobContainerConfigurationExtensions.cs @@ -12,11 +12,11 @@ namespace Volo.Abp.BlobStoring.Database public static BlobContainerConfiguration UseDatabase( this BlobContainerConfiguration containerConfiguration, - Action fileSystemConfigureAction) + Action databaseConfigureAction) { containerConfiguration.ProviderType = typeof(DatabaseBlobProvider); - fileSystemConfigureAction(new DatabaseBlobProviderConfiguration(containerConfiguration)); + databaseConfigureAction(new DatabaseBlobProviderConfiguration(containerConfiguration)); return containerConfiguration; } diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseDataSeedContributor.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseDataSeedContributor.cs deleted file mode 100644 index 8dc8ea382a..0000000000 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseDataSeedContributor.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.Data; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Guids; - -namespace Volo.Abp.BlobStoring.Database -{ - public class BlobStoringDatabaseDataSeedContributor : IDataSeedContributor, ITransientDependency - { - private readonly IGuidGenerator _guidGenerator; - - public BlobStoringDatabaseDataSeedContributor( - IGuidGenerator guidGenerator) - { - _guidGenerator = guidGenerator; - } - - public Task SeedAsync(DataSeedContext context) - { - /* Instead of returning the Task.CompletedTask, you can insert your test data - * at this point! - */ - - return Task.CompletedTask; - } - } -} \ No newline at end of file diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBaseModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBaseModule.cs index 11b23fb0a6..96e3bcaa90 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBaseModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBaseModule.cs @@ -1,10 +1,7 @@ using Microsoft.Extensions.DependencyInjection; -using Volo.Abp; using Volo.Abp.Authorization; using Volo.Abp.Autofac; -using Volo.Abp.Data; using Volo.Abp.Modularity; -using Volo.Abp.Threading; namespace Volo.Abp.BlobStoring.Database { @@ -29,23 +26,5 @@ namespace Volo.Abp.BlobStoring.Database }); }); } - - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - SeedTestData(context); - } - - private static void SeedTestData(ApplicationInitializationContext context) - { - AsyncHelper.RunSync(async () => - { - using (var scope = context.ServiceProvider.CreateScope()) - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - } - }); - } } } From f0f7ea25dc721abbc94e0ad8bf95fb9bbcdcf667 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Fri, 29 May 2020 14:59:29 +0300 Subject: [PATCH 39/53] MongoDB Container Tests removed --- .../MongoDB/MongoDbContainer_Test.cs | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbContainer_Test.cs diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbContainer_Test.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbContainer_Test.cs deleted file mode 100644 index 20b275a035..0000000000 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.MongoDB.Tests/MongoDB/MongoDbContainer_Test.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Volo.Abp.BlobStoring.Database.MongoDB -{ - public class MongoDbContainer_Test : BlobStoringDatabaseTestBase - { - - } -} \ No newline at end of file From 2666c14a4379070de1e292a74c0fae05a2ab2d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 15:45:57 +0300 Subject: [PATCH 40/53] Add Volo.Abp.EntityFrameworkCore.Oracle.Devart package. --- nupkg/common.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index 3b5ae4b1df..cb0faceb51 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -71,6 +71,7 @@ $projects = ( "framework/src/Volo.Abp.Emailing", "framework/src/Volo.Abp.EntityFrameworkCore", "framework/src/Volo.Abp.EntityFrameworkCore.MySQL", + "framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart", "framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql", "framework/src/Volo.Abp.EntityFrameworkCore.Sqlite", "framework/src/Volo.Abp.EntityFrameworkCore.SqlServer", From 52d95b10cf8700f3d47a1db95f12172f2812227f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 15:54:49 +0300 Subject: [PATCH 41/53] Revize the localization resource path for the timing package. --- .../Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs | 9 ++++++--- .../{Resources/AbpTiming => }/AbpTimingResource.cs | 0 .../Localization/{Resources/AbpTiming => }/en.json | 0 .../Localization/{Resources/AbpTiming => }/tr.json | 0 .../Localization/{Resources/AbpTiming => }/zh-Hans.json | 0 .../Localization/{Resources/AbpTiming => }/zh-Hant.json | 0 6 files changed, 6 insertions(+), 3 deletions(-) rename framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/{Resources/AbpTiming => }/AbpTimingResource.cs (100%) rename framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/{Resources/AbpTiming => }/en.json (100%) rename framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/{Resources/AbpTiming => }/tr.json (100%) rename framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/{Resources/AbpTiming => }/zh-Hans.json (100%) rename framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/{Resources/AbpTiming => }/zh-Hant.json (100%) diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs index a306f3def9..3db42c2e55 100644 --- a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs +++ b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/AbpTimingModule.cs @@ -7,14 +7,17 @@ using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.Timing { - [DependsOn(typeof(AbpVirtualFileSystemModule), typeof(AbpSettingsModule))] + [DependsOn( + typeof(AbpVirtualFileSystemModule), + typeof(AbpSettingsModule) + )] public class AbpTimingModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { Configure(options => { - options.FileSets.AddEmbedded("Volo.Abp", "Volo/Abp"); + options.FileSets.AddEmbedded(); }); Configure(options => @@ -22,7 +25,7 @@ namespace Volo.Abp.Timing options .Resources .Add("en") - .AddVirtualJson("/Timing/Localization/Resources/AbpTiming"); + .AddVirtualJson("/Volo/Abp/Timing/Localization"); }); } } diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/AbpTimingResource.cs b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/AbpTimingResource.cs similarity index 100% rename from framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/AbpTimingResource.cs rename to framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/AbpTimingResource.cs diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/en.json b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/en.json similarity index 100% rename from framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/en.json rename to framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/en.json diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/tr.json b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/tr.json similarity index 100% rename from framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/tr.json rename to framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/tr.json diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hans.json b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/zh-Hans.json similarity index 100% rename from framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hans.json rename to framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/zh-Hans.json diff --git a/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hant.json b/framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/zh-Hant.json similarity index 100% rename from framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/Resources/AbpTiming/zh-Hant.json rename to framework/src/Volo.Abp.Timing/Volo/Abp/Timing/Localization/zh-Hant.json From bfcf9a918073416b0d800e5f20be326aa1bc38d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 16:01:45 +0300 Subject: [PATCH 42/53] BlobStoringDatabaseTestBase should not derive from BlobContainer_Tests --- .../EntityFrameworkCore/EfCoreContainer_Test.cs | 2 +- .../BlobStoringDatabaseTestBase.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/EfCoreContainer_Test.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/EfCoreContainer_Test.cs index 5902923c83..3d46a033d8 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/EfCoreContainer_Test.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/EfCoreContainer_Test.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore { - public class EfCoreContainer_Test : BlobStoringDatabaseTestBase + public class EfCoreContainer_Test : BlobContainer_Tests { } diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBase.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBase.cs index bac1f18c9d..7b426f55dc 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBase.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.TestBase/BlobStoringDatabaseTestBase.cs @@ -8,7 +8,7 @@ using Volo.Abp.Testing; namespace Volo.Abp.BlobStoring.Database { - public abstract class BlobStoringDatabaseTestBase : BlobContainer_Tests + public abstract class BlobStoringDatabaseTestBase : AbpIntegratedTest where TStartupModule : IAbpModule { protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) From 73bf93dbdbdc47d0bad6887c71b3ca2e450f5de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 16:09:49 +0300 Subject: [PATCH 43/53] Revise blob and container classes. --- .../Volo/Abp/BlobStoring/Database/Blob.cs | 30 +++++++++---------- .../Abp/BlobStoring/Database/Container.cs | 13 ++++---- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs index f156597d22..6f3e8c7806 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Blob.cs @@ -7,38 +7,38 @@ namespace Volo.Abp.BlobStoring.Database { public class Blob : AggregateRoot, IMultiTenant { - public Guid ContainerId { get; set; } + public virtual Guid ContainerId { get; protected set; } - public Guid? TenantId { get; } + public virtual Guid? TenantId { get; protected set; } - public string Name { get; set; } + public virtual string Name { get; protected set; } - public byte[] Content { get; private set; } - - public Blob(Guid id, Guid containerId, [NotNull]string name, byte[] content, Guid? tenantId) : base(id) - { - Check.NotNullOrWhiteSpace(name, nameof(name), BlobConsts.MaxNameLength); - CheckContentLength(content); + public virtual byte[] Content { get; protected set; } - Content = content; + public Blob(Guid id, Guid containerId, [NotNull] string name, [NotNull] byte[] content, Guid? tenantId = null) + : base(id) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name), BlobConsts.MaxNameLength); ContainerId = containerId; - Name = name; + Content = CheckContentLength(content); TenantId = tenantId; } public virtual void SetContent(byte[] content) { - CheckContentLength(content); - - Content = content; + Content = CheckContentLength(content); } - protected virtual void CheckContentLength(byte[] content) + protected virtual byte[] CheckContentLength(byte[] content) { + Check.NotNull(content, nameof(content)); + if (content.Length >= BlobConsts.MaxContentLength) { throw new AbpException($"Blob content size cannot be more than {BlobConsts.MaxContentLength} Bytes."); } + + return content; } } } \ No newline at end of file diff --git a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs index 927e98ae25..ebe8bbf20b 100644 --- a/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs +++ b/modules/blob-storing-database/src/Volo.Abp.BlobStoring.Database.Domain/Volo/Abp/BlobStoring/Database/Container.cs @@ -5,18 +5,17 @@ using Volo.Abp.MultiTenancy; namespace Volo.Abp.BlobStoring.Database { - public class Container : AggregateRoot, IMultiTenant + public class Container : AggregateRoot, IMultiTenant //TODO: Rename to BlobContainer { - public Guid? TenantId { get; } + public virtual Guid? TenantId { get; protected set; } - public string Name { get; set; } + public virtual string Name { get; protected set; } - public Container(Guid id, [NotNull]string name, Guid? tenantId = null) : base(id) + public Container(Guid id, [NotNull] string name, Guid? tenantId = null) + : base(id) { - Check.NotNullOrWhiteSpace(name, nameof(name), ContainerConsts.MaxNameLength); - + Name = Check.NotNullOrWhiteSpace(name, nameof(name), ContainerConsts.MaxNameLength); TenantId = tenantId; - Name = name; } } } \ No newline at end of file From 658fc200edd7955c78fdc020068cf136a9af325e Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Fri, 29 May 2020 16:33:09 +0300 Subject: [PATCH 44/53] add sample connection string --- docs/en/Entity-Framework-Core-Oracle.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/en/Entity-Framework-Core-Oracle.md b/docs/en/Entity-Framework-Core-Oracle.md index ed15ae79ea..94b7b45f04 100644 --- a/docs/en/Entity-Framework-Core-Oracle.md +++ b/docs/en/Entity-Framework-Core-Oracle.md @@ -27,6 +27,11 @@ Oracle connection strings are different than SQL Server connection strings. So, You typically will change the `appsettings.json` inside the `.DbMigrator` and `.Web` projects, but it depends on your solution structure. +A sample connection string for Oracle: +``` +Data Source=localhost;User Id=myuser;Password=mypassword; +``` + ## Re-Generate the Migrations The startup template uses [Entity Framework Core's Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/). EF Core Migrations depend on the selected DBMS provider. So, changing the DBMS provider will cause the migration fails. From f05804ae5750b71b773f2dc03a396193945f8f55 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Fri, 29 May 2020 16:44:42 +0300 Subject: [PATCH 45/53] add casting when use UseOracle for builder.Options --- docs/en/Entity-Framework-Core-Oracle.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/en/Entity-Framework-Core-Oracle.md b/docs/en/Entity-Framework-Core-Oracle.md index 94b7b45f04..7a4e950943 100644 --- a/docs/en/Entity-Framework-Core-Oracle.md +++ b/docs/en/Entity-Framework-Core-Oracle.md @@ -19,6 +19,23 @@ Find `UseSqlServer()` calls in your solution, replace with `UseOracle()`. Check * *YourProjectName*EntityFrameworkCoreModule.cs inside the `.EntityFrameworkCore` project. * *YourProjectName*MigrationsDbContextFactory.cs inside the `.EntityFrameworkCore.DbMigrations` project. + +In the `CreateDbContext()` method of the *YourProjectName*MigrationsDbContextFactory.cs, replace the following code block + +``` +var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); +``` + +with this one +``` +var builder = (DbContextOptionsBuilder) + new DbContextOptionsBuilder().UseOracle + ( + configuration.GetConnectionString("Default") + ); +``` + > Depending on your solution structure, you may find more code files need to be changed. ## Change the Connection Strings From 79e52ba758deafa5103e2431d81c1888defb3ac6 Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Fri, 29 May 2020 21:04:58 +0300 Subject: [PATCH 46/53] Update Entity-Framework-Core-Oracle.md --- docs/en/Entity-Framework-Core-Oracle.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/en/Entity-Framework-Core-Oracle.md b/docs/en/Entity-Framework-Core-Oracle.md index 7a4e950943..c6b520bde7 100644 --- a/docs/en/Entity-Framework-Core-Oracle.md +++ b/docs/en/Entity-Framework-Core-Oracle.md @@ -51,14 +51,15 @@ Data Source=localhost;User Id=myuser;Password=mypassword; ## Re-Generate the Migrations -The startup template uses [Entity Framework Core's Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/). EF Core Migrations depend on the selected DBMS provider. So, changing the DBMS provider will cause the migration fails. +The startup template uses [Entity Framework Core's Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/) by default. +EF Core Migrations depend on the selected DBMS provider. Changing the DBMS provider, may not work with the existing migrations. -* Delete the Migrations folder under the `.EntityFrameworkCore.DbMigrations` project and re-build the solution. -* Run `Add-Migration "Initial"` on the Package Manager Console (select the `.DbMigrator` (or `.Web`) project as the startup project in the Solution Explorer and select the `.EntityFrameworkCore.DbMigrations` project as the default project in the Package Manager Console). +* Delete the `Migrations` folder under the `.EntityFrameworkCore.DbMigrations` project and re-build the solution. +* Run `Add-Migration "Initial"` on the Package Manager Console window (select the `.DbMigrator` (or `.Web`) project as the startup project in the Solution Explorer and select the `.EntityFrameworkCore.DbMigrations` project as the default project in the Package Manager Console). -This will create a database migration with all database objects (tables) configured. +This will scaffold a new migration for Oracle. -Run the `.DbMigrator` project to create the database and seed the initial data. +Run the `.DbMigrator` project to create the database, apply the changes and seed the initial data. ## Run the Application From 16968cfc7c521c32a7c96275be3fec10b4708e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 22:46:49 +0300 Subject: [PATCH 47/53] Added If object extension. --- .../System/AbpObjectExtensions.cs | 45 +++++++++++++++++++ .../System/ObjectExtension_Test.cs | 17 +++++++ 2 files changed, 62 insertions(+) diff --git a/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs index 36896ea59a..49e0d6dea6 100644 --- a/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs +++ b/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs @@ -42,5 +42,50 @@ namespace System { return list.Contains(item); } + + /// + /// Can be used to conditionally perform a function + /// on an object and return the modified or the original object. + /// It is useful for chained calls. + /// + /// An object + /// A condition + /// A function that is executed only if the condition is true + /// Type of the object + /// + /// Returns the modified object (by the if the is true) + /// or the original object if the is false + /// + public static T If(this T obj, bool condition, Func func) + { + if (condition) + { + return func(obj); + } + + return obj; + } + + /// + /// Can be used to conditionally perform an action + /// on an object and return the original object. + /// It is useful for chained calls on the object. + /// + /// An object + /// A condition + /// An action that is executed only if the condition is true + /// Type of the object + /// + /// Returns the original object. + /// + public static T If(this T obj, bool condition, Action action) + { + if (condition) + { + action(obj); + } + + return obj; + } } } diff --git a/framework/test/Volo.Abp.Core.Tests/System/ObjectExtension_Test.cs b/framework/test/Volo.Abp.Core.Tests/System/ObjectExtension_Test.cs index 4345c60491..be429658ed 100644 --- a/framework/test/Volo.Abp.Core.Tests/System/ObjectExtension_Test.cs +++ b/framework/test/Volo.Abp.Core.Tests/System/ObjectExtension_Test.cs @@ -52,5 +52,22 @@ namespace System str = null; str.IsIn("a", "b", "c").ShouldBe(false); } + + [Fact] + public void If_Tests() + { + var value = 0; + + value = value.If(true, v => v + 1); + value.ShouldBe(1); + + value = value.If(false, v => v + 1); + value.ShouldBe(1); + + value = value + .If(true, v => v + 3) + .If(false, v => v + 5); + value.ShouldBe(4); + } } } From a322a9441f337da804b850eba8684e08f06b56a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 29 May 2020 22:54:35 +0300 Subject: [PATCH 48/53] Don't set default value for AccessFailedCount if using oracle. --- ...IdentityDbContextModelBuilderExtensions.cs | 78 ++++++++++++------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs index 7dfe662884..74cc2ce995 100644 --- a/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs +++ b/modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/IdentityDbContextModelBuilderExtensions.cs @@ -28,14 +28,25 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); b.ConfigureAbpUser(); - b.Property(u => u.NormalizedUserName).IsRequired().HasMaxLength(IdentityUserConsts.MaxNormalizedUserNameLength).HasColumnName(nameof(IdentityUser.NormalizedUserName)); - b.Property(u => u.NormalizedEmail).IsRequired().HasMaxLength(IdentityUserConsts.MaxNormalizedEmailLength).HasColumnName(nameof(IdentityUser.NormalizedEmail)); - b.Property(u => u.PasswordHash).HasMaxLength(IdentityUserConsts.MaxPasswordHashLength).HasColumnName(nameof(IdentityUser.PasswordHash)); - b.Property(u => u.SecurityStamp).IsRequired().HasMaxLength(IdentityUserConsts.MaxSecurityStampLength).HasColumnName(nameof(IdentityUser.SecurityStamp)); - b.Property(u => u.TwoFactorEnabled).HasDefaultValue(false).HasColumnName(nameof(IdentityUser.TwoFactorEnabled)); - b.Property(u => u.LockoutEnabled).HasDefaultValue(false).HasColumnName(nameof(IdentityUser.LockoutEnabled)); - b.Property(u => u.AccessFailedCount).HasDefaultValue(0).HasColumnName(nameof(IdentityUser.AccessFailedCount)); - + b.Property(u => u.NormalizedUserName).IsRequired() + .HasMaxLength(IdentityUserConsts.MaxNormalizedUserNameLength) + .HasColumnName(nameof(IdentityUser.NormalizedUserName)); + b.Property(u => u.NormalizedEmail).IsRequired() + .HasMaxLength(IdentityUserConsts.MaxNormalizedEmailLength) + .HasColumnName(nameof(IdentityUser.NormalizedEmail)); + b.Property(u => u.PasswordHash).HasMaxLength(IdentityUserConsts.MaxPasswordHashLength) + .HasColumnName(nameof(IdentityUser.PasswordHash)); + b.Property(u => u.SecurityStamp).IsRequired().HasMaxLength(IdentityUserConsts.MaxSecurityStampLength) + .HasColumnName(nameof(IdentityUser.SecurityStamp)); + b.Property(u => u.TwoFactorEnabled).HasDefaultValue(false) + .HasColumnName(nameof(IdentityUser.TwoFactorEnabled)); + b.Property(u => u.LockoutEnabled).HasDefaultValue(false) + .HasColumnName(nameof(IdentityUser.LockoutEnabled)); + + b.Property(u => u.AccessFailedCount) + .If(!builder.IsUsingOracle(), p => p.HasDefaultValue(0)) + .HasColumnName(nameof(IdentityUser.AccessFailedCount)); + b.HasMany(u => u.Claims).WithOne().HasForeignKey(uc => uc.UserId).IsRequired(); b.HasMany(u => u.Logins).WithOne().HasForeignKey(ul => ul.UserId).IsRequired(); b.HasMany(u => u.Roles).WithOne().HasForeignKey(ur => ur.UserId).IsRequired(); @@ -55,7 +66,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); b.Property(x => x.Id).ValueGeneratedNever(); - + b.Property(uc => uc.ClaimType).HasMaxLength(IdentityUserClaimConsts.MaxClaimTypeLength).IsRequired(); b.Property(uc => uc.ClaimValue).HasMaxLength(IdentityUserClaimConsts.MaxClaimValueLength); @@ -68,12 +79,12 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(ur => new { ur.UserId, ur.RoleId }); + b.HasKey(ur => new {ur.UserId, ur.RoleId}); b.HasOne().WithMany().HasForeignKey(ur => ur.RoleId).IsRequired(); b.HasOne().WithMany(u => u.Roles).HasForeignKey(ur => ur.UserId).IsRequired(); - b.HasIndex(ur => new { ur.RoleId, ur.UserId }); + b.HasIndex(ur => new {ur.RoleId, ur.UserId}); }); builder.Entity(b => @@ -82,13 +93,16 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(x => new { x.UserId, x.LoginProvider }); + b.HasKey(x => new {x.UserId, x.LoginProvider}); - b.Property(ul => ul.LoginProvider).HasMaxLength(IdentityUserLoginConsts.MaxLoginProviderLength).IsRequired(); - b.Property(ul => ul.ProviderKey).HasMaxLength(IdentityUserLoginConsts.MaxProviderKeyLength).IsRequired(); - b.Property(ul => ul.ProviderDisplayName).HasMaxLength(IdentityUserLoginConsts.MaxProviderDisplayNameLength); + b.Property(ul => ul.LoginProvider).HasMaxLength(IdentityUserLoginConsts.MaxLoginProviderLength) + .IsRequired(); + b.Property(ul => ul.ProviderKey).HasMaxLength(IdentityUserLoginConsts.MaxProviderKeyLength) + .IsRequired(); + b.Property(ul => ul.ProviderDisplayName) + .HasMaxLength(IdentityUserLoginConsts.MaxProviderDisplayNameLength); - b.HasIndex(l => new { l.LoginProvider, l.ProviderKey }); + b.HasIndex(l => new {l.LoginProvider, l.ProviderKey}); }); builder.Entity(b => @@ -97,9 +111,10 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(l => new { l.UserId, l.LoginProvider, l.Name }); + b.HasKey(l => new {l.UserId, l.LoginProvider, l.Name}); - b.Property(ul => ul.LoginProvider).HasMaxLength(IdentityUserTokenConsts.MaxLoginProviderLength).IsRequired(); + b.Property(ul => ul.LoginProvider).HasMaxLength(IdentityUserTokenConsts.MaxLoginProviderLength) + .IsRequired(); b.Property(ul => ul.Name).HasMaxLength(IdentityUserTokenConsts.MaxNameLength).IsRequired(); }); @@ -111,7 +126,9 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.Property(r => r.Name).IsRequired().HasMaxLength(IdentityRoleConsts.MaxNameLength); b.Property(r => r.NormalizedName).IsRequired().HasMaxLength(IdentityRoleConsts.MaxNormalizedNameLength); - b.Property(u => u.ConcurrencyStamp).IsRequired().IsConcurrencyToken().HasMaxLength(IdentityRoleConsts.MaxConcurrencyStampLength).HasColumnName(nameof(IdentityRole.ConcurrencyStamp)); + b.Property(u => u.ConcurrencyStamp).IsRequired().IsConcurrencyToken() + .HasMaxLength(IdentityRoleConsts.MaxConcurrencyStampLength) + .HasColumnName(nameof(IdentityRole.ConcurrencyStamp)); b.Property(r => r.IsDefault).HasColumnName(nameof(IdentityRole.IsDefault)); b.Property(r => r.IsStatic).HasColumnName(nameof(IdentityRole.IsStatic)); b.Property(r => r.IsPublic).HasColumnName(nameof(IdentityRole.IsPublic)); @@ -141,11 +158,14 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); - b.Property(uc => uc.Name).HasMaxLength(IdentityClaimTypeConsts.MaxNameLength).IsRequired(); // make unique + b.Property(uc => uc.Name).HasMaxLength(IdentityClaimTypeConsts.MaxNameLength) + .IsRequired(); // make unique b.Property(uc => uc.Regex).HasMaxLength(IdentityClaimTypeConsts.MaxRegexLength); b.Property(uc => uc.RegexDescription).HasMaxLength(IdentityClaimTypeConsts.MaxRegexDescriptionLength); b.Property(uc => uc.Description).HasMaxLength(IdentityClaimTypeConsts.MaxDescriptionLength); - b.Property(uc => uc.ConcurrencyStamp).IsRequired().IsConcurrencyToken().HasMaxLength(IdentityClaimTypeConsts.MaxConcurrencyStampLength).HasColumnName(nameof(IdentityClaimType.ConcurrencyStamp)); + b.Property(uc => uc.ConcurrencyStamp).IsRequired().IsConcurrencyToken() + .HasMaxLength(IdentityClaimTypeConsts.MaxConcurrencyStampLength) + .HasColumnName(nameof(IdentityClaimType.ConcurrencyStamp)); }); builder.Entity(b => @@ -154,8 +174,10 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); - b.Property(ou => ou.Code).IsRequired().HasMaxLength(OrganizationUnitConsts.MaxCodeLength).HasColumnName(nameof(OrganizationUnit.Code)); - b.Property(ou => ou.DisplayName).IsRequired().HasMaxLength(OrganizationUnitConsts.MaxDisplayNameLength).HasColumnName(nameof(OrganizationUnit.DisplayName)); + b.Property(ou => ou.Code).IsRequired().HasMaxLength(OrganizationUnitConsts.MaxCodeLength) + .HasColumnName(nameof(OrganizationUnit.Code)); + b.Property(ou => ou.DisplayName).IsRequired().HasMaxLength(OrganizationUnitConsts.MaxDisplayNameLength) + .HasColumnName(nameof(OrganizationUnit.DisplayName)); b.HasMany().WithOne().HasForeignKey(ou => ou.ParentId); b.HasMany(ou => ou.Roles).WithOne().HasForeignKey(our => our.OrganizationUnitId).IsRequired(); @@ -169,11 +191,11 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(ou => new { ou.OrganizationUnitId, ou.RoleId }); + b.HasKey(ou => new {ou.OrganizationUnitId, ou.RoleId}); b.HasOne().WithMany().HasForeignKey(ou => ou.RoleId).IsRequired(); - b.HasIndex(ou => new { ou.RoleId, ou.OrganizationUnitId }); + b.HasIndex(ou => new {ou.RoleId, ou.OrganizationUnitId}); }); builder.Entity(b => @@ -182,12 +204,12 @@ namespace Volo.Abp.Identity.EntityFrameworkCore b.ConfigureByConvention(); - b.HasKey(ou => new { ou.OrganizationUnitId, ou.UserId }); + b.HasKey(ou => new {ou.OrganizationUnitId, ou.UserId}); b.HasOne().WithMany().HasForeignKey(ou => ou.OrganizationUnitId).IsRequired(); - b.HasIndex(ou => new { ou.UserId, ou.OrganizationUnitId }); + b.HasIndex(ou => new {ou.UserId, ou.OrganizationUnitId}); }); } } -} +} \ No newline at end of file From f09138530c122502c11ca7c8a649172f720945e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 30 May 2020 00:49:20 +0300 Subject: [PATCH 49/53] Fix Devart.Data.Oracle.Entity.EFCore naming --- .../Volo/Abp/EntityFrameworkCore/AbpDbContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs index 1f1cf4953e..2c49f6408a 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs @@ -129,7 +129,7 @@ namespace Volo.Abp.EntityFrameworkCore return EfCoreDatabaseProvider.PostgreSql; case "Pomelo.EntityFrameworkCore.MySql": return EfCoreDatabaseProvider.MySql; - case "Devart.Data.Oracle.EFCore": + case "Devart.Data.Oracle.Entity.EFCore": return EfCoreDatabaseProvider.Oracle; case "Microsoft.EntityFrameworkCore.Sqlite": return EfCoreDatabaseProvider.Sqlite; From 987eeab7e7f39b0816424a2b8b4fb26b9483d2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 30 May 2020 01:13:40 +0300 Subject: [PATCH 50/53] Add useExistingConnectionIfAvailable option to UseOracle. --- ...ontextConfigurationContextOracleDevartExtensions.cs | 5 +++-- .../AbpDbContextOptionsOracleDevartExtensions.cs | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleDevartExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleDevartExtensions.cs index 9a768bb5ca..482ee8b9a8 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleDevartExtensions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextConfigurationContextOracleDevartExtensions.cs @@ -10,9 +10,10 @@ namespace Volo.Abp.EntityFrameworkCore { public static DbContextOptionsBuilder UseOracle( [NotNull] this AbpDbContextConfigurationContext context, - [CanBeNull] Action oracleOptionsAction = null) + [CanBeNull] Action oracleOptionsAction = null, + bool useExistingConnectionIfAvailable = false) { - if (context.ExistingConnection != null) + if (useExistingConnectionIfAvailable && context.ExistingConnection != null) { return context.DbContextOptions.UseOracle(context.ExistingConnection, oracleOptionsAction); } diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleDevartExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleDevartExtensions.cs index 22a8c1f7ab..20887ceb79 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleDevartExtensions.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore.Oracle.Devart/Volo/Abp/EntityFrameworkCore/AbpDbContextOptionsOracleDevartExtensions.cs @@ -8,22 +8,24 @@ namespace Volo.Abp.EntityFrameworkCore { public static void UseOracle( [NotNull] this AbpDbContextOptions options, - [CanBeNull] Action oracleOptionsAction = null) + [CanBeNull] Action oracleOptionsAction = null, + bool useExistingConnectionIfAvailable = false) { options.Configure(context => { - context.UseOracle(oracleOptionsAction); + context.UseOracle(oracleOptionsAction, useExistingConnectionIfAvailable); }); } public static void UseOracle( [NotNull] this AbpDbContextOptions options, - [CanBeNull] Action oracleOptionsAction = null) + [CanBeNull] Action oracleOptionsAction = null, + bool useExistingConnectionIfAvailable = false) where TDbContext : AbpDbContext { options.Configure(context => { - context.UseOracle(oracleOptionsAction); + context.UseOracle(oracleOptionsAction, useExistingConnectionIfAvailable); }); } } From fa364fe3d26d5134500b0ab27f8ebbf9e7a8ed44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 30 May 2020 01:41:44 +0300 Subject: [PATCH 51/53] Better implement max lengths for oracle. --- .../Volo/Abp/AuditLogging/AuditLogConsts.cs | 3 +++ .../Volo/Abp/AuditLogging/AuditLog.cs | 2 +- ...itLoggingDbContextModelBuilderExtensions.cs | 10 ++-------- .../Volo/Abp/IdentityServer/SecretConsts.cs | 1 + ...tyServerDbContextModelCreatingExtensions.cs | 18 +++++++----------- .../Abp/SettingManagement/SettingConsts.cs | 1 + ...anagementDbContextModelBuilderExtensions.cs | 10 ++-------- 7 files changed, 17 insertions(+), 28 deletions(-) diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AuditLogConsts.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AuditLogConsts.cs index 1a592fc8b8..504e7451e0 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AuditLogConsts.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain.Shared/Volo/Abp/AuditLogging/AuditLogConsts.cs @@ -16,6 +16,9 @@ public const int MaxExceptionsLength = 4000; + //TODO: Replace with MaxExceptionsLength in v3.0 + public static int MaxExceptionsLengthValue { get; set; } = MaxExceptionsLength; + public const int MaxCommentsLength = 256; public const int MaxUrlLength = 256; diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLog.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLog.cs index 752ccb953c..63dbd4802b 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLog.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.Domain/Volo/Abp/AuditLogging/AuditLog.cs @@ -99,7 +99,7 @@ namespace Volo.Abp.AuditLogging Exceptions = auditInfo .Exceptions? .JoinAsString(Environment.NewLine) - .Truncate(AuditLogConsts.MaxExceptionsLength); + .Truncate(AuditLogConsts.MaxExceptionsLengthValue); Comments = auditInfo .Comments? diff --git a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingDbContextModelBuilderExtensions.cs b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingDbContextModelBuilderExtensions.cs index 59480bb1bb..b44242e511 100644 --- a/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingDbContextModelBuilderExtensions.cs +++ b/modules/audit-logging/src/Volo.Abp.AuditLogging.EntityFrameworkCore/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingDbContextModelBuilderExtensions.cs @@ -37,14 +37,8 @@ namespace Volo.Abp.AuditLogging.EntityFrameworkCore b.Property(x => x.Url).HasMaxLength(AuditLogConsts.MaxUrlLength).HasColumnName(nameof(AuditLog.Url)); b.Property(x => x.HttpStatusCode).HasColumnName(nameof(AuditLog.HttpStatusCode)); - if (builder.IsUsingOracle()) - { - b.Property(x => x.Exceptions).HasMaxLength(2000).HasColumnName(nameof(AuditLog.Exceptions)); - } - else - { - b.Property(x => x.Exceptions).HasMaxLength(AuditLogConsts.MaxExceptionsLength).HasColumnName(nameof(AuditLog.Exceptions)); - } + if (builder.IsUsingOracle()) { AuditLogConsts.MaxExceptionsLengthValue = 2000; } + b.Property(x => x.Exceptions).HasMaxLength(AuditLogConsts.MaxExceptionsLengthValue).HasColumnName(nameof(AuditLog.Exceptions)); b.Property(x => x.Comments).HasMaxLength(AuditLogConsts.MaxCommentsLength).HasColumnName(nameof(AuditLog.Comments)); b.Property(x => x.ExecutionDuration).HasColumnName(nameof(AuditLog.ExecutionDuration)); diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/SecretConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/SecretConsts.cs index b21f901f25..76635e322e 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/SecretConsts.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/SecretConsts.cs @@ -4,6 +4,7 @@ { public const int TypeMaxLength = 250; public const int ValueMaxLength = 4000; + public static int ValueMaxLengthValue { get; set; } = ValueMaxLength; public const int DescriptionMaxLength = 2000; } } \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs index 89d69f3d24..124eb8d91d 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs @@ -131,12 +131,10 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle)) { - b.Property(x => x.Value).HasMaxLength(300).IsRequired(); - } - else - { - b.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired(); + SecretConsts.ValueMaxLengthValue = 300; } + + b.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLengthValue).IsRequired(); b.Property(x => x.Description).HasMaxLength(SecretConsts.DescriptionMaxLength); }); @@ -272,12 +270,10 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql, EfCoreDatabaseProvider.Oracle)) { - b.Property(x => x.Value).HasMaxLength(300).IsRequired(); - } - else - { - b.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLength).IsRequired(); - } + SecretConsts.ValueMaxLengthValue = 300; + } + + b.Property(x => x.Value).HasMaxLength(SecretConsts.ValueMaxLengthValue).IsRequired(); }); builder.Entity(b => diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingConsts.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingConsts.cs index 0b92e24ece..44a21f3ccb 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingConsts.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.Domain.Shared/Volo/Abp/SettingManagement/SettingConsts.cs @@ -4,6 +4,7 @@ { public const int MaxNameLength = 128; public const int MaxValueLength = 2048; + public static int MaxValueLengthValue { get; set; } = MaxValueLength; public const int MaxProviderNameLength = 64; public const int MaxProviderKeyLength = 64; } diff --git a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs index be6467c601..6f0bd5c3f8 100644 --- a/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs +++ b/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContextModelBuilderExtensions.cs @@ -42,14 +42,8 @@ namespace Volo.Abp.SettingManagement.EntityFrameworkCore b.Property(x => x.Name).HasMaxLength(SettingConsts.MaxNameLength).IsRequired(); - if (builder.IsUsingOracle()) - { - b.Property(x => x.Value).HasMaxLength(2000).IsRequired(); - } - else - { - b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLength).IsRequired(); - } + if (builder.IsUsingOracle()) { SettingConsts.MaxValueLengthValue = 2000; } + b.Property(x => x.Value).HasMaxLength(SettingConsts.MaxValueLengthValue).IsRequired(); b.Property(x => x.ProviderName).HasMaxLength(SettingConsts.MaxProviderNameLength); b.Property(x => x.ProviderKey).HasMaxLength(SettingConsts.MaxProviderKeyLength); From 5f2aa6fc397213e4383a0aa9245a7784045b9043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 30 May 2020 01:50:09 +0300 Subject: [PATCH 52/53] Make constants changeable. --- .../ClientPostLogoutRedirectUriConsts.cs | 1 + .../Clients/ClientRedirectUriConsts.cs | 1 + .../Grants/PersistedGrantConsts.cs | 4 +-- ...yServerDbContextModelCreatingExtensions.cs | 32 ++++++++----------- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUriConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUriConsts.cs index 8fe55ba018..3092232d47 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUriConsts.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientPostLogoutRedirectUriConsts.cs @@ -3,5 +3,6 @@ public class ClientPostLogoutRedirectUriConsts { public const int PostLogoutRedirectUriMaxLength = 2000; + public static int PostLogoutRedirectUriMaxLengthValue { get; set; } = 2000; } } \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientRedirectUriConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientRedirectUriConsts.cs index d67bbea509..e972388487 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientRedirectUriConsts.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Clients/ClientRedirectUriConsts.cs @@ -3,5 +3,6 @@ public class ClientRedirectUriConsts { public const int RedirectUriMaxLength = 2000; + public static int RedirectUriMaxLengthValue { get; set; } = 2000; } } \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs index ab46d03ece..6d0836ab17 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain.Shared/Volo/Abp/IdentityServer/Grants/PersistedGrantConsts.cs @@ -6,9 +6,7 @@ public const int TypeMaxLength = 50; public const int SubjectIdMaxLength = 200; public const int ClientIdMaxLength = 200; - - // 50000 chosen to be explicit to allow enough size to avoid truncation, yet stay beneath the MySql row size limit of ~65K - // apparently anything over 4K converts to nvarchar(max) on SqlServer public const int DataMaxLength = 50000; + public static int DataMaxLengthValue { get; set; }= 50000; } } \ No newline at end of file diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs index 124eb8d91d..8acb8a9539 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs @@ -80,13 +80,10 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql)) { - b.Property(x => x.RedirectUri).HasMaxLength(300).IsRequired(); - } - else - { - b.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLength) - .IsRequired(); - } + ClientRedirectUriConsts.RedirectUriMaxLengthValue = 300; + } + + b.Property(x => x.RedirectUri).HasMaxLength(ClientRedirectUriConsts.RedirectUriMaxLengthValue).IsRequired(); }); builder.Entity(b => @@ -99,13 +96,12 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql)) { - b.Property(x => x.PostLogoutRedirectUri).HasMaxLength(300).IsRequired(); - } - else - { - b.Property(x => x.PostLogoutRedirectUri) - .HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLength).IsRequired(); - } + ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLengthValue = 300; + } + + b.Property(x => x.PostLogoutRedirectUri) + .HasMaxLength(ClientPostLogoutRedirectUriConsts.PostLogoutRedirectUriMaxLengthValue) + .IsRequired(); }); builder.Entity(b => @@ -199,12 +195,10 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore if (IsDatabaseProvider(builder, options, EfCoreDatabaseProvider.MySql)) { - b.Property(x => x.Data).HasMaxLength(10000).IsRequired(); - } - else - { - b.Property(x => x.Data).HasMaxLength(PersistedGrantConsts.DataMaxLength).IsRequired(); + PersistedGrantConsts.DataMaxLengthValue = 10000; //TODO: MySQL accepts 20.000. We can consider to change in v3.0. } + + b.Property(x => x.Data).HasMaxLength(PersistedGrantConsts.DataMaxLengthValue).IsRequired(); b.HasKey(x => x.Key); //TODO: What about Id!!! From d2056574cd5259afaa9f5b9292a5928085b8caaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sat, 30 May 2020 02:25:33 +0300 Subject: [PATCH 53/53] Refactor dom-event-handlers.js. --- .../bootstrap/dom-event-handlers.js | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index 6b8ed10120..b9e1880e36 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -50,20 +50,28 @@ scriptObject.initDom && scriptObject.initDom($el); }); } - - abp.dom.onNodeAdded(function (args) { - args.$el.findWithSelf('[data-toggle="tooltip"]').tooltip({ + + function initializeToolTip($tooltips){ + $tooltips.tooltip({ container: 'body' }); + } - args.$el.findWithSelf('[data-toggle="popover"]').popover({ + function initializePopover($popovers){ + $popovers.popover({ container: 'body' }); + } - args.$el.findWithSelf('.timeago').timeago(); + function initializeTimeAgo($timeagos){ + $timeagos.timeago(); + } + abp.dom.onNodeAdded(function (args) { + initializeToolTip(args.$el.findWithSelf('[data-toggle="tooltip"]')); + initializePopover(args.$el.findWithSelf('[data-toggle="popover"]')); + initializeTimeAgo(args.$el.findWithSelf('.timeago')); enableFormFeatures(args.$el.findWithSelf('form'), true); - initializeScript(args.$el); }); @@ -74,18 +82,10 @@ }); $(function () { + initializeToolTip($('[data-toggle="tooltip"]')); + initializePopover($('[data-toggle="popover"]')); + initializeTimeAgo($('.timeago')); enableFormFeatures($('form')); - - $('[data-toggle="tooltip"]').tooltip({ - container: 'body' - }); - - $('[data-toggle="popover"]').popover({ - container: 'body' - }); - - $('.timeago').timeago(); - $('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); });