mirror of https://github.com/abpframework/abp.git
173 changed files with 2362 additions and 719 deletions
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 34 KiB |
@ -1,10 +1,10 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers |
|||
{ |
|||
public class AbpScriptBundleTagHelperService : AbpBundleTagHelperService<AbpScriptBundleTagHelper> |
|||
public class AbpScriptBundleTagHelperService : AbpBundleTagHelperService<AbpScriptBundleTagHelper, AbpScriptBundleTagHelperService> |
|||
{ |
|||
public AbpScriptBundleTagHelperService(AbpTagHelperScriptService resourceHelper) |
|||
public AbpScriptBundleTagHelperService(AbpTagHelperScriptService resourceHelper) |
|||
: base(resourceHelper) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,10 +1,10 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers |
|||
{ |
|||
public class AbpScriptTagHelperService : AbpBundleItemTagHelperService<AbpScriptTagHelper> |
|||
public class AbpScriptTagHelperService : AbpBundleItemTagHelperService<AbpScriptTagHelper, AbpScriptTagHelperService> |
|||
{ |
|||
public AbpScriptTagHelperService(AbpTagHelperScriptService resourceService) |
|||
: base(resourceService) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,10 +1,10 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers |
|||
{ |
|||
public class AbpStyleBundleTagHelperService : AbpBundleTagHelperService<AbpStyleBundleTagHelper> |
|||
public class AbpStyleBundleTagHelperService : AbpBundleTagHelperService<AbpStyleBundleTagHelper, AbpStyleBundleTagHelperService> |
|||
{ |
|||
public AbpStyleBundleTagHelperService(AbpTagHelperStyleService resourceHelper) |
|||
public AbpStyleBundleTagHelperService(AbpTagHelperStyleService resourceHelper) |
|||
: base(resourceHelper) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,10 +1,10 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers |
|||
{ |
|||
public class AbpStyleTagHelperService : AbpBundleItemTagHelperService<AbpStyleTagHelper> |
|||
public class AbpStyleTagHelperService : AbpBundleItemTagHelperService<AbpStyleTagHelper, AbpStyleTagHelperService> |
|||
{ |
|||
public AbpStyleTagHelperService(AbpTagHelperStyleService resourceService) |
|||
: base(resourceService) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,19 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpApplicationPath |
|||
{ |
|||
public class AbpApplicationPathViewComponent : AbpViewComponent |
|||
{ |
|||
public IViewComponentResult Invoke() |
|||
{ |
|||
var applicationPath = ViewContext.HttpContext.Request.PathBase.Value; |
|||
var model = new AbpApplicationPathViewComponentModel |
|||
{ |
|||
ApplicationPath = applicationPath == null ? "/" : applicationPath.EnsureEndsWith('/') |
|||
}; |
|||
|
|||
return View("~/Pages/Shared/Components/AbpApplicationPath/Default.cshtml",model); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpApplicationPath |
|||
{ |
|||
public class AbpApplicationPathViewComponentModel |
|||
{ |
|||
public string ApplicationPath { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,4 @@ |
|||
@model Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Shared.Components.AbpApplicationPath.AbpApplicationPathViewComponentModel |
|||
<script type="text/javascript"> |
|||
var abp = abp || {}; abp.appPath = '@Model.ApplicationPath'; |
|||
</script> |
|||
@ -0,0 +1,15 @@ |
|||
using Microsoft.AspNetCore.Mvc.Rendering; |
|||
using Microsoft.AspNetCore.Mvc.Routing; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace Microsoft.AspNetCore.Mvc.ViewFeatures |
|||
{ |
|||
public static class ViewContextExtensions |
|||
{ |
|||
public static IUrlHelper GetUrlHelper(this ViewContext viewContext) |
|||
{ |
|||
var urlHelperFactory = viewContext.HttpContext.RequestServices.GetRequiredService<IUrlHelperFactory>(); |
|||
return urlHelperFactory.GetUrlHelper(viewContext); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,167 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using Microsoft.AspNetCore.Mvc.ApplicationParts; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc |
|||
{ |
|||
/// <summary>
|
|||
/// This class is used to align order of the MVC Application Parts with the order of
|
|||
/// ABP module dependencies.
|
|||
/// </summary>
|
|||
public static class ApplicationPartSorter |
|||
{ |
|||
public static void Sort(ApplicationPartManager partManager, IModuleContainer moduleContainer) |
|||
{ |
|||
/* Performing a double Reverse() to preserve the original order for non-sorted parts |
|||
*/ |
|||
|
|||
var dependencyDictionary = CreateDependencyDictionary(partManager, moduleContainer); |
|||
|
|||
var sortedParts = partManager |
|||
.ApplicationParts |
|||
.Reverse() //First Revers
|
|||
.SortByDependencies(p => dependencyDictionary[p]); |
|||
|
|||
sortedParts.Reverse(); //Reverse again
|
|||
|
|||
//Replace the original parts with the sorted parts
|
|||
partManager.ApplicationParts.Clear(); |
|||
foreach (var applicationPart in sortedParts) |
|||
{ |
|||
partManager.ApplicationParts.Add(applicationPart); |
|||
} |
|||
} |
|||
|
|||
private static Dictionary<ApplicationPart, List<ApplicationPart>> CreateDependencyDictionary( |
|||
ApplicationPartManager partManager, IModuleContainer moduleContainer) |
|||
{ |
|||
var dependencyDictionary = new Dictionary<ApplicationPart, List<ApplicationPart>>(); |
|||
|
|||
foreach (var applicationPart in partManager.ApplicationParts) |
|||
{ |
|||
dependencyDictionary[applicationPart] = |
|||
CreateDependencyList(applicationPart, partManager, moduleContainer); |
|||
} |
|||
|
|||
return dependencyDictionary; |
|||
} |
|||
|
|||
private static List<ApplicationPart> CreateDependencyList( |
|||
ApplicationPart applicationPart, |
|||
ApplicationPartManager partManager, |
|||
IModuleContainer moduleContainer) |
|||
{ |
|||
var list = new List<ApplicationPart>(); |
|||
|
|||
if (applicationPart is AssemblyPart assemblyPart) |
|||
{ |
|||
AddDependencies(list, assemblyPart, partManager, moduleContainer); |
|||
} |
|||
else if (applicationPart is CompiledRazorAssemblyPart compiledRazorAssemblyPart) |
|||
{ |
|||
AddDependencies(list, compiledRazorAssemblyPart, partManager, moduleContainer); |
|||
} |
|||
|
|||
return list; |
|||
} |
|||
|
|||
private static void AddDependencies( |
|||
List<ApplicationPart> list, |
|||
AssemblyPart assemblyPart, |
|||
ApplicationPartManager partManager, |
|||
IModuleContainer moduleContainer) |
|||
{ |
|||
var dependedAssemblyParts = GetDependedAssemblyParts( |
|||
partManager, |
|||
moduleContainer, |
|||
assemblyPart |
|||
); |
|||
|
|||
list.AddRange(dependedAssemblyParts); |
|||
|
|||
foreach (var dependedAssemblyPart in dependedAssemblyParts) |
|||
{ |
|||
var viewsPart = GetViewsPartOrNull(partManager, dependedAssemblyPart); |
|||
if (viewsPart != null) |
|||
{ |
|||
list.Add(viewsPart); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private static void AddDependencies( |
|||
List<ApplicationPart> list, |
|||
CompiledRazorAssemblyPart compiledRazorAssemblyPart, |
|||
ApplicationPartManager partManager, |
|||
IModuleContainer moduleContainer) |
|||
{ |
|||
if (!compiledRazorAssemblyPart.Name.EndsWith(".Views")) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
var originalAssemblyPart = GetOriginalAssemblyPartOrNull(compiledRazorAssemblyPart, partManager); |
|||
if (originalAssemblyPart == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
list.Add(originalAssemblyPart); |
|||
} |
|||
|
|||
private static AssemblyPart[] GetDependedAssemblyParts( |
|||
ApplicationPartManager partManager, |
|||
IModuleContainer moduleContainer, |
|||
AssemblyPart assemblyPart) |
|||
{ |
|||
var moduleDescriptor = GetModuleDescriptorForAssemblyOrNull(moduleContainer, assemblyPart.Assembly); |
|||
if (moduleDescriptor == null) |
|||
{ |
|||
return Array.Empty<AssemblyPart>(); |
|||
} |
|||
|
|||
var moduleDependedAssemblies = moduleDescriptor |
|||
.Dependencies |
|||
.Select(d => d.Assembly) |
|||
.ToArray(); |
|||
|
|||
return partManager.ApplicationParts |
|||
.OfType<AssemblyPart>() |
|||
.Where(a => a.Assembly.IsIn(moduleDependedAssemblies)) |
|||
.Distinct() |
|||
.ToArray(); |
|||
} |
|||
|
|||
private static CompiledRazorAssemblyPart GetViewsPartOrNull(ApplicationPartManager partManager, |
|||
ApplicationPart assemblyPart) |
|||
{ |
|||
var viewsAssemblyName = assemblyPart.Name + ".Views"; |
|||
return partManager |
|||
.ApplicationParts |
|||
.OfType<CompiledRazorAssemblyPart>() |
|||
.FirstOrDefault(p => p.Name == viewsAssemblyName); |
|||
} |
|||
|
|||
private static AssemblyPart GetOriginalAssemblyPartOrNull( |
|||
CompiledRazorAssemblyPart compiledRazorAssemblyPart, |
|||
ApplicationPartManager partManager) |
|||
{ |
|||
var originalAssemblyName = compiledRazorAssemblyPart.Name.RemovePostFix(".Views"); |
|||
return partManager.ApplicationParts |
|||
.OfType<AssemblyPart>() |
|||
.FirstOrDefault(p => p.Name == originalAssemblyName); |
|||
} |
|||
|
|||
private static IAbpModuleDescriptor GetModuleDescriptorForAssemblyOrNull( |
|||
IModuleContainer moduleContainer, |
|||
Assembly assembly) |
|||
{ |
|||
return moduleContainer |
|||
.Modules |
|||
.FirstOrDefault(m => m.Assembly == assembly); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
{ |
|||
"culture": "cs", |
|||
"texts": { |
|||
"MaxResultCountExceededExceptionMessage": "{0} nemůže být více než {1}! Navyšte {2}.{3} na straně serveru pro více výsledků." |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
{ |
|||
"culture": "cs", |
|||
"texts": { |
|||
"DisplayName:Abp.Timing.Timezone": "Časové pásmo", |
|||
"Description:Abp.Timing.Timezone": "Časové pásmo aplikace" |
|||
} |
|||
} |
|||
@ -0,0 +1,177 @@ |
|||
using System; |
|||
using AutoMapper; |
|||
using Shouldly; |
|||
using Volo.Abp.Auditing; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Abp.AutoMapper |
|||
{ |
|||
public class AutoMapperExpressionExtensions_Tests |
|||
{ |
|||
[Fact] |
|||
public void Should_Ignore_Configured_Property() |
|||
{ |
|||
var mapper = CreateMapper( |
|||
cfg => cfg |
|||
.CreateMap<SimpleClass1, SimpleClass2>() |
|||
.Ignore(x => x.Value2) |
|||
.Ignore(x => x.Value3) |
|||
); |
|||
|
|||
var obj2 = mapper.Map<SimpleClass2>( |
|||
new SimpleClass1 |
|||
{ |
|||
Value1 = "v1", |
|||
Value2 = "v2" |
|||
} |
|||
); |
|||
|
|||
obj2.Value1.ShouldBe("v1"); |
|||
obj2.Value2.ShouldBeNull(); |
|||
obj2.Value3.ShouldBeNull(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_Ignore_Audit_Properties() |
|||
{ |
|||
var mapper = CreateMapper( |
|||
cfg => cfg |
|||
.CreateMap<SimpleClassAudited1, SimpleClassAudited2>() |
|||
.IgnoreFullAuditedObjectProperties() |
|||
); |
|||
|
|||
var obj2 = mapper.Map<SimpleClassAudited2>( |
|||
new SimpleClassAudited1 |
|||
{ |
|||
CreationTime = DateTime.Now, |
|||
CreatorId = Guid.NewGuid(), |
|||
LastModificationTime = DateTime.Now, |
|||
LastModifierId = Guid.NewGuid(), |
|||
DeleterId = Guid.NewGuid(), |
|||
DeletionTime = DateTime.Now, |
|||
IsDeleted = true |
|||
} |
|||
); |
|||
|
|||
obj2.CreationTime.ShouldBe(default); |
|||
obj2.CreatorId.ShouldBeNull(); |
|||
obj2.LastModificationTime.ShouldBe(default); |
|||
obj2.LastModifierId.ShouldBeNull(); |
|||
obj2.DeleterId.ShouldBeNull(); |
|||
obj2.DeletionTime.ShouldBeNull(); |
|||
obj2.IsDeleted.ShouldBeFalse(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Should_Ignore_Audit_Properties_With_User() |
|||
{ |
|||
var mapper = CreateMapper( |
|||
cfg => cfg |
|||
.CreateMap<SimpleClassAuditedWithUser1, SimpleClassAuditedWithUser2>() |
|||
.IgnoreFullAuditedObjectProperties<SimpleClassAuditedWithUser1, SimpleClassAuditedWithUser2, SimpleUser>() |
|||
); |
|||
|
|||
var obj2 = mapper.Map<SimpleClassAuditedWithUser2>( |
|||
new SimpleClassAuditedWithUser1 |
|||
{ |
|||
CreationTime = DateTime.Now, |
|||
CreatorId = Guid.NewGuid(), |
|||
LastModificationTime = DateTime.Now, |
|||
LastModifierId = Guid.NewGuid(), |
|||
DeleterId = Guid.NewGuid(), |
|||
DeletionTime = DateTime.Now, |
|||
IsDeleted = true, |
|||
Creator = new SimpleUser(), |
|||
Deleter = new SimpleUser(), |
|||
LastModifier = new SimpleUser() |
|||
} |
|||
); |
|||
|
|||
obj2.CreationTime.ShouldBe(default); |
|||
obj2.CreatorId.ShouldBeNull(); |
|||
obj2.LastModificationTime.ShouldBe(default); |
|||
obj2.LastModifierId.ShouldBeNull(); |
|||
obj2.DeleterId.ShouldBeNull(); |
|||
obj2.DeletionTime.ShouldBeNull(); |
|||
obj2.IsDeleted.ShouldBeFalse(); |
|||
obj2.Creator.ShouldBeNull(); |
|||
obj2.Deleter.ShouldBeNull(); |
|||
obj2.LastModifier.ShouldBeNull(); |
|||
} |
|||
|
|||
private static IMapper CreateMapper(Action<IMapperConfigurationExpression> configure) |
|||
{ |
|||
var configuration = new MapperConfiguration(configure); |
|||
configuration.AssertConfigurationIsValid(); |
|||
return configuration.CreateMapper(); |
|||
} |
|||
|
|||
public class SimpleClass1 |
|||
{ |
|||
public string Value1 { get; set; } |
|||
public string Value2 { get; set; } |
|||
} |
|||
|
|||
public class SimpleClass2 |
|||
{ |
|||
public string Value1 { get; set; } |
|||
public string Value2 { get; set; } |
|||
public string Value3 { get; set; } |
|||
} |
|||
|
|||
public class SimpleClassAudited1 : IFullAuditedObject |
|||
{ |
|||
public DateTime CreationTime { get; set; } |
|||
public Guid? CreatorId { get; set; } |
|||
public DateTime? LastModificationTime { get; set; } |
|||
public Guid? LastModifierId { get; set; } |
|||
public bool IsDeleted { get; set; } |
|||
public DateTime? DeletionTime { get; set; } |
|||
public Guid? DeleterId { get; set; } |
|||
} |
|||
|
|||
public class SimpleClassAudited2 : IFullAuditedObject |
|||
{ |
|||
public DateTime CreationTime { get; set; } |
|||
public Guid? CreatorId { get; set; } |
|||
public DateTime? LastModificationTime { get; set; } |
|||
public Guid? LastModifierId { get; set; } |
|||
public bool IsDeleted { get; set; } |
|||
public DateTime? DeletionTime { get; set; } |
|||
public Guid? DeleterId { get; set; } |
|||
} |
|||
|
|||
public class SimpleClassAuditedWithUser1 : IFullAuditedObject<SimpleUser> |
|||
{ |
|||
public DateTime CreationTime { get; set; } |
|||
public Guid? CreatorId { get; set; } |
|||
public DateTime? LastModificationTime { get; set; } |
|||
public Guid? LastModifierId { get; set; } |
|||
public bool IsDeleted { get; set; } |
|||
public DateTime? DeletionTime { get; set; } |
|||
public Guid? DeleterId { get; set; } |
|||
public SimpleUser Creator { get; set; } |
|||
public SimpleUser LastModifier { get; set; } |
|||
public SimpleUser Deleter { get; set; } |
|||
} |
|||
|
|||
public class SimpleClassAuditedWithUser2 : IFullAuditedObject<SimpleUser> |
|||
{ |
|||
public DateTime CreationTime { get; set; } |
|||
public Guid? CreatorId { get; set; } |
|||
public DateTime? LastModificationTime { get; set; } |
|||
public Guid? LastModifierId { get; set; } |
|||
public bool IsDeleted { get; set; } |
|||
public DateTime? DeletionTime { get; set; } |
|||
public Guid? DeleterId { get; set; } |
|||
public SimpleUser Creator { get; set; } |
|||
public SimpleUser LastModifier { get; set; } |
|||
public SimpleUser Deleter { get; set; } |
|||
} |
|||
|
|||
public class SimpleUser |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
{ |
|||
"culture": "cs", |
|||
"texts": { |
|||
"hello": "Ahoj" |
|||
} |
|||
} |
|||
@ -1,5 +1,5 @@ |
|||
{ |
|||
"culture": "de", |
|||
"culture": "en", |
|||
"texts": { |
|||
"hello": "Hello" |
|||
} |
|||
|
|||
@ -0,0 +1,7 @@ |
|||
{ |
|||
"culture": "cs", |
|||
"texts": { |
|||
"HelloText": "Ahoj {0}", |
|||
"HowAreYou": "jak se máš?" |
|||
} |
|||
} |
|||
@ -1,4 +1,4 @@ |
|||
@using Localization.Resources.AbpUi |
|||
@using Microsoft.AspNetCore.Mvc.Localization |
|||
@inject IHtmlLocalizer<AbpUiResource> L |
|||
<a href="/Account/Login">@L["Login"]</a> |
|||
<a href="~/Account/Login">@L["Login"]</a> |
|||
|
|||
@ -0,0 +1,21 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlobStoring.Database.Host.ConsoleApp.ConsoleApp", "src\BlobStoring.Database.Host.ConsoleApp.ConsoleApp\BlobStoring.Database.Host.ConsoleApp.ConsoleApp.csproj", "{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}" |
|||
EndProject |
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E8067AED-2B6E-4134-AAF8-9101457D709A}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(NestedProjects) = preSolution |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2} = {E8067AED-2B6E-4134-AAF8-9101457D709A} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
@ -0,0 +1,23 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
public class BlobService : IBlobService, ITransientDependency |
|||
{ |
|||
private readonly IBlobContainer<ProfilePictureContainer> _container; |
|||
|
|||
public BlobService(IBlobContainer<ProfilePictureContainer> container) |
|||
{ |
|||
_container = container; |
|||
} |
|||
|
|||
public async Task SaveFile(string fileName = "File Name", string fileContent = "File Content") |
|||
{ |
|||
await _container.SaveAsync(fileName, fileContent.GetBytes(), true); |
|||
Console.WriteLine($"File: {fileName} is successfully saved"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="appsettings.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Include="appsettings.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.SqlServer\Volo.Abp.EntityFrameworkCore.SqlServer.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\src\Volo.Abp.BlobStoring.Database.EntityFrameworkCore\Volo.Abp.BlobStoring.Database.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.4" /> |
|||
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" /> |
|||
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" /> |
|||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> |
|||
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.2" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,32 @@ |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using Volo.Abp; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
public class ConsoleAppConsoleAppHostedService : IHostedService |
|||
{ |
|||
public async Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
using (var application = AbpApplicationFactory.Create<ConsoleAppConsoleAppModule>(options => |
|||
{ |
|||
options.UseAutofac(); |
|||
options.Services.AddLogging(c => c.AddSerilog()); |
|||
})) |
|||
{ |
|||
application.Initialize(); |
|||
|
|||
var blobService = application.ServiceProvider.GetService<BlobService>(); |
|||
|
|||
await blobService.SaveFile("Test File 2", "Test Content 2"); |
|||
|
|||
application.Shutdown(); |
|||
} |
|||
} |
|||
|
|||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
using BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.BlobStoring; |
|||
using Volo.Abp.BlobStoring.Database; |
|||
using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.SqlServer; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpEntityFrameworkCoreSqlServerModule), |
|||
typeof(BlobStoringDatabaseEntityFrameworkCoreModule) |
|||
)] |
|||
public class ConsoleAppConsoleAppModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
ConfigureEntityFramework(context); |
|||
|
|||
context.Services.AddSingleton<IBlobProvider, DatabaseBlobProvider>(); |
|||
|
|||
Configure<AbpBlobStoringOptions>(options => |
|||
{ |
|||
options.Containers.ConfigureDefault(container => |
|||
{ |
|||
container.ProviderType = typeof(DatabaseBlobProvider); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureEntityFramework(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpDbConnectionOptions>(options => |
|||
{ |
|||
options.ConnectionStrings.Default = "Server=localhost;Database=BlobStoring_Host;Trusted_Connection=True;MultipleActiveResultSets=true"; |
|||
}); |
|||
|
|||
context.Services.AddAbpDbContext<BlobStoringHostDbContext>(options => |
|||
{ |
|||
options.AddDefaultRepositories(true); |
|||
}); |
|||
|
|||
Configure<AbpDbContextOptions>(x => |
|||
{ |
|||
x.UseSqlServer(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.BlobStoring.Database.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore |
|||
{ |
|||
public class BlobStoringHostDbContext : AbpDbContext<BlobStoringHostDbContext> |
|||
{ |
|||
public BlobStoringHostDbContext(DbContextOptions<BlobStoringHostDbContext> options) : base(options) |
|||
{ |
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureBlobStoring(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System.IO; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore |
|||
{ |
|||
public class BlobStoringHostDbContextFactory : IDesignTimeDbContextFactory<BlobStoringHostDbContext> |
|||
{ |
|||
public BlobStoringHostDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var configuration = BuildConfiguration(); |
|||
|
|||
var builder = new DbContextOptionsBuilder<BlobStoringHostDbContext>() |
|||
.UseSqlServer(configuration.GetConnectionString("Default")); |
|||
|
|||
return new BlobStoringHostDbContext(builder.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Directory.GetCurrentDirectory()) |
|||
.AddJsonFile("appsettings.json", optional: false); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore |
|||
{ |
|||
public class BlobStoringHostDbSchemaMigrator : IBlobStoringHostDbSchemaMigrator, ITransientDependency |
|||
{ |
|||
private readonly IServiceProvider _serviceProvider; |
|||
|
|||
public BlobStoringHostDbSchemaMigrator(IServiceProvider serviceProvider) |
|||
{ |
|||
_serviceProvider = serviceProvider; |
|||
} |
|||
|
|||
public async Task MigrateAsync() |
|||
{ |
|||
await _serviceProvider |
|||
.GetRequiredService<BlobStoringHostDbContext>() |
|||
.Database |
|||
.MigrateAsync(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore |
|||
{ |
|||
public interface IBlobStoringHostDbSchemaMigrator |
|||
{ |
|||
Task MigrateAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp |
|||
{ |
|||
public interface IBlobService |
|||
{ |
|||
Task SaveFile(string fileName = "File Name", string fileContent = "File Content"); |
|||
} |
|||
} |
|||
@ -0,0 +1,97 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations |
|||
{ |
|||
[DbContext(typeof(BlobStoringHostDbContext))] |
|||
[Migration("20200531134550_Initial")] |
|||
partial class Initial |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) |
|||
.HasAnnotation("ProductVersion", "3.1.4") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlob", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<Guid>("ContainerId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<byte[]>("Content") |
|||
.HasColumnType("varbinary(max)") |
|||
.HasMaxLength(2147483647); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(256)") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "ContainerId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobs"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlobContainer", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(128)") |
|||
.HasMaxLength(128); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobContainers"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations |
|||
{ |
|||
public partial class Initial : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "AbpBlobContainers", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(nullable: false), |
|||
ExtraProperties = table.Column<string>(nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(nullable: true), |
|||
TenantId = table.Column<Guid>(nullable: true), |
|||
Name = table.Column<string>(maxLength: 128, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpBlobContainers", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "AbpBlobs", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(nullable: false), |
|||
ExtraProperties = table.Column<string>(nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(nullable: true), |
|||
ContainerId = table.Column<Guid>(nullable: false), |
|||
TenantId = table.Column<Guid>(nullable: true), |
|||
Name = table.Column<string>(maxLength: 256, nullable: false), |
|||
Content = table.Column<byte[]>(maxLength: 2147483647, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_AbpBlobs", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpBlobContainers_TenantId_Name", |
|||
table: "AbpBlobContainers", |
|||
columns: new[] { "TenantId", "Name" }); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_AbpBlobs_TenantId_ContainerId_Name", |
|||
table: "AbpBlobs", |
|||
columns: new[] { "TenantId", "ContainerId", "Name" }); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "AbpBlobContainers"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "AbpBlobs"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using BlobStoring.Database.Host.ConsoleApp.ConsoleApp.EfCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations |
|||
{ |
|||
[DbContext(typeof(BlobStoringHostDbContext))] |
|||
[Migration("20200531143839_FK_Added")] |
|||
partial class FK_Added |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) |
|||
.HasAnnotation("ProductVersion", "3.1.4") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128) |
|||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlob", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<Guid>("ContainerId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<byte[]>("Content") |
|||
.HasColumnType("varbinary(max)") |
|||
.HasMaxLength(2147483647); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(256)") |
|||
.HasMaxLength(256); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("ContainerId"); |
|||
|
|||
b.HasIndex("TenantId", "ContainerId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobs"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlobContainer", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasColumnName("ConcurrencyStamp") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnName("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("nvarchar(128)") |
|||
.HasMaxLength(128); |
|||
|
|||
b.Property<Guid?>("TenantId") |
|||
.HasColumnName("TenantId") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("TenantId", "Name"); |
|||
|
|||
b.ToTable("AbpBlobContainers"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Volo.Abp.BlobStoring.Database.DatabaseBlob", b => |
|||
{ |
|||
b.HasOne("Volo.Abp.BlobStoring.Database.DatabaseBlobContainer", null) |
|||
.WithMany() |
|||
.HasForeignKey("ContainerId") |
|||
.OnDelete(DeleteBehavior.Cascade) |
|||
.IsRequired(); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue