Skip to content

Commit 08b80a2

Browse files
committed
Merge branch 'dev/develop'
2 parents 1199004 + df8a96a commit 08b80a2

20 files changed

+157
-59
lines changed

build/nuget-build.bat

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dotnet pack ../src/OSharp.EntityFrameworkCore.Oracle/OSharp.EntityFrameworkCore.
1313
dotnet pack ../src/OSharp.EntityFrameworkCore.PostgreSql/OSharp.EntityFrameworkCore.PostgreSql.csproj -c Release --output nupkgs
1414
dotnet pack ../src/OSharp.EntityFrameworkCore.Sqlite/OSharp.EntityFrameworkCore.Sqlite.csproj -c Release --output nupkgs
1515
dotnet pack ../src/OSharp.EntityFrameworkCore.SqlServer/OSharp.EntityFrameworkCore.SqlServer.csproj -c Release --output nupkgs
16+
dotnet pack ../src/OSharp.Exceptionless/OSharp.Exceptionless.csproj -c Release --output nupkgs
1617
dotnet pack ../src/OSharp.Hangfire/OSharp.Hangfire.csproj -c Release --output nupkgs
1718
dotnet pack ../src/OSharp.Hosting.Apis/OSharp.Hosting.Apis.csproj -c Release --output nupkgs
1819
dotnet pack ../src/OSharp.Hosting.Core/OSharp.Hosting.Core.csproj -c Release --output nupkgs

build/nuget-delete.bat

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
:: 此命令将删除nuget官网上的osharp指定版本的包
1+
:: 此命令将删除nuget官网上的osharp指定版本的包
22
@echo off
3-
set /p version=请输入要删除的版本号:
3+
set /p version=请输入要删除的版本号:
44
nuget delete OSharpNS.Core %version% -src https://www.nuget.org -NonInteractive
55
nuget delete OSharpNS.AspNetCore %version% -src https://www.nuget.org -NonInteractive
66
nuget delete OSharpNS.Authorization.Datas %version% -src https://www.nuget.org -NonInteractive

build/public.props

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
<Project>
1+
<Project>
22
<PropertyGroup>
33
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
44
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
55
<Authors>LiuliuSoft</Authors>
6-
<Company>柳柳软件(66soft.net)</Company>
7-
<Copyright>Copyright @ 66SOFT 2014-2020</Copyright>
6+
<Company>柳柳软件(liuliusoft)</Company>
7+
<Copyright>Copyright (c) 2014-2020 LIULIUSOFT. All rights reserved.</Copyright>
88
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
9-
<PackageProjectUrl>https://github.com/i66soft/osharp</PackageProjectUrl>
10-
<PackageIconUrl>https://en.gravatar.com/userimage/140788132/0ff3b1e68fa0154337b1528c4276e276.png?size=80</PackageIconUrl>
11-
<RepositoryUrl>https://github.com/i66soft/osharp.git</RepositoryUrl>
9+
<PackageProjectUrl>https://github.com/dotnetcore/osharp</PackageProjectUrl>
10+
<PackageReleaseNotes>https://github.com/dotnetcore/osharp/releases</PackageReleaseNotes>
11+
<PackageIconUrl>https://en.gravatar.com/userimage/140788132/0ff3b1e68fa0154337b1528c4276e276.png?size=128</PackageIconUrl>
12+
<RepositoryUrl>https://github.com/dotnetcore/osharp</RepositoryUrl>
1213
<RepositoryType>git</RepositoryType>
1314
<PackageTags>osharp osharpns</PackageTags>
1415
<NeutralLanguage>zh-CHS</NeutralLanguage>
1516
<SignAssembly>true</SignAssembly>
1617
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)OSharp.Keys.snk</AssemblyOriginatorKeyFile>
18+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
19+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
20+
<IncludeSymbols>true</IncludeSymbols>
21+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1722
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
26+
</ItemGroup>
1827
</Project>

build/version.props

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<VersionPrefix>7</VersionPrefix>
55
<VersionSuffix>-preview</VersionSuffix>
66
<VersionSuffixVersion>0826</VersionSuffixVersion>
7-
<Version>$(VersionMain).$(VersionPrefix)$(VersionSuffix)$(VersionSuffixVersion)</Version>
8-
<!--<Version>$(VersionMain).$(VersionPrefix)</Version>-->
7+
<!--<Version>$(VersionMain).$(VersionPrefix)$(VersionSuffix)$(VersionSuffixVersion)</Version>-->
8+
<Version>$(VersionMain).$(VersionPrefix)</Version>
99
<AssemblyVersion>$(VersionMain).$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionMain).$(VersionPrefix).$(VersionSuffixVersion)</FileVersion>
1111
</PropertyGroup>

osharp.sln

+7
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OSharp.Hosting.Apis", "src\
9292
EndProject
9393
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OSharp.EntityFrameworkCore.Oracle", "src\OSharp.EntityFrameworkCore.Oracle\OSharp.EntityFrameworkCore.Oracle.csproj", "{4E26B25A-11F4-445E-AE75-BCE02FA3CA29}"
9494
EndProject
95+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OSharp.Exceptionless", "src\OSharp.Exceptionless\OSharp.Exceptionless.csproj", "{DF42EE5B-627F-408D-8E7F-675FACD5A318}"
96+
EndProject
9597
Global
9698
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9799
Debug|Any CPU = Debug|Any CPU
@@ -234,6 +236,10 @@ Global
234236
{4E26B25A-11F4-445E-AE75-BCE02FA3CA29}.Debug|Any CPU.Build.0 = Debug|Any CPU
235237
{4E26B25A-11F4-445E-AE75-BCE02FA3CA29}.Release|Any CPU.ActiveCfg = Release|Any CPU
236238
{4E26B25A-11F4-445E-AE75-BCE02FA3CA29}.Release|Any CPU.Build.0 = Release|Any CPU
239+
{DF42EE5B-627F-408D-8E7F-675FACD5A318}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
240+
{DF42EE5B-627F-408D-8E7F-675FACD5A318}.Debug|Any CPU.Build.0 = Debug|Any CPU
241+
{DF42EE5B-627F-408D-8E7F-675FACD5A318}.Release|Any CPU.ActiveCfg = Release|Any CPU
242+
{DF42EE5B-627F-408D-8E7F-675FACD5A318}.Release|Any CPU.Build.0 = Release|Any CPU
237243
EndGlobalSection
238244
GlobalSection(SolutionProperties) = preSolution
239245
HideSolutionNode = FALSE
@@ -275,6 +281,7 @@ Global
275281
{FD428746-CA60-4F80-BC53-BA1A69CF739F} = {611006C4-BCE9-4EDC-8473-A85530C7FADE}
276282
{3C2FF651-1C3F-4A8B-AB77-89E26DA260D0} = {611006C4-BCE9-4EDC-8473-A85530C7FADE}
277283
{4E26B25A-11F4-445E-AE75-BCE02FA3CA29} = {611006C4-BCE9-4EDC-8473-A85530C7FADE}
284+
{DF42EE5B-627F-408D-8E7F-675FACD5A318} = {611006C4-BCE9-4EDC-8473-A85530C7FADE}
278285
EndGlobalSection
279286
GlobalSection(ExtensibilityGlobals) = postSolution
280287
SolutionGuid = {F1A8840B-B7DE-410D-9FA7-BA36515D2E11}

samples/blazor/Liuliu.Demo.BlazorClient/Liuliu.Demo.BlazorClient.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="BootstrapBlazor" Version="3.1.16" />
10+
<PackageReference Include="BootstrapBlazor" Version="3.1.17" />
1111
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
1212
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
1313
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" />

samples/web/Liuliu.Demo.Mvc/Migrations/20200825153425_Init.Designer.cs renamed to samples/web/Liuliu.Demo.Mvc/Migrations/20200826162104_Init.Designer.cs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/web/Liuliu.Demo.Mvc/appsettings.Development.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
},
88
"OSharp": {
99
"DbContexts": {
10-
"SqlServer": {
11-
"DbContextTypeName": "OSharp.Entity.DefaultDbContext,OSharp.EntityFrameworkCore",
12-
//"ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=osharp-mvc-dev02;Trusted_Connection=True;MultipleActiveResultSets=true",
13-
"ConnectionString": "Data Source=osharp-mvc-dev.db",
14-
"DatabaseType": "Sqlite",
15-
"LazyLoadingProxiesEnabled": true,
16-
"AuditEntityEnabled": true,
17-
"AutoMigrationEnabled": true
18-
}
10+
"SqlServer": {
11+
"DbContextTypeName": "OSharp.Entity.DefaultDbContext,OSharp.EntityFrameworkCore",
12+
//"ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=osharp-mvc-dev02;Trusted_Connection=True;MultipleActiveResultSets=true",
13+
"ConnectionString": "Data Source=osharp-mvc-dev.db",
14+
"DatabaseType": "Sqlite",
15+
"LazyLoadingProxiesEnabled": true,
16+
"DateTimeUtcFormatEnabled": true,
17+
"AuditEntityEnabled": true,
18+
"AutoMigrationEnabled": true
19+
}
1920
},
2021
"Jwt": {
2122
"Issuer": "osharp identity",

src/OSharp.EntityFrameworkCore/DbContextBase.cs

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// -----------------------------------------------------------------------
1+
// -----------------------------------------------------------------------
22
// <copyright file="DbContextBase.cs" company="OSharp开源团队">
33
// Copyright (c) 2014-2019 OSharp. All rights reserved.
44
// </copyright>
@@ -45,7 +45,7 @@ protected DbContextBase(DbContextOptions options, IServiceProvider serviceProvid
4545
_serviceProvider = serviceProvider;
4646
_entityManager = serviceProvider.GetService<IEntityManager>();
4747
_osharpDbOptions = serviceProvider?.GetOSharpOptions()?.DbContexts?.Values.FirstOrDefault(m => m.DbContextType == GetType());
48-
Logger = serviceProvider?.GetLogger(this);
48+
Logger = serviceProvider.GetLogger(this);
4949
}
5050

5151
/// <summary>
@@ -80,10 +80,10 @@ protected DbContextBase(DbContextOptions options, IServiceProvider serviceProvid
8080
public override int SaveChanges()
8181
{
8282
IList<AuditEntityEntry> auditEntities = new List<AuditEntityEntry>();
83-
if (_osharpDbOptions?.AuditEntityEnabled == true)
83+
if (_osharpDbOptions.AuditEntityEnabled == true)
8484
{
8585
IAuditEntityProvider auditEntityProvider = _serviceProvider.GetService<IAuditEntityProvider>();
86-
auditEntities = auditEntityProvider?.GetAuditEntities(this)?.ToList();
86+
auditEntities = auditEntityProvider?.GetAuditEntities(this).ToList();
8787
}
8888

8989
//开启或使用现有事务
@@ -94,7 +94,7 @@ public override int SaveChanges()
9494
{
9595
AuditEntityEventData eventData = new AuditEntityEventData(auditEntities);
9696
IEventBus eventBus = _serviceProvider.GetService<IEventBus>();
97-
eventBus?.Publish(this, eventData);
97+
eventBus.Publish(this, eventData);
9898
}
9999

100100
return count;
@@ -128,10 +128,10 @@ public override int SaveChanges()
128128
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
129129
{
130130
IList<AuditEntityEntry> auditEntities = new List<AuditEntityEntry>();
131-
if (_osharpDbOptions?.AuditEntityEnabled == true)
131+
if (_osharpDbOptions.AuditEntityEnabled == true)
132132
{
133133
IAuditEntityProvider auditEntityProvider = _serviceProvider.GetService<IAuditEntityProvider>();
134-
auditEntities = auditEntityProvider?.GetAuditEntities(this)?.ToList();
134+
auditEntities = auditEntityProvider?.GetAuditEntities(this).ToList();
135135
}
136136

137137
//开启或使用现有事务
@@ -189,20 +189,26 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
189189
foreach (IEntityRegister register in registers)
190190
{
191191
register.RegisterTo(modelBuilder);
192-
Logger?.LogDebug($"将实体类 {register.EntityType} 注册到上下文 {contextType} 中");
192+
Logger.LogDebug($"将实体类 {register.EntityType} 注册到上下文 {contextType} 中");
193193
}
194-
Logger?.LogInformation($"上下文 {contextType} 注册了{registers.Length}个实体类");
194+
Logger.LogInformation($"上下文 {contextType} 注册了{registers.Length}个实体类");
195195

196-
//按预定前缀更改表名
197-
var entityTypes = modelBuilder.Model.GetEntityTypes().ToList();
196+
List<IMutableEntityType> entityTypes = modelBuilder.Model.GetEntityTypes().ToList();
198197
foreach (IMutableEntityType entityType in entityTypes)
199198
{
199+
//启用时间属性UTC格式
200+
if (_osharpDbOptions.DateTimeUtcFormatEnabled)
201+
{
202+
IEntityDateTimeUtcConversion utcConversion = _serviceProvider.GetService<IEntityDateTimeUtcConversion>();
203+
utcConversion.Convert(entityType);
204+
}
205+
206+
//按预定前缀更改表名
200207
string prefix = GetTableNamePrefix(entityType.ClrType);
201208
if (prefix.IsNullOrEmpty())
202209
{
203210
continue;
204211
}
205-
206212
modelBuilder.Entity(entityType.ClrType).ToTable($"{prefix}_{entityType.GetTableName()}");
207213
}
208214
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file="EntityDateTimeUtcConversion.cs" company="OSharp开源团队">
3+
// Copyright (c) 2014-2020 OSharp. All rights reserved.
4+
// </copyright>
5+
// <site>http://www.osharp.org</site>
6+
// <last-editor>郭明锋</last-editor>
7+
// <last-date>2020-08-26 23:44</last-date>
8+
// -----------------------------------------------------------------------
9+
10+
using System;
11+
12+
using Microsoft.EntityFrameworkCore;
13+
using Microsoft.EntityFrameworkCore.Metadata;
14+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
15+
16+
17+
namespace OSharp.Entity
18+
{
19+
/// <summary>
20+
/// 实体时间属性UTC转换器
21+
/// </summary>
22+
/// <seealso cref="OSharp.Entity.IEntityDateTimeUtcConversion" />
23+
public class EntityDateTimeUtcConversion : IEntityDateTimeUtcConversion
24+
{
25+
private readonly ValueConverter<DateTime, DateTime> _dateTimeConverter;
26+
private readonly ValueConverter<DateTime?, DateTime?> _nullableDateTimeConverter;
27+
28+
/// <summary>
29+
/// 初始化一个<see cref="EntityDateTimeUtcConversion"/>类型的新实例
30+
/// </summary>
31+
public EntityDateTimeUtcConversion()
32+
{
33+
_dateTimeConverter = new ValueConverter<DateTime, DateTime>(
34+
local => local.ToUniversalTime(),
35+
utc => utc.ToLocalTime());
36+
_nullableDateTimeConverter = new ValueConverter<DateTime?, DateTime?>(
37+
local => local.HasValue ? local.Value.ToUniversalTime() : local,
38+
utc => utc.HasValue ? utc.Value.ToLocalTime() : utc);
39+
}
40+
41+
/// <summary>
42+
/// 转换指定的实体类型。
43+
/// </summary>
44+
/// <param name="entityType">实体类型</param>
45+
public void Convert(IMutableEntityType entityType)
46+
{
47+
foreach (IMutableProperty property in entityType.GetProperties())
48+
{
49+
if (property.ClrType == typeof(DateTime))
50+
{
51+
property.SetValueConverter(_dateTimeConverter);
52+
}
53+
else if (property.ClrType == typeof(DateTime?))
54+
{
55+
property.SetValueConverter(_nullableDateTimeConverter);
56+
}
57+
}
58+
}
59+
}
60+
}

src/OSharp.EntityFrameworkCore/EntityFrameworkCorePackBase.cs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public override IServiceCollection AddServices(IServiceCollection services)
4242
services.TryAddScoped<IUnitOfWorkManager, UnitOfWorkManager>();
4343
services.TryAddSingleton<IEntityConfigurationTypeFinder, EntityConfigurationTypeFinder>();
4444
services.TryAddSingleton<IEntityManager, EntityManager>();
45+
services.TryAddSingleton<IEntityDateTimeUtcConversion, EntityDateTimeUtcConversion>();
4546
services.AddSingleton<DbContextModelCache>();
4647
services.AddOsharpDbContext<DefaultDbContext>();
4748

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file="IEntityUtcConverter.cs" company="OSharp开源团队">
3+
// Copyright (c) 2014-2020 OSharp. All rights reserved.
4+
// </copyright>
5+
// <site>http://www.osharp.org</site>
6+
// <last-editor>郭明锋</last-editor>
7+
// <last-date>2020-08-26 23:37</last-date>
8+
// -----------------------------------------------------------------------
9+
10+
using Microsoft.EntityFrameworkCore.Metadata;
11+
12+
13+
namespace OSharp.Entity
14+
{
15+
/// <summary>
16+
/// 实体时间属性UTC转换器
17+
/// </summary>
18+
public interface IEntityDateTimeUtcConversion
19+
{
20+
/// <summary>
21+
/// 转换指定的实体类型。
22+
/// </summary>
23+
/// <param name="entityType">实体类型</param>
24+
void Convert(IMutableEntityType entityType);
25+
}
26+
}

src/OSharp.Exceptionless/OSharp.Exceptionless.csproj

+3-6
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@
44
<Import Project="../../build/version.props" />
55

66
<PropertyGroup>
7-
<TargetFramework>netcoreapp2.2</TargetFramework>
7+
<TargetFramework>netcoreapp3.1</TargetFramework>
88
<PackageId>OSharpNS.Exceptionless</PackageId>
99
<Summary>OSharp Exceptionless 分布式日志组件</Summary>
1010
<Description>OSharp Exceptionless 分布式日志组件,封装基于Exceptionless 分布式日志记录实现</Description>
1111
<RootNamespace>OSharp.Exceptionless</RootNamespace>
12-
<Version>2.2.6</Version>
13-
<AssemblyVersion>2.2.6.0</AssemblyVersion>
14-
<FileVersion>2.2.6.0</FileVersion>
1512
</PropertyGroup>
1613

17-
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|AnyCPU'">
14+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
1815
<OutputPath>bin\Release\</OutputPath>
1916
<DocumentationFile>bin\Release\OSharp.Exceptionless.xml</DocumentationFile>
2017
</PropertyGroup>
2118

2219
<ItemGroup>
23-
<PackageReference Include="Exceptionless.AspNetCore" Version="4.3.2027" />
20+
<PackageReference Include="Exceptionless.AspNetCore" Version="4.4.1" />
2421
</ItemGroup>
2522

2623
<ItemGroup>

src/OSharp.Hosting.Apis/OSharp.Hosting.Apis.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<OutputType>Library</OutputType>
1010
<Summary>OSharp框架非业务WebAPI实现</Summary>
1111
<Description>OSharp框架非业务WebAPI实现,封装框架非业务如认证,权限,系统,消息等模块的WebApi实现</Description>
12+
<IsPackable>true</IsPackable>
1213
</PropertyGroup>
1314

1415
<ItemGroup>

src/OSharp.Log4Net/OSharp.Log4Net.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="log4net" Version="2.0.8" />
19+
<PackageReference Include="log4net" Version="2.0.9" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

src/OSharp.NLog/OSharp.NLog.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="NLog" Version="4.7.3" />
20+
<PackageReference Include="NLog" Version="4.7.4" />
2121
</ItemGroup>
2222

2323
<ItemGroup>

src/OSharp.Wpf/OSharp.Wpf.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="FluentValidation" Version="9.1.3" />
19+
<PackageReference Include="FluentValidation" Version="9.2.0" />
2020
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="3.1.7" />
2121
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
2222
<PackageReference Include="Stylet" Version="1.3.4" />

src/OSharp/Core/Options/OSharpDbContextOptions.cs

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public OsharpDbContextOptions()
5454
/// </summary>
5555
public bool LazyLoadingProxiesEnabled { get; set; }
5656

57+
/// <summary>
58+
/// 获取或设置 是否启用时间UTC格式
59+
/// </summary>
60+
public bool DateTimeUtcFormatEnabled { get; set; }
61+
5762
/// <summary>
5863
/// 获取或设置 是否允许审计实体
5964
/// </summary>

0 commit comments

Comments
 (0)